Fix CMake integration of usearch and annoy

Registers usearch and annoy properly via configure_config.cmake and
config.h.in like all other 3rd party libs, instead of (mis)using
target_compile_definitions.
This commit is contained in:
Robert Schulze 2024-08-09 09:22:38 +00:00
parent a39b9cf643
commit d7211f9d12
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
11 changed files with 31 additions and 16 deletions

View File

@ -20,5 +20,4 @@ add_library(_annoy INTERFACE)
target_include_directories(_annoy SYSTEM INTERFACE ${ANNOY_SOURCE_DIR})
add_library(ch_contrib::annoy ALIAS _annoy)
target_compile_definitions(_annoy INTERFACE ENABLE_ANNOY)
target_compile_definitions(_annoy INTERFACE ANNOYLIB_MULTITHREADED_BUILD)

View File

@ -12,4 +12,3 @@ target_include_directories(_usearch SYSTEM INTERFACE
${USEARCH_PROJECT_DIR}/include)
add_library(ch_contrib::usearch ALIAS _usearch)
target_compile_definitions(_usearch INTERFACE ENABLE_USEARCH)

View File

@ -58,6 +58,8 @@
#cmakedefine01 USE_FILELOG
#cmakedefine01 USE_ODBC
#cmakedefine01 USE_BLAKE3
#cmakedefine01 USE_ANNOY
#cmakedefine01 USE_USEARCH
#cmakedefine01 USE_SKIM
#cmakedefine01 USE_PRQL
#cmakedefine01 USE_ULID

View File

@ -52,6 +52,8 @@
#include <memory>
#include <unordered_map>
#include "config.h"
using namespace DB;
namespace
@ -1476,11 +1478,11 @@ static void buildIndexes(
MergeTreeIndexConditionPtr condition;
if (index_helper->isVectorSearch())
{
#ifdef ENABLE_ANNOY
#if USE_ANNOY
if (const auto * annoy = typeid_cast<const MergeTreeIndexAnnoy *>(index_helper.get()))
condition = annoy->createIndexCondition(query_info, context);
#endif
#ifdef ENABLE_USEARCH
#if USE_USEARCH
if (const auto * usearch = typeid_cast<const MergeTreeIndexUSearch *>(index_helper.get()))
condition = usearch->createIndexCondition(query_info, context);
#endif

View File

@ -1,7 +1,7 @@
#ifdef ENABLE_ANNOY
#include <Storages/MergeTree/MergeTreeIndexAnnoy.h>
#if USE_ANNOY
#include <Columns/ColumnArray.h>
#include <Common/typeid_cast.h>
#include <Core/Field.h>

View File

@ -1,6 +1,8 @@
#pragma once
#ifdef ENABLE_ANNOY
#include "config.h"
#if USE_ANNOY
#include <Storages/MergeTree/ApproximateNearestNeighborIndexesCommon.h>

View File

@ -1,10 +1,10 @@
#ifdef ENABLE_USEARCH
#include <Storages/MergeTree/MergeTreeIndexUSearch.h>
#if USE_USEARCH
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpass-failed"
#include <Storages/MergeTree/MergeTreeIndexUSearch.h>
#include <Columns/ColumnArray.h>
#include <Common/typeid_cast.h>
#include <Core/Field.h>

View File

@ -1,12 +1,16 @@
#pragma once
#ifdef ENABLE_USEARCH
#include "config.h"
#include <Storages/MergeTree/ApproximateNearestNeighborIndexesCommon.h>
#if USE_USEARCH
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpass-failed"
#include <Storages/MergeTree/ApproximateNearestNeighborIndexesCommon.h>
#include <usearch/index_dense.hpp>
#pragma clang diagnostic pop
namespace DB

View File

@ -127,12 +127,12 @@ MergeTreeIndexFactory::MergeTreeIndexFactory()
registerCreator("hypothesis", hypothesisIndexCreator);
registerValidator("hypothesis", hypothesisIndexValidator);
#ifdef ENABLE_ANNOY
#if USE_ANNOY
registerCreator("annoy", annoyIndexCreator);
registerValidator("annoy", annoyIndexValidator);
#endif
#ifdef ENABLE_USEARCH
#if USE_USEARCH
registerCreator("usearch", usearchIndexCreator);
registerValidator("usearch", usearchIndexValidator);
#endif

View File

@ -15,6 +15,7 @@
#include <Interpreters/ExpressionActions.h>
#include <DataTypes/DataTypeLowCardinality.h>
#include "config.h"
constexpr auto INDEX_FILE_PREFIX = "skp_idx_";
@ -230,12 +231,12 @@ void bloomFilterIndexValidator(const IndexDescription & index, bool attach);
MergeTreeIndexPtr hypothesisIndexCreator(const IndexDescription & index);
void hypothesisIndexValidator(const IndexDescription & index, bool attach);
#ifdef ENABLE_ANNOY
#if USE_ANNOY
MergeTreeIndexPtr annoyIndexCreator(const IndexDescription & index);
void annoyIndexValidator(const IndexDescription & index, bool attach);
#endif
#ifdef ENABLE_USEARCH
#if USE_USEARCH
MergeTreeIndexPtr usearchIndexCreator(const IndexDescription& index);
void usearchIndexValidator(const IndexDescription& index, bool attach);
#endif

View File

@ -164,6 +164,12 @@ endif()
if (TARGET ch_contrib::bcrypt)
set(USE_BCRYPT 1)
endif()
if (TARGET ch_contrib::annoy)
set(USE_ANNOY 1)
endif()
if (TARGET ch_contrib::usearch)
set(USE_USEARCH 1)
endif()
if (TARGET ch_contrib::ssh)
set(USE_SSH 1)
endif()