Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Elasticsearch 7.8 support (#147)
Browse files Browse the repository at this point in the history
* 7.8 support
  • Loading branch information
vamshin committed Jun 25, 2020
1 parent eb7cba4 commit fec3ad5
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build-tools/knnplugin-coverage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ allprojects{
jacocoTestReport.dependsOn integTest.runner

testClusters.integTest {
jvmArgs " ${dummyIntegTest.jacoco.getAsJvmArg()}"
jvmArgs " ${dummyIntegTest.jacoco.getAsJvmArg()}".replace('javaagent:','javaagent:/')
systemProperty 'com.sun.management.jmxremote', "true"
systemProperty 'com.sun.management.jmxremote.authenticate', "false"
systemProperty 'com.sun.management.jmxremote.port', "7777"
Expand Down
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

buildscript {
ext {
es_version = System.getProperty("es.version", "7.7.0")
es_version = System.getProperty("es.version", "7.8.0")
es_group = "org.elasticsearch"
distribution = 'oss-zip'
}
Expand Down Expand Up @@ -202,8 +202,7 @@ forbiddenPatterns {
// see https://github.com/elastic/elasticsearch/blob/323f312bbc829a63056a79ebe45adced5099f6e6/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/TestingConventionsTasks.java
// enable testingConventions check will cause errors like: "Classes ending with [Tests] must subclass [LuceneTestCase]"
testingConventions.enabled = false
licenseHeaders.enabled = true

validateNebulaPom.enabled = false
apply plugin: 'nebula.ospackage'

// This is afterEvaluate because the bundlePlugin ZIP task is updated afterEvaluate and changes the ZIP name to match the plugin name
Expand All @@ -224,7 +223,7 @@ afterEvaluate {
dirMode 0755

requires('elasticsearch-oss', versions.elasticsearch, EQUAL)
requires("opendistro-knnlib", "1.8.0.0", EQUAL)
requires("opendistro-knnlib", "${opendistroVersion}.0", EQUAL)
packager = 'Amazon'
vendor = 'Amazon'
os = 'LINUX'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public Float getWeightAsPercentage() {

/**
* Returns the how much space an index is taking up in the cache is as a percentage of the total cache capacity
*
* @param indexName name of the index
* @return Percentage of the cache full
*/
public Float getWeightAsPercentage(final String indexName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,12 @@ public static int getEfSearchParam(String index) {
* @return spaceType value
*/
public static String getSpaceType(String index) {
return KNNSettings.state().clusterService.state().getMetaData()
return KNNSettings.state().clusterService.state().getMetadata()
.index(index).getSettings().get(KNN_SPACE_TYPE, SpaceTypes.l2.getValue());
}

public static int getIndexSettingValue(String index, String settingName, int defaultValue) {
return KNNSettings.state().clusterService.state().getMetaData()
return KNNSettings.state().clusterService.state().getMetadata()
.index(index).getSettings()
.getAsInt(settingName, defaultValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.index.mapper.ArrayValueMapperParser;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.FieldNamesFieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
Expand All @@ -49,7 +48,7 @@
/**
* Field Mapper for KNN vector type.
*/
public class KNNVectorFieldMapper extends FieldMapper implements ArrayValueMapperParser {
public class KNNVectorFieldMapper extends FieldMapper {
public static final String CONTENT_TYPE = "knn_vector";
public static final String KNN_FIELD = "knn_field";

Expand Down Expand Up @@ -235,6 +234,11 @@ public Query termQuery(Object value, QueryShardContext context) {
}
}

@Override
public final boolean parsesArrayValue() {
return true;
}

@Override
public void parse(ParseContext context) throws IOException {
if (!KNNSettings.isKNNPluginEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.elasticsearch.plugins.MapperPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.SearchPlugin;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.script.ScriptService;
Expand Down Expand Up @@ -119,7 +120,8 @@ public Collection<Object> createComponents(Client client, ClusterService cluster
ResourceWatcherService resourceWatcherService, ScriptService scriptService,
NamedXContentRegistry xContentRegistry, Environment environment,
NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry,
IndexNameExpressionResolver indexNameExpressionResolver) {
IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<RepositoriesService> repositoriesServiceSupplier) {
KNNIndexCache.setResourceWatcherService(resourceWatcherService);
KNNSettings.state().initialize(client, clusterService);
KNNCircuitBreaker.getInstance().initialize(threadPool, clusterService, client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void increment() {
}

/**
* @param value counter value
* Set the value of a counter
*/
public void set(long value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public class KNNIndexCacheTests extends ESSingleNodeTestCase {

@Override
public void setUp() throws Exception {
super.setUp();
// Reset all of the counters
for (KNNCounter knnCounter : KNNCounter.values()) {
knnCounter.set(0L);
}
super.setUp();
}

@Override
Expand All @@ -63,9 +63,9 @@ protected boolean resetNodeAfterTest() {

@Override
public void tearDown() throws Exception {
super.tearDown();
KNNIndexCache.getInstance().evictAllGraphsFromCache();
KNNIndexCache.getInstance().close();
super.tearDown();
}

public void testGetIndicesCacheStats() throws IOException, InterruptedException, ExecutionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class KNNCodecTestCase extends KNNTestCase {
protected void setUpMockClusterService() {
ClusterService clusterService = mock(ClusterService.class, RETURNS_DEEP_STUBS);
Settings settings = Settings.Builder.EMPTY_SETTINGS;
when(clusterService.state().getMetaData().index(Mockito.anyString()).getSettings()).thenReturn(settings);
when(clusterService.state().getMetadata().index(Mockito.anyString()).getSettings()).thenReturn(settings);
KNNSettings.state().setClusterService(clusterService);
}

Expand Down

0 comments on commit fec3ad5

Please sign in to comment.