use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class MultipleIndexPopulatorTest method shouldIncludeIndexSampleUpdatesInStatsOnFlip.
@Test
void shouldIncludeIndexSampleUpdatesInStatsOnFlip() {
IndexProxyFactory indexProxyFactory = mock(IndexProxyFactory.class);
FailedIndexProxyFactory failedIndexProxyFactory = mock(FailedIndexProxyFactory.class);
FlippableIndexProxy flipper = new FlippableIndexProxy();
flipper.setFlipTarget(indexProxyFactory);
IndexPopulator indexPopulator = createIndexPopulator();
addPopulator(indexPopulator, 1, flipper, failedIndexProxyFactory);
int indexSize = 100;
int uniqueValues = 110;
int sampleSize = 120;
int updates = 130;
IndexSample sample = new IndexSample(indexSize, uniqueValues, sampleSize, updates);
when(indexPopulator.sample(any(CursorContext.class))).thenReturn(sample);
multipleIndexPopulator.createStoreScan(PageCacheTracer.NULL);
multipleIndexPopulator.flipAfterStoreScan(false, NULL);
verify(indexPopulator).close(true, NULL);
verify(indexStatisticsStore).replaceStats(1, sample);
verify(schemaState).clear();
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class UniqueDatabaseIndexSamplerTest method uniqueSamplingUseDocumentsNumber.
@Test
void uniqueSamplingUseDocumentsNumber() throws IndexNotFoundKernelException {
when(indexSearcher.getIndexReader().numDocs()).thenReturn(17);
UniqueLuceneIndexSampler sampler = new UniqueLuceneIndexSampler(indexSearcher, taskControl);
IndexSample sample = sampler.sampleIndex(NULL);
assertEquals(17, sample.indexSize());
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class LuceneSchemaIndexPopulationIT method partitionedIndexPopulation.
@ParameterizedTest
@ValueSource(ints = { 7, 11, 14, 20, 35, 58 })
void partitionedIndexPopulation(int affectedNodes) throws Exception {
Path rootFolder = testDir.directory("partitionIndex" + affectedNodes).resolve("uniqueIndex" + affectedNodes);
try (SchemaIndex uniqueIndex = LuceneSchemaIndexBuilder.create(descriptor, writable(), Config.defaults()).withFileSystem(fileSystem).withIndexRootFolder(rootFolder).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, SIMPLE_TOKEN_LOOKUP)) {
generateUpdates(indexAccessor, affectedNodes);
indexAccessor.force(NULL);
// now index is online and should contain updates data
assertTrue(uniqueIndex.isOnline());
try (var indexReader = indexAccessor.newValueReader();
NodeValueIterator results = new NodeValueIterator();
IndexSampler indexSampler = indexReader.createSampler()) {
indexReader.query(NULL_CONTEXT, results, unconstrained(), PropertyIndexQuery.exists(1));
long[] nodes = PrimitiveLongCollections.asArray(results);
assertEquals(affectedNodes, nodes.length);
IndexSample sample = indexSampler.sampleIndex(NULL);
assertEquals(affectedNodes, sample.indexSize());
assertEquals(affectedNodes, sample.uniqueValues());
assertEquals(affectedNodes, sample.sampleSize());
}
}
}
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class NonUniqueDatabaseIndexPopulatorTest method sampleEmptyIndex.
@Test
void sampleEmptyIndex() {
populator = newPopulator();
IndexSample sample = populator.sample(NULL);
assertEquals(new IndexSample(), sample);
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class DefaultNonUniqueIndexSamplerTest method assertSampledValues.
private static void assertSampledValues(NonUniqueIndexSampler sampler, long expectedIndexSize, long expectedUniqueValues, long expectedSampledSize) {
IndexSample sample = sampler.sample(NULL);
assertEquals(expectedIndexSize, sample.indexSize());
assertEquals(expectedUniqueValues, sample.uniqueValues());
assertEquals(expectedSampledSize, sample.sampleSize());
}
Aggregations