Skip to content

Commit

Permalink
fix: Xplan validation erroneously throws warning on missing objects
Browse files Browse the repository at this point in the history
Closes #890
  • Loading branch information
emanuelaepure10 committed Jul 11, 2024
1 parent ef6534f commit 85098fe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.NoSuchElementException;
import java.util.Queue;
import java.util.Set;
import java.util.stream.Collectors;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -199,7 +198,14 @@ public InstanceCollection next() {
*/
private List<InstanceReference> getNextAtomicPart() {
// select an arbitrary vertex
Vertex vtx = graph.someVertex();
Vertex vtx = null;

if (handleFirst != null) {
vtx = graph.getVertex(handleFirst);
}
if (vtx == null) {
vtx = graph.someVertex();
}
if (vtx != null) {
// get all vertices associated with that vertex
final Set<Vertex> visited = new LinkedHashSet<>();
Expand Down Expand Up @@ -235,23 +241,21 @@ public Boolean compute(LoopBundle<Vertex> loop) {
if (ref != null) {
result.add(ref);
}
else {
Iterable<Vertex> referers = associated.getVertices(Direction.IN);
else if (!vtx.getId().equals(associated.getId())) {
Set<String> ids = new HashSet<>();
if (referers != null) {
for (Vertex referer : referers) {
Object ident = referer.getId();
if (ident != null) {
ids.add(ident.toString());
}
for (Vertex referer : associated.getVertices(Direction.IN)) {
Object ident = referer.getId();
if (ident != null) {
ids.add(ident.toString());
}
}

if (ids.isEmpty()) {
log.warn("Encountered referenced object w/o associated instance: "
+ associated.getId());
}
else {
String enumIds = ids.stream().collect(Collectors.joining(", "));
String enumIds = String.join(", ", ids);
log.warn("Encountered referenced object w/o associated instance: "
+ associated.getId() + " - referenced from " + enumIds);
}
Expand Down Expand Up @@ -294,23 +298,37 @@ public void remove() {

private boolean partitioned = false;

private final T handleFirst;

/**
* Create a new reference graph from the given instance collection.
*
* @param inspector the instance inspector to use
* @param instances the
* @param handleFirst the ID of the first instance to handle, optional and
* can be null
*/
public ReferenceGraph(IdentityReferenceInspector<T> inspector, InstanceCollection instances) {
public ReferenceGraph(IdentityReferenceInspector<T> inspector, InstanceCollection instances,
T handleFirst) {
this.graph = new CustomTinkerGraph();
this.inspector = inspector;
this.originalCollection = instances;
this.handleFirst = handleFirst;

populate(instances);

// identified vertices no longer needed after populate
identifiedVertices.clear();
}

/**
* @param inspector the instance inspector to use
* @param instances the
*/
public ReferenceGraph(IdentityReferenceInspector<T> inspector, InstanceCollection instances) {
this(inspector, instances, null);
}

/**
* Populate the graph with the instances from the given collection.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void partitionByPlan(ProgressIndicator progress, IOReporter reporter)
for (String planId : planIdToInstancesMapping.keySet()) {
MultiInstanceCollection mic = new MultiInstanceCollection(
Arrays.asList(planIdToInstancesMapping.get(planId), nonPlanInstances));
ReferenceGraph<String> rg = new ReferenceGraph<String>(new XMLInspector(), mic);
ReferenceGraph<String> rg = new ReferenceGraph<String>(new XMLInspector(), mic, planId);

Iterator<InstanceCollection> p = rg.partition(1, reporter);
while (p.hasNext()) {
Expand Down

0 comments on commit 85098fe

Please sign in to comment.