Skip to content

Commit

Permalink
fix: correct the delete edge with single from or to
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Aug 24, 2023
1 parent 3f9b97d commit ec69ca0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class FetchEdgesFromToVerticesStep extends AbstractExecutionStep {
private Iterator<OEdge> currentFromEdgesIter;
private Iterator toIterator;

private Set<ORID> toList = new HashSet<>();
private Set<ORID> toList;
private boolean inited = false;

private OEdge nextEdge = null;
Expand Down Expand Up @@ -124,7 +124,7 @@ private void init() {
fromValues = ctx.getVariable(fromAlias);
if (fromValues instanceof Iterable && !(fromValues instanceof OIdentifiable)) {
fromValues = ((Iterable) fromValues).iterator();
} else if (!(fromValues instanceof Iterator)) {
} else if (!(fromValues instanceof Iterator) && fromValues != null) {
fromValues = Collections.singleton(fromValues).iterator();
}

Expand All @@ -133,29 +133,31 @@ private void init() {
toValues = ctx.getVariable(toAlias);
if (toValues instanceof Iterable && !(toValues instanceof OIdentifiable)) {
toValues = ((Iterable) toValues).iterator();
} else if (!(toValues instanceof Iterator)) {
} else if (!(toValues instanceof Iterator) && toValues != null) {
toValues = Collections.singleton(toValues).iterator();
}

fromIter = (Iterator) fromValues;

Iterator toIter = (Iterator) toValues;

while (toIter != null && toIter.hasNext()) {
Object elem = toIter.next();
if (elem instanceof OResult) {
elem = ((OResult) elem).toElement();
}
if (elem instanceof OIdentifiable && !(elem instanceof OElement)) {
elem = ((OIdentifiable) elem).getRecord();
}
if (!(elem instanceof OElement)) {
throw new OCommandExecutionException("Invalid vertex: " + elem);
if (toIter != null) {
toList = new HashSet<ORID>();
while (toIter.hasNext()) {
Object elem = toIter.next();
if (elem instanceof OResult) {
elem = ((OResult) elem).toElement();
}
if (elem instanceof OIdentifiable && !(elem instanceof OElement)) {
elem = ((OIdentifiable) elem).getRecord();
}
if (!(elem instanceof OElement)) {
throw new OCommandExecutionException("Invalid vertex: " + elem);
}
((OElement) elem).asVertex().ifPresent(x -> toList.add(x.getIdentity()));
}
((OElement) elem).asVertex().ifPresent(x -> toList.add(x.getIdentity()));
}

toIterator = toList.iterator();
toIterator = toList.iterator();
}

fetchNextEdge();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ public OInternalExecutionPlan createExecutionPlan(
rightExpression,
ctx,
enableProfiling);
String fromLabel = null;
if (leftExpression != null) {
fromLabel = "$__ORIENT_DELETE_EDGE_fromV";
}
handleFetchFromTo(
result,
ctx,
"$__ORIENT_DELETE_EDGE_fromV",
fromLabel,
"$__ORIENT_DELETE_EDGE_toV",
className,
targetClusterName,
Expand Down

0 comments on commit ec69ca0

Please sign in to comment.