/** * Split the given nodes into lists keyed by the bucket index 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 -> Integer .valueOf(info.nodeOrder.bucket(node, parentIndex.depthIndex() + 1)); ListMultimap<Integer, Node> nodesByBucket = Multimaps.index(nodes, keyFunction); return nodesByBucket; }
@Override public void endBucket(NodeRef leftParent, NodeRef rigthParent, BucketIndex bucketIndex, @Nullable Bucket left, @Nullable Bucket right) { int bucketDepth = bucketIndex.depthIndex(); if (bucketDepth > 3) { throw new IllegalStateException(); } }
@Override public boolean bucket(NodeRef lparent, NodeRef rparent, BucketIndex bucketIndex, Bucket left, Bucket right) { int bucketDepth = bucketIndex.depthIndex(); maxDepth.set(Math.max(maxDepth.get(), bucketDepth + 1));// use +1 cause we want the // number of levels, not the // zero-based level index return true; } });
int childBucket = ORDER.bucket(childName, bucketIndex.depthIndex()); boolean applies = childBucket == bucketIndex.lastIndex().intValue();
@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); }
@Override public boolean bucket(NodeRef leftParent, NodeRef rightParent, BucketIndex bucketIndex, @Nullable Bucket left, @Nullable Bucket right) { out.printf("%sBUCKET: [%s] %s\n", indent, bucketIndex, right); int indentLength = 2 * (1 + bucketIndex.depthIndex()); indent = Strings.padStart("", indentLength, ' '); return true; }
/** * 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 matches(Object item) { int bucketDepth = ((BucketIndex) item).depthIndex(); return bucketDepth == expectedDepth; } };
@Override public boolean bucket(NodeRef lparent, NodeRef rparent, BucketIndex bucketIndex, Bucket left, Bucket right) { int bucketDepth = bucketIndex.depthIndex(); maxDepth.set(Math.max(maxDepth.get(), bucketDepth + 1));// use +1 cause we want the // number of levels, not the // zero-based level index return true; } });
@Override public void endBucket(NodeRef leftParent, NodeRef rigthParent, BucketIndex bucketIndex, @Nullable Bucket left, @Nullable Bucket right) { int bucketDepth = bucketIndex.depthIndex(); if (bucketDepth > 3) { throw new IllegalStateException(); } }
@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); }
@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 boolean matches(Object item) { int bucketDepth = ((BucketIndex) item).depthIndex(); return bucketDepth == expectedDepth; } };
@Override public void endBucket(NodeRef leftParent, NodeRef rigthParent, BucketIndex bucketIndex, @Nullable Bucket left, @Nullable Bucket right) { int bucketDepth = bucketIndex.depthIndex(); if (bucketDepth > 3) { throw new IllegalStateException(); } }
@Override public boolean matches(Object item) { int bucketDepth = ((BucketIndex) item).depthIndex(); return bucketDepth == expectedDepth; } };
@Override public boolean bucket(NodeRef lparent, NodeRef rparent, BucketIndex bucketIndex, Bucket left, Bucket right) { int bucketDepth = bucketIndex.depthIndex(); maxDepth.set(Math.max(maxDepth.get(), bucketDepth + 1));// use +1 cause we want the // number of levels, not the // zero-based level index return true; } });
@Override public boolean bucket(NodeRef leftParent, NodeRef rightParent, BucketIndex bucketIndex, @Nullable Bucket left, @Nullable Bucket right) { out.printf("%sBUCKET: [%s] %s\n", indent, bucketIndex, right); int indentLength = 2 * (1 + bucketIndex.depthIndex()); indent = Strings.padStart("", indentLength, ' '); return true; }