use of org.neo4j.storageengine.api.schema.LabelScanReader in project neo4j by neo4j.
the class StoreStatementTest method shouldCloseOpenedLabelScanReader.
@Test
public void shouldCloseOpenedLabelScanReader() throws Exception {
// given
Supplier<LabelScanReader> scanStore = mock(Supplier.class);
LabelScanReader scanReader = mock(LabelScanReader.class);
when(scanStore.get()).thenReturn(scanReader);
StoreStatement statement = new StoreStatement(MockedNeoStores.basicMockedNeoStores(), mock(Supplier.class), scanStore, LockService.NO_LOCK_SERVICE);
statement.acquire();
// when
LabelScanReader actualReader = statement.getLabelScanReader();
// then
assertEquals(scanReader, actualReader);
// when
statement.close();
// then
verify(scanStore).get();
verifyNoMoreInteractions(scanStore);
verify(scanReader).close();
verifyNoMoreInteractions(scanReader);
}
use of org.neo4j.storageengine.api.schema.LabelScanReader in project neo4j by neo4j.
the class DynamicIndexStoreViewTest method visitOnlyLabeledNodesWhenThresholdNotReached.
@Test
public void visitOnlyLabeledNodesWhenThresholdNotReached() throws Exception {
LabelScanReader labelScanReader = mock(LabelScanReader.class);
when(labelScanStore.newReader()).thenReturn(labelScanReader);
when(nodeLabelRanges.maxCount()).thenReturn(1L);
PrimitiveLongIterator labeledNodesIterator = PrimitiveLongCollections.iterator(1, 2, 3, 4, 5, 6, 7, 8);
when(nodeStore.getHighestPossibleIdInUse()).thenReturn(200L);
when(nodeStore.getHighId()).thenReturn(20L);
when(labelScanReader.nodesWithAnyOfLabels(2, 6)).thenReturn(labeledNodesIterator);
mockLabelNodeCount(countStore, 2);
mockLabelNodeCount(countStore, 6);
DynamicIndexStoreView storeView = new DynamicIndexStoreView(labelScanStore, LockService.NO_LOCK_SERVICE, neoStores, NullLogProvider.getInstance());
StoreScan<Exception> storeScan = storeView.visitNodes(new int[] { 2, 6 }, propertyKeyIdFilter, propertyUpdateVisitor, labelUpdateVisitor, false);
storeScan.run();
Mockito.verify(nodeStore, times(8)).getRecord(anyLong(), any(NodeRecord.class), any(RecordLoad.class));
}
use of org.neo4j.storageengine.api.schema.LabelScanReader in project neo4j by neo4j.
the class LabelScanStoreTest method shouldUpdateAFullRange.
@Test
public void shouldUpdateAFullRange() throws Exception {
// given
long label0Id = 0;
List<NodeLabelUpdate> label0Updates = new ArrayList<>();
Set<Long> nodes = new HashSet<>();
for (int i = 0; i < 34; i++) {
label0Updates.add(NodeLabelUpdate.labelChanges(i, new long[] {}, new long[] { label0Id }));
nodes.add((long) i);
}
start(label0Updates);
// when
write(Collections.emptyIterator());
// then
LabelScanReader reader = store.newReader();
Set<Long> nodesWithLabel0 = PrimitiveLongCollections.toSet(reader.nodesWithLabel((int) label0Id));
assertEquals(nodes, nodesWithLabel0);
}
use of org.neo4j.storageengine.api.schema.LabelScanReader in project neo4j by neo4j.
the class NativeLabelScanStoreIT method verifyReads.
private void verifyReads(long[] expected) {
try (LabelScanReader reader = store.newReader()) {
for (int i = 0; i < LABEL_COUNT; i++) {
long[] actualNodes = asArray(reader.nodesWithLabel(i));
long[] expectedNodes = nodesWithLabel(expected, i);
assertArrayEquals(expectedNodes, actualNodes);
}
}
}
Aggregations