Search in sources :

Example 11 with PartitionedLuceneLabelScanWriter

use of org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter in project neo4j by neo4j.

the class NodeRangeDocumentLabelScanStorageStrategyTest method shouldRemoveLabelFieldsThatDoesNotRepresentAnyNodes.

@Test
public void shouldRemoveLabelFieldsThatDoesNotRepresentAnyNodes() throws Exception {
    // given
    IndexWriter indexWriter = mock(IndexWriter.class);
    Document doc = document(format.rangeField(0), format.labelField(7, 0x1), format.labelField(8, 0x1));
    WritableIndexPartition partition = newIndexPartitionMock(indexWriter, doc);
    WritableDatabaseLabelScanIndex index = buildLuceneIndex(partition);
    LabelScanWriter writer = new PartitionedLuceneLabelScanWriter(index, format);
    // when
    writer.write(labelChanges(0, labels(7, 8), labels(8)));
    writer.close();
    // then
    verify(indexWriter).updateDocument(eq(format.rangeTerm(0)), match(document(format.rangeField(0), format.labelField(8, 0x01), format.labelSearchField(8))));
}
Also used : WritableDatabaseLabelScanIndex(org.neo4j.kernel.api.impl.labelscan.WritableDatabaseLabelScanIndex) IndexWriter(org.apache.lucene.index.IndexWriter) PartitionedLuceneLabelScanWriter(org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter) WritableIndexPartition(org.neo4j.kernel.api.impl.index.partition.WritableIndexPartition) Document(org.apache.lucene.document.Document) PartitionedLuceneLabelScanWriter(org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter) LabelScanWriter(org.neo4j.kernel.api.labelscan.LabelScanWriter) Test(org.junit.Test)

Example 12 with PartitionedLuceneLabelScanWriter

use of org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter in project neo4j by neo4j.

the class NodeRangeDocumentLabelScanStorageStrategyTest method shouldStoreAnyNodeIdInRange.

@Test
public void shouldStoreAnyNodeIdInRange() throws Exception {
    for (int i = 0, max = 1 << format.bitmapFormat().shift; i < max; i++) {
        // given
        IndexWriter indexWriter = mock(IndexWriter.class);
        WritableIndexPartition partition = newIndexPartitionMock(indexWriter);
        WritableDatabaseLabelScanIndex index = buildLuceneIndex(partition);
        LabelScanWriter writer = new PartitionedLuceneLabelScanWriter(index, format);
        // when
        writer.write(labelChanges(i, labels(), labels(7)));
        writer.close();
        // then
        Document document = new Document();
        format.addRangeValuesField(document, 0);
        format.addLabelAndSearchFields(document, 7, new Bitmap(1L << i));
        verify(indexWriter).updateDocument(eq(format.rangeTerm(0)), match(document));
    }
}
Also used : Bitmap(org.neo4j.kernel.api.impl.labelscan.bitmaps.Bitmap) WritableDatabaseLabelScanIndex(org.neo4j.kernel.api.impl.labelscan.WritableDatabaseLabelScanIndex) IndexWriter(org.apache.lucene.index.IndexWriter) PartitionedLuceneLabelScanWriter(org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter) WritableIndexPartition(org.neo4j.kernel.api.impl.index.partition.WritableIndexPartition) Document(org.apache.lucene.document.Document) PartitionedLuceneLabelScanWriter(org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter) LabelScanWriter(org.neo4j.kernel.api.labelscan.LabelScanWriter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 PartitionedLuceneLabelScanWriter (org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter)12 Document (org.apache.lucene.document.Document)9 IndexWriter (org.apache.lucene.index.IndexWriter)6 WritableIndexPartition (org.neo4j.kernel.api.impl.index.partition.WritableIndexPartition)6 WritableDatabaseLabelScanIndex (org.neo4j.kernel.api.impl.labelscan.WritableDatabaseLabelScanIndex)6 LabelScanWriter (org.neo4j.kernel.api.labelscan.LabelScanWriter)6 Term (org.apache.lucene.index.Term)4 Bitmap (org.neo4j.kernel.api.impl.labelscan.bitmaps.Bitmap)2 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 TermQuery (org.apache.lucene.search.TermQuery)1 PartitionSearcher (org.neo4j.kernel.api.impl.index.partition.PartitionSearcher)1