use of org.neo4j.kernel.impl.api.index.StoreScan in project neo4j by neo4j.
the class FullScanStoreViewTest method shouldScanExistingRelationshipsForARelationshipType.
@Test
void shouldScanExistingRelationshipsForARelationshipType() {
// given
TestPropertyScanConsumer propertyScanConsumer = new TestPropertyScanConsumer();
StoreScan storeScan = storeView.visitRelationships(new int[] { relTypeId }, id -> id == relPropertyKeyId, propertyScanConsumer, null, true, true, NULL, INSTANCE);
// when
storeScan.run(NO_EXTERNAL_UPDATES);
// then
assertThat(propertyScanConsumer.batches.get(0)).containsExactlyInAnyOrder(record(aKnowsS.getId(), relPropertyKeyId, "long", new long[] { relTypeId }), record(sKnowsA.getId(), relPropertyKeyId, "lengthy", new long[] { relTypeId }));
}
use of org.neo4j.kernel.impl.api.index.StoreScan in project neo4j by neo4j.
the class FullScanStoreViewTest method shouldLockNodesWhileReadingThem.
@Test
void shouldLockNodesWhileReadingThem() {
// given
StoreScan storeScan = storeView.visitNodes(new int[] { labelId }, id -> id == propertyKeyId, new TestPropertyScanConsumer(), null, false, true, NULL, INSTANCE);
// when
storeScan.run(NO_EXTERNAL_UPDATES);
// then
assertThat(lockMocks.size()).as("allocated locks: " + lockMocks.keySet()).isGreaterThanOrEqualTo(2);
Lock lock0 = lockMocks.get(0L);
Lock lock1 = lockMocks.get(1L);
assertNotNull(lock0, "Lock[node=0] never acquired");
assertNotNull(lock1, "Lock[node=1] never acquired");
InOrder order = inOrder(locks, lock0, lock1);
order.verify(locks).acquireNodeLock(0, SHARED);
order.verify(lock0).release();
order.verify(locks).acquireNodeLock(1, SHARED);
order.verify(lock1).release();
}
use of org.neo4j.kernel.impl.api.index.StoreScan in project neo4j by neo4j.
the class FullScanStoreViewTest method shouldScanExistingNodesForALabel.
@Test
void shouldScanExistingNodesForALabel() {
// given
TestPropertyScanConsumer propertyScanConsumer = new TestPropertyScanConsumer();
StoreScan storeScan = storeView.visitNodes(new int[] { labelId }, id -> id == propertyKeyId, propertyScanConsumer, new TestTokenScanConsumer(), false, true, NULL, INSTANCE);
// when
storeScan.run(NO_EXTERNAL_UPDATES);
// then
assertThat(propertyScanConsumer.batches.get(0)).containsExactlyInAnyOrder(record(alistair.getId(), propertyKeyId, "Alistair", new long[] { labelId }), record(stefan.getId(), propertyKeyId, "Stefan", new long[] { labelId }));
}
use of org.neo4j.kernel.impl.api.index.StoreScan in project neo4j by neo4j.
the class DynamicIndexStoreViewTest method shouldVisitNodesUsingTokenIndex.
@Test
void shouldVisitNodesUsingTokenIndex() throws Exception {
long[] nodeIds = { 1, 2, 3, 4, 5, 6, 7, 8 };
int[] indexedLabels = { 2, 6 };
StubStorageCursors cursors = new StubStorageCursors().withTokenIndexes();
IndexProxy indexProxy = mock(IndexProxy.class);
IndexProxyProvider indexProxies = mock(IndexProxyProvider.class);
StubTokenIndexReader tokenReader = new StubTokenIndexReader();
IndexDescriptor descriptor = forSchema(forAnyEntityTokens(NODE), DESCRIPTOR).withName("index").materialise(0);
when(indexProxy.getState()).thenReturn(InternalIndexState.ONLINE);
when(indexProxy.newTokenReader()).thenReturn(tokenReader);
when(indexProxy.getDescriptor()).thenReturn(descriptor);
when(indexProxies.getIndexProxy(any())).thenReturn(indexProxy);
// Nodes indexed by label
for (long nodeId : nodeIds) {
cursors.withNode(nodeId).propertyId(1).relationship(1).labels(2, 6);
tokenReader.index(indexedLabels, nodeId);
}
// Nodes not indexed
cursors.withNode(9).labels(5);
cursors.withNode(10).labels(6);
DynamicIndexStoreView storeView = dynamicIndexStoreView(cursors, indexProxies);
TestTokenScanConsumer consumer = new TestTokenScanConsumer();
StoreScan storeScan = storeView.visitNodes(indexedLabels, Predicates.ALWAYS_TRUE_INT, new TestPropertyScanConsumer(), consumer, false, true, NULL, INSTANCE);
storeScan.run(StoreScan.NO_EXTERNAL_UPDATES);
assertThat(consumer.batches.size()).isEqualTo(1);
assertThat(consumer.batches.get(0).size()).isEqualTo(nodeIds.length);
}
use of org.neo4j.kernel.impl.api.index.StoreScan in project neo4j by neo4j.
the class DynamicIndexStoreViewTest method shouldVisitAllNodesWithoutTokenIndexes.
@Test
void shouldVisitAllNodesWithoutTokenIndexes() {
long[] nodeIds = { 1, 2, 3, 4, 5, 6, 7, 8 };
int[] indexedLabels = { 2, 6 };
StubStorageCursors cursors = new StubStorageCursors().withoutTokenIndexes();
IndexProxyProvider indexProxies = mock(IndexProxyProvider.class);
// Nodes indexed by label
for (long nodeId : nodeIds) {
cursors.withNode(nodeId).propertyId(1).relationship(1).labels(2, 6);
}
// Nodes not in index
cursors.withNode(9).labels(5);
cursors.withNode(10).labels(6);
DynamicIndexStoreView storeView = dynamicIndexStoreView(cursors, indexProxies);
TestTokenScanConsumer consumer = new TestTokenScanConsumer();
StoreScan storeScan = storeView.visitNodes(indexedLabels, Predicates.ALWAYS_TRUE_INT, new TestPropertyScanConsumer(), consumer, false, true, NULL, INSTANCE);
storeScan.run(StoreScan.NO_EXTERNAL_UPDATES);
assertThat(consumer.batches.size()).isEqualTo(1);
assertThat(consumer.batches.get(0).size()).isEqualTo(nodeIds.length + 2);
}
Aggregations