Search in sources :

Example 1 with Order

use of org.janusgraph.graphdb.internal.Order in project janusgraph by JanusGraph.

the class JanusGraphIndexTest method checkIndexingCounts.

private void checkIndexingCounts(String[] words, int numV, int originalNumV, boolean checkOrder) {
    for (final String word : words) {
        final int expectedSize = numV / words.length;
        assertCount(expectedSize, tx.query().has("text", Text.CONTAINS, word).vertices());
        assertCount(expectedSize, tx.query().has("text", Text.CONTAINS, word).edges());
        // Test ordering
        if (checkOrder) {
            for (String orderKey : new String[] { "time", "category" }) {
                for (Order order : Order.values()) {
                    for (JanusGraphQuery traversal : ImmutableList.of(tx.query().has("text", Text.CONTAINS, word).orderBy(orderKey, order.getTP()), tx.query().has("text", Text.CONTAINS, word).orderBy(orderKey, order.getTP()))) {
                        verifyElementOrder(traversal.vertices(), orderKey, order, expectedSize);
                    }
                }
            }
        }
    }
    assertCount(3, tx.query().has("group", 3).orderBy("time", incr).limit(3).vertices());
    assertCount(3, tx.query().has("group", 3).orderBy("time", decr).limit(3).edges());
    for (int i = 0; i < numV / 2; i += numV / 10) {
        assertCount(i, tx.query().has("time", Cmp.GREATER_THAN_EQUAL, i).has("time", Cmp.LESS_THAN, i + i).vertices());
        assertCount(i, tx.query().has("time", Cmp.GREATER_THAN_EQUAL, i).has("time", Cmp.LESS_THAN, i + i).edges());
    }
    for (int i = 0; i < numV; i += 5) {
        testGeo(i, originalNumV, numV);
    }
    // Queries combining mixed and composite indexes
    assertCount(4, tx.query().has("category", 1).interval("time", 10, 28).vertices());
    assertCount(4, tx.query().has("category", 1).interval("time", 10, 28).edges());
    assertCount(5, tx.query().has("time", Cmp.GREATER_THAN_EQUAL, 10).has("time", Cmp.LESS_THAN, 30).has("text", Text.CONTAINS, words[0]).vertices());
    double offset = (19 * 50.0 / originalNumV);
    double distance = Geoshape.point(0.0, 0.0).getPoint().distance(Geoshape.point(offset, offset).getPoint()) + 20;
    assertCount(5, tx.query().has("location", Geo.INTERSECT, Geoshape.circle(0.0, 0.0, distance)).has("text", Text.CONTAINS, words[0]).vertices());
    assertCount(5, tx.query().has("boundary", Geo.INTERSECT, Geoshape.circle(0.0, 0.0, distance)).has("text", Text.CONTAINS, words[0]).vertices());
    assertCount(numV, tx.query().vertices());
    assertCount(numV, tx.query().edges());
    assertCount(numV / words.length, tx.query().has("name", Cmp.GREATER_THAN_EQUAL, "world").vertices());
    assertCount(numV / words.length, tx.query().has("name", Cmp.GREATER_THAN_EQUAL, "world").edges());
    assertCount(0, tx.query().has("name", Cmp.GREATER_THAN, "world").vertices());
    assertCount(0, tx.query().has("name", Cmp.GREATER_THAN, "world").edges());
    assertCount(numV - numV / words.length, tx.query().has("name", Cmp.LESS_THAN, "world").vertices());
    assertCount(numV - numV / words.length, tx.query().has("name", Cmp.LESS_THAN, "world").edges());
    assertCount(numV, tx.query().has("name", Cmp.LESS_THAN_EQUAL, "world").vertices());
    assertCount(numV, tx.query().has("name", Cmp.LESS_THAN_EQUAL, "world").edges());
}
Also used : Order(org.janusgraph.graphdb.internal.Order) JanusGraphQuery(org.janusgraph.core.JanusGraphQuery)

Aggregations

JanusGraphQuery (org.janusgraph.core.JanusGraphQuery)1 Order (org.janusgraph.graphdb.internal.Order)1