Search in sources :

Example 16 with IndexSample

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());
}
Also used : IndexSample(org.neo4j.kernel.api.index.IndexSample)

Example 17 with IndexSample

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));
}
Also used : IndexSample(org.neo4j.kernel.api.index.IndexSample) IndexSampler(org.neo4j.kernel.api.index.IndexSampler) Test(org.junit.jupiter.api.Test)

Example 18 with IndexSample

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);
}
Also used : IndexSample(org.neo4j.kernel.api.index.IndexSample) IndexSampler(org.neo4j.kernel.api.index.IndexSampler) Test(org.junit.jupiter.api.Test)

Example 19 with IndexSample

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);
}
Also used : IndexSample(org.neo4j.kernel.api.index.IndexSample)

Example 20 with IndexSample

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);
}
Also used : IndexSample(org.neo4j.kernel.api.index.IndexSample) CursorContext(org.neo4j.io.pagecache.context.CursorContext) ValueIndexReader(org.neo4j.kernel.api.index.ValueIndexReader) IndexSampler(org.neo4j.kernel.api.index.IndexSampler) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

IndexSample (org.neo4j.kernel.api.index.IndexSample)56 Test (org.junit.jupiter.api.Test)43 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)14 CursorContext (org.neo4j.io.pagecache.context.CursorContext)13 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)10 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)8 IndexEntryUpdate (org.neo4j.storageengine.api.IndexEntryUpdate)8 NodePropertyAccessor (org.neo4j.storageengine.api.NodePropertyAccessor)8 IndexProvider (org.neo4j.kernel.api.index.IndexProvider)7 IndexSampler (org.neo4j.kernel.api.index.IndexSampler)7 ArrayList (java.util.ArrayList)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Config (org.neo4j.configuration.Config)6 Transaction (org.neo4j.graphdb.Transaction)6 IOException (java.io.IOException)5 Path (java.nio.file.Path)4 Arrays.asList (java.util.Arrays.asList)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4