use of com.thinkaurelius.titan.core.PropertyKey in project titan by thinkaurelius.
the class TitanIndexTest method testDualMapping.
@Test
public void testDualMapping() {
if (!indexFeatures.supportsStringMapping(Mapping.TEXTSTRING))
return;
PropertyKey name = makeKey("name", String.class);
TitanGraphIndex mixed = mgmt.buildIndex("mixed", Vertex.class).addKey(name, Mapping.TEXTSTRING.asParameter()).buildMixedIndex(INDEX);
mixed.name();
finishSchema();
tx.addVertex("name", "Long John Don");
tx.addVertex("name", "Long Little Lewis");
tx.addVertex("name", "Middle Sister Mabel");
clopen();
evaluateQuery(tx.query().has("name", Cmp.EQUAL, "Long John Don"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "mixed");
evaluateQuery(tx.query().has("name", Text.CONTAINS, "Long"), ElementCategory.VERTEX, 2, new boolean[] { true, true }, "mixed");
evaluateQuery(tx.query().has("name", Text.CONTAINS, "Long Don"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "mixed");
evaluateQuery(tx.query().has("name", Text.CONTAINS_PREFIX, "Lon"), ElementCategory.VERTEX, 2, new boolean[] { true, true }, "mixed");
evaluateQuery(tx.query().has("name", Text.CONTAINS_REGEX, "Lit*le"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "mixed");
evaluateQuery(tx.query().has("name", Text.REGEX, "Long.*"), ElementCategory.VERTEX, 2, new boolean[] { true, true }, "mixed");
evaluateQuery(tx.query().has("name", Text.PREFIX, "Middle"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "mixed");
for (Vertex u : tx.getVertices()) {
String n = u.<String>value("name");
if (n.endsWith("Don")) {
u.remove();
} else if (n.endsWith("Lewis")) {
u.property(VertexProperty.Cardinality.single, "name", "Big Brother Bob");
} else if (n.endsWith("Mabel")) {
u.property("name").remove();
}
}
clopen();
evaluateQuery(tx.query().has("name", Text.CONTAINS, "Long"), ElementCategory.VERTEX, 0, new boolean[] { true, true }, "mixed");
evaluateQuery(tx.query().has("name", Text.CONTAINS, "Big"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "mixed");
evaluateQuery(tx.query().has("name", Text.PREFIX, "Big"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "mixed");
evaluateQuery(tx.query().has("name", Text.PREFIX, "Middle"), ElementCategory.VERTEX, 0, new boolean[] { true, true }, "mixed");
}
use of com.thinkaurelius.titan.core.PropertyKey in project titan by thinkaurelius.
the class TitanGraphTest method testIndexUpdatesWithReindexAndRemove.
@Test
public void testIndexUpdatesWithReindexAndRemove() throws InterruptedException, ExecutionException {
clopen(option(LOG_SEND_DELAY, MANAGEMENT_LOG), Duration.ofMillis(0), option(KCVSLog.LOG_READ_LAG_TIME, MANAGEMENT_LOG), Duration.ofMillis(50), option(LOG_READ_INTERVAL, MANAGEMENT_LOG), Duration.ofMillis(250));
//Types without index
PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).make();
PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SET).make();
EdgeLabel friend = mgmt.makeEdgeLabel("friend").multiplicity(Multiplicity.MULTI).make();
PropertyKey sensor = mgmt.makePropertyKey("sensor").dataType(Double.class).cardinality(Cardinality.LIST).make();
finishSchema();
RelationTypeIndex pindex, eindex;
TitanGraphIndex gindex;
//Add some sensor & friend data
TitanVertex v = tx.addVertex();
for (int i = 0; i < 10; i++) {
v.property("sensor", i, "time", i);
v.property("name", "v" + i);
TitanVertex o = tx.addVertex();
v.addEdge("friend", o, "time", i);
}
newTx();
//Indexes should not yet be in use
v = getV(tx, v);
evaluateQuery(v.query().keys("sensor").interval("time", 1, 5).orderBy("time", decr), PROPERTY, 4, 1, new boolean[] { false, false }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().keys("sensor").interval("time", 101, 105).orderBy("time", decr), PROPERTY, 0, 1, new boolean[] { false, false }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 1, 5).orderBy("time", decr), EDGE, 4, 1, new boolean[] { false, false }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 101, 105).orderBy("time", decr), EDGE, 0, 1, new boolean[] { false, false }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(tx.query().has("name", "v5"), ElementCategory.VERTEX, 1, new boolean[] { false, true });
evaluateQuery(tx.query().has("name", "v105"), ElementCategory.VERTEX, 0, new boolean[] { false, true });
newTx();
//Create indexes after the fact
finishSchema();
sensor = mgmt.getPropertyKey("sensor");
time = mgmt.getPropertyKey("time");
name = mgmt.getPropertyKey("name");
friend = mgmt.getEdgeLabel("friend");
mgmt.buildPropertyIndex(sensor, "byTime", decr, time);
mgmt.buildEdgeIndex(friend, "byTime", Direction.OUT, decr, time);
mgmt.buildIndex("bySensorReading", Vertex.class).addKey(name).buildCompositeIndex();
finishSchema();
newTx();
//Add some sensor & friend data that should already be indexed even though index is not yet enabled
v = getV(tx, v);
for (int i = 100; i < 110; i++) {
v.property("sensor", i, "time", i);
v.property("name", "v" + i);
TitanVertex o = tx.addVertex();
v.addEdge("friend", o, "time", i);
}
tx.commit();
//Should not yet be able to enable since not yet registered
pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime");
eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime");
gindex = mgmt.getGraphIndex("bySensorReading");
try {
mgmt.updateIndex(pindex, SchemaAction.ENABLE_INDEX);
fail();
} catch (IllegalArgumentException e) {
}
try {
mgmt.updateIndex(eindex, SchemaAction.ENABLE_INDEX);
fail();
} catch (IllegalArgumentException e) {
}
try {
mgmt.updateIndex(gindex, SchemaAction.ENABLE_INDEX);
fail();
} catch (IllegalArgumentException e) {
}
mgmt.commit();
ManagementUtil.awaitVertexIndexUpdate(graph, "byTime", "sensor", 10, ChronoUnit.SECONDS);
ManagementUtil.awaitGraphIndexUpdate(graph, "bySensorReading", 5, ChronoUnit.SECONDS);
finishSchema();
//Verify new status
pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime");
eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime");
gindex = mgmt.getGraphIndex("bySensorReading");
assertEquals(SchemaStatus.REGISTERED, pindex.getIndexStatus());
assertEquals(SchemaStatus.REGISTERED, eindex.getIndexStatus());
assertEquals(SchemaStatus.REGISTERED, gindex.getIndexStatus(gindex.getFieldKeys()[0]));
finishSchema();
//Simply enable without reindex
eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime");
mgmt.updateIndex(eindex, SchemaAction.ENABLE_INDEX);
finishSchema();
assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "byTime", "friend").status(SchemaStatus.ENABLED).timeout(10L, ChronoUnit.SECONDS).call().getSucceeded());
//Reindex the other two
pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime");
ScanMetrics reindexSensorByTime = mgmt.updateIndex(pindex, SchemaAction.REINDEX).get();
finishSchema();
gindex = mgmt.getGraphIndex("bySensorReading");
ScanMetrics reindexBySensorReading = mgmt.updateIndex(gindex, SchemaAction.REINDEX).get();
finishSchema();
assertNotEquals(0, reindexSensorByTime.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT));
assertNotEquals(0, reindexBySensorReading.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT));
//Every index should now be enabled
pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime");
eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime");
gindex = mgmt.getGraphIndex("bySensorReading");
assertEquals(SchemaStatus.ENABLED, eindex.getIndexStatus());
assertEquals(SchemaStatus.ENABLED, pindex.getIndexStatus());
assertEquals(SchemaStatus.ENABLED, gindex.getIndexStatus(gindex.getFieldKeys()[0]));
//Add some more sensor & friend data
newTx();
v = getV(tx, v);
for (int i = 200; i < 210; i++) {
v.property("sensor", i, "time", i);
v.property("name", "v" + i);
TitanVertex o = tx.addVertex();
v.addEdge("friend", o, "time", i);
}
newTx();
//Use indexes now but only see new data for property and graph index
v = getV(tx, v);
evaluateQuery(v.query().keys("sensor").interval("time", 1, 5).orderBy("time", decr), PROPERTY, 4, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().keys("sensor").interval("time", 101, 105).orderBy("time", decr), PROPERTY, 4, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().keys("sensor").interval("time", 201, 205).orderBy("time", decr), PROPERTY, 4, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 1, 5).orderBy("time", decr), EDGE, 0, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 101, 105).orderBy("time", decr), EDGE, 4, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 201, 205).orderBy("time", decr), EDGE, 4, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(tx.query().has("name", "v5"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "bySensorReading");
evaluateQuery(tx.query().has("name", "v105"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "bySensorReading");
evaluateQuery(tx.query().has("name", "v205"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "bySensorReading");
finishSchema();
eindex = mgmt.getRelationIndex(mgmt.getRelationType("friend"), "byTime");
ScanMetrics reindexFriendByTime = mgmt.updateIndex(eindex, SchemaAction.REINDEX).get();
finishSchema();
assertNotEquals(0, reindexFriendByTime.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT));
finishSchema();
newTx();
//It should now have all the answers
v = getV(tx, v);
evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 1, 5).orderBy("time", decr), EDGE, 4, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 101, 105).orderBy("time", decr), EDGE, 4, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 201, 205).orderBy("time", decr), EDGE, 4, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime");
gindex = mgmt.getGraphIndex("bySensorReading");
mgmt.updateIndex(pindex, SchemaAction.DISABLE_INDEX);
mgmt.updateIndex(gindex, SchemaAction.DISABLE_INDEX);
mgmt.commit();
tx.commit();
ManagementUtil.awaitVertexIndexUpdate(graph, "byTime", "sensor", 10, ChronoUnit.SECONDS);
ManagementUtil.awaitGraphIndexUpdate(graph, "bySensorReading", 5, ChronoUnit.SECONDS);
finishSchema();
pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime");
gindex = mgmt.getGraphIndex("bySensorReading");
assertEquals(SchemaStatus.DISABLED, pindex.getIndexStatus());
assertEquals(SchemaStatus.DISABLED, gindex.getIndexStatus(gindex.getFieldKeys()[0]));
finishSchema();
newTx();
//The two disabled indexes should force full scans
v = getV(tx, v);
evaluateQuery(v.query().keys("sensor").interval("time", 1, 5).orderBy("time", decr), PROPERTY, 4, 1, new boolean[] { false, false }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().keys("sensor").interval("time", 101, 105).orderBy("time", decr), PROPERTY, 4, 1, new boolean[] { false, false }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().keys("sensor").interval("time", 201, 205).orderBy("time", decr), PROPERTY, 4, 1, new boolean[] { false, false }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 1, 5).orderBy("time", decr), EDGE, 4, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 101, 105).orderBy("time", decr), EDGE, 4, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(v.query().labels("friend").direction(OUT).interval("time", 201, 205).orderBy("time", decr), EDGE, 4, 1, new boolean[] { true, true }, tx.getPropertyKey("time"), Order.DESC);
evaluateQuery(tx.query().has("name", "v5"), ElementCategory.VERTEX, 1, new boolean[] { false, true });
evaluateQuery(tx.query().has("name", "v105"), ElementCategory.VERTEX, 1, new boolean[] { false, true });
evaluateQuery(tx.query().has("name", "v205"), ElementCategory.VERTEX, 1, new boolean[] { false, true });
tx.commit();
finishSchema();
pindex = mgmt.getRelationIndex(mgmt.getRelationType("sensor"), "byTime");
gindex = mgmt.getGraphIndex("bySensorReading");
ScanMetrics pmetrics = mgmt.updateIndex(pindex, SchemaAction.REMOVE_INDEX).get();
ScanMetrics gmetrics = mgmt.updateIndex(gindex, SchemaAction.REMOVE_INDEX).get();
finishSchema();
assertEquals(30, pmetrics.getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT));
assertEquals(30, gmetrics.getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT));
}
use of com.thinkaurelius.titan.core.PropertyKey in project titan by thinkaurelius.
the class TitanGraphTest method testVertexCentricIndexWithNull.
@Test
public void testVertexCentricIndexWithNull() {
EdgeLabel bought = makeLabel("bought");
PropertyKey time = makeKey("time", Long.class);
mgmt.buildEdgeIndex(bought, "byTimeDesc", BOTH, decr, time);
mgmt.buildEdgeIndex(bought, "byTimeIncr", BOTH, incr, time);
finishSchema();
TitanVertex v1 = tx.addVertex(), v2 = tx.addVertex();
v1.addEdge("bought", v2).property("time", 1);
v1.addEdge("bought", v2).property("time", 2);
v1.addEdge("bought", v2).property("time", 3);
v1.addEdge("bought", v2);
v1.addEdge("bought", v2);
assertEquals(5, v1.query().direction(OUT).labels("bought").edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", 1).edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 3).has("time", Cmp.GREATER_THAN, 1).edgeCount());
assertEquals(3, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 5).edgeCount());
assertEquals(3, v1.query().direction(OUT).labels("bought").has("time", Cmp.GREATER_THAN, 0).edgeCount());
assertEquals(2, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 3).edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", Cmp.GREATER_THAN, 2).edgeCount());
assertEquals(2, v1.query().direction(OUT).labels("bought").hasNot("time").edgeCount());
assertEquals(5, v1.query().direction(OUT).labels("bought").edgeCount());
newTx();
v1 = tx.getVertex(v1.longId());
//Queries copied from above
assertEquals(5, v1.query().direction(OUT).labels("bought").edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", 1).edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 3).has("time", Cmp.GREATER_THAN, 1).edgeCount());
assertEquals(3, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 5).edgeCount());
assertEquals(3, v1.query().direction(OUT).labels("bought").has("time", Cmp.GREATER_THAN, 0).edgeCount());
assertEquals(2, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 3).edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", Cmp.GREATER_THAN, 2).edgeCount());
assertEquals(2, v1.query().direction(OUT).labels("bought").hasNot("time").edgeCount());
assertEquals(5, v1.query().direction(OUT).labels("bought").edgeCount());
}
use of com.thinkaurelius.titan.core.PropertyKey in project titan by thinkaurelius.
the class TitanGraphTest method testIndexUniqueness.
@Test
public void testIndexUniqueness() {
PropertyKey time = makeKey("time", Long.class);
PropertyKey text = makeKey("text", String.class);
VertexLabel person = mgmt.makeVertexLabel("person").make();
VertexLabel org = mgmt.makeVertexLabel("organization").make();
TitanGraphIndex vindex1 = mgmt.buildIndex("vindex1", Vertex.class).addKey(time).indexOnly(person).unique().buildCompositeIndex();
TitanGraphIndex vindex2 = mgmt.buildIndex("vindex2", Vertex.class).addKey(time).addKey(text).unique().buildCompositeIndex();
finishSchema();
//================== VERTEX UNIQUENESS ====================
//I) Label uniqueness
//Ia) Uniqueness violation in same transaction
failTransactionOnCommit(new TransactionJob() {
@Override
public void run(TitanTransaction tx) {
TitanVertex v0 = tx.addVertex("person");
v0.property(VertexProperty.Cardinality.single, "time", 1);
TitanVertex v1 = tx.addVertex("person");
v1.property(VertexProperty.Cardinality.single, "time", 1);
}
});
//Ib) Uniqueness violation across transactions
TitanVertex v0 = tx.addVertex("person");
v0.property(VertexProperty.Cardinality.single, "time", 1);
newTx();
failTransactionOnCommit(new TransactionJob() {
@Override
public void run(TitanTransaction tx) {
TitanVertex v1 = tx.addVertex("person");
v1.property(VertexProperty.Cardinality.single, "time", 1);
}
});
//Ic) However, this should work since the label is different
TitanVertex v1 = tx.addVertex("organization");
v1.property(VertexProperty.Cardinality.single, "time", 1);
newTx();
//II) Composite uniqueness
//IIa) Uniqueness violation in same transaction
failTransactionOnCommit(new TransactionJob() {
@Override
public void run(TitanTransaction tx) {
TitanVertex v0 = tx.addVertex("time", 2, "text", "hello");
TitanVertex v1 = tx.addVertex("time", 2, "text", "hello");
}
});
//IIb) Uniqueness violation across transactions
v0 = tx.addVertex("time", 2, "text", "hello");
newTx();
failTransactionOnCommit(new TransactionJob() {
@Override
public void run(TitanTransaction tx) {
TitanVertex v1 = tx.addVertex("time", 2, "text", "hello");
}
});
}
use of com.thinkaurelius.titan.core.PropertyKey in project titan by thinkaurelius.
the class TitanGraphTest method testThreadBoundTx.
/**
* Tests that elements can be accessed beyond their transactional boundaries if they
* are bound to single-threaded graph transactions
*/
@Test
@SuppressWarnings("deprecation")
public void testThreadBoundTx() {
PropertyKey t = mgmt.makePropertyKey("type").dataType(Integer.class).make();
mgmt.buildIndex("etype", Edge.class).addKey(t).buildCompositeIndex();
((StandardEdgeLabelMaker) mgmt.makeEdgeLabel("friend")).sortKey(t).make();
finishSchema();
TitanVertex v1 = graph.addVertex("name", "Vertex1", "age", 35);
TitanVertex v2 = graph.addVertex("name", "Vertex2", "age", 45);
TitanVertex v3 = graph.addVertex("name", "Vertex3", "age", 55);
Edge e1 = v1.addEdge("knows", v2, "time", 5);
Edge e2 = v2.addEdge("knows", v3, "time", 15);
Edge e3 = v3.addEdge("knows", v1, "time", 25);
Edge e4 = v2.addEdge("friend", v2, "type", 1);
for (TitanVertex v : new TitanVertex[] { v1, v2, v3 }) {
assertCount(2, v.query().direction(Direction.BOTH).labels("knows").edges());
assertCount(1, v.query().direction(Direction.OUT).labels("knows").edges());
TitanEdge tmpE = getOnlyElement(v.query().direction(Direction.OUT).labels("knows").edges());
assertEquals(5, tmpE.<Integer>value("time") % 10);
}
e3.property("time", 35);
assertEquals(35, e3.<Integer>value("time").intValue());
v1.addEdge("friend", v2, "type", 0);
graph.tx().commit();
e4.property("type", 2);
TitanEdge ef = getOnlyElement(v1.query().direction(Direction.OUT).labels("friend").edges());
assertEquals(ef, (Edge) getOnlyElement(graph.query().has("type", 0).edges()));
ef.property("type", 1);
graph.tx().commit();
assertEquals(35, e3.<Integer>value("time").intValue());
e3 = getE(graph, e3);
e3.property("time", 45);
assertEquals(45, e3.<Integer>value("time").intValue());
assertEquals(15, e2.<Integer>value("time").intValue());
e2.property("time", 25);
assertEquals(25, e2.<Integer>value("time").intValue());
assertEquals(35, v1.<Integer>value("age").intValue());
assertEquals(55, v3.<Integer>value("age").intValue());
v3.property("age", 65);
assertEquals(65, v3.<Integer>value("age").intValue());
e1 = getE(graph, e1);
for (TitanVertex v : new TitanVertex[] { v1, v2, v3 }) {
assertCount(2, v.query().direction(Direction.BOTH).labels("knows").edges());
assertCount(1, v.query().direction(Direction.OUT).labels("knows").edges());
assertEquals(5, getOnlyElement(v.query().direction(Direction.OUT).labels("knows").edges()).<Integer>value("time").intValue() % 10);
}
graph.tx().commit();
VertexProperty prop = v1.properties().next();
assertTrue(getId(prop) > 0);
prop = (VertexProperty) ((Iterable) graph.multiQuery((TitanVertex) v1).properties().values().iterator().next()).iterator().next();
assertTrue(getId(prop) > 0);
assertEquals(45, e3.<Integer>value("time").intValue());
assertEquals(5, e1.<Integer>value("time").intValue());
assertEquals(35, v1.<Integer>value("age").intValue());
assertEquals(65, v3.<Integer>value("age").intValue());
for (TitanVertex v : new TitanVertex[] { v1, v2, v3 }) {
assertCount(2, v.query().direction(Direction.BOTH).labels("knows").edges());
assertCount(1, v.query().direction(Direction.OUT).labels("knows").edges());
assertEquals(5, getOnlyElement(v.query().direction(Direction.OUT).labels("knows").edges()).<Integer>value("time").intValue() % 10);
}
graph.tx().commit();
v1 = graph.addVertex();
v2 = graph.addVertex();
v1.addEdge("knows", v2);
graph.tx().commit();
v3 = graph.addVertex();
Edge e = v1.addEdge("knows", v3);
assertFalse(e.property("age").isPresent());
}
Aggregations