Search in sources :

Example 11 with IndexSample

use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.

the class UniqueDatabaseIndexPopulatorTest method sampleIncludedUpdates.

@Test
void sampleIncludedUpdates() {
    LabelSchemaDescriptor schemaDescriptor = forLabel(1, 1);
    populator = newPopulator();
    List<IndexEntryUpdate<?>> updates = Arrays.asList(add(1, schemaDescriptor, "foo"), add(2, schemaDescriptor, "bar"), add(3, schemaDescriptor, "baz"), add(4, schemaDescriptor, "qux"));
    updates.forEach(populator::includeSample);
    IndexSample sample = populator.sample(NULL);
    assertEquals(new IndexSample(4, 4, 4), sample);
}
Also used : IndexEntryUpdate(org.neo4j.storageengine.api.IndexEntryUpdate) IndexSample(org.neo4j.kernel.api.index.IndexSample) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) Test(org.junit.jupiter.api.Test)

Example 12 with IndexSample

use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.

the class NonUniqueDatabaseIndexSamplerTest method nonUniqueIndexSampling.

@Test
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(NULL));
}
Also used : IndexSample(org.neo4j.kernel.api.index.IndexSample) IndexReaderStub(org.neo4j.kernel.api.impl.index.IndexReaderStub) Terms(org.apache.lucene.index.Terms) Test(org.junit.jupiter.api.Test)

Example 13 with IndexSample

use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.

the class BatchInsertTest method shouldRepopulatePreexistingIndexed.

