use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.
the class RelationshipEntity method getAllProperties.
public Map<String, Object> getAllProperties(PropertyCursor propertyCursor) {
KernelTransaction transaction = internalTransaction.kernelTransaction();
Map<String, Object> properties = new HashMap<>();
try {
RelationshipScanCursor relationships = transaction.ambientRelationshipCursor();
TokenRead token = transaction.tokenRead();
singleRelationship(transaction, relationships);
relationships.properties(propertyCursor);
while (propertyCursor.next()) {
properties.put(token.propertyKeyName(propertyCursor.propertyKey()), propertyCursor.propertyValue().asObjectCopy());
}
} catch (PropertyKeyIdNotFoundKernelException e) {
throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
}
return properties;
}
use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.
the class SchemaImpl method getConstraints.
@Override
public Iterable<ConstraintDefinition> getConstraints(final Label label) {
transaction.assertOpen();
TokenRead tokenRead = transaction.tokenRead();
SchemaRead schemaRead = transaction.schemaRead();
int labelId = tokenRead.nodeLabel(label.name());
if (labelId == TokenRead.NO_TOKEN) {
return emptyList();
}
return asConstraintDefinitions(schemaRead.constraintsGetForLabel(labelId), tokenRead);
}
use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.
the class SchemaImpl method getConstraints.
@Override
public Iterable<ConstraintDefinition> getConstraints(RelationshipType type) {
transaction.assertOpen();
TokenRead tokenRead = transaction.tokenRead();
SchemaRead schemaRead = transaction.schemaRead();
int typeId = tokenRead.relationshipType(type.name());
if (typeId == TokenRead.NO_TOKEN) {
return emptyList();
}
return asConstraintDefinitions(schemaRead.constraintsGetForRelationshipType(typeId), tokenRead);
}
use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.
the class KernelTransactionSecurityContextTest method shouldAllowTokenReadAccessInWriteOnlyMode.
@Test
void shouldAllowTokenReadAccessInWriteOnlyMode() {
// Given
KernelTransactionImplementation tx = newTransaction(AnonymousContext.writeOnly());
// When
TokenRead tokenRead = tx.tokenRead();
// Then
assertNotNull(tokenRead);
}
use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.
the class StartOldDbOnCurrentVersionAndCreateFusionIndexIT method countIndexedNodes.
private static int countIndexedNodes(GraphDatabaseAPI db, Label label, String... keys) throws Exception {
try (InternalTransaction tx = (InternalTransaction) db.beginTx()) {
KernelTransaction ktx = tx.kernelTransaction();
TokenRead tokenRead = ktx.tokenRead();
int labelId = tokenRead.nodeLabel(label.name());
int[] propertyKeyIds = new int[keys.length];
for (int i = 0; i < propertyKeyIds.length; i++) {
propertyKeyIds[i] = tokenRead.propertyKey(keys[i]);
}
PropertyIndexQuery[] predicates = new PropertyIndexQuery[propertyKeyIds.length];
for (int i = 0; i < propertyKeyIds.length; i++) {
predicates[i] = PropertyIndexQuery.exists(propertyKeyIds[i]);
}
IndexDescriptor index = single(ktx.schemaRead().index(SchemaDescriptor.forLabel(labelId, propertyKeyIds)));
IndexReadSession indexSession = ktx.dataRead().indexReadSession(index);
int count = 0;
try (NodeValueIndexCursor cursor = ktx.cursors().allocateNodeValueIndexCursor(ktx.cursorContext(), ktx.memoryTracker())) {
ktx.dataRead().nodeIndexSeek(indexSession, cursor, unconstrained(), predicates);
while (cursor.next()) {
count++;
}
}
tx.commit();
return count;
}
}
Aggregations