Search in sources :

Example 1 with SimpleEntityTokenClient

use of org.neo4j.storageengine.api.schema.SimpleEntityTokenClient in project neo4j by neo4j.

the class DefaultTokenIndexReaderTest method shouldFindMultipleWithProgressorAscending.

@Test
void shouldFindMultipleWithProgressorAscending() {
    // WHEN
    var reader = new DefaultTokenIndexReader(index);
    SimpleEntityTokenClient tokenClient = new SimpleEntityTokenClient();
    reader.query(tokenClient, IndexQueryConstraints.constrained(IndexOrder.ASCENDING, false), new TokenPredicate(LABEL_ID), NULL);
    // THEN
    assertArrayEquals(expected, asArray(tokenClient));
}
Also used : TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) SimpleEntityTokenClient(org.neo4j.storageengine.api.schema.SimpleEntityTokenClient) Test(org.junit.jupiter.api.Test)

Example 2 with SimpleEntityTokenClient

use of org.neo4j.storageengine.api.schema.SimpleEntityTokenClient 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)

Example 3 with SimpleEntityTokenClient

use of org.neo4j.storageengine.api.schema.SimpleEntityTokenClient in project neo4j by neo4j.

the class BatchInsertTokenIndexesTest method assertTokenIndexContains.

private void assertTokenIndexContains(TokenIndexReader reader, int tokenId, Long... intityIds) {
    SimpleEntityTokenClient tokenClient = new SimpleEntityTokenClient();
    reader.query(tokenClient, unconstrained(), new TokenPredicate(tokenId), CursorContext.NULL);
    var found = new ArrayList<Long>();
    while (tokenClient.next()) {
        found.add(tokenClient.reference);
    }
    assertThat(found).containsExactlyInAnyOrder(intityIds);
}
Also used : TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) ArrayList(java.util.ArrayList) SimpleEntityTokenClient(org.neo4j.storageengine.api.schema.SimpleEntityTokenClient)

Example 4 with SimpleEntityTokenClient

use of org.neo4j.storageengine.api.schema.SimpleEntityTokenClient in project neo4j by neo4j.

the class DefaultTokenIndexReaderTest method shouldFindMultipleEntitiesInEachRange.

@Test
void shouldFindMultipleEntitiesInEachRange() {
    // WHEN
    var reader = new DefaultTokenIndexReader(index);
    SimpleEntityTokenClient tokenClient = new SimpleEntityTokenClient();
    reader.query(tokenClient, unconstrained(), new TokenPredicate(LABEL_ID), NULL);
    // THEN
    assertArrayEquals(expected, asArray(tokenClient));
}
Also used : TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) SimpleEntityTokenClient(org.neo4j.storageengine.api.schema.SimpleEntityTokenClient) Test(org.junit.jupiter.api.Test)

Example 5 with SimpleEntityTokenClient

use of org.neo4j.storageengine.api.schema.SimpleEntityTokenClient in project neo4j by neo4j.

the class DefaultTokenIndexReaderTest method shouldFindMultipleWithProgressorDescending.

@Test
void shouldFindMultipleWithProgressorDescending() {
    // WHEN
    var reader = new DefaultTokenIndexReader(index);
    SimpleEntityTokenClient tokenClient = new SimpleEntityTokenClient();
    reader.query(tokenClient, IndexQueryConstraints.constrained(IndexOrder.DESCENDING, false), new TokenPredicate(LABEL_ID), NULL);
    // THEN
    ArrayUtils.reverse(expected);
    assertArrayEquals(expected, asArray(tokenClient));
}
Also used : TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) SimpleEntityTokenClient(org.neo4j.storageengine.api.schema.SimpleEntityTokenClient) Test(org.junit.jupiter.api.Test)

Aggregations

TokenPredicate (org.neo4j.internal.kernel.api.TokenPredicate)5 SimpleEntityTokenClient (org.neo4j.storageengine.api.schema.SimpleEntityTokenClient)5 Test (org.junit.jupiter.api.Test)3 ArrayList (java.util.ArrayList)2 TokenIndexReader (org.neo4j.kernel.api.index.TokenIndexReader)1 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)1