Program: 113164
Project: 113164
Buggy source:
@Override public RangeDecomposition decomposeRange(final NumericData[] rangePerDimension,final CompactHilbertCurve compactHilbertCurve,final SFCDimensionDefinition[] dimensionDefinitions,final int totalPrecision,final int maxFilteredIndexedRanges,final boolean removeVacuum){
  final List<BigInteger> minRangeList=new ArrayList<BigInteger>();
  final List<BigInteger> maxRangeList=new ArrayList<BigInteger>();
  final BigIntegerContent zero=new BigIntegerContent(BigInteger.valueOf(0L));
  final List<BigIntegerRange> region=new ArrayList<BigIntegerRange>(dimensionDefinitions.length);
  for (int d=0; d < dimensionDefinitions.length; d++) {
    final BigInteger normalizedMin=normalizeDimension(dimensionDefinitions[d],rangePerDimension[d].getMin(),binsPerDimension[d]);
    final BigInteger normalizedMax=normalizeDimension(dimensionDefinitions[d],rangePerDimension[d].getMax(),binsPerDimension[d]);
    minRangeList.add(normalizedMin);
    maxRangeList.add(normalizedMax);
    region.add(BigIntegerRange.of(normalizedMin,normalizedMax.add(BigInteger.ONE)));
  }
  final BigInteger minQuadSize=getMinimumQuadSize(minRangeList,maxRangeList);
  final RegionInspector<BigIntegerRange,BigIntegerContent> regionInspector=SimpleRegionInspector.create(ImmutableList.of(region),new BigIntegerContent(minQuadSize),Functions.<BigIntegerRange>identity(),BigIntegerRangeHome.INSTANCE,zero);
  final PlainFilterCombiner<BigIntegerRange,BigInteger,BigIntegerContent,BigIntegerRange> intervalCombiner=new PlainFilterCombiner<BigIntegerRange,BigInteger,BigIntegerContent,BigIntegerRange>(BigIntegerRange.of(0,1));
  final QueryBuilder<BigIntegerRange,BigIntegerRange> queryBuilder=BacktrackingQueryBuilder.create(regionInspector,intervalCombiner,maxFilteredIndexedRanges,removeVacuum,BigIntegerRangeHome.INSTANCE,zero);
  compactHilbertCurve.accept(new ZoomingSpaceVisitorAdapter(compactHilbertCurve,queryBuilder));
  final List<FilteredIndexRange<BigIntegerRange,BigIntegerRange>> hilbertRanges=queryBuilder.get().getFilteredIndexRanges();
  final ByteArrayRange[] sfcRanges=new ByteArrayRange[hilbertRanges.size()];
  final int expectedByteCount=(int)Math.ceil(totalPrecision / 8.0);
  if (expectedByteCount <= 0) {
    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<BigIntegerRange,BigIntegerRange> range=hilbertRanges.get(i);
    final byte[] start=HilbertSFC.fitExpectedByteCount(expectedByteCount,range.getIndexRange().getStart().toByteArray());
    final byte[] end=HilbertSFC.fitExpectedByteCount(expectedByteCount,range.getIndexRange().getEnd().toByteArray());
    sfcRanges[i]=new ByteArrayRange(new ByteArrayId(start),new ByteArrayId(end));
  }
  final RangeDecomposition rangeDecomposition=new RangeDecomposition(sfcRanges);
  return rangeDecomposition;
}

Fixed version (ground truth):
@Override public RangeDecomposition decomposeRange(final NumericData[] rangePerDimension,final CompactHilbertCurve compactHilbertCurve,final SFCDimensionDefinition[] dimensionDefinitions,final int totalPrecision,final int maxFilteredIndexedRanges,final boolean removeVacuum){
  final List<BigInteger> minRangeList=new ArrayList<BigInteger>();
  final List<BigInteger> maxRangeList=new ArrayList<BigInteger>();
  final BigIntegerContent zero=new BigIntegerContent(BigInteger.valueOf(0L));
  final List<BigIntegerRange> region=new ArrayList<BigIntegerRange>(dimensionDefinitions.length);
  for (int d=0; d < dimensionDefinitions.length; d++) {
    final BigInteger normalizedMin=normalizeDimension(dimensionDefinitions[d],rangePerDimension[d].getMin(),binsPerDimension[d]);
    final BigInteger normalizedMax=normalizeDimension(dimensionDefinitions[d],rangePerDimension[d].getMax(),binsPerDimension[d]);
    minRangeList.add(normalizedMin);
    maxRangeList.add(normalizedMax);
    region.add(BigIntegerRange.of(normalizedMin,normalizedMax.add(BigInteger.ONE)));
  }
  final BigInteger minQuadSize=getMinimumQuadSize(minRangeList,maxRangeList);
  final RegionInspector<BigIntegerRange,BigIntegerContent> regionInspector=SimpleRegionInspector.create(ImmutableList.of(region),new BigIntegerContent(minQuadSize),Functions.<BigIntegerRange>identity(),BigIntegerRangeHome.INSTANCE,zero);
  final PlainFilterCombiner<BigIntegerRange,BigInteger,BigIntegerContent,BigIntegerRange> intervalCombiner=new PlainFilterCombiner<BigIntegerRange,BigInteger,BigIntegerContent,BigIntegerRange>(BigIntegerRange.of(0,1));
  final QueryBuilder<BigIntegerRange,BigIntegerRange> queryBuilder=BacktrackingQueryBuilder.create(regionInspector,intervalCombiner,maxFilteredIndexedRanges,removeVacuum,BigIntegerRangeHome.INSTANCE,zero);
  compactHilbertCurve.accept(new ZoomingSpaceVisitorAdapter(compactHilbertCurve,queryBuilder));
  final List<FilteredIndexRange<BigIntegerRange,BigIntegerRange>> hilbertRanges=queryBuilder.get().getFilteredIndexRanges();
  final ByteArrayRange[] sfcRanges=new ByteArrayRange[hilbertRanges.size()];
  final int expectedByteCount=(int)Math.ceil(totalPrecision / 8.0);
  if (expectedByteCount <= 0) {
    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<BigIntegerRange,BigIntegerRange> range=hilbertRanges.get(i);
    final BigInteger startValue=clamp(minHilbertValue,maxHilbertValue,range.getIndexRange().getStart());
    final BigInteger endValue=clamp(minHilbertValue,maxHilbertValue,range.getIndexRange().getEnd());
    final byte[] start=HilbertSFC.fitExpectedByteCount(expectedByteCount,startValue.toByteArray());
    final byte[] end=HilbertSFC.fitExpectedByteCount(expectedByteCount,endValue.toByteArray());
    sfcRanges[i]=new ByteArrayRange(new ByteArrayId(start),new ByteArrayId(end));
  }
  final RangeDecomposition rangeDecomposition=new RangeDecomposition(sfcRanges);
  return rangeDecomposition;
}