BitVector[] path = new BitVector[elementLengths.length];
for (int i = 0; i < path.length; ++i) {
path[i] = BitVectorFactories.OPTIMAL.apply(elementLengths[path.length - i - 1]);
}
StreamingRollup<BitVector, BigIntegerContent> rollup = BoundedRollup.create(
new BigIntegerContent(BigInteger.ZERO), cacheSize);
Scan fullScan = new Scan();
ResultScanner scanner = table.getScanner(fullScan);
BitVector hilbertIndex = BitVectorFactories.OPTIMAL.apply(spec.sumBitsPerDimension());
for (Result row : scanner) {
hilbertIndex.copyFromBigEndian(row.getRow());
for (int i = 0; i < path.length; ++i) {
path[i] = path[i].clone();
}
BitVectorMath.split(hilbertIndex, path);
// We should say the exact number of times. Saying one is correct, but
// suboptimal.
BigIntegerContent v = new BigIntegerContent(BigInteger.ONE);
rollup.feedRow(Iterators.<BitVector>forArray(path), v);
}
MapNode<BitVector, BigIntegerContent> rolledupTree = rollup.finish();
Pow2LengthBitSetRangeFactory<BigIntegerContent> factory = Pow2LengthBitSetRangeFactory.create(Ints.asList(elementLengths));
Map<Pow2LengthBitSetRange, NodeValue<BigIntegerContent>> rolledupMap = factory.apply(rolledupTree);