GumpacG commented on code in PR #3448: URL: https://github.com/apache/tinkerpop/pull/3448#discussion_r3399891315
########## docs/src/upgrade/release-4.x.x.asciidoc: ########## @@ -501,10 +501,49 @@ It cannot be passed to `traversal().with(...)`, and mutating its collections has re-query elements against the original graph, extract their ids and call `g.V(id)` or `g.E(id)` against the original `GraphTraversalSource`. +==== Tree No Longer Extends HashMap + +`Tree` no longer extends `HashMap`. It is now a `final` class that holds a `Map` internally and exposes a +tree-shaped API instead of `Map` methods. This is a breaking change for code that treated a `tree()` result as a +`Map`. + +Replacements for the common `Map`-based access patterns: + +[options="header"] +|======================= +|3.x (`Tree` as `Map`) |4.x (`Tree` API) +|`tree.get(key)` |`tree.childAt(key)` (throws if absent) or `tree.findSubtree(key)` (recursive, returns `Optional`) +|`tree.containsKey(key)` |`tree.hasChild(key)` +|`tree.keySet()` |`tree.rootNodes()` +|`tree.size()` |`tree.rootNodes().size()` for root entries, or `tree.nodeCount()` for total nodes +|`getObjectsAtDepth(d)` |`getNodesAtDepth(d)` (now 0-based: depth 0 returns the roots) Review Comment: I agree that it's not exactly a "node" however, renaming to "objects" may make other tree functions not very tree-like. For example, `nodeCount()` would have to be `objectCount()` and `rootNodes()` would have to be `rootObjects()`. I think it would be more conducive for tree users to keep "node". -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
