Search in sources :

Example 11 with TokenSet

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

the class NodeEntity method getLabels.

public Iterable<Label> getLabels(NodeCursor nodes) {
    KernelTransaction transaction = internalTransaction.kernelTransaction();
    try {
        singleNode(transaction, nodes);
        TokenSet tokenSet = nodes.labels();
        TokenRead tokenRead = transaction.tokenRead();
        List<Label> list = new ArrayList<>(tokenSet.numberOfTokens());
        for (int i = 0; i < tokenSet.numberOfTokens(); i++) {
            list.add(label(tokenRead.nodeLabelName(tokenSet.token(i))));
        }
        return list;
    } catch (LabelNotFoundKernelException e) {
        throw new IllegalStateException("Label retrieved through kernel API should exist.", e);
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) LabelNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.LabelNotFoundKernelException) TokenSet(org.neo4j.internal.kernel.api.TokenSet) Label(org.neo4j.graphdb.Label) ArrayList(java.util.ArrayList) TokenRead(org.neo4j.internal.kernel.api.TokenRead)

Aggregations

TokenSet (org.neo4j.internal.kernel.api.TokenSet)11 Test (org.junit.jupiter.api.Test)9 InOrder (org.mockito.InOrder)3 NodeCursor (org.neo4j.internal.kernel.api.NodeCursor)3 StubNodeCursor (org.neo4j.internal.kernel.api.helpers.StubNodeCursor)3 TestRelationshipChain (org.neo4j.internal.kernel.api.helpers.TestRelationshipChain)3 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)3 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Label (org.neo4j.graphdb.Label)1 PropertyCursor (org.neo4j.internal.kernel.api.PropertyCursor)1 TokenRead (org.neo4j.internal.kernel.api.TokenRead)1 LabelNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.LabelNotFoundKernelException)1 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)1 Value (org.neo4j.values.storable.Value)1