use of org.neo4j.storageengine.api.StorageNodeCursor in project neo4j by neo4j.
the class StoreScanStageTest method shouldAbortScanOnStopped.
@Test
void shouldAbortScanOnStopped() {
// given
StubStorageCursors data = someData();
EntityIdIterator entityIdIterator = new CursorEntityIdIterator<>(data.allocateNodeCursor(NULL));
AtomicInteger numBatchesProcessed = new AtomicInteger();
AtomicBoolean continueScanning = new AtomicBoolean(true);
AbortingExternalUpdatesCheck externalUpdatesCheck = new AbortingExternalUpdatesCheck(1, continueScanning);
var writer = new PropertyConsumer(() -> numBatchesProcessed.incrementAndGet());
StoreScanStage<StorageNodeCursor> scan = new StoreScanStage(dbConfig, config, ct -> entityIdIterator, externalUpdatesCheck, continueScanning, data, new int[] { LABEL }, alwaysTrue(), writer, null, new NodeCursorBehaviour(data), id -> null, true, jobScheduler, PageCacheTracer.NULL, EmptyMemoryTracker.INSTANCE);
// when
runScan(scan);
// then
assertThat(numBatchesProcessed.get()).isEqualTo(2);
}
use of org.neo4j.storageengine.api.StorageNodeCursor in project neo4j by neo4j.
the class NeoStoresTest method nodeAddProperty.
private StorageProperty nodeAddProperty(long nodeId, int key, Object value) {
StorageProperty property = new PropertyKeyValue(key, Values.of(value));
StorageProperty oldProperty = null;
try (StorageNodeCursor nodeCursor = storageReader.allocateNodeCursor(NULL)) {
nodeCursor.single(nodeId);
if (nodeCursor.next()) {
StorageProperty fetched = getProperty(key, nodeCursor.propertiesReference());
if (fetched != null) {
oldProperty = fetched;
}
}
}
if (oldProperty == null) {
transactionState.nodeDoAddProperty(nodeId, key, property.value());
} else {
transactionState.nodeDoChangeProperty(nodeId, key, property.value());
}
return property;
}
use of org.neo4j.storageengine.api.StorageNodeCursor in project neo4j by neo4j.
the class TxStateTransactionDataSnapshot method takeSnapshot.
private void takeSnapshot(MemoryTracker memoryTracker) {
var cursorContext = transaction.cursorContext();
try (StorageNodeCursor node = store.allocateNodeCursor(cursorContext);
StoragePropertyCursor properties = store.allocatePropertyCursor(cursorContext, memoryTracker)) {
TokenRead tokenRead = transaction.tokenRead();
snapshotRemovedNodes(memoryTracker, node, properties, tokenRead);
snapshotRemovedRelationships(memoryTracker, properties, tokenRead);
snapshotModifiedNodes(memoryTracker, node, properties, tokenRead);
snapshotModifiedRelationships(memoryTracker, properties, tokenRead);
} catch (PropertyKeyIdNotFoundKernelException e) {
throw new IllegalStateException("An entity that does not exist was modified.", e);
}
}
use of org.neo4j.storageengine.api.StorageNodeCursor in project neo4j by neo4j.
the class RecordStorageReaderLabelTest method labelsShouldNotLeakOutAsProperties.
@Test
void labelsShouldNotLeakOutAsProperties() throws Exception {
// GIVEN
long nodeId = createNode(map("name", "Node"), label1);
int namePropertyKeyId = propertyKeyId("name");
// WHEN THEN
StorageNodeCursor nodeCursor = storageReader.allocateNodeCursor(NULL);
StoragePropertyCursor propertyCursor = storageReader.allocatePropertyCursor(NULL, INSTANCE);
nodeCursor.single(nodeId);
assertTrue(nodeCursor.next());
nodeCursor.properties(propertyCursor);
assertTrue(propertyCursor.next());
assertEquals(namePropertyKeyId, propertyCursor.propertyKey());
assertFalse(propertyCursor.next());
}
use of org.neo4j.storageengine.api.StorageNodeCursor in project neo4j by neo4j.
the class RecordStorageReaderRelTypesAndDegreeTest method testDegreeByDirectionAndTypeForDenseNodeWithPartiallyDeletedRelChains.
protected void testDegreeByDirectionAndTypeForDenseNodeWithPartiallyDeletedRelChains(boolean modifyInChain, boolean modifyOutChain, boolean modifyLoopChain) throws Exception {
int inRelCount = randomRelCount();
int outRelCount = randomRelCount();
int loopRelCount = randomRelCount();
long nodeId = createNode(inRelCount, outRelCount, loopRelCount);
StorageNodeCursor cursor = newCursor(nodeId);
if (modifyInChain) {
markRandomRelsInGroupNotInUse(nodeId, IN);
}
if (modifyOutChain) {
markRandomRelsInGroupNotInUse(nodeId, OUT);
}
if (modifyLoopChain) {
markRandomRelsInGroupNotInUse(nodeId, LOOP);
}
assertEquals(0, degreeForDirectionAndType(cursor, OUTGOING, relTypeId(IN)));
assertEquals(outRelCount, degreeForDirectionAndType(cursor, OUTGOING, relTypeId(OUT)));
assertEquals(loopRelCount, degreeForDirectionAndType(cursor, OUTGOING, relTypeId(LOOP)));
assertEquals(0, degreeForDirectionAndType(cursor, INCOMING, relTypeId(OUT)));
assertEquals(inRelCount, degreeForDirectionAndType(cursor, INCOMING, relTypeId(IN)));
assertEquals(loopRelCount, degreeForDirectionAndType(cursor, INCOMING, relTypeId(LOOP)));
assertEquals(inRelCount, degreeForDirectionAndType(cursor, BOTH, relTypeId(IN)));
assertEquals(outRelCount, degreeForDirectionAndType(cursor, BOTH, relTypeId(OUT)));
assertEquals(loopRelCount, degreeForDirectionAndType(cursor, BOTH, relTypeId(LOOP)));
}
Aggregations