Search in sources :

Example 1 with IndexSample

use of org.neo4j.storageengine.api.schema.IndexSample in project neo4j by neo4j.

the class PartitionedIndexReaderTest method samplingOverPartitions.

@Test
public void samplingOverPartitions() throws IndexNotFoundKernelException {
    PartitionedIndexReader indexReader = createPartitionedReaderFromReaders();
    when(indexReader1.createSampler()).thenReturn(new SimpleSampler(1));
    when(indexReader2.createSampler()).thenReturn(new SimpleSampler(2));
    when(indexReader3.createSampler()).thenReturn(new SimpleSampler(3));
    IndexSampler sampler = indexReader.createSampler();
    assertEquals(new IndexSample(6, 6, 6), sampler.sampleIndex());
}
Also used : IndexSample(org.neo4j.storageengine.api.schema.IndexSample) IndexSampler(org.neo4j.storageengine.api.schema.IndexSampler) Test(org.junit.Test)

Example 2 with IndexSample

use of org.neo4j.storageengine.api.schema.IndexSample in project neo4j by neo4j.

the class NonUniqueDatabaseIndexPopulatingUpdaterTest method verifySamplingResult.

private static void verifySamplingResult(NonUniqueIndexSampler sampler, long expectedIndexSize, long expectedUniqueValues, long expectedSampleSize) {
    IndexSample sample = sampler.result();
    assertEquals(expectedIndexSize, sample.indexSize());
    assertEquals(expectedUniqueValues, sample.uniqueValues());
    assertEquals(expectedSampleSize, sample.sampleSize());
}
Also used : IndexSample(org.neo4j.storageengine.api.schema.IndexSample)

Example 3 with IndexSample

use of org.neo4j.storageengine.api.schema.IndexSample 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)

Example 4 with IndexSample

use of org.neo4j.storageengine.api.schema.IndexSample in project neo4j by neo4j.

the class MultipleIndexPopulatorUpdatesTest method createIndexPopulator.

private IndexPopulator createIndexPopulator() {
    IndexPopulator populator = mock(IndexPopulator.class);
    when(populator.sampleResult()).thenReturn(new IndexSample());
    return populator;
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexSample(org.neo4j.storageengine.api.schema.IndexSample)

Example 5 with IndexSample

use of org.neo4j.storageengine.api.schema.IndexSample in project neo4j by neo4j.

the class DefaultNonUniqueIndexSamplerTest method assertSampledValues.

private void assertSampledValues(NonUniqueIndexSampler sampler, long expectedIndexSize, long expectedUniqueValues, long expectedSampledSize) {
    IndexSample sample = sampler.result();
    assertEquals(expectedIndexSize, sample.indexSize());
    assertEquals(expectedUniqueValues, sample.uniqueValues());
    assertEquals(expectedSampledSize, sample.sampleSize());
}
Also used : IndexSample(org.neo4j.storageengine.api.schema.IndexSample)

Aggregations

IndexSample (org.neo4j.storageengine.api.schema.IndexSample)8 Test (org.junit.Test)3 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)2 IndexSampler (org.neo4j.storageengine.api.schema.IndexSampler)2 File (java.io.File)1 IOException (java.io.IOException)1 RAMDirectory (org.apache.lucene.store.RAMDirectory)1 Before (org.junit.Before)1 PartitionSearcher (org.neo4j.kernel.api.impl.index.partition.PartitionSearcher)1 WritableIndexPartition (org.neo4j.kernel.api.impl.index.partition.WritableIndexPartition)1 LuceneIndexAccessor (org.neo4j.kernel.api.impl.schema.LuceneIndexAccessor)1 SchemaIndex (org.neo4j.kernel.api.impl.schema.SchemaIndex)1 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)1 IndexReader (org.neo4j.storageengine.api.schema.IndexReader)1 DoubleLatch (org.neo4j.test.DoubleLatch)1