Search in sources :

Example 11 with ModulesBuilder

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);
}
Also used : EnvironmentModule(org.elasticsearch.env.EnvironmentModule) IndexNameModule(org.elasticsearch.index.IndexNameModule) IndicesAnalysisService(org.elasticsearch.indices.analysis.IndicesAnalysisService) Injector(org.elasticsearch.common.inject.Injector) IndexSettingsModule(org.elasticsearch.index.settings.IndexSettingsModule) SettingsModule(org.elasticsearch.common.settings.SettingsModule) Environment(org.elasticsearch.env.Environment) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) IndexSettingsModule(org.elasticsearch.index.settings.IndexSettingsModule) AnalysisModule(org.elasticsearch.index.analysis.AnalysisModule)

Example 12 with ModulesBuilder

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);
}
Also used : NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) ClusterService(org.elasticsearch.cluster.ClusterService) SysClusterExpressionModule(io.crate.operation.reference.sys.cluster.SysClusterExpressionModule) Injector(org.elasticsearch.common.inject.Injector) ClusterName(org.elasticsearch.cluster.ClusterName) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) ClusterReferenceResolver(io.crate.metadata.ClusterReferenceResolver) Module(org.elasticsearch.common.inject.Module) SysClusterExpressionModule(io.crate.operation.reference.sys.cluster.SysClusterExpressionModule) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) CrateSettings(io.crate.metadata.settings.CrateSettings) Settings(org.elasticsearch.common.settings.Settings) Before(org.junit.Before)

Example 13 with ModulesBuilder

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);
}
Also used : NodeSysExpression(io.crate.operation.reference.sys.node.local.NodeSysExpression) MonitorModule(io.crate.monitor.MonitorModule) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) SysNodeExpressionModule(io.crate.operation.reference.sys.node.local.SysNodeExpressionModule)

Example 14 with ModulesBuilder

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));
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) Functions(io.crate.metadata.Functions) Document(org.apache.lucene.document.Document) AggregationImplModule(io.crate.execution.engine.aggregation.impl.AggregationImplModule) Row1(io.crate.data.Row1) SortedNumericDocValuesField(org.apache.lucene.document.SortedNumericDocValuesField) SortedNumericDocValuesField(org.apache.lucene.document.SortedNumericDocValuesField) NumericDocValuesField(org.apache.lucene.document.NumericDocValuesField) IndexWriter(org.apache.lucene.index.IndexWriter) ByteBuffersDirectory(org.apache.lucene.store.ByteBuffersDirectory) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) SumAggregation(io.crate.execution.engine.aggregation.impl.SumAggregation) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

ModulesBuilder (org.elasticsearch.common.inject.ModulesBuilder)14 Functions (io.crate.metadata.Functions)7 Injector (org.elasticsearch.common.inject.Injector)5 OnHeapMemoryManager (io.crate.memory.OnHeapMemoryManager)4 SettingsModule (org.elasticsearch.common.settings.SettingsModule)4 Setup (org.openjdk.jmh.annotations.Setup)4 Input (io.crate.data.Input)3 Row1 (io.crate.data.Row1)3 AggregationImplModule (io.crate.execution.engine.aggregation.impl.AggregationImplModule)3 InputCollectExpression (io.crate.execution.engine.collect.InputCollectExpression)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 List (java.util.List)3 TimeUnit (java.util.concurrent.TimeUnit)3 RamAccounting (io.crate.breaker.RamAccounting)2 Row (io.crate.data.Row)2 SumAggregation (io.crate.execution.engine.aggregation.impl.SumAggregation)2 AggregateMode (io.crate.expression.symbol.AggregateMode)2 Literal (io.crate.expression.symbol.Literal)2 Signature (io.crate.metadata.functions.Signature)2