use of org.neo4j.storageengine.api.PropertyKeyValue 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.PropertyKeyValue in project neo4j by neo4j.
the class SchemaStore method schemaRecordToMap.
private static Map<String, Value> schemaRecordToMap(SchemaRecord record, PropertyStore propertyStore, TokenHolders tokenHolders, CursorContext cursorContext) throws MalformedSchemaRuleException {
Map<String, Value> props = new HashMap<>();
PropertyRecord propRecord = propertyStore.newRecord();
long nextProp = record.getNextProp();
while (nextProp != NO_NEXT_PROPERTY.longValue()) {
try {
propertyStore.getRecord(nextProp, propRecord, RecordLoad.NORMAL, cursorContext);
} catch (InvalidRecordException e) {
throw new MalformedSchemaRuleException("Cannot read schema rule because it is referencing a property record (id " + nextProp + ") that is invalid: " + propRecord, e);
}
for (PropertyBlock propertyBlock : propRecord) {
PropertyKeyValue propertyKeyValue = propertyBlock.newPropertyKeyValue(propertyStore, cursorContext);
insertPropertyIntoMap(propertyKeyValue, props, tokenHolders);
}
nextProp = propRecord.getNextProp();
}
if (props.isEmpty()) {
IndexDescriptor descriptor = IndexDescriptor.NLI_PROTOTYPE.materialise(record.getId());
props.putAll(mapifySchemaRule(descriptor));
}
return props;
}
use of org.neo4j.storageengine.api.PropertyKeyValue in project neo4j by neo4j.
the class TxStateVisitorTest method shouldSeeAddedRelationshipProperties.
@Test
void shouldSeeAddedRelationshipProperties() throws Exception {
// Given
long relId = 1L;
int propKey = 2;
GatheringVisitor visitor = new GatheringVisitor();
Value value = Values.of("hello");
state.relationshipDoReplaceProperty(relId, propKey, Values.of(""), value);
// When
state.accept(visitor);
// Then
StorageProperty prop = new PropertyKeyValue(propKey, Values.of("hello"));
assertThat(visitor.relPropertyChanges).containsExactly(propChange(relId, noProperty, singletonList(prop), IntSets.immutable.empty()));
}
Aggregations