@Override public void write(final PathArgument child, final NormalizedNode<?, ?> data) { delegate.write(child, data); }
@Override public void delete(final PathArgument child) { delegate.delete(child); }
@Override public void enter(final PathArgument... path) { delegate.enter(path); }
AbstractNodeIterator next(final DataTreeModificationCursor cursor) { while (iterator.hasNext()) { final DataTreeCandidateNode node = iterator.next(); switch (node.getModificationType()) { case DELETE: cursor.delete(node.getIdentifier()); break; case APPEARED: case DISAPPEARED: case SUBTREE_MODIFIED: final Collection<DataTreeCandidateNode> children = node.getChildNodes(); if (!children.isEmpty()) { cursor.enter(node.getIdentifier()); return new ExitingNodeIterator(this, children.iterator()); } break; case UNMODIFIED: // No-op break; case WRITE: cursor.write(node.getIdentifier(), node.getDataAfter().get()); break; default: throw new IllegalArgumentException("Unsupported modification " + node.getModificationType()); } } exitNode(cursor); return getParent(); }
private static void applyNode(final DataTreeModificationCursor cursor, final ModifiedNode node) { switch (node.getOperation()) { case NONE: break; case DELETE: cursor.delete(node.getIdentifier()); break; case MERGE: cursor.merge(node.getIdentifier(), node.getWrittenValue()); applyChildren(cursor, node); break; case TOUCH: // TODO: we could improve efficiency of cursor use if we could understand // nested TOUCH operations. One way of achieving that would be a proxy // cursor, which would keep track of consecutive enter and exit calls // and coalesce them. applyChildren(cursor, node); break; case WRITE: cursor.write(node.getIdentifier(), node.getWrittenValue()); applyChildren(cursor, node); break; default: throw new IllegalArgumentException("Unhandled node operation " + node.getOperation()); } }
private static void applyChildren(final DataTreeModificationCursor cursor, final ModifiedNode node) { final Collection<ModifiedNode> children = node.getChildren(); if (!children.isEmpty()) { cursor.enter(node.getIdentifier()); for (final ModifiedNode child : children) { applyNode(cursor, child); } cursor.exit(); } }
@Override protected void exitNode(final DataTreeModificationCursor cursor) { cursor.exit(); } }
@Override public void merge(final PathArgument child, final NormalizedNode<?, ?> data) { delegate.merge(child, data); }
@Override public void close() { delegate.close(); }
public Optional<NormalizedNode<?, ?>> readNode(final PathArgument child) { return delegate.readNode(child); }
AbstractNodeIterator next(final DataTreeModificationCursor cursor) { while (iterator.hasNext()) { final DataTreeCandidateNode node = iterator.next(); switch (node.getModificationType()) { case DELETE: cursor.delete(node.getIdentifier()); break; case APPEARED: case DISAPPEARED: case SUBTREE_MODIFIED: final Collection<DataTreeCandidateNode> children = node.getChildNodes(); if (!children.isEmpty()) { cursor.enter(node.getIdentifier()); return new ExitingNodeIterator(this, children.iterator()); } break; case UNMODIFIED: // No-op break; case WRITE: cursor.write(node.getIdentifier(), node.getDataAfter().get()); break; default: throw new IllegalArgumentException("Unsupported modification " + node.getModificationType()); } } exitNode(cursor); return getParent(); }
private static void applyNode(final DataTreeModificationCursor cursor, final ModifiedNode node) { switch (node.getOperation()) { case NONE: break; case DELETE: cursor.delete(node.getIdentifier()); break; case MERGE: cursor.merge(node.getIdentifier(), node.getWrittenValue()); applyChildren(cursor, node); break; case TOUCH: // TODO: we could improve efficiency of cursor use if we could understand // nested TOUCH operations. One way of achieving that would be a proxy // cursor, which would keep track of consecutive enter and exit calls // and coalesce them. applyChildren(cursor, node); break; case WRITE: cursor.write(node.getIdentifier(), node.getWrittenValue()); applyChildren(cursor, node); break; default: throw new IllegalArgumentException("Unhandled node operation " + node.getOperation()); } }
private static void applyChildren(final DataTreeModificationCursor cursor, final ModifiedNode node) { final Collection<ModifiedNode> children = node.getChildren(); if (!children.isEmpty()) { cursor.enter(node.getIdentifier()); for (final ModifiedNode child : children) { applyNode(cursor, child); } cursor.exit(); } }
@Override protected void exitNode(final DataTreeModificationCursor cursor) { cursor.exit(); } }
switch (node.getModificationType()) { case DELETE: cursor.delete(rootPath.getLastPathArgument()); break; case SUBTREE_MODIFIED: cursor.enter(rootPath.getLastPathArgument()); AbstractNodeIterator iterator = new ExitingNodeIterator(null, node.getChildNodes().iterator()); do { cursor.write(rootPath.getLastPathArgument(), node.getDataAfter().get()); break; default:
@Benchmark @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) public void write100KSingleNodeWithOneInnerItemInOneCommitCursorBenchmark() throws DataValidationFailedException { final CursorAwareDataTreeModification modification = begin(); try (DataTreeModificationCursor cursor = modification.createCursor(BenchmarkModel.OUTER_LIST_PATH)) { for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) { cursor.write(OUTER_LIST_IDS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]); } } commit(modification); }
@Override public void exit() { delegate.exit(); }
@Override public void enter(final Iterable<PathArgument> path) { delegate.enter(path); }
/** * Applies the {@code node} to the {@code cursor}, note that if the top node of (@code node} is RootNode * you need to use {@link #applyRootedNodeToCursor(DataTreeModificationCursor, YangInstanceIdentifier, * DataTreeCandidateNode) applyRootedNodeToCursor} method that works with rooted node candidates. * * @param cursor cursor from the modification we want to apply the {@code node} to * @param node candidate tree to apply */ public static void applyToCursor(final DataTreeModificationCursor cursor, final DataTreeCandidateNode node) { switch (node.getModificationType()) { case DELETE: cursor.delete(node.getIdentifier()); break; case SUBTREE_MODIFIED: cursor.enter(node.getIdentifier()); AbstractNodeIterator iterator = new ExitingNodeIterator(null, node.getChildNodes().iterator()); do { iterator = iterator.next(cursor); } while (iterator != null); break; case UNMODIFIED: // No-op break; case WRITE: cursor.write(node.getIdentifier(), node.getDataAfter().get()); break; default: throw new IllegalArgumentException("Unsupported modification " + node.getModificationType()); } }
@Benchmark @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) public void write50KSingleNodeWithTwoInnerItemsInOneCommitCursorBenchmark() throws DataValidationFailedException { final CursorAwareDataTreeModification modification = begin(); try (DataTreeModificationCursor cursor = modification.createCursor(BenchmarkModel.OUTER_LIST_PATH)) { for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) { cursor.write(OUTER_LIST_IDS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]); } } commit(modification); }