use of org.elasticsearch.common.inject.ModulesBuilder in project crate by crate.
the class LuceneQueryBuilderTest method createAnalysisService.
private AnalysisService createAnalysisService(Settings indexSettings, Index index) {
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(indexSettings), new EnvironmentModule(new Environment(indexSettings))).createInjector();
Injector injector = new ModulesBuilder().add(new IndexSettingsModule(index, indexSettings), new IndexNameModule(index), new AnalysisModule(indexSettings, parentInjector.getInstance(IndicesAnalysisService.class))).createChildInjector(parentInjector);
return injector.getInstance(AnalysisService.class);
}
use of org.elasticsearch.common.inject.ModulesBuilder in project crate by crate.
the class TestGlobalSysExpressions method prepare.
@Before
public void prepare() throws Exception {
Injector injector = new ModulesBuilder().add(new SysClusterExpressionModule()).add((Module) binder -> {
binder.bind(ClusterService.class).toInstance(new NoopClusterService());
binder.bind(Settings.class).toInstance(Settings.EMPTY);
binder.bind(ClusterName.class).toInstance(new ClusterName("cluster"));
binder.bind(ClusterReferenceResolver.class).asEagerSingleton();
}).createInjector();
resolver = injector.getInstance(ClusterReferenceResolver.class);
}
use of org.elasticsearch.common.inject.ModulesBuilder in project crate by crate.
the class SysNodesExpressionsWithDefaultExtendedStatsTest method prepare.
private void prepare(boolean isDataNode) throws Exception {
injector = new ModulesBuilder().add(new SysNodesExpressionsTest.TestModule(isDataNode), new MonitorModule(Settings.EMPTY), new SysNodeExpressionModule()).createInjector();
resolver = injector.getInstance(NodeSysExpression.class);
}
use of org.elasticsearch.common.inject.ModulesBuilder in project crate by crate.
the class GroupingLongCollectorBenchmark method createGroupingCollector.
@Setup
public void createGroupingCollector() throws Exception {
IndexWriter iw = new IndexWriter(new ByteBuffersDirectory(), new IndexWriterConfig(new StandardAnalyzer()));
Functions functions = new ModulesBuilder().add(new AggregationImplModule()).createInjector().getInstance(Functions.class);
SumAggregation<?> sumAgg = (SumAggregation<?>) functions.getQualified(Signature.aggregate(SumAggregation.NAME, DataTypes.INTEGER.getTypeSignature(), DataTypes.LONG.getTypeSignature()), List.of(DataTypes.INTEGER), DataTypes.INTEGER);
var memoryManager = new OnHeapMemoryManager(bytes -> {
});
groupBySumCollector = createGroupBySumCollector(sumAgg, memoryManager);
int size = 20_000_000;
rows = new ArrayList<>(size);
numbers = new long[size];
for (int i = 0; i < size; i++) {
long value = (long) i % 200;
rows.add(new Row1(value));
numbers[i] = value;
var doc = new Document();
doc.add(new NumericDocValuesField("x", value));
doc.add(new SortedNumericDocValuesField("y", value));
iw.addDocument(doc);
}
iw.commit();
iw.forceMerge(1, true);
searcher = new IndexSearcher(DirectoryReader.open(iw));
}
Aggregations