if (expectedByteCount <= 0) {
// special case for no precision
return new RangeDecomposition(
new ByteArrayRange[] {
new ByteArrayRange(
new ByteArrayId(
new byte[] {}),
new ByteArrayId(
new byte[] {}))
});
}
for (int i = 0; i < hilbertRanges.size(); i++) {
final FilteredIndexRange<LongRange, LongRange> range = hilbertRanges.get(i);
// sanity check that values fit within the expected range
// it seems that uzaygezen can produce a value at 2^totalPrecision
// rather than 2^totalPrecision - 1
final long startValue = clamp(
minHilbertValue,
maxHilbertValue,
range.getIndexRange().getStart());
final long endValue = clamp(
minHilbertValue,
maxHilbertValue,
range.getIndexRange().getEnd() - 1);
// make sure its padded if necessary
final byte[] start = HilbertSFC.fitExpectedByteCount(
expectedByteCount,
ByteBuffer.allocate(
8).putLong(
startValue).array());
// make sure its padded if necessary
final byte[] end = HilbertSFC.fitExpectedByteCount(
expectedByteCount,
ByteBuffer.allocate(
8).putLong(
endValue).array());
sfcRanges[i] = new ByteArrayRange(
new ByteArrayId(
start),
new ByteArrayId(
end));
}
final RangeDecomposition rangeDecomposition = new RangeDecomposition(
sfcRanges);