Search in sources :

Example 1 with RELATIONSHIP

use of org.neo4j.common.EntityType.RELATIONSHIP in project neo4j by neo4j.

the class DynamicIndexStoreViewTest method shouldVisitAllRelationshipsWithoutTokenIndexes.

@Test
void shouldVisitAllRelationshipsWithoutTokenIndexes() {
    StubStorageCursors cursors = new StubStorageCursors().withoutTokenIndexes();
    IndexProxyProvider indexProxies = mock(IndexProxyProvider.class);
    int targetType = 1;
    int notTargetType = 2;
    int[] targetTypeArray = { targetType };
    String targetPropertyKey = "key";
    Value propertyValue = Values.stringValue("value");
    MutableLongList relationshipsWithTargetType = LongLists.mutable.empty();
    long id = 0;
    int wantedPropertyUpdates = 5;
    for (int i = 0; i < wantedPropertyUpdates; i++) {
        // Relationship fitting our target
        cursors.withRelationship(id, 1, targetType, 3).properties(targetPropertyKey, propertyValue);
        relationshipsWithTargetType.add(id++);
        // Relationship with different type
        cursors.withRelationship(id, 1, notTargetType, 3).properties(targetPropertyKey, propertyValue);
        relationshipsWithTargetType.add(id++);
    }
    int targetPropertyKeyId = cursors.propertyKeyTokenHolder().getIdByName(targetPropertyKey);
    IntPredicate propertyKeyIdFilter = value -> value == targetPropertyKeyId;
    DynamicIndexStoreView storeView = dynamicIndexStoreView(cursors, indexProxies);
    TestTokenScanConsumer tokenConsumer = new TestTokenScanConsumer();
    TestPropertyScanConsumer propertyScanConsumer = new TestPropertyScanConsumer();
    StoreScan storeScan = storeView.visitRelationships(targetTypeArray, propertyKeyIdFilter, propertyScanConsumer, tokenConsumer, false, true, NULL, INSTANCE);
    storeScan.run(StoreScan.NO_EXTERNAL_UPDATES);
    assertThat(tokenConsumer.batches.size()).isEqualTo(1);
    assertThat(tokenConsumer.batches.get(0).size()).isEqualTo(relationshipsWithTargetType.size());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IndexProxy(org.neo4j.kernel.impl.api.index.IndexProxy) IndexPrototype.forSchema(org.neo4j.internal.schema.IndexPrototype.forSchema) InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) IndexProxyProvider(org.neo4j.kernel.impl.api.index.IndexingService.IndexProxyProvider) Predicates(org.neo4j.function.Predicates) LongLists(org.eclipse.collections.impl.factory.primitive.LongLists) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Config(org.neo4j.configuration.Config) StoreScan(org.neo4j.kernel.impl.api.index.StoreScan) Value(org.neo4j.values.storable.Value) NULL(org.neo4j.io.pagecache.tracing.PageCacheTracer.NULL) MutableLongList(org.eclipse.collections.api.list.primitive.MutableLongList) NullLogProvider(org.neo4j.logging.NullLogProvider) IntPredicate(java.util.function.IntPredicate) Supplier(java.util.function.Supplier) Values(org.neo4j.values.storable.Values) StorageReader(org.neo4j.storageengine.api.StorageReader) JobSchedulerFactory(org.neo4j.kernel.impl.scheduler.JobSchedulerFactory) JobScheduler(org.neo4j.scheduler.JobScheduler) Mockito.when(org.mockito.Mockito.when) RELATIONSHIP(org.neo4j.common.EntityType.RELATIONSHIP) NO_LOCKS(org.neo4j.kernel.impl.locking.Locks.NO_LOCKS) Test(org.junit.jupiter.api.Test) AfterEach(org.junit.jupiter.api.AfterEach) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) StubStorageCursors(org.neo4j.storageengine.api.StubStorageCursors) NO_LOCK_SERVICE(org.neo4j.lock.LockService.NO_LOCK_SERVICE) DESCRIPTOR(org.neo4j.kernel.impl.index.schema.TokenIndexProvider.DESCRIPTOR) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) NODE(org.neo4j.common.EntityType.NODE) SchemaDescriptor.forAnyEntityTokens(org.neo4j.internal.schema.SchemaDescriptor.forAnyEntityTokens) Mockito.mock(org.mockito.Mockito.mock) MutableLongList(org.eclipse.collections.api.list.primitive.MutableLongList) IntPredicate(java.util.function.IntPredicate) StoreScan(org.neo4j.kernel.impl.api.index.StoreScan) Value(org.neo4j.values.storable.Value) IndexProxyProvider(org.neo4j.kernel.impl.api.index.IndexingService.IndexProxyProvider) StubStorageCursors(org.neo4j.storageengine.api.StubStorageCursors) Test(org.junit.jupiter.api.Test)

Aggregations

IntPredicate (java.util.function.IntPredicate)1 Supplier (java.util.function.Supplier)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 MutableLongList (org.eclipse.collections.api.list.primitive.MutableLongList)1 LongLists (org.eclipse.collections.impl.factory.primitive.LongLists)1 AfterEach (org.junit.jupiter.api.AfterEach)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 NODE (org.neo4j.common.EntityType.NODE)1 RELATIONSHIP (org.neo4j.common.EntityType.RELATIONSHIP)1 Config (org.neo4j.configuration.Config)1 Predicates (org.neo4j.function.Predicates)1 InternalIndexState (org.neo4j.internal.kernel.api.InternalIndexState)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 IndexPrototype.forSchema (org.neo4j.internal.schema.IndexPrototype.forSchema)1 SchemaDescriptor.forAnyEntityTokens (org.neo4j.internal.schema.SchemaDescriptor.forAnyEntityTokens)1 NULL (org.neo4j.io.pagecache.tracing.PageCacheTracer.NULL)1 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)1