@ParameterizedTest
@MethodSource("params")
void shouldRepopulatePreexistingIndexed(int denseNodeThreshold) throws Throwable {
    // GIVEN
    long jakewins = dbWithIndexAndSingleIndexedNode(denseNodeThreshold);
    IndexPopulator populator = mock(IndexPopulator.class);
    IndexProvider provider = mock(IndexProvider.class);
    IndexAccessor accessor = mock(IndexAccessor.class);
    when(provider.getProviderDescriptor()).thenReturn(DESCRIPTOR);
    when(provider.completeConfiguration(any(IndexDescriptor.class))).then(inv -> inv.getArgument(0));
    when(provider.getPopulator(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(), any(), any(TokenNameLookup.class))).thenReturn(populator);
    when(populator.sample(any(CursorContext.class))).thenReturn(new IndexSample());
    when(provider.getOnlineAccessor(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(TokenNameLookup.class))).thenReturn(accessor);
    BatchInserter inserter = newBatchInserterWithIndexProvider(singleInstanceIndexProviderFactory(KEY, provider), provider.getProviderDescriptor(), denseNodeThreshold);
    long boggle = inserter.createNode(map("handle", "b0ggl3"), label("Hacker"));
    // WHEN
    inserter.shutdown();
    // THEN
    verify(provider).init();
    verify(provider).start();
    verify(provider).getPopulator(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(), any(), any(TokenNameLookup.class));
    verify(populator).create();
    verify(populator).add(argThat(c -> c.contains(add(jakewins, internalIndex.schema(), Values.of("Jakewins"))) && c.contains(add(boggle, internalIndex.schema(), Values.of("b0ggl3")))), any(CursorContext.class));
    verify(populator).verifyDeferredConstraints(any(NodePropertyAccessor.class));
    verify(populator).close(eq(true), any());
    verify(provider).stop();
    verify(provider).shutdown();
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) Arrays(java.util.Arrays) ResourceIterator(org.neo4j.graphdb.ResourceIterator) DatabaseReadOnlyChecker.readOnly(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.readOnly) CursorContext(org.neo4j.io.pagecache.context.CursorContext) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Direction(org.neo4j.graphdb.Direction) TokenNameLookup(org.neo4j.common.TokenNameLookup) IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) NORMAL(org.neo4j.kernel.impl.store.record.RecordLoad.NORMAL) Config(org.neo4j.configuration.Config) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) NULL(org.neo4j.io.pagecache.context.CursorContext.NULL) RecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector) TokenIndexProviderFactory(org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory) SchemaStore(org.neo4j.kernel.impl.store.SchemaStore) Set(java.util.Set) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) Arguments(org.junit.jupiter.params.provider.Arguments) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) ConstraintDefinition(org.neo4j.graphdb.schema.ConstraintDefinition) Stream(java.util.stream.Stream) BatchInserter(org.neo4j.batchinsert.BatchInserter) IndexEntryUpdate.add(org.neo4j.storageengine.api.IndexEntryUpdate.add) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) RelationshipType(org.neo4j.graphdb.RelationshipType) NodeStore(org.neo4j.kernel.impl.store.NodeStore) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Mockito.mock(org.mockito.Mockito.mock) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) MapUtil.map(org.neo4j.internal.helpers.collection.MapUtil.map) SimpleDateFormat(java.text.SimpleDateFormat) KernelVersion(org.neo4j.kernel.KernelVersion) Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) OptionalLong(java.util.OptionalLong) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) GBPTreeCountsStore(org.neo4j.internal.counts.GBPTreeCountsStore) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MemoryTracker(org.neo4j.memory.MemoryTracker) NodePropertyAccessor(org.neo4j.storageengine.api.NodePropertyAccessor) TestIndexProviderDescriptor(org.neo4j.kernel.impl.api.index.TestIndexProviderDescriptor) IndexSample(org.neo4j.kernel.api.index.IndexSample) Files(java.nio.file.Files) Iterators(org.neo4j.internal.helpers.collection.Iterators) IOException(java.io.IOException) Label.label(org.neo4j.graphdb.Label.label) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ExtensionFactory(org.neo4j.kernel.extension.ExtensionFactory) TokenHolders(org.neo4j.token.TokenHolders) ConstraintType(org.neo4j.graphdb.schema.ConstraintType) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) Iterators.asCollection(org.neo4j.internal.helpers.collection.Iterators.asCollection) SchemaIndexTestHelper.singleInstanceIndexProviderFactory(org.neo4j.kernel.impl.api.index.SchemaIndexTestHelper.singleInstanceIndexProviderFactory) SchemaRule(org.neo4j.internal.schema.SchemaRule) SchemaRuleAccess(org.neo4j.internal.recordstorage.SchemaRuleAccess) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) MyRelTypes(org.neo4j.kernel.impl.MyRelTypes) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) NodeLabelsField(org.neo4j.kernel.impl.store.NodeLabelsField) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Iterables.map(org.neo4j.internal.helpers.collection.Iterables.map) Iterables.single(org.neo4j.internal.helpers.collection.Iterables.single) Transaction(org.neo4j.graphdb.Transaction) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) MethodSource(org.junit.jupiter.params.provider.MethodSource) PageCache(org.neo4j.io.pagecache.PageCache) TestDirectory(org.neo4j.test.rule.TestDirectory) RecordStorageEngine(org.neo4j.internal.recordstorage.RecordStorageEngine) Neo4jLayoutExtension(org.neo4j.test.extension.Neo4jLayoutExtension) String.format(java.lang.String.format) Test(org.junit.jupiter.api.Test) List(java.util.List) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Label(org.neo4j.graphdb.Label) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) HashMap(java.util.HashMap) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) Iterators.iterator(org.neo4j.internal.helpers.collection.Iterators.iterator) IndexProvider(org.neo4j.kernel.api.index.IndexProvider) Values(org.neo4j.values.storable.Values) GraphDatabaseSettings.preallocate_logical_logs(org.neo4j.configuration.GraphDatabaseSettings.preallocate_logical_logs) HashSet(java.util.HashSet) ConstraintViolationException(org.neo4j.graphdb.ConstraintViolationException) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Inject(org.neo4j.test.extension.Inject) Iterables(org.neo4j.internal.helpers.collection.Iterables) GraphDatabaseSettings.dense_node_threshold(org.neo4j.configuration.GraphDatabaseSettings.dense_node_threshold) GraphDatabaseInternalSettings(org.neo4j.configuration.GraphDatabaseInternalSettings) Arguments.arguments(org.junit.jupiter.params.provider.Arguments.arguments) TestIndexDescriptorFactory(org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory) PageCacheExtension(org.neo4j.test.extension.pagecache.PageCacheExtension) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) CountsAccessor(org.neo4j.counts.CountsAccessor) Relationship(org.neo4j.graphdb.Relationship) CountsBuilder(org.neo4j.internal.counts.CountsBuilder) Iterators.asSet(org.neo4j.internal.helpers.collection.Iterators.asSet) Pair(org.neo4j.internal.helpers.collection.Pair) GraphDatabaseSettings.neo4j_home(org.neo4j.configuration.GraphDatabaseSettings.neo4j_home) BatchInserters(org.neo4j.batchinsert.BatchInserters) Collections(java.util.Collections) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) BatchInserter(org.neo4j.batchinsert.BatchInserter) TokenNameLookup(org.neo4j.common.TokenNameLookup) IndexSample(org.neo4j.kernel.api.index.IndexSample) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) CursorContext(org.neo4j.io.pagecache.context.CursorContext) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) NodePropertyAccessor(org.neo4j.storageengine.api.NodePropertyAccessor) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 14 with IndexSample

