Search in sources :

Example 1 with LuceneIndexAccessor

use of org.neo4j.kernel.api.impl.schema.LuceneIndexAccessor in project neo4j by neo4j.

the class LuceneSchemaIndexPopulationIT method partitionedIndexPopulation.

@Test
public void partitionedIndexPopulation() throws Exception {
    try (SchemaIndex uniqueIndex = LuceneSchemaIndexBuilder.create(descriptor).withFileSystem(fileSystemRule.get()).withIndexRootFolder(testDir.directory("partitionIndex" + affectedNodes)).withIndexIdentifier("uniqueIndex" + affectedNodes).build()) {
        uniqueIndex.open();
        // index is empty and not yet exist
        assertEquals(0, uniqueIndex.allDocumentsReader().maxCount());
        assertFalse(uniqueIndex.exists());
        try (LuceneIndexAccessor indexAccessor = new LuceneIndexAccessor(uniqueIndex, descriptor)) {
            generateUpdates(indexAccessor, affectedNodes);
            indexAccessor.force();
            // now index is online and should contain updates data
            assertTrue(uniqueIndex.isOnline());
            try (IndexReader indexReader = indexAccessor.newReader()) {
                long[] nodes = PrimitiveLongCollections.asArray(indexReader.query(IndexQuery.exists(1)));
                assertEquals(affectedNodes, nodes.length);
                IndexSampler indexSampler = indexReader.createSampler();
                IndexSample sample = indexSampler.sampleIndex();
                assertEquals(affectedNodes, sample.indexSize());
                assertEquals(affectedNodes, sample.uniqueValues());
                assertEquals(affectedNodes, sample.sampleSize());
            }
        }
    }
}
Also used : LuceneIndexAccessor(org.neo4j.kernel.api.impl.schema.LuceneIndexAccessor) IndexSample(org.neo4j.storageengine.api.schema.IndexSample) SchemaIndex(org.neo4j.kernel.api.impl.schema.SchemaIndex) IndexReader(org.neo4j.storageengine.api.schema.IndexReader) IndexSampler(org.neo4j.storageengine.api.schema.IndexSampler) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 LuceneIndexAccessor (org.neo4j.kernel.api.impl.schema.LuceneIndexAccessor)1 SchemaIndex (org.neo4j.kernel.api.impl.schema.SchemaIndex)1 IndexReader (org.neo4j.storageengine.api.schema.IndexReader)1 IndexSample (org.neo4j.storageengine.api.schema.IndexSample)1 IndexSampler (org.neo4j.storageengine.api.schema.IndexSampler)1