Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Annoy knn search #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions cmake/GetAnnoy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2023-2024, Manticore Software LTD (https://manticoresearch.com)
# All rights reserved
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set ( ANNOY_GITHUB "https://github.com/manticoresoftware/annoy/archive/refs/heads/main.zip" )
set ( ANNOY_BUNDLEZIP "${LIBS_BUNDLE}/annoy.zip" )

cmake_minimum_required ( VERSION 3.17 FATAL_ERROR )
include ( update_bundle )

# determine destination folder where we expect pre-built annoy
find_package ( Annoy QUIET CONFIG )
return_if_target_found ( Annoy::Annoy "found ready" )

# not found. Populate and prepare sources
select_nearest_url ( ANNOY_PLACE annoy ${ANNOY_BUNDLEZIP} ${ANNOY_GITHUB} )
fetch_sources ( annoy ${ANNOY_PLACE} ANNOY_SRC )

get_build ( ANNOY_BUILD annoy )
external_build ( Annoy ANNOY_SRC ANNOY_BUILD )

find_package ( Annoy REQUIRED CONFIG )
4 changes: 3 additions & 1 deletion knn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ cmake_minimum_required ( VERSION 3.17 )

include ( GetHNSW )

include ( GetAnnoy )

add_library ( knn_lib MODULE knn.cpp knn.h iterator.cpp iterator.h )

if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
message ( STATUS "Add sse 4.1 to compiler flags for ${CMAKE_SYSTEM_PROCESSOR} arch" )
target_compile_options ( knn_lib PUBLIC $<${GNUC_CXX}:-msse4.1> )
endif ()

target_link_libraries ( knn_lib PRIVATE hnswlib::hnswlib columnar_root util common )
target_link_libraries ( knn_lib PRIVATE hnswlib::hnswlib Annoy::Annoy columnar_root util common )
set_target_properties( knn_lib PROPERTIES PREFIX "" OUTPUT_NAME lib_manticore_knn )
Loading
Loading