ibessonov commented on a change in pull request #208:
URL: https://github.com/apache/ignite-3/pull/208#discussion_r670429854
##########
File path:
modules/configuration/src/main/java/org/apache/ignite/internal/configuration/util/ConfigurationUtil.java
##########
@@ -291,87 +340,155 @@ else if (val instanceof Map)
* @param updates Tree with updates.
* @return Map of changes.
*/
- public static Map<String, Serializable> nodeToFlatMap(
- SuperRoot curRoot,
- SuperRoot updates
- ) {
+ public static Map<String, Serializable>
createFlattenedUpdatesMap(SuperRoot curRoot, SuperRoot updates) {
+ // Resulting map.
Map<String, Serializable> values = new HashMap<>();
+ // Current methods traverses two trees at the same time. In order to
reuse visitor object it's decided to
+ // use explicit stack for the left tree. We need to reuse visitor
object because it accumulates full keys.
+ Deque<InnerNode> oldInnerNodesStack = new
ArrayDeque<>(Set.of(curRoot));
+
updates.traverseChildren(new KeysTrackingConfigurationVisitor<>() {
- /** Write nulls instead of actual values. Makes sense for
deletions from named lists. */
- private boolean writeNulls;
+ /** Flag indicates that "old" and "new" trees are literally the
same at the moment. */
+ private boolean singleTreeTraversal;
+
+ /**
+ * Makes sense only if {@link #singleTreeTraversal} is {@code
true}. Helps distinguishing creation from
+ * deletion. Always {@code false} if {@link #singleTreeTraversal}
is {@code false}.
+ */
+ private boolean deletion;
/** {@inheritDoc} */
- @Override public Map<String, Serializable> doVisitLeafNode(String
key, Serializable val) {
- if (val != null)
- values.put(currentKey(), writeNulls ? null : val);
+ @Override public Void doVisitLeafNode(String key, Serializable
newVal) {
+ // Read same value from old tree.
+ Serializable oldVal =
oldInnerNodesStack.peek().traverseChild(key, leafNodeVisitor());
Review comment:
peek() will not return null here, dequeue is never empty
--
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]