use of com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx in project titan by thinkaurelius.
the class VertexJobConverter method startTransaction.
public static StandardTitanTx startTransaction(StandardTitanGraph graph) {
StandardTransactionBuilder txb = graph.buildTransaction().readOnly();
txb.setPreloadedData(true);
txb.checkInternalVertexExistence(false);
txb.dirtyVertexSize(0);
txb.vertexCacheSize(0);
return (StandardTitanTx) txb.start();
}
use of com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx in project titan by thinkaurelius.
the class PartitionedVertexProgramExecutor method run.
public void run(int numThreads, ScanMetrics metrics) {
StandardTitanTx tx = null;
Map<Long, EntryList> pVertexAggregates = vertexMemory.retrievePartitionAggregates();
//Nothing to do here
if (pVertexAggregates.isEmpty())
return;
try (WorkerPool workers = new WorkerPool(numThreads)) {
tx = VertexJobConverter.startTransaction(graph);
for (Map.Entry<Long, EntryList> pvertices : pVertexAggregates.entrySet()) {
if (pvertices.getValue() == null) {
metrics.incrementCustom(GHOTST_PARTITION_VERTEX);
continue;
}
workers.submit(new PartitionedVertexProcessor(pvertices.getKey(), pvertices.getValue(), tx, metrics));
}
} catch (Throwable ex) {
log.error("Could not post-process partitioned vertices", ex);
metrics.incrementCustom(PARTITION_VERTEX_POSTFAIL);
} finally {
if (tx != null && tx.isOpen())
tx.rollback();
}
}
use of com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx in project titan by thinkaurelius.
the class RelationTypeIndexWrapper method getSortKey.
@Override
public RelationType[] getSortKey() {
StandardTitanTx tx = type.tx();
long[] ids = type.getSortKey();
RelationType[] keys = new RelationType[ids.length];
for (int i = 0; i < keys.length; i++) {
keys[i] = tx.getExistingRelationType(ids[i]);
}
return keys;
}
use of com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx 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.graphdb.transaction.StandardTitanTx in project titan by thinkaurelius.
the class StandardTitanGraph method newTransaction.
public StandardTitanTx newTransaction(final TransactionConfiguration configuration) {
if (!isOpen)
ExceptionFactory.graphShutdown();
try {
StandardTitanTx tx = new StandardTitanTx(this, configuration);
tx.setBackendTransaction(openBackendTransaction(tx));
openTransactions.add(tx);
return tx;
} catch (BackendException e) {
throw new TitanException("Could not start new transaction", e);
}
}
Aggregations