Search in sources :

Example 31 with ByteBuffersDirectory

use of org.apache.lucene.store.ByteBuffersDirectory 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)

Example 32 with ByteBuffersDirectory

use of org.apache.lucene.store.ByteBuffersDirectory in project crate by crate.

the class OrderedLuceneBatchIteratorBenchmark method createLuceneBatchIterator.

@Setup
public void createLuceneBatchIterator() throws Exception {
    IndexWriter iw = new IndexWriter(new ByteBuffersDirectory(), new IndexWriterConfig(new StandardAnalyzer()));
    dummyShardId = new ShardId("dummy", UUIDs.randomBase64UUID(), 1);
    columnName = "x";
    for (int i = 0; i < 10_000_000; i++) {
        Document doc = new Document();
        doc.add(new NumericDocValuesField(columnName, i));
        iw.addDocument(doc);
    }
    iw.commit();
    iw.forceMerge(1, true);
    indexSearcher = new IndexSearcher(DirectoryReader.open(iw, true, true));
    collectorContext = new CollectorContext();
    reference = new Reference(new ReferenceIdent(new RelationName(Schemas.DOC_SCHEMA_NAME, "dummyTable"), columnName), RowGranularity.DOC, DataTypes.INTEGER, 1, null);
    orderBy = new OrderBy(Collections.singletonList(reference), reverseFlags, nullsFirst);
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) OrderBy(io.crate.analyze.OrderBy) Reference(io.crate.metadata.Reference) Document(org.apache.lucene.document.Document) ReferenceIdent(io.crate.metadata.ReferenceIdent) ShardId(org.elasticsearch.index.shard.ShardId) 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) RelationName(io.crate.metadata.RelationName) CollectorContext(io.crate.expression.reference.doc.lucene.CollectorContext) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

ByteBuffersDirectory (org.apache.lucene.store.ByteBuffersDirectory)32 IndexWriter (org.apache.lucene.index.IndexWriter)18 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)18 Document (org.apache.lucene.document.Document)15 IndexSearcher (org.apache.lucene.search.IndexSearcher)13 Directory (org.apache.lucene.store.Directory)13 Test (org.junit.Test)11 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)8 NumericDocValuesField (org.apache.lucene.document.NumericDocValuesField)6 TextField (org.apache.lucene.document.TextField)6 Before (org.junit.Before)6 BytesRef (org.apache.lucene.util.BytesRef)5 SortedSetDocValuesField (org.apache.lucene.document.SortedSetDocValuesField)4 RandomizedTest (com.carrotsearch.randomizedtesting.RandomizedTest)3 Row (io.crate.data.Row)3 LuceneCollectorExpression (io.crate.expression.reference.doc.lucene.LuceneCollectorExpression)3 ScoreCollectorExpression (io.crate.expression.reference.doc.lucene.ScoreCollectorExpression)3 KeywordAnalyzer (org.apache.lucene.analysis.core.KeywordAnalyzer)3 DirectoryReader (org.apache.lucene.index.DirectoryReader)3 Term (org.apache.lucene.index.Term)3