private void setupChainGraph(int numV, String[] strs, boolean sameNameMapping) { clopen(option(INDEX_NAME_MAPPING, INDEX), sameNameMapping); TitanGraphIndex vindex = getExternalIndex(Vertex.class, INDEX); TitanGraphIndex eindex = getExternalIndex(Edge.class, INDEX); TitanGraphIndex pindex = getExternalIndex(TitanVertexProperty.class, INDEX); PropertyKey name = makeKey("name", String.class); mgmt.addIndexKey(vindex, name, getStringMapping()); mgmt.addIndexKey(eindex, name, getStringMapping()); mgmt.addIndexKey(pindex, name, getStringMapping(), Parameter.of("mapped-name", "xstr")); PropertyKey text = makeKey("text", String.class); mgmt.addIndexKey(vindex, text, getTextMapping(), Parameter.of("mapped-name", "xtext")); mgmt.addIndexKey(eindex, text, getTextMapping()); mgmt.addIndexKey(pindex, text, getTextMapping()); mgmt.makeEdgeLabel("knows").signature(name).make(); mgmt.makePropertyKey("uid").dataType(String.class).signature(text).make(); finishSchema(); TitanVertex previous = null; for (int i = 0; i < numV; i++) { TitanVertex v = graph.addVertex("name", strs[i % strs.length], "text", strs[i % strs.length]); Edge e = v.addEdge("knows", previous == null ? v : previous, "name", strs[i % strs.length], "text", strs[i % strs.length]); VertexProperty p = v.property("uid", "v" + i, "name", strs[i % strs.length], "text", strs[i % strs.length]); previous = v; } }
private void testIndexing(Cardinality cardinality) { if (supportsCollections()) { PropertyKey stringProperty = mgmt.makePropertyKey("name").dataType(String.class).cardinality(cardinality).make(); PropertyKey intProperty = mgmt.makePropertyKey("age").dataType(Integer.class).cardinality(cardinality).make(); PropertyKey longProperty = mgmt.makePropertyKey("long").dataType(Long.class).cardinality(cardinality).make(); PropertyKey uuidProperty = mgmt.makePropertyKey("uuid").dataType(UUID.class).cardinality(cardinality).make(); PropertyKey geoProperty = mgmt.makePropertyKey("geo").dataType(Geoshape.class).cardinality(cardinality).make(); mgmt.buildIndex("collectionIndex", Vertex.class).addKey(stringProperty, getStringMapping()).addKey(intProperty).addKey(longProperty).addKey(uuidProperty).addKey(geoProperty).buildMixedIndex(INDEX); finishSchema(); testCollection(cardinality, "name", "Totoro", "Hiro"); testCollection(cardinality, "age", 1, 2); testCollection(cardinality, "long", 1L, 2L); testCollection(cardinality, "uuid", UUID.randomUUID(), UUID.randomUUID()); testCollection(cardinality, "geo", Geoshape.point(1.0, 1.0), Geoshape.point(2.0, 2.0)); } else { try { PropertyKey stringProperty = mgmt.makePropertyKey("name").dataType(String.class).cardinality(cardinality).make(); //This should throw an exception mgmt.buildIndex("collectionIndex", Vertex.class).addKey(stringProperty, getStringMapping()).buildMixedIndex(INDEX); Assert.fail("Should have thrown an exception"); } catch (TitanException e) { } } }
addKey(name, getStringMapping()).addKey(time).buildMixedIndex(INDEX); mgmt.buildIndex("index2", Vertex.class).indexOnly(event). addKey(text, getTextMapping()).buildMixedIndex(INDEX);
addKey(name, getStringMapping()).addKey(time).buildMixedIndex(INDEX); mgmt.buildIndex("index2", Edge.class).indexOnly(label). addKey(text, getTextMapping()).buildMixedIndex(INDEX);
addKey(name, getStringMapping()).buildMixedIndex(INDEX); TitanGraphIndex index2 = mgmt.buildIndex("index2", Vertex.class).indexOnly(person). addKey(text, getTextMapping()).addKey(weight).buildMixedIndex(INDEX);
private void setupChainGraph(int numV, String[] strs, boolean sameNameMapping) { clopen(option(INDEX_NAME_MAPPING,INDEX),sameNameMapping); TitanGraphIndex vindex = getExternalIndex(Vertex.class,INDEX); TitanGraphIndex eindex = getExternalIndex(Edge.class,INDEX); TitanGraphIndex pindex = getExternalIndex(TitanProperty.class,INDEX); PropertyKey name = makeKey("name",String.class); mgmt.addIndexKey(vindex, name, getStringMapping()); mgmt.addIndexKey(eindex, name, getStringMapping()); mgmt.addIndexKey(pindex, name, getStringMapping(), Parameter.of("mapped-name", "xstr")); PropertyKey text = makeKey("text",String.class); mgmt.addIndexKey(vindex, text, getTextMapping(), Parameter.of("mapped-name","xtext")); mgmt.addIndexKey(eindex, text, getTextMapping()); mgmt.addIndexKey(pindex, text, getTextMapping()); mgmt.makeEdgeLabel("knows").signature(name).make(); mgmt.makePropertyKey("uid").dataType(String.class).signature(text).make(); finishSchema(); TitanVertex previous = null; for (int i=0;i<numV;i++) { TitanVertex v = graph.addVertex(null); v.setProperty("name",strs[i%strs.length]); v.setProperty("text",strs[i%strs.length]); TitanEdge e = v.addEdge("knows",previous==null?v:previous); e.setProperty("name",strs[i%strs.length]); e.setProperty("text",strs[i%strs.length]); TitanProperty p = v.addProperty("uid","v"+i); p.setProperty("name", strs[i % strs.length]); p.setProperty("text", strs[i % strs.length]); previous=v; } }
addKey(name, getStringMapping()).addKey(time).buildMixedIndex(INDEX); mgmt.buildIndex("index2",Edge.class).indexOnly(label). addKey(text, getTextMapping()).buildMixedIndex(INDEX);
addKey(name, getStringMapping()).addKey(time).buildMixedIndex(INDEX); mgmt.buildIndex("index2",Vertex.class).indexOnly(event). addKey(text, getTextMapping()).buildMixedIndex(INDEX);
addKey(name, getStringMapping()).buildMixedIndex(INDEX); TitanGraphIndex index2 = mgmt.buildIndex("index2",Vertex.class).indexOnly(person). addKey(text, getTextMapping()).addKey(weight).buildMixedIndex(INDEX);