Skip to content

Commit

Permalink
If vertex existence verification isn't needed, getVertices() should r…
Browse files Browse the repository at this point in the history
…un a query.
  • Loading branch information
mbroecheler committed Jan 15, 2015
1 parent 22539c6 commit 1856ae7
Showing 1 changed file with 18 additions and 8 deletions.
Expand Up @@ -159,9 +159,9 @@ public class StandardTitanTx extends TitanBlueprintsTransaction implements TypeI
*/ */
private boolean isOpen; private boolean isOpen;


private final Retriever<Long, InternalVertex> existingVertexRetriever; private final VertexConstructor existingVertexRetriever;
private final Retriever<Long, InternalVertex> externalVertexRetriever; private final VertexConstructor externalVertexRetriever;
private final Retriever<Long, InternalVertex> internalVertexRetriever; private final VertexConstructor internalVertexRetriever;


public StandardTitanTx(StandardTitanGraph graph, TransactionConfiguration config) { public StandardTitanTx(StandardTitanGraph graph, TransactionConfiguration config) {
Preconditions.checkNotNull(graph); Preconditions.checkNotNull(graph);
Expand Down Expand Up @@ -381,11 +381,17 @@ public Iterable<TitanVertex> getVertices(long... ids) {
} }
} }
if (!vids.isEmpty()) { if (!vids.isEmpty()) {
List<EntryList> existence = graph.edgeMultiQuery(vids,graph.vertexExistenceQuery,txHandle); if (externalVertexRetriever.hasVerifyExistence()) {
for (int i = 0; i < vids.size(); i++) { List<EntryList> existence = graph.edgeMultiQuery(vids,graph.vertexExistenceQuery,txHandle);
if (!existence.get(i).isEmpty()) { for (int i = 0; i < vids.size(); i++) {
long id = vids.get(i); if (!existence.get(i).isEmpty()) {
result.add(vertexCache.get(id, existingVertexRetriever)); long id = vids.get(i);
result.add(vertexCache.get(id, existingVertexRetriever));
}
}
} else {
for (int i = 0; i < vids.size(); i++) {
result.add(vertexCache.get(vids.get(i),externalVertexRetriever));
} }
} }
} }
Expand Down Expand Up @@ -416,6 +422,10 @@ private VertexConstructor(boolean verifyExistence, boolean createStubVertex) {
this.createStubVertex = createStubVertex; this.createStubVertex = createStubVertex;
} }


public boolean hasVerifyExistence() {
return verifyExistence;
}

@Override @Override
public InternalVertex get(Long vertexid) { public InternalVertex get(Long vertexid) {
Preconditions.checkArgument(vertexid!=null && vertexid > 0, "Invalid vertex id: %s",vertexid); Preconditions.checkArgument(vertexid!=null && vertexid > 0, "Invalid vertex id: %s",vertexid);
Expand Down

0 comments on commit 1856ae7

Please sign in to comment.