Skip to content

Commit

Permalink
use TokenRead to read relationship tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
fickludd committed Mar 1, 2018
1 parent bb00809 commit 132ae9d
Showing 1 changed file with 4 additions and 12 deletions.
Expand Up @@ -150,12 +150,8 @@ public ResourceIterable<Relationship> getRelationships( RelationshipType type, D
@Override
public ResourceIterable<Relationship> getRelationships( final Direction direction, RelationshipType... types )
{
final int[] typeIds;
KernelTransaction transaction = safeAcquireTransaction();
try ( Statement statement = transaction.acquireStatement() )
{
typeIds = relTypeIds( types, statement );
}
int[] typeIds = relTypeIds( types, transaction.tokenRead() );
return innerGetRelationships( transaction, direction, typeIds );
}

Expand Down Expand Up @@ -187,12 +183,8 @@ public boolean hasRelationship( RelationshipType... types )
@Override
public boolean hasRelationship( Direction direction, RelationshipType... types )
{
final int[] typeIds;
KernelTransaction transaction = safeAcquireTransaction();
try ( Statement statement = transaction.acquireStatement() )
{
typeIds = relTypeIds( types, statement );
}
int[] typeIds = relTypeIds( types, transaction.tokenRead() );
return innerHasRelationships( transaction, direction, typeIds );
}

Expand Down Expand Up @@ -791,13 +783,13 @@ private ResourceIterator<Relationship> getRelationshipSelectionIterator(
}
}

private int[] relTypeIds( RelationshipType[] types, Statement statement )
private int[] relTypeIds( RelationshipType[] types, TokenRead token )
{
int[] ids = new int[types.length];
int outIndex = 0;
for ( RelationshipType type : types )
{
int id = statement.readOperations().relationshipTypeGetForName( type.name() );
int id = token.relationshipType( type.name() );
if ( id != NO_SUCH_RELATIONSHIP_TYPE )
{
ids[outIndex++] = id;
Expand Down

0 comments on commit 132ae9d

Please sign in to comment.