sb.append(DASHBREAK); for (RelationTypeIndex ri: relationIndexes) { sb.append(String.format(relationPattern, ri.name(), ri.getType(), ri.getDirection(), ri.getSortKey()[0], ri.getSortOrder(), ri.getIndexStatus().name()));
management = g.openManagement(); idx = management.getRelationIndex(management.getRelationType(relationTypeName), relationIndexName); actualStatus = idx.getIndexStatus(); LOGGER.info("Index {} (relation type {}) has status {}", relationIndexName, relationTypeName, actualStatus); if (statuses.contains(actualStatus)) {
private IndexIdentifier(Index index) { Preconditions.checkArgument(index != null); indexName = index.name(); if (index instanceof RelationTypeIndex) relationTypeName = ((RelationTypeIndex) index).getType().name(); else relationTypeName = null; Preconditions.checkArgument(StringUtils.isNotBlank(indexName)); hashcode = new HashCodeBuilder().append(indexName).append(relationTypeName).toHashCode(); }
,indexName); Preconditions.checkArgument(idx!=null,"Index could not be found: %s @ %s",indexName,relationTypeName); isStable = idx.getIndexStatus().isStable(); } else { JanusGraphIndex idx = management.getGraphIndex(indexName);
RelationTypeIndex.class.isAssignableFrom(index.getClass()) ? ((RelationTypeIndex) index).getType() : null; final String relationTypeName = relationType == null ? StringUtils.EMPTY : relationType.name(); Preconditions.checkNotNull(indexName);
final String name1n = name1.name(), connect1n = connect1.name(), connect2n = connect2.name(), connect3n = connect3.name(), child1n = child1.name(), link1n = link1.name(); assertTrue(mgmt.containsRelationIndex(connect, "weightDesc")); assertFalse(mgmt.containsRelationIndex(child, "weightDesc")); assertEquals("time+weight", mgmt.getRelationIndex(connect, "time+weight").name()); assertNotNull(mgmt.getRelationIndex(link, "time")); assertNull(mgmt.getRelationIndex(name, "time")); assertTrue(mgmt.containsRelationIndex(connect, "weightDesc")); assertFalse(mgmt.containsRelationIndex(child, "weightDesc")); assertEquals("time+weight", mgmt.getRelationIndex(connect, "time+weight").name()); assertNotNull(mgmt.getRelationIndex(link, "time")); assertNull(mgmt.getRelationIndex(name, "time"));
@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(); }
RelationTypeIndex.class.isAssignableFrom(index.getClass()) ? ((RelationTypeIndex) index).getType() : null; final String relationTypeName = relationType == null ? StringUtils.EMPTY : relationType.name(); Preconditions.checkNotNull(indexName);
@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(); }
eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime"); graphIndex = mgmt.getGraphIndex("bySensorReading"); assertEquals(SchemaStatus.REGISTERED, pindex.getIndexStatus()); assertEquals(SchemaStatus.REGISTERED, eindex.getIndexStatus()); assertEquals(SchemaStatus.REGISTERED, graphIndex.getIndexStatus(graphIndex.getFieldKeys()[0])); finishSchema(); eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime"); graphIndex = mgmt.getGraphIndex("bySensorReading"); assertEquals(SchemaStatus.ENABLED, eindex.getIndexStatus()); assertEquals(SchemaStatus.ENABLED, pindex.getIndexStatus()); assertEquals(SchemaStatus.ENABLED, graphIndex.getIndexStatus(graphIndex.getFieldKeys()[0])); assertEquals(SchemaStatus.DISABLED, pindex.getIndexStatus()); assertEquals(SchemaStatus.DISABLED, graphIndex.getIndexStatus(graphIndex.getFieldKeys()[0])); finishSchema();