use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.

the class BatchInsertTest method shouldRunIndexPopulationJobAtShutdown.

@ParameterizedTest
@MethodSource("params")
void shouldRunIndexPopulationJobAtShutdown(int denseNodeThreshold) throws Throwable {
    // GIVEN
    IndexPopulator populator = mock(IndexPopulator.class);
    IndexProvider provider = mock(IndexProvider.class);
    IndexAccessor accessor = mock(IndexAccessor.class);
    when(provider.getProviderDescriptor()).thenReturn(DESCRIPTOR);
    when(provider.getPopulator(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(), any(), any(TokenNameLookup.class))).thenReturn(populator);
    when(populator.sample(any(CursorContext.class))).thenReturn(new IndexSample());
    when(provider.getOnlineAccessor(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(TokenNameLookup.class))).thenReturn(accessor);
    when(provider.completeConfiguration(any(IndexDescriptor.class))).then(inv -> inv.getArgument(0));
    BatchInserter inserter = newBatchInserterWithIndexProvider(singleInstanceIndexProviderFactory(KEY, provider), provider.getProviderDescriptor(), denseNodeThreshold);
    inserter.createDeferredSchemaIndex(label("Hacker")).on("handle").create();
    long nodeId = inserter.createNode(map("handle", "Jakewins"), label("Hacker"));
    // WHEN
    inserter.shutdown();
    // THEN
    verify(provider).init();
    verify(provider).start();
    verify(provider).getPopulator(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(), any(), any(TokenNameLookup.class));
    verify(populator).create();
    verify(populator).add(argThat(c -> c.contains(add(nodeId, internalIndex.schema(), Values.of("Jakewins")))), any(CursorContext.class));
    verify(populator).verifyDeferredConstraints(any(NodePropertyAccessor.class));
    verify(populator).close(eq(true), any());
    verify(provider).stop();
    verify(provider).shutdown();
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) Arrays(java.util.Arrays) ResourceIterator(org.neo4j.graphdb.ResourceIterator) DatabaseReadOnlyChecker.readOnly(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.readOnly) CursorContext(org.neo4j.io.pagecache.context.CursorContext) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Direction(org.neo4j.graphdb.Direction) TokenNameLookup(org.neo4j.common.TokenNameLookup) IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) NORMAL(org.neo4j.kernel.impl.store.record.RecordLoad.NORMAL) Config(org.neo4j.configuration.Config) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) NULL(org.neo4j.io.pagecache.context.CursorContext.NULL) RecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector) TokenIndexProviderFactory(org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory) SchemaStore(org.neo4j.kernel.impl.store.SchemaStore) Set(java.util.Set) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) Arguments(org.junit.jupiter.params.provider.Arguments) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) ConstraintDefinition(org.neo4j.graphdb.schema.ConstraintDefinition) Stream(java.util.stream.Stream) BatchInserter(org.neo4j.batchinsert.BatchInserter) IndexEntryUpdate.add(org.neo4j.storageengine.api.IndexEntryUpdate.add) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) RelationshipType(org.neo4j.graphdb.RelationshipType) NodeStore(org.neo4j.kernel.impl.store.NodeStore) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Mockito.mock(org.mockito.Mockito.mock) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) MapUtil.map(org.neo4j.internal.helpers.collection.MapUtil.map) SimpleDateFormat(java.text.SimpleDateFormat) KernelVersion(org.neo4j.kernel.KernelVersion) Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) OptionalLong(java.util.OptionalLong) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) GBPTreeCountsStore(org.neo4j.internal.counts.GBPTreeCountsStore) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MemoryTracker(org.neo4j.memory.MemoryTracker) NodePropertyAccessor(org.neo4j.storageengine.api.NodePropertyAccessor) TestIndexProviderDescriptor(org.neo4j.kernel.impl.api.index.TestIndexProviderDescriptor) IndexSample(org.neo4j.kernel.api.index.IndexSample) Files(java.nio.file.Files) Iterators(org.neo4j.internal.helpers.collection.Iterators) IOException(java.io.IOException) Label.label(org.neo4j.graphdb.Label.label) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ExtensionFactory(org.neo4j.kernel.extension.ExtensionFactory) TokenHolders(org.neo4j.token.TokenHolders) ConstraintType(org.neo4j.graphdb.schema.ConstraintType) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) Iterators.asCollection(org.neo4j.internal.helpers.collection.Iterators.asCollection) SchemaIndexTestHelper.singleInstanceIndexProviderFactory(org.neo4j.kernel.impl.api.index.SchemaIndexTestHelper.singleInstanceIndexProviderFactory) SchemaRule(org.neo4j.internal.schema.SchemaRule) SchemaRuleAccess(org.neo4j.internal.recordstorage.SchemaRuleAccess) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) MyRelTypes(org.neo4j.kernel.impl.MyRelTypes) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) NodeLabelsField(org.neo4j.kernel.impl.store.NodeLabelsField) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Iterables.map(org.neo4j.internal.helpers.collection.Iterables.map) Iterables.single(org.neo4j.internal.helpers.collection.Iterables.single) Transaction(org.neo4j.graphdb.Transaction) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) MethodSource(org.junit.jupiter.params.provider.MethodSource) PageCache(org.neo4j.io.pagecache.PageCache) TestDirectory(org.neo4j.test.rule.TestDirectory) RecordStorageEngine(org.neo4j.internal.recordstorage.RecordStorageEngine) Neo4jLayoutExtension(org.neo4j.test.extension.Neo4jLayoutExtension) String.format(java.lang.String.format) Test(org.junit.jupiter.api.Test) List(java.util.List) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Label(org.neo4j.graphdb.Label) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) HashMap(java.util.HashMap) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) Iterators.iterator(org.neo4j.internal.helpers.collection.Iterators.iterator) IndexProvider(org.neo4j.kernel.api.index.IndexProvider) Values(org.neo4j.values.storable.Values) GraphDatabaseSettings.preallocate_logical_logs(org.neo4j.configuration.GraphDatabaseSettings.preallocate_logical_logs) HashSet(java.util.HashSet) ConstraintViolationException(org.neo4j.graphdb.ConstraintViolationException) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Inject(org.neo4j.test.extension.Inject) Iterables(org.neo4j.internal.helpers.collection.Iterables) GraphDatabaseSettings.dense_node_threshold(org.neo4j.configuration.GraphDatabaseSettings.dense_node_threshold) GraphDatabaseInternalSettings(org.neo4j.configuration.GraphDatabaseInternalSettings) Arguments.arguments(org.junit.jupiter.params.provider.Arguments.arguments) TestIndexDescriptorFactory(org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory) PageCacheExtension(org.neo4j.test.extension.pagecache.PageCacheExtension) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) CountsAccessor(org.neo4j.counts.CountsAccessor) Relationship(org.neo4j.graphdb.Relationship) CountsBuilder(org.neo4j.internal.counts.CountsBuilder) Iterators.asSet(org.neo4j.internal.helpers.collection.Iterators.asSet) Pair(org.neo4j.internal.helpers.collection.Pair) GraphDatabaseSettings.neo4j_home(org.neo4j.configuration.GraphDatabaseSettings.neo4j_home) BatchInserters(org.neo4j.batchinsert.BatchInserters) Collections(java.util.Collections) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) BatchInserter(org.neo4j.batchinsert.BatchInserter) TokenNameLookup(org.neo4j.common.TokenNameLookup) IndexSample(org.neo4j.kernel.api.index.IndexSample) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) CursorContext(org.neo4j.io.pagecache.context.CursorContext) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) NodePropertyAccessor(org.neo4j.storageengine.api.NodePropertyAccessor) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 15 with IndexSample

use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.

the class NonUniqueDatabaseIndexPopulatorTest method sampleIncludedUpdatesWithDuplicates.

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

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