try { if (StringUtils.isNotBlank(relationTypeName)) { RelationTypeIndex idx = mgmt.getRelationIndex(mgmt.getRelationType(relationTypeName) ,indexName); Preconditions.checkArgument(idx!=null,"Index could not be found: %s @ %s",indexName,relationTypeName);
try { mgmt = g.openManagement(); idx = mgmt.getRelationIndex(mgmt.getRelationType(relationTypeName), relationIndexName); actualStatus = idx.getIndexStatus(); LOGGER.info("Index {} (relation type {}) has status {}", relationIndexName, relationTypeName, actualStatus);
@Test public void testRemoveRelationIndex() throws InterruptedException, BackendException, ExecutionException { tx.commit(); mgmt.commit(); // Load the "Graph of the Gods" sample data GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true); // Disable the "battlesByTime" index TitanManagement m = graph.openManagement(); RelationType battled = m.getRelationType("battled"); RelationTypeIndex battlesByTime = m.getRelationIndex(battled, "battlesByTime"); m.updateIndex(battlesByTime, SchemaAction.DISABLE_INDEX); m.commit(); graph.tx().commit(); // Block until the SchemaStatus transitions to DISABLED assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "battlesByTime", "battled") .status(SchemaStatus.DISABLED).call().getSucceeded()); // Remove index MapReduceIndexManagement mri = new MapReduceIndexManagement(graph); m = graph.openManagement(); battled = m.getRelationType("battled"); battlesByTime = m.getRelationIndex(battled, "battlesByTime"); ScanMetrics metrics = mri.updateIndex(battlesByTime, SchemaAction.REMOVE_INDEX).get(); assertEquals(6, metrics.getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT)); }
RelationTypeIndex index = m.getRelationIndex(m.getRelationType("lives"), "livesByReason"); m.updateIndex(index, SchemaAction.ENABLE_INDEX); m.commit(); index = m.getRelationIndex(m.getRelationType("lives"), "livesByReason"); ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REINDEX).get(); assertEquals(8, metrics.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT));
pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime"); eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime"); gindex = mgmt.getGraphIndex("bySensorReading"); try { pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime"); eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime"); gindex = mgmt.getGraphIndex("bySensorReading"); assertEquals(SchemaStatus.REGISTERED, pindex.getIndexStatus()); eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime"); mgmt.updateIndex(eindex, SchemaAction.ENABLE_INDEX); finishSchema(); pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime"); ScanMetrics reindexSensorByTime = mgmt.updateIndex(pindex, SchemaAction.REINDEX).get(); finishSchema(); pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime"); eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime"); gindex = mgmt.getGraphIndex("bySensorReading"); assertEquals(SchemaStatus.ENABLED, eindex.getIndexStatus()); eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime"); ScanMetrics reindexFriendByTime = mgmt.updateIndex(eindex, SchemaAction.REINDEX).get(); finishSchema(); pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime"); gindex = mgmt.getGraphIndex("bySensorReading");
private static void makeIndicesVertexCentric(TitanManagement management){ ResourceBundle keys = ResourceBundle.getBundle("indices-edges"); Set<String> edgeLabels = keys.keySet(); for(String edgeLabel : edgeLabels){ String properties = keys.getString(edgeLabel); if(properties.length() > 0){ String[] propertyKey = keys.getString(edgeLabel).split(","); for (String aPropertyKey : propertyKey) { PropertyKey key = management.getPropertyKey(aPropertyKey); if (key == null) throw new RuntimeException("Trying to create edge index on label [" + edgeLabel + "] but the property [" + aPropertyKey + "] does not exist"); RelationType relationType = management.getRelationType(edgeLabel); if (management.getRelationIndex(relationType, edgeLabel + "by" + aPropertyKey) == null) { EdgeLabel label = management.getEdgeLabel(edgeLabel); management.buildEdgeIndex(label, edgeLabel + "by" + aPropertyKey, Direction.OUT, Order.decr, key); } } } } }
private static void makeIndicesVertexCentric(TitanManagement management){ ResourceBundle keys = ResourceBundle.getBundle("indices-edges"); Set<String> edgeLabels = keys.keySet(); for(String edgeLabel : edgeLabels){ String properties = keys.getString(edgeLabel); if(properties.length() > 0){ String[] propertyKey = keys.getString(edgeLabel).split(","); for (String aPropertyKey : propertyKey) { PropertyKey key = management.getPropertyKey(aPropertyKey); if (key == null) throw new RuntimeException("Trying to create edge index on label [" + edgeLabel + "] but the property [" + aPropertyKey + "] does not exist"); RelationType relationType = management.getRelationType(edgeLabel); if (management.getRelationIndex(relationType, edgeLabel + "by" + aPropertyKey) == null) { EdgeLabel label = management.getEdgeLabel(edgeLabel); management.buildEdgeIndex(label, edgeLabel + "by" + aPropertyKey, Direction.OUT, Order.decr, key); } } } } }
try { mgmt = g.openManagement(); idx = mgmt.getRelationIndex(mgmt.getRelationType(relationTypeName), relationIndexName); actualStatus = idx.getIndexStatus(); LOGGER.info("Index {} (relation type {}) has status {}", relationIndexName, relationTypeName, actualStatus);
try { if (StringUtils.isNotBlank(relationTypeName)) { RelationTypeIndex idx = mgmt.getRelationIndex(mgmt.getRelationType(relationTypeName) ,indexName); Preconditions.checkArgument(idx!=null,"Index could not be found: %s @ %s",indexName,relationTypeName);
mgmt.updateIndex(mgmt.getRelationIndex(mgmt.getRelationType("sensor"),"byTime"), SchemaAction.ENABLE_INDEX); fail(); } catch (IllegalArgumentException e) {} try { mgmt.updateIndex(mgmt.getRelationIndex(mgmt.getRelationType("friend"),"byTime"), SchemaAction.ENABLE_INDEX); fail(); } catch (IllegalArgumentException e) {} fail(); } catch (IllegalArgumentException e) {} mgmt.updateIndex(mgmt.getRelationIndex(mgmt.getRelationType("sensor"),"byTime"), SchemaAction.REGISTER_INDEX); mgmt.updateIndex(mgmt.getRelationIndex(mgmt.getRelationType("friend"),"byTime"), SchemaAction.REGISTER_INDEX); mgmt.updateIndex(mgmt.getGraphIndex("bySensorReading"), SchemaAction.REGISTER_INDEX); mgmt.commit(); mgmt.updateIndex(mgmt.getRelationIndex(mgmt.getRelationType("sensor"),"byTime"), SchemaAction.ENABLE_INDEX); mgmt.updateIndex(mgmt.getRelationIndex(mgmt.getRelationType("friend"),"byTime"), SchemaAction.ENABLE_INDEX); mgmt.updateIndex(mgmt.getGraphIndex("bySensorReading"), SchemaAction.ENABLE_INDEX); finishSchema();