use of org.neo4j.storageengine.api.StoragePropertyCursor in project neo4j by neo4j.
the class RecordStorageReaderPropertyTest method shouldGetAllNodeProperties.
@Test
void shouldGetAllNodeProperties() throws Exception {
// GIVEN
String longString = "AlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalong";
Object[] properties = { longString, createNew(String.class), createNew(long.class), createNew(int.class), createNew(byte.class), createNew(short.class), createNew(boolean.class), createNew(char.class), createNew(float.class), createNew(double.class), array(0, String.class), array(0, long.class), array(0, int.class), array(0, byte.class), array(0, short.class), array(0, boolean.class), array(0, char.class), array(0, float.class), array(0, double.class), array(1, String.class), array(1, long.class), array(1, int.class), array(1, byte.class), array(1, short.class), array(1, boolean.class), array(1, char.class), array(1, float.class), array(1, double.class), array(256, String.class), array(256, long.class), array(256, int.class), array(256, byte.class), array(256, short.class), array(256, boolean.class), array(256, char.class), array(256, float.class), array(256, double.class) };
for (Object value : properties) {
// given
long nodeId = createNode(singletonMap("prop", value), label1);
// when
try (StorageNodeCursor node = storageReader.allocateNodeCursor(NULL)) {
node.single(nodeId);
assertTrue(node.next());
try (StoragePropertyCursor props = storageReader.allocatePropertyCursor(NULL, INSTANCE)) {
node.properties(props);
if (props.next()) {
Value propVal = props.propertyValue();
// then
assertTrue(propVal.equals(Values.of(value)), propVal + ".equals(" + value + ")");
} else {
fail();
}
}
}
}
}
use of org.neo4j.storageengine.api.StoragePropertyCursor in project neo4j by neo4j.
the class GraphStoreFixture method nodeAsUpdates.
public EntityUpdates nodeAsUpdates(long nodeId) {
try (StorageReader storeReader = storageEngine.newReader();
StorageNodeCursor nodeCursor = storeReader.allocateNodeCursor(NULL);
StoragePropertyCursor propertyCursor = storeReader.allocatePropertyCursor(NULL, INSTANCE)) {
nodeCursor.single(nodeId);
long[] labels;
if (!nodeCursor.next() || !nodeCursor.hasProperties() || (labels = nodeCursor.labels()).length == 0) {
return null;
}
nodeCursor.properties(propertyCursor);
EntityUpdates.Builder update = EntityUpdates.forEntity(nodeId, true).withTokens(labels);
while (propertyCursor.next()) {
update.added(propertyCursor.propertyKey(), propertyCursor.propertyValue());
}
return update.build();
}
}
use of org.neo4j.storageengine.api.StoragePropertyCursor 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.StoragePropertyCursor 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.StoragePropertyCursor in project neo4j by neo4j.
the class GenerateIndexUpdatesStep method process.
@Override
protected void process(long[] entityIds, BatchSender sender, CursorContext cursorContext) throws Exception {
GeneratedIndexUpdates updates = new GeneratedIndexUpdates(gatherPropertyUpdates, gatherTokenUpdates);
try (CURSOR nodeCursor = entityCursorBehaviour.allocateEntityScanCursor(cursorContext);
StoragePropertyCursor propertyCursor = reader.allocatePropertyCursor(cursorContext, memoryTracker)) {
for (long entityId : entityIds) {
try (Lock ignored = lockFunction.apply(entityId)) {
nodeCursor.single(entityId);
if (nodeCursor.next()) {
generateUpdates(updates, nodeCursor, propertyCursor);
if (updates.propertiesByteSize > maxBatchSizeBytes) {
batchDone(updates, sender);
updates = new GeneratedIndexUpdates(gatherPropertyUpdates, gatherTokenUpdates);
}
}
}
}
}
batchDone(updates, sender);
}
Aggregations