Search in sources :

Example 6 with IndexSample

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

the class OnlineIndexSamplingJobTest method setup.

@Before
public void setup() throws IndexNotFoundKernelException {
    when(indexProxy.getDescriptor()).thenReturn(indexDescriptor);
    when(indexProxy.newReader()).thenReturn(indexReader);
    when(indexReader.createSampler()).thenReturn(indexSampler);
    when(indexSampler.sampleIndex()).thenReturn(new IndexSample(indexSize, indexUniqueValues, indexSize));
}
Also used : IndexSample(org.neo4j.storageengine.api.schema.IndexSample) Before(org.junit.Before)

Example 7 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 8 with IndexSample

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

the class NonUniqueDatabaseIndexSamplerTest method nonUniqueIndexSampling.

@Test
public void nonUniqueIndexSampling() throws Exception {
    Terms aTerms = getTerms("a", 1);
    Terms idTerms = getTerms("id", 2);
    Terms bTerms = getTerms("b", 3);
    Map<String, Terms> fieldTermsMap = MapUtil.genericMap("0string", aTerms, "id", idTerms, "0array", bTerms);
    IndexReaderStub indexReader = new IndexReaderStub(new SamplingFields(fieldTermsMap));
    indexReader.setElements(new String[4]);
    when(indexSearcher.getIndexReader()).thenReturn(indexReader);
    assertEquals(new IndexSample(4, 2, 4), createSampler().sampleIndex());
}
Also used : IndexSample(org.neo4j.storageengine.api.schema.IndexSample) IndexReaderStub(org.neo4j.kernel.api.impl.index.IndexReaderStub) Terms(org.apache.lucene.index.Terms) Test(org.junit.Test)

Example 9 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 10 with IndexSample

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

the class NonUniqueDatabaseIndexPopulatorTest method sampleIncludedUpdatesWithDuplicates.

@Test
public void sampleIncludedUpdatesWithDuplicates() throws Exception {
    populator = newPopulator();
    List<IndexEntryUpdate> updates = Arrays.asList(IndexEntryUpdate.add(1, labelSchemaDescriptor, "foo"), IndexEntryUpdate.add(2, labelSchemaDescriptor, "bar"), IndexEntryUpdate.add(3, labelSchemaDescriptor, "foo"));
    updates.forEach(populator::includeSample);
    IndexSample sample = populator.sampleResult();
    assertEquals(new IndexSample(3, 2, 3), sample);
}
Also used : IndexEntryUpdate(org.neo4j.kernel.api.index.IndexEntryUpdate) IndexSample(org.neo4j.storageengine.api.schema.IndexSample) Test(org.junit.Test)

Aggregations

IndexSample (org.neo4j.storageengine.api.schema.IndexSample)21 Test (org.junit.Test)12 IndexEntryUpdate (org.neo4j.kernel.api.index.IndexEntryUpdate)4 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)4 IndexSampler (org.neo4j.storageengine.api.schema.IndexSampler)4 Before (org.junit.Before)2 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)2 IndexReader (org.neo4j.storageengine.api.schema.IndexReader)2 File (java.io.File)1 IOException (java.io.IOException)1 Terms (org.apache.lucene.index.Terms)1 RAMDirectory (org.apache.lucene.store.RAMDirectory)1 IndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)1 IndexReaderStub (org.neo4j.kernel.api.impl.index.IndexReaderStub)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 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)1 LabelSchemaDescriptor (org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor)1