Skip to content

Commit

Permalink
replace lambda with reference
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi committed Jun 3, 2024
1 parent d2f3918 commit 6598843
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public <T> T compile(Script script, ScriptContext<T> scriptContext) {
throw new UnsupportedOperationException();
}
},
query -> bitsetFilterCache.getBitSetProducer(query),
bitsetFilterCache::getBitSetProducer,
MapperMetrics.NOOP
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public IndexService(
() -> newSearchExecutionContext(0, 0, null, System::currentTimeMillis, null, emptyMap()),
idFieldMapper,
scriptService,
query -> bitsetFilterCache.getBitSetProducer(query),
bitsetFilterCache::getBitSetProducer,
mapperMetrics
);
this.indexFieldData = new IndexFieldDataService(indexSettings, indicesFieldDataCache, circuitBreakerService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void onRemoval(ShardId shardId, Accountable accountable) {}
() -> null,
settings.getMode().idFieldMapperWithoutFieldData(),
ScriptCompiler.NONE,
query -> bitsetFilterCache.getBitSetProducer(query),
bitsetFilterCache::getBitSetProducer,
MapperMetrics.NOOP
);
return new CodecService(service, BigArrays.NON_RECYCLING_INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ private static ObjectMapper createObjectMapper(String name) {
}

private static NestedObjectMapper createNestedObjectMapper(String name) {
return new NestedObjectMapper.Builder(name, IndexVersion.current(), query -> { throw new UnsupportedOperationException(); }).build(
MapperBuilderContext.root(false, false)
);
return new NestedObjectMapper.Builder(name, IndexVersion.current()).build(MapperBuilderContext.root(false, false));
}

private static MappingLookup createMappingLookup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void onRemoval(ShardId shardId, Accountable accountable) {}
indexAnalyzers,
indexSettings,
indexSettings.getMode().idFieldMapperWithoutFieldData(),
query -> bitsetFilterCache.getBitSetProducer(query)
bitsetFilterCache::getBitSetProducer
);

Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers = mapperRegistry.getMetadataMapperParsers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ public void testMultiLevelParents() throws IOException {
}

private static NestedObjectMapper buildMapper(String name) {
return new NestedObjectMapper.Builder(name, IndexVersion.current(), query -> { throw new UnsupportedOperationException(); }).build(
MapperBuilderContext.root(false, false)
);
return new NestedObjectMapper.Builder(name, IndexVersion.current()).build(MapperBuilderContext.root(false, false));
}

public void testAllParentFilters() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1500,12 +1500,12 @@ public void testIndexTemplatesMergeIncludes() throws IOException {
}

public void testMergeNested() {
NestedObjectMapper firstMapper = new NestedObjectMapper.Builder("nested1", IndexVersion.current(), query -> {
throw new UnsupportedOperationException();
}).includeInParent(true).includeInRoot(true).build(MapperBuilderContext.root(false, false));
NestedObjectMapper secondMapper = new NestedObjectMapper.Builder("nested1", IndexVersion.current(), query -> {
throw new UnsupportedOperationException();
}).includeInParent(false).includeInRoot(true).build(MapperBuilderContext.root(false, false));
NestedObjectMapper firstMapper = new NestedObjectMapper.Builder("nested1", IndexVersion.current()).includeInParent(true)
.includeInRoot(true)
.build(MapperBuilderContext.root(false, false));
NestedObjectMapper secondMapper = new NestedObjectMapper.Builder("nested1", IndexVersion.current()).includeInParent(false)
.includeInRoot(true)
.build(MapperBuilderContext.root(false, false));

MapperException e = expectThrows(
MapperException.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,6 @@ protected List<ObjectMapper> objectMappers() {
);

public static NestedObjectMapper nestedObject(String path) {
return new NestedObjectMapper.Builder(path, IndexVersion.current(), query -> { throw new UnsupportedOperationException(); }).build(
MapperBuilderContext.root(false, false)
);
return new NestedObjectMapper.Builder(path, IndexVersion.current()).build(MapperBuilderContext.root(false, false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ protected final SearchExecutionContext createMockSearchExecutionContext(IndexSea
};
NestedLookup nestedLookup = NestedLookup.build(
List.of(
new NestedObjectMapper.Builder("path", IndexVersion.current(), query -> bitsetFilterCache.getBitSetProducer(query)).build(
new NestedObjectMapper.Builder("path", IndexVersion.current()).build(
MapperBuilderContext.root(false, false)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void onRemoval(ShardId shardId, Accountable accountable) {}
() -> null,
indexSettings.getMode().idFieldMapperWithoutFieldData(),
ScriptCompiler.NONE,
query -> bitsetFilterCache.getBitSetProducer(query),
bitsetFilterCache::getBitSetProducer,
MapperMetrics.NOOP
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ protected final MapperService createMapperService(IndexVersion version, Settings
).getMapperRegistry();

SimilarityService similarityService = new SimilarityService(indexSettings, null, Map.of());
BitsetFilterCache bitsetFilterCache = new BitsetFilterCache(indexSettings, new BitsetFilterCache.Listener() {
@Override
public void onCache(ShardId shardId, Accountable accountable) {}

@Override
public void onRemoval(ShardId shardId, Accountable accountable) {}
});
return new MapperService(
() -> TransportVersion.current(),
indexSettings,
Expand All @@ -223,8 +230,8 @@ protected final MapperService createMapperService(IndexVersion version, Settings
},
indexSettings.getMode().buildIdFieldMapper(idFieldDataEnabled),
this::compileScript,
bitsetFilterCache::getBitSetProducer,
MapperMetrics.NOOP

);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public void onRemoval(ShardId shardId, Accountable accountable) {}
() -> createShardContext(null),
idxSettings.getMode().idFieldMapperWithoutFieldData(),
ScriptCompiler.NONE,
query -> bitsetFilterCache.getBitSetProducer(query),
bitsetFilterCache::getBitSetProducer,
MapperMetrics.NOOP
);
IndicesFieldDataCache indicesFieldDataCache = new IndicesFieldDataCache(nodeSettings, new IndexFieldDataCache.Listener() {
Expand Down

0 comments on commit 6598843

Please sign in to comment.