@Test public void createNodePartitionLinearList2() throws Exception { Node<InvariantSpan> a = new Node<>(new InvariantSpan(1, 1, documentHash)); Node<InvariantSpan> b = new Node<>(new InvariantSpan(2, 1, documentHash)); Node<InvariantSpan> c = new Node<>(new InvariantSpan(3, 1, documentHash)); Node<InvariantSpan> d = new Node<>(new InvariantSpan(4, 1, documentHash)); Node<InvariantSpan> ab = new Node.Builder<InvariantSpan>(1).left(a).right(b).build(); Node<InvariantSpan> ac = new Node.Builder<InvariantSpan>(2).left(ab).right(c).build(); Node<InvariantSpan> ac_dummy = new Node.Builder<InvariantSpan>(3).left(ac).build(); Node<InvariantSpan> ad = new Node.Builder<InvariantSpan>(3).left(ac_dummy).right(d).build(); Node<InvariantSpan> root = new Node.Builder<InvariantSpan>(4).left(ad).build(); NodeIndex<InvariantSpan> e = RopeUtils.index(3, root, 0); List<Node<InvariantSpan>> orphans = Partitioner.pruneIndexNode(e.node, 3, e.displacement); }
public static <S extends StreamElement> List<Node<S>> pruneIndexNode(Node<S> indexNode, long leftPartitionWidth, long displacement) { if (indexNode.isRightNode()) { if (indexNode.parent.parent != null) { if (indexNode.parent.left != null) { displacement -= indexNode.parent.left.weight; indexNode.parent.parent.isRed = false; } return pruneTree(indexNode.parent.parent, 0, leftPartitionWidth, displacement, indexNode.parent.parent.isRightNode()); } return new ArrayList<>(); } else { return pruneTree(indexNode.parent, 0, leftPartitionWidth, displacement, true); } }
Partitioner { public static <S extends StreamElement> List<Node<S>> pruneIndexNode(Node<S> indexNode, long leftPartitionWidth, long displacement) { if (indexNode.isRightNode()) { if (indexNode.parent.parent != null) { if (indexNode.parent.left != null) { displacement -= indexNode.parent.left.weight; indexNode.parent.parent.isRed = false; } return pruneTree(indexNode.parent.parent, 0, leftPartitionWidth, displacement, indexNode.parent.parent.isRightNode()); } return new ArrayList<>(); } else { return pruneTree(indexNode.parent, 0, leftPartitionWidth, displacement, true); } } }
Partitioner { public static <S extends StreamElement> List<Node<S>> pruneIndexNode(Node<S> indexNode, long leftPartitionWidth, long displacement) { if (indexNode.isRightNode()) { if (indexNode.parent.parent != null) { if (indexNode.parent.left != null) { displacement -= indexNode.parent.left.weight; indexNode.parent.parent.isRed = false; } return pruneTree(indexNode.parent.parent, 0, leftPartitionWidth, displacement, indexNode.parent.parent.isRightNode()); } return new ArrayList<>(); } else { return pruneTree(indexNode.parent, 0, leftPartitionWidth, displacement, true); } }  }
Partitioner { public static <S extends StreamElement> List<Node<S>> pruneIndexNode(Node<S> indexNode, long leftPartitionWidth, long displacement) { if (indexNode.isRightNode()) { if (indexNode.parent.parent != null) { if (indexNode.parent.left != null) { displacement -= indexNode.parent.left.weight; indexNode.parent.parent.isRed = false; } return pruneTree(indexNode.parent.parent, 0, leftPartitionWidth, displacement, indexNode.parent.parent.isRightNode()); } return new ArrayList<>(); } else { return pruneTree(indexNode.parent, 0, leftPartitionWidth, displacement, true); } }  static NodePartition<T> createNodePartition(long leftPartitionWidth, Node<T> x); static List<Node<S>> pruneIndexNode(Node<S> indexNode, long leftPartitionWidth,
			long displacement); }
Partitioner { public static <S extends StreamElement> List<Node<S>> pruneIndexNode(Node<S> indexNode, long leftPartitionWidth, long displacement) { if (indexNode.isRightNode()) { if (indexNode.parent.parent != null) { if (indexNode.parent.left != null) { displacement -= indexNode.parent.left.weight; indexNode.parent.parent.isRed = false; } return pruneTree(indexNode.parent.parent, 0, leftPartitionWidth, displacement, indexNode.parent.parent.isRightNode()); } return new ArrayList<>(); } else { return pruneTree(indexNode.parent, 0, leftPartitionWidth, displacement, true); } }  static NodePartition<T> createNodePartition(long leftPartitionWidth, Node<T> x); static List<Node<S>> pruneIndexNode(Node<S> indexNode, long leftPartitionWidth,
			long displacement);  }