use of com.thinkaurelius.titan.core.RelationType in project titan by thinkaurelius.
the class RelationIdentifier method findRelation.
TitanRelation findRelation(TitanTransaction tx) {
TitanVertex v = ((StandardTitanTx) tx).getInternalVertex(outVertexId);
if (v == null || v.isRemoved())
return null;
TitanVertex typeVertex = tx.getVertex(typeId);
if (typeVertex == null)
return null;
if (!(typeVertex instanceof RelationType))
throw new IllegalArgumentException("Invalid RelationIdentifier: typeID does not reference a type");
RelationType type = (RelationType) typeVertex;
Iterable<? extends TitanRelation> rels;
if (((RelationType) typeVertex).isEdgeLabel()) {
Direction dir = Direction.OUT;
TitanVertex other = ((StandardTitanTx) tx).getInternalVertex(inVertexId);
if (other == null || other.isRemoved())
return null;
if (((StandardTitanTx) tx).isPartitionedVertex(v) && !((StandardTitanTx) tx).isPartitionedVertex(other)) {
//Swap for likely better performance
TitanVertex tmp = other;
other = v;
v = tmp;
dir = Direction.IN;
}
rels = ((VertexCentricQueryBuilder) v.query()).noPartitionRestriction().types((EdgeLabel) type).direction(dir).adjacent(other).edges();
} else {
rels = ((VertexCentricQueryBuilder) v.query()).noPartitionRestriction().types((PropertyKey) type).properties();
}
for (TitanRelation r : rels) {
//Find current or previous relation
if (r.longId() == relationId || ((r instanceof StandardRelation) && ((StandardRelation) r).getPreviousID() == relationId))
return r;
}
return null;
}
use of com.thinkaurelius.titan.core.RelationType in project titan by thinkaurelius.
the class AbstractIndexManagementIT method testRemoveRelationIndex.
@Test
public void testRemoveRelationIndex() throws InterruptedException, BackendException, ExecutionException {
tx.commit();
mgmt.commit();
// Load the "Graph of the Gods" sample data
GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);
// Disable the "battlesByTime" index
TitanManagement m = graph.openManagement();
RelationType battled = m.getRelationType("battled");
RelationTypeIndex battlesByTime = m.getRelationIndex(battled, "battlesByTime");
m.updateIndex(battlesByTime, SchemaAction.DISABLE_INDEX);
m.commit();
graph.tx().commit();
// Block until the SchemaStatus transitions to DISABLED
assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "battlesByTime", "battled").status(SchemaStatus.DISABLED).call().getSucceeded());
// Remove index
MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
m = graph.openManagement();
battled = m.getRelationType("battled");
battlesByTime = m.getRelationIndex(battled, "battlesByTime");
ScanMetrics metrics = mri.updateIndex(battlesByTime, SchemaAction.REMOVE_INDEX).get();
assertEquals(6, metrics.getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT));
}
Aggregations