[
https://issues.apache.org/jira/browse/CALCITE-6698?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17899273#comment-17899273
]
Stamatis Zampetakis commented on CALCITE-6698:
----------------------------------------------
Thanks for the feedback [~julianhyde] . Indeed, I was not sure if I should log
this as a bug or not but taking into account the class Javadoc and the behavior
of the other getter methods I found the naming of the methods misleading.
Anyways, I think I raised the PR a bit too soon. Instead of changing the
behavior of the methods, which is gonna be a breaking change, I will just
update the Javadoc with further explanations.
Other than that, I was thinking if it is worth introducing some extra "alias"
methods, i.e., "getMaximal" "getMinimal", which are standard terms in poset
terminology to make the API easier to consume. From my perspective, minimal and
maximal are more descriptive than "getNonChildren" and "getNonParents".
Thoughts?
> Wrong (swapped) results in PartiallyOrderedSet#getNonChildren and
> getNonParents
> -------------------------------------------------------------------------------
>
> Key: CALCITE-6698
> URL: https://issues.apache.org/jira/browse/CALCITE-6698
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Stamatis Zampetakis
> Assignee: Stamatis Zampetakis
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.39.0
>
>
> {{PartiallyOrderedSet#getNonChildren}} and
> {{PartiallyOrderedSet#getNonParents}} methods return wrong results.
> According to the class Javadoc:
> {code:java}
> * <p>In addition to the usual set methods, there are methods to determine the
> * immediate parents and children of an element in the set, and method to find
> * all elements which have no parents or no children (i.e. "root" and "leaf"
> * elements).
> {code}
> * {{getNonChildren}} should return all elements which have no children (leafs)
> * {{getNonParents}} should return all elements which have no parents (roots)
> Currently, the two methods return the opposite results.
> {code:java}
> PartiallyOrderedSet<Integer> poset =
> new PartiallyOrderedSet<>((i,j) -> i <= j);
> poset.add(10);
> poset.add(20);
> poset.add(30);
> StringBuilder sb = new StringBuilder();
> poset.out(sb);
> {code}
> {noformat}
> PartiallyOrderedSet size: 3 elements: {
> 30 parents: [] children: [20]
> 20 parents: [30] children: [10]
> 10 parents: [20] children: []
> }
> {noformat}
> {code:java}
> poset.getNonChildren(); // should return 10 but it returns 30
> poset.getNonParents(); // should return 30 but it returns 10
> {code}
> The current implementation also contradicts the results of
> getChildren/getParents methods:
> {code:java}
> poset.getChildren(30); // returns 20 so it contradicts getNonChildren()
> poset.getParents(10); // returns 20 so it contradicts getNonParents()
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)