use of org.neo4j.internal.kernel.api.RelationshipScanCursor in project neo4j by neo4j.
the class RelationshipEntity method getProperty.
@Override
public Object getProperty(String key, Object defaultValue) {
if (null == key) {
throw new IllegalArgumentException("(null) property key is not allowed");
}
KernelTransaction transaction = internalTransaction.kernelTransaction();
RelationshipScanCursor relationships = transaction.ambientRelationshipCursor();
PropertyCursor properties = transaction.ambientPropertyCursor();
int propertyKey = transaction.tokenRead().propertyKey(key);
if (propertyKey == TokenRead.NO_TOKEN) {
return defaultValue;
}
singleRelationship(transaction, relationships);
relationships.properties(properties);
return properties.seekProperty(propertyKey) ? properties.propertyValue().asObjectCopy() : defaultValue;
}
use of org.neo4j.internal.kernel.api.RelationshipScanCursor in project neo4j by neo4j.
the class RelationshipEntity method getProperties.
@Override
public Map<String, Object> getProperties(String... keys) {
Objects.requireNonNull(keys, "Properties keys should be not null array.");
if (keys.length == 0) {
return Collections.emptyMap();
}
KernelTransaction transaction = internalTransaction.kernelTransaction();
int itemsToReturn = keys.length;
TokenRead token = transaction.tokenRead();
// Find ids, note we are betting on that the number of keys
// is small enough not to use a set here.
int[] propertyIds = new int[itemsToReturn];
for (int i = 0; i < itemsToReturn; i++) {
String key = keys[i];
if (key == null) {
throw new NullPointerException(String.format("Key %d was null", i));
}
propertyIds[i] = token.propertyKey(key);
}
Map<String, Object> properties = new HashMap<>(itemsToReturn);
RelationshipScanCursor relationships = transaction.ambientRelationshipCursor();
PropertyCursor propertyCursor = transaction.ambientPropertyCursor();
singleRelationship(transaction, relationships);
relationships.properties(propertyCursor);
int propertiesToFind = itemsToReturn;
while (propertiesToFind > 0 && propertyCursor.next()) {
// Do a linear check if this is a property we are interested in.
int currentKey = propertyCursor.propertyKey();
for (int i = 0; i < itemsToReturn; i++) {
if (propertyIds[i] == currentKey) {
properties.put(keys[i], propertyCursor.propertyValue().asObjectCopy());
propertiesToFind--;
break;
}
}
}
return properties;
}
use of org.neo4j.internal.kernel.api.RelationshipScanCursor in project neo4j by neo4j.
the class RelationshipEntity method initializeData.
public boolean initializeData() {
if (startNode == NO_ID) {
KernelTransaction transaction = internalTransaction.kernelTransaction();
RelationshipScanCursor relationships = transaction.ambientRelationshipCursor();
return initializeData(relationships);
}
return true;
}
Aggregations