int childBucket = ORDER.bucket(childName, bucketIndex.depthIndex()); boolean applies = childBucket == bucketIndex.lastIndex().intValue();
public @Override boolean bucket(NodeRef leftParent, NodeRef rightParent, BucketIndex bucketIndex, @Nullable Bucket left, @Nullable Bucket right) { if (rightParent == null || right == null) { // not interested in purely deleted content return false; } // which "old" object the "new" bucket is being compared against. final ObjectId leftId = bucketIndex.left().getId(); boolean r = addBucket(progress, leftId, right); return r; }
@Override protected void compute() { final @Nullable NodeRef leftNode = info.left.parentRef; final @Nullable NodeRef rightNode = info.right.parentRef; if (Objects.equal(leftNode, rightNode)) { return; } if (info.consumer.isCancelled()) { return; } if (info.consumer.tree(leftNode, rightNode)) { RevTree left; RevTree right; left = leftNode == null || RevTree.EMPTY_TREE_ID.equals(leftNode.getObjectId()) ? RevTree.EMPTY : info.left.source.getTree(leftNode.getObjectId()); right = rightNode == null || RevTree.EMPTY_TREE_ID.equals(rightNode.getObjectId()) ? RevTree.EMPTY : info.right.source.getTree(rightNode.getObjectId()); if (info.reportFeatures || (left.numTrees() > 0 || right.numTrees() > 0)) { TraverseTreeContents traverseTreeContents = new TraverseTreeContents(info, left, right, BucketIndex.root(left, right)); traverseTreeContents.compute(); } } info.consumer.endTree(leftNode, rightNode); } }
@Override protected void compute() { final @Nullable NodeRef leftNode = info.left.parentRef; final @Nullable NodeRef rightNode = info.right.parentRef; if (Objects.equal(leftNode, rightNode)) { return; } if (info.consumer.isCancelled()) { return; } if (info.consumer.tree(leftNode, rightNode)) { RevTree left; RevTree right; left = leftNode == null || RevTree.EMPTY_TREE_ID.equals(leftNode.getObjectId()) ? RevTree.EMPTY : info.left.source.getTree(leftNode.getObjectId()); right = rightNode == null || RevTree.EMPTY_TREE_ID.equals(rightNode.getObjectId()) ? RevTree.EMPTY : info.right.source.getTree(rightNode.getObjectId()); TraverseTreeContents traverseTreeContents = new TraverseTreeContents(info, left, right, BucketIndex.root(left, right)); traverseTreeContents.compute(); } info.consumer.endTree(leftNode, rightNode); } }
public BucketIndex append(final Integer index, RevTree left, RevTree right) { return append(index.intValue(), left, right); }
public static BucketIndex root(RevTree left, RevTree right) { return new BucketIndex(left, right); }
public BucketIndex append(final int index, RevTree left, RevTree right) { return new BucketIndex(this.indexPath, index, left, right); }
public static BucketIndex root(RevTree left, RevTree right) { return new BucketIndex(left, right); }
public BucketIndex append(final Integer index, RevTree left, RevTree right) { return append(index.intValue(), left, right); }
public BucketIndex append(final int index, RevTree left, RevTree right) { return new BucketIndex(this.indexPath, index, left, right); }
@Override public BucketIndex apply(Integer i) { return bucketIndex.append(i, left, right); }};
/** * Split the given nodes into lists keyed by the bucket indes they would belong if they were * part of a tree bucket at the given {@code bucketDepth} */ protected final ListMultimap<Integer, Node> splitNodesToBucketsAtDepth(Iterator<Node> nodes, final BucketIndex parentIndex) { Function<Node, Integer> keyFunction = (node) -> ORDER.bucket(node, parentIndex.depthIndex() + 1); ListMultimap<Integer, Node> nodesByBucket = Multimaps.index(nodes, keyFunction); return nodesByBucket; }
@Override public boolean bucket(NodeRef leftParent, NodeRef rigthParent, BucketIndex bucketIndex, @Nullable Bucket left, @Nullable Bucket right) { int bucketDepth = bucketIndex.depthIndex(); if (bucketDepth > 3) { throw new IllegalStateException(); } return true; }
@Override public void endBucket(NodeRef leftParent, NodeRef rightParent, BucketIndex bucketIndex, @Nullable Bucket left, @Nullable Bucket right) { int indentLength = 2 * (bucketIndex.depthIndex()); indent = Strings.padStart("", indentLength, ' '); out.printf("%sEND BUCKET: [%s] %s\n", indent, bucketIndex, right); }