@Test public void testLargeJointIndexRetrieval() { makeVertexIndexedKey("sid", Integer.class); makeVertexIndexedKey("color", String.class); finishSchema(); int sids = 17; String[] colors = {"blue", "red", "yellow", "brown", "green", "orange", "purple"}; int multiplier = 200; int numV = sids * colors.length * multiplier; for (int i = 0; i < numV; i++) { TitanVertex v = graph.addVertex( "color", colors[i % colors.length], "sid", i % sids); } clopen(); assertCount(numV / sids, graph.query().has("sid", 8).vertices()); assertCount(numV / colors.length, graph.query().has("color", colors[2]).vertices()); assertCount(multiplier, graph.query().has("sid", 11).has("color", colors[3]).vertices()); }
@Test public void testLimitWithMixedIndexCoverage() { final String vt = "vt"; final String fn = "firstname"; final String user = "user"; final String alice = "alice"; final String bob = "bob"; PropertyKey vtk = makeVertexIndexedKey(vt, String.class); PropertyKey fnk = makeKey(fn, String.class); finishSchema(); TitanVertex a = tx.addVertex(vt, user, fn, "alice"); TitanVertex b = tx.addVertex(vt, user, fn, "bob"); TitanVertex v; v = getOnlyElement(tx.query().has(vt, user).has(fn, bob).limit(1).vertices()); assertEquals(bob, v.value(fn)); assertEquals(user, v.value(vt)); v = getOnlyElement(tx.query().has(vt, user).has(fn, alice).limit(1).vertices()); assertEquals(alice, v.value(fn)); assertEquals(user, v.value(vt)); tx.commit(); tx = graph.newTransaction(); v = getOnlyElement(tx.query().has(vt, user).has(fn, bob).limit(1).vertices()); assertEquals(bob, v.value(fn)); assertEquals(user, v.value(vt)); v = getOnlyElement(tx.query().has(vt, user).has(fn, alice).limit(1).vertices()); assertEquals(alice, v.value(fn)); assertEquals(user, v.value(vt)); }
PropertyKey someid = makeVertexIndexedKey("someid", Object.class);
@Test public void testJointIndexRetrieval() { makeVertexIndexedKey("name",String.class); makeVertexIndexedKey("color",String.class); finishSchema(); Vertex v = graph.addVertex(null); v.setProperty("name", "ilya"); v.setProperty("color", "blue"); graph.commit(); assertEquals(1, Iterables.size(graph.query().has("name", "ilya").vertices())); assertEquals(1, Iterables.size(graph.query().has("name", "ilya").has("color", "blue").vertices())); }
@Test public void testLargeJointIndexRetrieval() { makeVertexIndexedKey("sid",Integer.class); makeVertexIndexedKey("color",String.class); finishSchema(); int sids = 17; String[] colors = {"blue", "red", "yellow", "brown", "green", "orange", "purple"}; int multiplier = 200; int numV = sids * colors.length * multiplier; for (int i = 0; i < numV; i++) { Vertex v = graph.addVertex(null); v.setProperty("color", colors[i % colors.length]); v.setProperty("sid", i % sids); } graph.commit(); clopen(); assertEquals(numV / sids, Iterables.size(graph.query().has("sid", 8).vertices())); assertEquals(numV / colors.length, Iterables.size(graph.query().has("color", colors[2]).vertices())); assertEquals(multiplier, Iterables.size(graph.query().has("sid", 11).has("color", colors[3]).vertices())); }
final String bob = "bob"; PropertyKey vtk = makeVertexIndexedKey(vt,String.class); PropertyKey fnk = makeKey(fn,String.class);
PropertyKey someid = makeVertexIndexedKey("someid", Object.class);