Search in sources :

Example 21 with TokenRead

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

the class TokensSection method putTokenCounts.

static void putTokenCounts(Map<String, Object> metaData, Kernel kernel) throws TransactionFailureException {
    try (KernelTransaction tx = kernel.beginTransaction(KernelTransaction.Type.EXPLICIT, LoginContext.AUTH_DISABLED)) {
        TokenRead tokens = tx.tokenRead();
        metaData.put("labelCount", tokens.labelCount());
        metaData.put("relationshipTypeCount", tokens.relationshipTypeCount());
        metaData.put("propertyKeyCount", tokens.propertyKeyCount());
        tx.commit();
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TokenRead(org.neo4j.internal.kernel.api.TokenRead)

Example 22 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, Map<String, Object> propertyValues) {
    checkRelationshipType(relationshipType);
    checkArgument(propertyValues != null, "Property values can not be null");
    KernelTransaction transaction = kernelTransaction();
    TokenRead tokenRead = transaction.tokenRead();
    int typeId = tokenRead.relationshipType(relationshipType.name());
    PropertyIndexQuery.ExactPredicate[] queries = convertToQueries(propertyValues, tokenRead);
    return relationshipsByTypeAndProperties(transaction, typeId, queries);
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TokenRead(org.neo4j.internal.kernel.api.TokenRead)

Example 23 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, String template, StringSearchMode searchMode) {
    checkRelationshipType(relationshipType);
    checkPropertyKey(key);
    checkArgument(template != null, "Template must not be null");
    KernelTransaction transaction = kernelTransaction();
    TokenRead tokenRead = transaction.tokenRead();
    int typeId = tokenRead.relationshipType(relationshipType.name());
    int propertyId = tokenRead.propertyKey(key);
    PropertyIndexQuery query = getIndexQuery(template, searchMode, propertyId);
    return relationshipsByTypeAndProperty(transaction, typeId, query);
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) PropertyIndexQuery(org.neo4j.internal.kernel.api.PropertyIndexQuery) TokenRead(org.neo4j.internal.kernel.api.TokenRead)

Example 24 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(final Label myLabel, final String key, final String value, final StringSearchMode searchMode) {
    checkLabel(myLabel);
    checkPropertyKey(key);
    checkArgument(value != null, "Template must not be null");
    KernelTransaction transaction = kernelTransaction();
    TokenRead tokenRead = transaction.tokenRead();
    int labelId = tokenRead.nodeLabel(myLabel.name());
    int propertyId = tokenRead.propertyKey(key);
    PropertyIndexQuery query = getIndexQuery(value, searchMode, propertyId);
    return nodesByLabelAndProperty(transaction, labelId, query);
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) PropertyIndexQuery(org.neo4j.internal.kernel.api.PropertyIndexQuery) TokenRead(org.neo4j.internal.kernel.api.TokenRead)

Example 25 with TokenRead

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

the class RelationshipEntity method getPropertyKeys.

@Override
public Iterable<String> getPropertyKeys() {
    KernelTransaction transaction = internalTransaction.kernelTransaction();
    List<String> keys = new ArrayList<>();
    try {
        RelationshipScanCursor relationships = transaction.ambientRelationshipCursor();
        PropertyCursor properties = transaction.ambientPropertyCursor();
        singleRelationship(transaction, relationships);
        TokenRead token = transaction.tokenRead();
        relationships.properties(properties);
        while (properties.next()) {
            keys.add(token.propertyKeyName(properties.propertyKey()));
        }
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
    }
    return keys;
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) RelationshipScanCursor(org.neo4j.internal.kernel.api.RelationshipScanCursor) ArrayList(java.util.ArrayList) PropertyCursor(org.neo4j.internal.kernel.api.PropertyCursor) TokenRead(org.neo4j.internal.kernel.api.TokenRead) PropertyKeyIdNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

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