forked from opendistro-for-elasticsearch/k-NN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into enh/ability-to-pass-ef-search-in-query
* master: added github action to build library artifacts (opendistro-for-elasticsearch#132) FIX: buildDir->rootDir Build separate artifacts for library using CPack (opendistro-for-elasticsearch#123) Fix test structure (opendistro-for-elasticsearch#125)
- Loading branch information
Showing
14 changed files
with
141 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) | |
|
||
# Target Library to be built | ||
set(KNN_INDEX KNNIndexV1_7_3_6) | ||
set(KNN_PACKAGE_NAME opendistro-knnlib) | ||
|
||
# Check if similarity search exists | ||
find_path(NMS_REPO_DIR NAMES similarity_search PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external/nmslib REQUIRED) | ||
|
@@ -33,10 +34,11 @@ if (NOT EXISTS ${NMS_REPO_DIR}) | |
endif () | ||
|
||
# Add the subdirectory so it is possible to use its targets | ||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/nmslib/similarity_search) | ||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/nmslib/similarity_search EXCLUDE_FROM_ALL) | ||
|
||
# Set OS specific variables | ||
if (${CMAKE_SYSTEM_NAME} STREQUAL Darwin) | ||
set(CMAKE_MACOSX_RPATH 1) | ||
set(JVM_OS_TYPE darwin) | ||
set(LIB_EXT .jnilib) | ||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL Linux) | ||
|
@@ -47,14 +49,45 @@ else() | |
endif() | ||
|
||
# Compile the library | ||
add_library(${KNN_INDEX} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/src/v1736/com_amazon_opendistroforelasticsearch_knn_index_v1736_KNNIndex.cpp) | ||
add_library(${KNN_INDEX} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/src/com_amazon_opendistroforelasticsearch_knn_index_v1736_KNNIndex.cpp) | ||
target_link_libraries(${KNN_INDEX} NonMetricSpaceLib) | ||
target_include_directories(${KNN_INDEX} PRIVATE $ENV{JAVA_HOME}/include $ENV{JAVA_HOME}/include/${JVM_OS_TYPE} ${CMAKE_CURRENT_SOURCE_DIR}/external/nmslib/similarity_search/include) | ||
target_include_directories(${KNN_INDEX} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include $ENV{JAVA_HOME}/include $ENV{JAVA_HOME}/include/${JVM_OS_TYPE} ${CMAKE_CURRENT_SOURCE_DIR}/external/nmslib/similarity_search/include) | ||
|
||
set_target_properties(${KNN_INDEX} PROPERTIES SUFFIX ${LIB_EXT}) | ||
set_target_properties(${KNN_INDEX} PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
set_target_properties(${KNN_INDEX} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../buildSrc) | ||
set_target_properties(${KNN_INDEX} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/release) | ||
|
||
# Log directory where library will be placed | ||
get_target_property(JNILibDir ${KNN_INDEX} LIBRARY_OUTPUT_DIRECTORY) | ||
message(STATUS "JNI Library Output Directory: ${JNILibDir}") | ||
# Installation rules for shared library | ||
install(TARGETS ${KNN_INDEX} | ||
LIBRARY DESTINATION lib | ||
COMPONENT library) | ||
|
||
# CPack section to build artifacts | ||
set(KNN_MAINTAINER "OpenDistro for Elasticsearch Team <[email protected]>") | ||
set(ODFE_DOWNLOAD_URL "https://opendistro.github.io/elasticsearch/downloads") | ||
set(CPACK_PACKAGE_NAME ${KNN_PACKAGE_NAME}) | ||
set(CPACK_PACKAGE_VERSION 1.8.0.0) | ||
set(CMAKE_INSTALL_PREFIX /usr) | ||
set(CPACK_GENERATOR "RPM;DEB") | ||
SET(CPACK_OUTPUT_FILE_PREFIX packages) | ||
set(CPACK_PACKAGE_RELEASE 0.1) | ||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "KNN JNI library built off of NMSLIB for OpenDistro for Elasticsearch. Reference documentation can be found at https://opendistro.github.io/for-elasticsearch-docs/.") | ||
set(CPACK_PACKAGE_VENDOR "Amazon") | ||
set(CPACK_PACKAGE_CONTACT "Maintainer: ${KNN_MAINTAINER}") | ||
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) | ||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}_${JVM_OS_TYPE}.${CMAKE_SYSTEM_PROCESSOR}") | ||
|
||
# RPM Specific variables | ||
set(CPACK_RPM_PACKAGE_RELEASE ${CPACK_PACKAGE_RELEASE}) | ||
set(CPACK_RPM_PACKAGE_URL ${ODFE_DOWNLOAD_URL}) | ||
set(CPACK_RPM_PACKAGE_DESCRIPTION "Open Distro for Elasticsearch KNN JNI Library") | ||
set(CPACK_RPM_PACKAGE_LICENSE "ASL-2.0") | ||
|
||
# DEB Specific variables | ||
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${ODFE_DOWNLOAD_URL}) | ||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${KNN_MAINTAINER}) | ||
set(CPACK_DEBIAN_PACKAGE_SOURCE ${CPACK_PACKAGE_NAME}) | ||
set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) | ||
set(CPACK_DEBIAN_PACKAGE_SECTION "libs") | ||
|
||
include(CPack) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/test/java/com/amazon/opendistroforelasticsearch/knn/KNNTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. 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. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.knn; | ||
|
||
import com.amazon.opendistroforelasticsearch.knn.plugin.stats.KNNCounter; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.junit.Before; | ||
|
||
/** | ||
* Base class for integration tests for KNN plugin. Contains several methods for testing KNN ES functionality. | ||
*/ | ||
public class KNNTestCase extends ESTestCase { | ||
@Before | ||
public void resetCounters() { | ||
// Reset all of the counters | ||
for (KNNCounter knnCounter : KNNCounter.values()) { | ||
knnCounter.set(0L); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters