use of org.neo4j.storageengine.api.StorageProperty 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.StorageProperty in project neo4j by neo4j.
the class IteratingPropertyReceiverTest method shouldAcceptAndThenIterateOverProperties.
@Test
public void shouldAcceptAndThenIterateOverProperties() throws PropertyNotFoundException {
// GIVEN
IteratingPropertyReceiver<StorageProperty> receiver = new IteratingPropertyReceiver<>();
int propertyCount = 100;
for (int i = 0; i < propertyCount; i++) {
receiver.receive(Property.intProperty(1, i), 5);
}
// THEN
int count = 0;
while (receiver.hasNext()) {
StorageProperty property = receiver.next();
assertEquals(count++, ((Integer) property.value()).intValue());
}
assertFalse(receiver.hasNext());
assertEquals(propertyCount, count);
}
use of org.neo4j.storageengine.api.StorageProperty in project neo4j by neo4j.
the class TxStateTransactionDataSnapshot method snapshotModifiedNodes.
private void snapshotModifiedNodes(MemoryTracker memoryTracker, StorageNodeCursor node, StoragePropertyCursor properties, TokenRead tokenRead) throws PropertyKeyIdNotFoundKernelException {
for (NodeState nodeState : state.modifiedNodes()) {
Iterator<StorageProperty> added = nodeState.addedAndChangedProperties();
long nodeId = nodeState.getId();
while (added.hasNext()) {
StorageProperty property = added.next();
var entryView = createNodePropertyEntryView(memoryTracker, tokenRead, nodeId, property.propertyKeyId(), property.value(), committedValue(nodeState, property.propertyKeyId(), node, properties));
assignedNodeProperties.add(entryView);
}
nodeState.removedProperties().each(id -> {
try {
removedNodeProperties.add(createNodePropertyEntryView(memoryTracker, tokenRead, nodeId, id, null, committedValue(nodeState, id, node, properties)));
} catch (PropertyKeyIdNotFoundKernelException e) {
throw new IllegalStateException("Not existing node properties was modified for node " + nodeId, e);
}
});
final LongDiffSets labels = nodeState.labelDiffSets();
addLabelEntriesTo(nodeId, labels.getAdded(), assignedLabels);
addLabelEntriesTo(nodeId, labels.getRemoved(), removedLabels);
}
}
use of org.neo4j.storageengine.api.StorageProperty in project neo4j by neo4j.
the class TxStateTransactionDataSnapshot method snapshotModifiedRelationships.
private void snapshotModifiedRelationships(MemoryTracker memoryTracker, StoragePropertyCursor properties, TokenRead tokenRead) throws PropertyKeyIdNotFoundKernelException {
for (RelationshipState relState : state.modifiedRelationships()) {
Relationship relationship = relationship(relState.getId());
Iterator<StorageProperty> added = relState.addedAndChangedProperties();
while (added.hasNext()) {
StorageProperty property = added.next();
assignedRelationshipProperties.add(createRelationshipPropertyEntryView(memoryTracker, tokenRead, relationship, property.propertyKeyId(), property.value(), committedValue(relState, property.propertyKeyId(), this.relationship, properties)));
}
relState.removedProperties().each(id -> {
try {
var entryView = createRelationshipPropertyEntryView(memoryTracker, tokenRead, relationship, id, null, committedValue(relState, id, this.relationship, properties));
removedRelationshipProperties.add(entryView);
} catch (PropertyKeyIdNotFoundKernelException e) {
throw new IllegalStateException("Not existing properties was modified for relationship " + relState.getId(), e);
}
});
}
}
use of org.neo4j.storageengine.api.StorageProperty in project neo4j by neo4j.
the class EntityValueUpdatesTest method propertyLoader.
private static StorageReader propertyLoader(StorageProperty... properties) {
StubStorageCursors stub = new StubStorageCursors();
for (StorageProperty property : properties) {
stub.propertyKeyTokenHolder().addToken(new NamedToken(String.valueOf(property.propertyKeyId()), property.propertyKeyId()));
}
Map<String, Value> propertyMap = new HashMap<>();
for (StorageProperty p : properties) {
propertyMap.put(String.valueOf(p.propertyKeyId()), p.value());
}
stub.withNode(ENTITY_ID).properties(propertyMap);
stub.withRelationship(ENTITY_ID, 1, 1, 2).properties(propertyMap);
return stub;
}
Aggregations