@Test public void dropIntIndexTest() { ThunderGraph thunderGraph = new ThunderGraph(this.dbPath); try { thunderGraph.createKeyIndex("name1", Vertex.class); thunderGraph.commit(); Vertex v1 = thunderGraph.addVertex(null); v1.setProperty("name1", 1); Vertex v2 = thunderGraph.addVertex(null); v2.setProperty("name1", 1); Vertex v3 = thunderGraph.addVertex(null); v3.setProperty("name1", 1); thunderGraph.commit(); Assert.assertEquals(3, count(thunderGraph.getVertices("name1", 1))); Assert.assertEquals(3, thunderGraph.getDbEntries(DbEnum.VERTEX_INT_INDEX)); thunderGraph.dropKeyIndex("name1", Vertex.class); thunderGraph.commit(); // Still finds it just not via the index Assert.assertEquals(0, thunderGraph.getDbEntries(DbEnum.VERTEX_INT_INDEX)); Assert.assertEquals(3, count(thunderGraph.getVertices("name1", 1))); } finally { thunderGraph.shutdown(); } }
@Test public void testUpdateIndexedFieldOnEdge() { ThunderGraph thunderGraph = new ThunderGraph(this.dbPath); try { thunderGraph.createKeyIndex("name1", Edge.class); Vertex v1 = thunderGraph.addVertex(null); Vertex v2 = thunderGraph.addVertex(null); Vertex v3 = thunderGraph.addVertex(null); Vertex v4 = thunderGraph.addVertex(null); Edge e1 = v1.addEdge("label1", v2); Edge e2 = v1.addEdge("label1", v3); Edge e3 = v1.addEdge("label1", v4); e1.setProperty("name1", 1); e2.setProperty("name1", 1); e3.setProperty("name1", 1); thunderGraph.commit(); Assert.assertEquals(3, count(thunderGraph.getEdges("name1", 1))); e1.setProperty("name1", 2); thunderGraph.commit(); Assert.assertEquals(2, count(thunderGraph.getEdges("name1", 1))); e2.setProperty("name1", 2); thunderGraph.commit(); Assert.assertEquals(1, count(thunderGraph.getEdges("name1", 1))); e3.setProperty("name1", 2); thunderGraph.commit(); Assert.assertEquals(0, count(thunderGraph.getEdges("name1", 1))); Assert.assertEquals(3, count(thunderGraph.getEdges("name1", 2))); thunderGraph.printDb(DbEnum.EDGE_INT_INDEX); thunderGraph.dropKeyIndex("name1", Edge.class); thunderGraph.printDb(DbEnum.EDGE_INT_INDEX); } finally { thunderGraph.shutdown(); } }