use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class UniqueDatabaseIndexPopulatingUpdaterTest method verifySamplingResult.
private static void verifySamplingResult(UniqueIndexSampler sampler, long expectedValue) {
IndexSample sample = sampler.result();
assertEquals(expectedValue, sample.indexSize());
assertEquals(expectedValue, sample.uniqueValues());
assertEquals(expectedValue, sample.sampleSize());
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class PartitionedValueIndexReaderTest method samplingOverPartitions.
@Test
void samplingOverPartitions() throws IndexNotFoundKernelException {
PartitionedValueIndexReader 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(NULL));
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class AggregatingIndexSamplerTest method samplePartitionedIndex.
@Test
void samplePartitionedIndex() {
List<IndexSampler> samplers = Arrays.asList(createSampler(1), createSampler(2));
AggregatingIndexSampler partitionedSampler = new AggregatingIndexSampler(samplers);
IndexSample sample = partitionedSampler.sampleIndex(NULL);
assertEquals(new IndexSample(3, 3, 6), sample);
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class AllStoreHolder method indexUniqueValuesSelectivity.
@Override
public double indexUniqueValuesSelectivity(IndexDescriptor index) throws IndexNotFoundKernelException {
assertValidIndex(index);
acquireSharedSchemaLock(index);
ktx.assertOpen();
// Throws if the index has been dropped.
assertIndexExists(index);
final IndexSample indexSample = indexStatisticsStore.indexSample(index.getId());
long unique = indexSample.uniqueValues();
long size = indexSample.sampleSize();
return size == 0 ? 1.0d : ((double) unique) / ((double) size);
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class IndexingServiceTest method setUp.
@BeforeEach
void setUp() throws IndexNotFoundKernelException {
when(populator.sample(any(CursorContext.class))).thenReturn(new IndexSample());
when(indexStatisticsStore.indexSample(anyLong())).thenReturn(new IndexSample());
when(storeViewFactory.createTokenIndexStoreView(any())).thenReturn(storeView);
when(storeView.newPropertyAccessor(any(CursorContext.class), any())).thenReturn(propertyAccessor);
ValueIndexReader indexReader = mock(ValueIndexReader.class);
IndexSampler indexSampler = mock(IndexSampler.class);
when(indexSampler.sampleIndex(any())).thenReturn(new IndexSample());
when(indexReader.createSampler()).thenReturn(indexSampler);
when(accessor.newValueReader()).thenReturn(indexReader);
}
Aggregations