Search in sources :

Example 1 with TokenIndexReader

use of org.neo4j.kernel.api.index.TokenIndexReader in project neo4j by neo4j.

the class RelationshipTypeIndexIT method assertContainIds.

private void assertContainIds(List<Long> expectedIds) throws IndexNotFoundKernelException {
    int relationshipTypeId = getRelationshipTypeId();
    IndexProxy indexProxy = getIndexProxy();
    List<Long> actualIds = new ArrayList<>();
    try (TokenIndexReader reader = indexProxy.newTokenReader()) {
        SimpleEntityTokenClient tokenClient = new SimpleEntityTokenClient();
        reader.query(tokenClient, unconstrained(), new TokenPredicate(relationshipTypeId), CursorContext.NULL);
        while (tokenClient.next()) {
            actualIds.add(tokenClient.reference);
        }
    }
    expectedIds.sort(Long::compareTo);
    actualIds.sort(Long::compareTo);
    assertThat(actualIds).as("contains expected relationships").isEqualTo(expectedIds);
}
Also used : TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) ArrayList(java.util.ArrayList) IndexProxy(org.neo4j.kernel.impl.api.index.IndexProxy) SimpleEntityTokenClient(org.neo4j.storageengine.api.schema.SimpleEntityTokenClient) TokenIndexReader(org.neo4j.kernel.api.index.TokenIndexReader)

Aggregations

ArrayList (java.util.ArrayList)1 TokenPredicate (org.neo4j.internal.kernel.api.TokenPredicate)1 TokenIndexReader (org.neo4j.kernel.api.index.TokenIndexReader)1 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)1 SimpleEntityTokenClient (org.neo4j.storageengine.api.schema.SimpleEntityTokenClient)1