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));
}
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());
}
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());
}
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());
}
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);
}
Aggregations