try to add spotify-annoy

This commit is contained in:
Vladimir Makarov 2022-03-25 12:48:04 +00:00
parent dd1df58559
commit 4a9fbdf4dc
7 changed files with 74 additions and 0 deletions

3
.gitmodules vendored
View File

@ -262,3 +262,6 @@
[submodule "contrib/minizip-ng"]
path = contrib/minizip-ng
url = https://github.com/zlib-ng/minizip-ng
[submodule "contrib/spotify-annoy"]
path = contrib/spotify-annoy
url = https://github.com/spotify/annoy.git

View File

@ -89,6 +89,7 @@ add_contrib (protobuf-cmake protobuf)
add_contrib (openldap-cmake openldap)
add_contrib (grpc-cmake grpc)
add_contrib (msgpack-c-cmake msgpack-c)
add_contrib (spotify-annoy-cmake spotify-annoy)
if (ENABLE_FUZZING)
add_contrib (libprotobuf-mutator-cmake libprotobuf-mutator)

1
contrib/spotify-annoy vendored Submodule

@ -0,0 +1 @@
Subproject commit 6f6b0c84ab413337eb4d2e850a4cba637f52ccbc

View File

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.14)
add_library(SpotifyAnnoy INTERFACE)
set(SPOTIFY_ANNOY_PROJECT_DIR "${ClickHouse_SOURCE_DIR}/contrib/sporify-annoy")
set(SPOTIFY_ANNOY_SOURCE_DIR "${SPOTIFY_ANNOY_PROJECT_DIR}/src")
set(SPOTIFY_ANNOY_INCLUDE_DIR ${SPOTIFY_ANNOY_PROJECT_DIR}/include/annoy)
file(MAKE_DIRECTORY ${SPOTIFY_ANNOY_INCLUDE_DIR})
foreach (HEADER annoylib.h kissrandom.h mman.h)
file(COPY ${SPOTIFY_ANNOY_PROJECT_DIR}/src/${HEADER} DESTINATION ${SPOTIFY_ANNOY_INCLUDE_DIR})
endforeach()
target_include_directories(SpotifyAnnoy INTERFACE include/)
add_library(ch::contrib::spotify-annoy ALIAS SpotifyAnnoy)

View File

@ -522,6 +522,7 @@ if (TARGET ch_contrib::rapidjson)
endif()
dbms_target_link_libraries(PUBLIC ch_contrib::consistent_hashing)
dbms_target_link_libraries(PUBLIC ch_contrib::spotify-annoy)
include ("${ClickHouse_SOURCE_DIR}/cmake/add_check.cmake")

View File

@ -0,0 +1,21 @@
#include <Storages/MergeTree/MergeTreeIndexSimpleHnsw.h>
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
MergeTreeIndexGranuleSimpleHnsw::MergeTreeIndexGranuleSimpleHnsw(const String & index_name_, const Block & index_sample_block_)
: index_name(index_name_)
, index_sample_block(index_sample_block_)
{}
void MergeTreeIndexGranuleMinMax::serializeBinary(WriteBuffer & /*ostr*/) const{}
void MergeTreeIndexGranuleMinMax::deserializeBinary(ReadBuffer & /*istr*/, MergeTreeIndexVersion /*version*/){}
}

View File

@ -0,0 +1,31 @@
#pragma once
#include <Storages/MergeTree/MergeTreeIndices.h>
#include <Storages/MergeTree/MergeTreeData.h>
#include <Storages/MergeTree/KeyCondition.h>
#include "Storages/MergeTree/MergeTreeIndexMinMax.h"
#include <memory>
#include "object.h"
#include <spotify-annoy>
namespace DB
{
struct MergeTreeIndexGranuleSimpleSpotifyAnnoy final : public IMergeTreeIndexGranule
{
MergeTreeIndexGranuleSimpleSpotifyAnnoy(const String & index_name_, const Block & index_sample_block_);
~MergeTreeIndexGranuleSimpleSpotifyAnnoy() override = default;
void serializeBinary(WriteBuffer & ostr) const override;
void deserializeBinary(ReadBuffer & istr, MergeTreeIndexVersion version) override;
bool empty() const override { return true; }
String index_name;
Block index_sample_block;
similarity::ObjectVector batch_data;
};
}