@Test public void testIdCounts() { makeVertexIndexedUniqueKey("uid", Integer.class); mgmt.setConsistency(mgmt.getGraphIndex("uid"), ConsistencyModifier.LOCK); finishSchema(); //Schema and relation id pools are tapped, Schema id pool twice because the renew is triggered. Each id acquisition requires 1 mutations and 2 reads verifyStoreMetrics(ID_STORE_NAME, SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 3l, M_GET_SLICE, 6l)); }
public void testBatchLoadingLocking(boolean batchloading) { PropertyKey uid = makeKey("uid",Long.class); TitanGraphIndex uidIndex = mgmt.buildIndex("uid",Vertex.class).unique().addKey(uid).buildCompositeIndex(); mgmt.setConsistency(uid, ConsistencyModifier.LOCK); mgmt.setConsistency(uidIndex,ConsistencyModifier.LOCK); EdgeLabel knows = mgmt.makeEdgeLabel("knows").multiplicity(Multiplicity.ONE2ONE).make(); mgmt.setConsistency(knows,ConsistencyModifier.LOCK); finishSchema(); TestLockerManager.ERROR_ON_LOCKING=true; clopen(option(GraphDatabaseConfiguration.STORAGE_BATCH),batchloading, option(GraphDatabaseConfiguration.LOCK_BACKEND),"test"); int numV = 10000; long start = System.currentTimeMillis(); for (int i=0;i<numV;i++) { TitanVertex v = tx.addVertex("uid",i+1); v.addEdge("knows",v); } clopen(); // System.out.println("Time: " + (System.currentTimeMillis()-start)); for (int i=0;i<Math.min(numV,300);i++) { assertEquals(1, Iterables.size(graph.query().has("uid", i + 1).vertices())); TitanVertex v = Iterables.<TitanVertex>getOnlyElement(graph.query().has("uid", i + 1).vertices()); assertEquals(1, Iterables.size(v.query().direction(OUT).labels("knows").edges())); } }
TitanGraphIndex nameIndex = mgmt.buildIndex("name", Vertex.class) .addKey(name).unique().buildCompositeIndex(); mgmt.setConsistency(nameIndex, ConsistencyModifier.LOCK); EdgeLabel married = mgmt.makeEdgeLabel("married").multiplicity(Multiplicity.ONE2ONE).make(); mgmt.setConsistency(married, ConsistencyModifier.LOCK); EdgeLabel friend = mgmt.makeEdgeLabel("friend").multiplicity(Multiplicity.MULTI).make(); finishSchema();
@Test public void testIndexQueryWithLabelsAndContainsIN() { // This test is based on the steps to reproduce #882 String labelName = "labelName"; VertexLabel label = mgmt.makeVertexLabel(labelName).make(); PropertyKey uid = mgmt.makePropertyKey("uid").dataType(String.class).make(); TitanGraphIndex uidCompositeIndex = mgmt.buildIndex("uidIndex", Vertex.class).indexOnly(label).addKey(uid).unique().buildCompositeIndex(); mgmt.setConsistency(uidCompositeIndex, ConsistencyModifier.LOCK); finishSchema(); TitanVertex foo = graph.addVertex(labelName); TitanVertex bar = graph.addVertex(labelName); foo.property("uid", "foo"); bar.property("uid", "bar"); graph.tx().commit(); Iterable<TitanVertex> vertexes = graph.query() .has("uid", Contain.IN, ImmutableList.of("foo", "bar")) .has(LABEL_NAME, labelName) .vertices(); assertEquals(2, Iterables.size(vertexes)); for (TitanVertex v : vertexes) { assertEquals(labelName, v.vertexLabel().name()); } }
@Test public void checkPropertyLockingAndIndex() { PropertyKey uid = makeKey("uid",String.class); TitanGraphIndex index = mgmt.buildIndex("uid",Vertex.class).unique().addKey(uid).buildCompositeIndex(); mgmt.setConsistency(index, ConsistencyModifier.LOCK); mgmt.makePropertyKey("name").dataType(String.class).make(); mgmt.makePropertyKey("age").dataType(Integer.class).make(); finishSchema(); metricsPrefix = "checkPropertyLockingAndIndex"; TitanTransaction tx = graph.buildTransaction().groupName(metricsPrefix).start(); TitanVertex v = tx.addVertex("uid", "v1", "age", 25, "name", "john"); assertEquals(25,v.property("age").value()); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); verifyLockingOverwrite(INDEXSTORE_NAME, 1); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l)); resetMetrics(); tx = graph.buildTransaction().groupName(metricsPrefix).start(); v = Iterables.getOnlyElement(tx.query().has("uid", Cmp.EQUAL, "v1").vertices()); assertEquals(25,v.property("age").value()); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE,1l)); verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE,1l)); verifyStoreMetrics(METRICS_STOREMANAGER_NAME); }
PropertyKey uid = makeVertexIndexedUniqueKey("uid", Integer.class); PropertyKey name = makeKey("name", String.class); mgmt.setConsistency(uid, ConsistencyModifier.LOCK); mgmt.setConsistency(name, ConsistencyModifier.LOCK); mgmt.setConsistency(mgmt.getGraphIndex("uid"), ConsistencyModifier.LOCK); EdgeLabel knows = mgmt.makeEdgeLabel("knows").multiplicity(Multiplicity.SIMPLE).make(); EdgeLabel spouse = mgmt.makeEdgeLabel("spouse").multiplicity(Multiplicity.ONE2ONE).make(); EdgeLabel connect = mgmt.makeEdgeLabel("connect").multiplicity(Multiplicity.MULTI).make(); EdgeLabel related = mgmt.makeEdgeLabel("related").multiplicity(Multiplicity.MULTI).make(); mgmt.setConsistency(knows, ConsistencyModifier.LOCK); mgmt.setConsistency(spouse, ConsistencyModifier.LOCK); mgmt.setConsistency(related, ConsistencyModifier.FORK); finishSchema(); mgmt.setConsistency(mgmt.getPropertyKey("name"), ConsistencyModifier.FORK); fail(); } catch (IllegalArgumentException e) {
PropertyKey value = mgmt.makePropertyKey("value").dataType(Integer.class).cardinality(Cardinality.LIST).make(); PropertyKey valuef = mgmt.makePropertyKey("valuef").dataType(Integer.class).cardinality(Cardinality.LIST).make(); mgmt.setConsistency(valuef,ConsistencyModifier.FORK); mgmt.setConsistency(emf,ConsistencyModifier.FORK); EdgeLabel es = mgmt.makeEdgeLabel("es").multiplicity(Multiplicity.SIMPLE).make(); EdgeLabel o2o = mgmt.makeEdgeLabel("o2o").multiplicity(Multiplicity.ONE2ONE).make();
mgmt.setConsistency(mgmt.getGraphIndex("uid"),ConsistencyModifier.LOCK); finishSchema();
nameIndexBuilder.unique(); TitanGraphIndex namei = nameIndexBuilder.buildCompositeIndex(); mgmt.setConsistency(namei, ConsistencyModifier.LOCK); final PropertyKey age = mgmt.makePropertyKey("age").dataType(Integer.class).make(); if (null != mixedIndexName)
@Test public void testIdCounts() { makeVertexIndexedUniqueKey("uid",Integer.class); mgmt.setConsistency(mgmt.getGraphIndex("uid"),ConsistencyModifier.LOCK); finishSchema(); //Schema and relation id pools are tapped, Schema id pool twice because the renew is triggered. Each id acquisition requires 1 mutations and 2 reads verifyStoreMetrics(ID_STORE_NAME, SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 3l, M_GET_SLICE, 6l)); }
public void testBatchLoadingLocking(boolean batchloading) { PropertyKey uid = makeKey("uid",Long.class); TitanGraphIndex uidIndex = mgmt.buildIndex("uid",Vertex.class).unique().addKey(uid).buildCompositeIndex(); mgmt.setConsistency(uid, ConsistencyModifier.LOCK); mgmt.setConsistency(uidIndex,ConsistencyModifier.LOCK); EdgeLabel knows = mgmt.makeEdgeLabel("knows").multiplicity(Multiplicity.ONE2ONE).make(); mgmt.setConsistency(knows,ConsistencyModifier.LOCK); finishSchema(); TestLockerManager.ERROR_ON_LOCKING=true; clopen(option(GraphDatabaseConfiguration.STORAGE_BATCH),batchloading, option(GraphDatabaseConfiguration.LOCK_BACKEND),"test"); int numV = 10000; long start = System.currentTimeMillis(); for (int i=0;i<numV;i++) { TitanVertex v = tx.addVertex(); v.setProperty("uid",i+1); v.addEdge("knows",v); } clopen(); // System.out.println("Time: " + (System.currentTimeMillis()-start)); for (int i=0;i<Math.min(numV,300);i++) { assertEquals(1, Iterables.size(graph.query().has("uid", i + 1).vertices())); assertEquals(1, Iterables.size(graph.query().has("uid", i + 1).vertices().iterator().next().getEdges(Direction.OUT, "knows"))); } }
public void makeTypes(TitanGraph g) { Preconditions.checkArgument(edgeLabels <= edgePropKeys); TitanManagement mgmt = g.getManagementSystem(); for (int i = 0; i < vertexPropKeys; i++) { PropertyKey key = mgmt.makePropertyKey(getVertexPropertyName(i)).dataType(Integer.class).cardinality(Cardinality.SINGLE).make(); mgmt.setConsistency(key, ConsistencyModifier.LOCK); mgmt.buildIndex("v-"+getVertexPropertyName(i),Vertex.class).addKey(key).buildCompositeIndex(); } for (int i = 0; i < edgePropKeys; i++) { PropertyKey key = mgmt.makePropertyKey(getEdgePropertyName(i)).dataType(Integer.class).cardinality(Cardinality.SINGLE).make(); mgmt.setConsistency(key, ConsistencyModifier.LOCK); mgmt.buildIndex("e-"+getEdgePropertyName(i),Edge.class).addKey(key).buildCompositeIndex(); } for (int i = 0; i < edgeLabels; i++) { String labelName = getEdgeLabelName(i); String pkName = getSortKeyForLabel(labelName); PropertyKey pk = mgmt.getPropertyKey(pkName); ((StandardEdgeLabelMaker)mgmt.makeEdgeLabel(getEdgeLabelName(i))).sortKey(pk).make(); } PropertyKey uid = mgmt.makePropertyKey(UID_PROP).dataType(Long.class).cardinality(Cardinality.SINGLE).make(); mgmt.buildIndex("v-uid",Vertex.class).unique().addKey(uid).buildCompositeIndex(); mgmt.setConsistency(uid, ConsistencyModifier.LOCK); mgmt.commit(); log.debug("Committed types"); }
public void checkFastPropertyAndLocking(boolean fastProperty) { PropertyKey uid = makeKey("uid",String.class); TitanGraphIndex index = mgmt.buildIndex("uid",Vertex.class).unique().addKey(uid).buildCompositeIndex(); mgmt.setConsistency(index, ConsistencyModifier.LOCK); finishSchema();
TitanGraphIndex nameIndex = mgmt.buildIndex("name", Vertex.class) .addKey(name).unique().buildCompositeIndex(); mgmt.setConsistency(nameIndex, ConsistencyModifier.LOCK); EdgeLabel married = mgmt.makeEdgeLabel("married").multiplicity(Multiplicity.ONE2ONE).make(); mgmt.setConsistency(married,ConsistencyModifier.LOCK); EdgeLabel friend = mgmt.makeEdgeLabel("friend").multiplicity(Multiplicity.MULTI).make(); finishSchema();
@Test public void testIndexQueryWithLabelsAndContainsIN() { // This test is based on the steps to reproduce #882 String labelName = "labelName"; VertexLabel label = mgmt.makeVertexLabel(labelName).make(); PropertyKey uid = mgmt.makePropertyKey("uid").dataType(String.class).make(); TitanGraphIndex uidCompositeIndex = mgmt.buildIndex("uidIndex", Vertex.class).indexOnly(label).addKey(uid).unique().buildCompositeIndex(); mgmt.setConsistency(uidCompositeIndex, ConsistencyModifier.LOCK); finishSchema(); Vertex foo = graph.addVertexWithLabel(labelName); Vertex bar = graph.addVertexWithLabel(labelName); foo.setProperty("uid", "foo"); bar.setProperty("uid", "bar"); graph.commit(); Iterable<Vertex> vertexes = graph.query() .has("uid", Contain.IN, ImmutableList.of("foo", "bar")) .has("label", labelName) .vertices(); assertEquals(2, Iterables.size(vertexes)); for (Vertex v : vertexes) { assertEquals(labelName, ((TitanVertex)v).getLabel()); } }
PropertyKey id = makeVertexIndexedUniqueKey("uid",Integer.class); PropertyKey name = makeKey("name",String.class); mgmt.setConsistency(id, ConsistencyModifier.LOCK); mgmt.setConsistency(name, ConsistencyModifier.LOCK); mgmt.setConsistency(mgmt.getGraphIndex("uid"),ConsistencyModifier.LOCK); EdgeLabel knows = mgmt.makeEdgeLabel("knows").multiplicity(Multiplicity.SIMPLE).make(); EdgeLabel spouse = mgmt.makeEdgeLabel("spouse").multiplicity(Multiplicity.ONE2ONE).make(); EdgeLabel connect = mgmt.makeEdgeLabel("connect").multiplicity(Multiplicity.MULTI).make(); EdgeLabel related = mgmt.makeEdgeLabel("related").multiplicity(Multiplicity.MULTI).make(); mgmt.setConsistency(knows, ConsistencyModifier.LOCK); mgmt.setConsistency(spouse, ConsistencyModifier.LOCK); mgmt.setConsistency(related,ConsistencyModifier.FORK); finishSchema(); mgmt.setConsistency(mgmt.getPropertyKey("name"),ConsistencyModifier.FORK); fail(); } catch (IllegalArgumentException e) {}
mgmt.setConsistency(mgmt.getGraphIndex("uid"),ConsistencyModifier.LOCK); finishSchema();
PropertyKey value = mgmt.makePropertyKey("value").dataType(Integer.class).cardinality(Cardinality.LIST).make(); PropertyKey valuef = mgmt.makePropertyKey("valuef").dataType(Integer.class).cardinality(Cardinality.LIST).make(); mgmt.setConsistency(valuef,ConsistencyModifier.FORK); mgmt.setConsistency(emf,ConsistencyModifier.FORK); EdgeLabel es = mgmt.makeEdgeLabel("es").multiplicity(Multiplicity.SIMPLE).make(); EdgeLabel o2o = mgmt.makeEdgeLabel("o2o").multiplicity(Multiplicity.ONE2ONE).make();
nameIndexBuilder.unique(); TitanGraphIndex namei = nameIndexBuilder.buildCompositeIndex(); mgmt.setConsistency(namei, ConsistencyModifier.LOCK); final PropertyKey age = mgmt.makePropertyKey("age").dataType(Integer.class).make(); if (null != mixedIndexName)
final PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make(); TitanGraphIndex namei = mgmt.buildIndex("name",Vertex.class).addKey(name).unique().buildCompositeIndex(); mgmt.setConsistency(namei, ConsistencyModifier.LOCK); final PropertyKey age = mgmt.makePropertyKey("age").dataType(Integer.class).make(); mgmt.buildIndex("vertices",Vertex.class).addKey(age).buildMixedIndex(INDEX_NAME);