@Test public void testVertexCentricPropertyIndexOnSetCardinalityShouldWork() { clopen(option(LOG_SEND_DELAY, MANAGEMENT_LOG), Duration.ofMillis(0), option(KCVSLog.LOG_READ_LAG_TIME, MANAGEMENT_LOG), Duration.ofMillis(50), option(LOG_READ_INTERVAL, MANAGEMENT_LOG), Duration.ofMillis(250) ); PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).cardinality(Cardinality.SINGLE).make(); PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SET).make(); mgmt.buildPropertyIndex(name, "byTime", decr, time); finishSchema(); assertEquals(SchemaStatus.ENABLED, mgmt.getRelationIndex(mgmt.getRelationType("name"), "byTime").getIndexStatus()); JanusGraphVertex v = tx.addVertex(); v = getV(tx, v); for (int i = 200; i < 210; i++) { v.property("name", String.valueOf(i), "time", i); } evaluateQuery(v.query().keys("name").interval("time", 199, 210).orderBy("time", decr), PROPERTY, 10, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); tx.commit(); finishSchema(); }
@Test public void testVertexCentricIndexOrderingOnMetaPropertyWithCardinalityList() { clopen(option(LOG_SEND_DELAY, MANAGEMENT_LOG), Duration.ofMillis(0), option(KCVSLog.LOG_READ_LAG_TIME, MANAGEMENT_LOG), Duration.ofMillis(50), option(LOG_READ_INTERVAL, MANAGEMENT_LOG), Duration.ofMillis(250) ); PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).cardinality(Cardinality.LIST).make(); PropertyKey sensor = mgmt.makePropertyKey("sensor").dataType(Integer.class).cardinality(Cardinality.LIST).make(); mgmt.buildPropertyIndex(sensor, "byTime", decr, time); finishSchema(); JanusGraphVertex v = tx.addVertex(); for (int i = 200; i < 210; i++) { v.property("sensor", i, "time", i); } assertEquals(SchemaStatus.ENABLED, mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime").getIndexStatus()); evaluateQuery(v.query().keys("sensor").interval("time", 201, 205).orderBy("time", decr), PROPERTY, 4, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); tx.commit(); finishSchema(); }
@Test public void testVertexCentricIndexOrderingOnEdgePropertyWithCardinalityList() { clopen(option(LOG_SEND_DELAY, MANAGEMENT_LOG), Duration.ofMillis(0), option(KCVSLog.LOG_READ_LAG_TIME, MANAGEMENT_LOG), Duration.ofMillis(50), option(LOG_READ_INTERVAL, MANAGEMENT_LOG), Duration.ofMillis(250) ); PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).cardinality(Cardinality.LIST).make(); EdgeLabel friend = mgmt.makeEdgeLabel("friend").multiplicity(Multiplicity.MULTI).make(); mgmt.buildEdgeIndex(friend, "byTime", Direction.OUT, decr, time); finishSchema(); JanusGraphVertex v = tx.addVertex(); for (int i = 200; i < 210; i++) { JanusGraphVertex o = tx.addVertex(); v.addEdge("friend", o, "time", i); } assertEquals(SchemaStatus.ENABLED, mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime").getIndexStatus()); evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 201, 205).orderBy("time", decr), EDGE, 4, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); tx.commit(); finishSchema(); }
@Test public void testVertexCentricEdgeIndexOnSimpleMultiplicityShouldWork() { clopen(option(LOG_SEND_DELAY, MANAGEMENT_LOG), Duration.ofMillis(0), option(KCVSLog.LOG_READ_LAG_TIME, MANAGEMENT_LOG), Duration.ofMillis(50), option(LOG_READ_INTERVAL, MANAGEMENT_LOG), Duration.ofMillis(250) ); PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).cardinality(Cardinality.SINGLE).make(); EdgeLabel friend = mgmt.makeEdgeLabel("friend").multiplicity(Multiplicity.SIMPLE).make(); mgmt.buildEdgeIndex(friend, "byTime", Direction.OUT, decr, time); finishSchema(); assertEquals(SchemaStatus.ENABLED, mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime").getIndexStatus()); JanusGraphVertex v = tx.addVertex(); v = getV(tx, v); for (int i = 200; i < 210; i++) { JanusGraphVertex o = tx.addVertex(); v.addEdge("friend", o, "time", i); } evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 199, 210).orderBy("time", decr), EDGE, 10, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); tx.commit(); finishSchema(); }
evaluateQuery(v.query().keys("sensor").interval("time", 1, 5).orderBy("time", decr), PROPERTY, 4, 1, new boolean[]{false, false}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(v.query().keys("sensor").interval("time", 101, 105).orderBy("time", decr), PROPERTY, 0, 1, new boolean[]{false, false}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 1, 5).orderBy("time", decr), EDGE, 4, 1, new boolean[]{false, false}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 101, 105).orderBy("time", decr), EDGE, 0, 1, new boolean[]{false, false}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(tx.query().has("name", "v5"), evaluateQuery(v.query().keys("sensor").interval("time", 1, 5).orderBy("time", decr), PROPERTY, 4, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(v.query().keys("sensor").interval("time", 101, 105).orderBy("time", decr), PROPERTY, 4, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(v.query().keys("sensor").interval("time", 201, 205).orderBy("time", decr), PROPERTY, 4, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 1, 5).orderBy("time", decr), EDGE, 0, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 101, 105).orderBy("time", decr), EDGE, 4, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 201, 205).orderBy("time", decr), EDGE, 4, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(tx.query().has("name", "v5"), evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 1, 5).orderBy("time", decr), EDGE, 4, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 101, 105).orderBy("time", decr), EDGE, 4, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC); evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 201, 205).orderBy("time", decr),
evaluateQuery(v.query().keys("name").has("weight", Cmp.LESS_THAN, 0.9).orderBy("weight", incr), PROPERTY, 2 * numV / 10, 1, new boolean[]{true, true}, weight, Order.ASC); evaluateQuery(v.query().keys("name").interval("weight", 1.1, 2.2).orderBy("weight", decr).limit(numV / 10), PROPERTY, numV / 10, 1, new boolean[]{true, false}, weight, Order.DESC); evaluateQuery(v.query().keys("name").has("time", Cmp.EQUAL, 5).orderBy("weight", decr), PROPERTY, 1, 1, new boolean[]{false, false}, weight, Order.DESC); evaluateQuery(v.query().keys("name"), evaluateQuery(v.query().labels("child").direction(BOTH).has("time", Cmp.EQUAL, 5), EDGE, 1, 2, new boolean[0]); evaluateQuery(v.query().labels("child").direction(OUT).interval("time", 10, 20).orderBy("weight", decr).limit(5), EDGE, 5, 1, new boolean[]{true, false}, weight, Order.DESC); evaluateQuery(v.query().labels("child").direction(BOTH).interval("weight", 0.0, 1.0).orderBy("weight", decr), EDGE, 2 * numV / 10, 2, new boolean[]{false, false}, weight, Order.DESC); evaluateQuery(v.query().labels("child").direction(OUT).interval("weight", 0.0, 1.0), assertTrue(vl.isSorted()); assertTrue(isSortedByID(vl)); evaluateQuery(v.query().labels("child").interval("time", 70, 80).direction(OUT).orderBy("time", incr), EDGE, 10, 1, new boolean[]{true, true}, time, Order.ASC); vl = v.query().labels("child").interval("time", 70, 80).direction(OUT).orderBy("time", incr).vertexIds(); assertEquals(10, vl.size()); assertFalse(vl.isSorted()); evaluateQuery(v.query().labels("connect").interval("time", 10, 20).interval("weight", 0.0, 5.0).direction(OUT), EDGE, 10, 1, new boolean[]{false, true}); evaluateQuery(v.query().labels("connect").direction(OUT).orderBy("weight", incr).limit(10), EDGE, 10, 1, new boolean[]{true, true}, weight, Order.ASC); evaluateQuery(v.query().labels("connect").direction(OUT).orderBy("weight", decr).limit(10),