Search in sources :

Example 36 with TokenRead

use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.

the class SchemaImpl method getIndexes.

@Override
public Iterable<IndexDefinition> getIndexes(RelationshipType relationshipType) {
    transaction.assertOpen();
    TokenRead tokenRead = transaction.tokenRead();
    SchemaRead schemaRead = transaction.schemaRead();
    List<IndexDefinition> definitions = new ArrayList<>();
    int relationshipTypeId = tokenRead.relationshipType(relationshipType.name());
    if (relationshipTypeId == TokenRead.NO_TOKEN) {
        return emptyList();
    }
    Iterator<IndexDescriptor> indexes = schemaRead.indexesGetForRelationshipType(relationshipTypeId);
    addDefinitions(definitions, tokenRead, IndexDescriptor.sortByType(indexes));
    return definitions;
}
Also used : SchemaRead(org.neo4j.internal.kernel.api.SchemaRead) IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) ArrayList(java.util.ArrayList) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) TokenRead(org.neo4j.internal.kernel.api.TokenRead)

Example 37 with TokenRead

use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.

the class TransactionImpl method findNodes.

@Override
public ResourceIterator<Node> findNodes(Label label, String key1, Object value1, String key2, Object value2, String key3, Object value3) {
    checkLabel(label);
    checkPropertyKey(key1);
    checkPropertyKey(key2);
    checkPropertyKey(key3);
    KernelTransaction transaction = kernelTransaction();
    TokenRead tokenRead = transaction.tokenRead();
    int labelId = tokenRead.nodeLabel(label.name());
    return nodesByLabelAndProperties(transaction, labelId, PropertyIndexQuery.exact(tokenRead.propertyKey(key1), Values.of(value1, false)), PropertyIndexQuery.exact(tokenRead.propertyKey(key2), Values.of(value2, false)), PropertyIndexQuery.exact(tokenRead.propertyKey(key3), Values.of(value3, false)));
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TokenRead(org.neo4j.internal.kernel.api.TokenRead)

Example 38 with TokenRead

use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.

the class TransactionImpl method findNodes.

@Override
public ResourceIterator<Node> findNodes(Label label, Map<String, Object> propertyValues) {
    checkLabel(label);
    checkArgument(propertyValues != null, "Property values can not be null");
    KernelTransaction transaction = kernelTransaction();
    TokenRead tokenRead = transaction.tokenRead();
    int labelId = tokenRead.nodeLabel(label.name());
    PropertyIndexQuery.ExactPredicate[] queries = convertToQueries(propertyValues, tokenRead);
    return nodesByLabelAndProperties(transaction, labelId, queries);
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TokenRead(org.neo4j.internal.kernel.api.TokenRead)

Example 39 with TokenRead

use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.

the class TransactionImpl method findRelationships.

@Override
public ResourceIterator<Relationship> findRelationships(RelationshipType relationshipType, String key, Object value) {
    checkRelationshipType(relationshipType);
    checkPropertyKey(key);
    KernelTransaction transaction = kernelTransaction();
    TokenRead tokenRead = transaction.tokenRead();
    int labelId = tokenRead.relationshipType(relationshipType.name());
    int propertyId = tokenRead.propertyKey(key);
    return relationshipsByTypeAndProperty(transaction, labelId, PropertyIndexQuery.exact(propertyId, Values.of(value, false)));
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TokenRead(org.neo4j.internal.kernel.api.TokenRead)

Example 40 with TokenRead

use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.

the class KernelTransactionSecurityContextTest method shouldAllowTokenReadsInAccessMode.

@Test
void shouldAllowTokenReadsInAccessMode() {
    // Given
    KernelTransactionImplementation tx = newTransaction(AnonymousContext.access());
    // When
    TokenRead tokenRead = tx.tokenRead();
    // Then
    assertNotNull(tokenRead);
}
Also used : TokenRead(org.neo4j.internal.kernel.api.TokenRead) Test(org.junit.jupiter.api.Test)

Aggregations

TokenRead (org.neo4j.internal.kernel.api.TokenRead)59 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)42 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)27 Test (org.junit.jupiter.api.Test)19 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)18 ArrayList (java.util.ArrayList)13 HashMap (java.util.HashMap)13 Transaction (org.neo4j.graphdb.Transaction)13 SchemaReadCore (org.neo4j.internal.kernel.api.SchemaReadCore)13 Label (org.neo4j.graphdb.Label)12 SchemaRead (org.neo4j.internal.kernel.api.SchemaRead)11 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)11 InternalIndexState (org.neo4j.internal.kernel.api.InternalIndexState)10 RelationshipType (org.neo4j.graphdb.RelationshipType)7 PropertyKeyIdNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)6 Arrays (java.util.Arrays)5 List (java.util.List)5 Map (java.util.Map)5 Collectors (java.util.stream.Collectors)5 Stream (java.util.stream.Stream)5