Java Code Examples for com.thinkaurelius.titan.core.schema.TitanManagement#updateIndex()
The following examples show how to use
com.thinkaurelius.titan.core.schema.TitanManagement#updateIndex() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractIndexManagementIT.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test public void testRemoveGraphIndex() throws InterruptedException, BackendException, ExecutionException { tx.commit(); mgmt.commit(); // Load the "Graph of the Gods" sample data GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true); // Disable the "name" composite index TitanManagement m = graph.openManagement(); TitanGraphIndex nameIndex = m.getGraphIndex("name"); m.updateIndex(nameIndex, SchemaAction.DISABLE_INDEX); m.commit(); graph.tx().commit(); // Block until the SchemaStatus transitions to DISABLED assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "name") .status(SchemaStatus.DISABLED).call().getSucceeded()); // Remove index MapReduceIndexManagement mri = new MapReduceIndexManagement(graph); m = graph.openManagement(); TitanGraphIndex index = m.getGraphIndex("name"); ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REMOVE_INDEX).get(); assertEquals(12, metrics.getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT)); }
Example 2
Source File: AbstractIndexManagementIT.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@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)); }
Example 3
Source File: AbstractIndexManagementIT.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test public void testRepairRelationIndex() throws InterruptedException, BackendException, ExecutionException { tx.commit(); mgmt.commit(); // Load the "Graph of the Gods" sample data (WITHOUT mixed index coverage) GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true); // Create and enable a relation index on lives edges by reason TitanManagement m = graph.openManagement(); PropertyKey reason = m.getPropertyKey("reason"); EdgeLabel lives = m.getEdgeLabel("lives"); m.buildEdgeIndex(lives, "livesByReason", Direction.BOTH, Order.decr, reason); m.commit(); graph.tx().commit(); // Block until the SchemaStatus transitions to REGISTERED assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "livesByReason", "lives") .status(SchemaStatus.REGISTERED).call().getSucceeded()); m = graph.openManagement(); RelationTypeIndex index = m.getRelationIndex(m.getRelationType("lives"), "livesByReason"); m.updateIndex(index, SchemaAction.ENABLE_INDEX); m.commit(); graph.tx().commit(); // Block until the SchemaStatus transitions to ENABLED assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "livesByReason", "lives") .status(SchemaStatus.ENABLED).call().getSucceeded()); // Run a query that hits the index but erroneously returns nothing because we haven't repaired yet //assertFalse(graph.query().has("reason", "no fear of death").edges().iterator().hasNext()); // Repair MapReduceIndexManagement mri = new MapReduceIndexManagement(graph); m = graph.openManagement(); index = m.getRelationIndex(m.getRelationType("lives"), "livesByReason"); ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REINDEX).get(); assertEquals(8, metrics.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT)); }
Example 4
Source File: AbstractIndexManagementIT.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
@Test public void testRepairGraphIndex() throws InterruptedException, BackendException, ExecutionException { tx.commit(); mgmt.commit(); // Load the "Graph of the Gods" sample data (WITHOUT mixed index coverage) GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true); // Create and enable a graph index on age TitanManagement m = graph.openManagement(); PropertyKey age = m.getPropertyKey("age"); m.buildIndex("verticesByAge", Vertex.class).addKey(age).buildCompositeIndex(); m.commit(); graph.tx().commit(); // Block until the SchemaStatus transitions to REGISTERED assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "verticesByAge") .status(SchemaStatus.REGISTERED).call().getSucceeded()); m = graph.openManagement(); TitanGraphIndex index = m.getGraphIndex("verticesByAge"); m.updateIndex(index, SchemaAction.ENABLE_INDEX); m.commit(); graph.tx().commit(); // Block until the SchemaStatus transitions to ENABLED assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "verticesByAge") .status(SchemaStatus.ENABLED).call().getSucceeded()); // Run a query that hits the index but erroneously returns nothing because we haven't repaired yet assertFalse(graph.query().has("age", 10000).vertices().iterator().hasNext()); // Repair MapReduceIndexManagement mri = new MapReduceIndexManagement(graph); m = graph.openManagement(); index = m.getGraphIndex("verticesByAge"); ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REINDEX).get(); assertEquals(6, metrics.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT)); // Test the index Iterable<TitanVertex> hits = graph.query().has("age", 4500).vertices(); assertNotNull(hits); assertEquals(1, Iterables.size(hits)); TitanVertex v = Iterables.getOnlyElement(hits); assertNotNull(v); assertEquals("neptune", v.value("name")); }