@Test public void testDistribution() { final Map<ByteArray, Long> counts = new HashMap<>(); int total = 0; for (double x = 90; x < 180; x += 0.05) { for (double y = 50; y < 90; y += 0.5) { final NumericRange dimension1Range = new NumericRange(x, x + 0.002); final NumericRange dimension2Range = new NumericRange(y - 0.002, y); final MultiDimensionalNumericData sfcIndexedRange = new BasicNumericDataset(new NumericData[] {dimension1Range, dimension2Range}); for (final byte[] id : hashIdexStrategy.getInsertionPartitionKeys(sfcIndexedRange)) { final Long count = counts.get(new ByteArray(id)); final long nextcount = count == null ? 1 : count + 1; counts.put(new ByteArray(id), nextcount); total++; } } } final double mean = total / counts.size(); double diff = 0.0; for (final Long count : counts.values()) { diff += Math.pow(mean - count, 2); } final double sd = Math.sqrt(diff / counts.size()); assertTrue(sd < (mean * 0.18)); }
@Override public byte[][] getInsertionPartitionKeys(final MultiDimensionalNumericData insertionData) { final long hashCode; if (insertionData.isEmpty()) { hashCode = insertionData.hashCode(); } else { hashCode = Arrays.hashCode(insertionData.getMaxValuesPerDimension()) + (31 * Arrays.hashCode(insertionData.getMinValuesPerDimension())); } final int position = (int) (Math.abs(hashCode) % keys.length); return new byte[][] {keys[position]}; }
HashKeyIndexStrategy implements
    PartitionIndexStrategy<MultiDimensionalNumericData, MultiDimensionalNumericData> { @Override public byte[][] getInsertionPartitionKeys(final MultiDimensionalNumericData insertionData) { final long hashCode; if (insertionData.isEmpty()) { hashCode = insertionData.hashCode(); } else { hashCode = Arrays.hashCode(insertionData.getMaxValuesPerDimension()) + (31 * Arrays.hashCode(insertionData.getMinValuesPerDimension())); } final int position = (int) (Math.abs(hashCode) % keys.length); return new byte[][] {keys[position]}; } }
HashKeyIndexStrategy implements
    PartitionIndexStrategy<MultiDimensionalNumericData, MultiDimensionalNumericData> { @Override public byte[][] getInsertionPartitionKeys(final MultiDimensionalNumericData insertionData) { final long hashCode; if (insertionData.isEmpty()) { hashCode = insertionData.hashCode(); } else { hashCode = Arrays.hashCode(insertionData.getMaxValuesPerDimension()) + (31 * Arrays.hashCode(insertionData.getMinValuesPerDimension())); } final int position = (int) (Math.abs(hashCode) % keys.length); return new byte[][] {keys[position]}; } HashKeyIndexStrategy();  HashKeyIndexStrategy(final int size); }
HashKeyIndexStrategy implements
    PartitionIndexStrategy<MultiDimensionalNumericData, MultiDimensionalNumericData> { @Override public byte[][] getInsertionPartitionKeys(final MultiDimensionalNumericData insertionData) { final long hashCode; if (insertionData.isEmpty()) { hashCode = insertionData.hashCode(); } else { hashCode = Arrays.hashCode(insertionData.getMaxValuesPerDimension()) + (31 * Arrays.hashCode(insertionData.getMinValuesPerDimension())); } final int position = (int) (Math.abs(hashCode) % keys.length); return new byte[][] {keys[position]}; } HashKeyIndexStrategy();  HashKeyIndexStrategy(final int size); @Override String getId(); @Override byte[] toBinary(); @Override void fromBinary(final byte[] bytes); byte[][] getPartitionKeys(); @Override int getPartitionKeyLength(); @Override List<IndexMetaData> createMetaData(); @Override byte[][] getInsertionPartitionKeys(final MultiDimensionalNumericData insertionData); @Override byte[][] getQueryPartitionKeys(
      final MultiDimensionalNumericData queryData,
      final IndexMetaData... hints); @Override byte[][] getPredefinedSplits(); }
HashKeyIndexStrategy implements
    PartitionIndexStrategy<MultiDimensionalNumericData, MultiDimensionalNumericData> { @Override public byte[][] getInsertionPartitionKeys(final MultiDimensionalNumericData insertionData) { final long hashCode; if (insertionData.isEmpty()) { hashCode = insertionData.hashCode(); } else { hashCode = Arrays.hashCode(insertionData.getMaxValuesPerDimension()) + (31 * Arrays.hashCode(insertionData.getMinValuesPerDimension())); } final int position = (int) (Math.abs(hashCode) % keys.length); return new byte[][] {keys[position]}; } HashKeyIndexStrategy();  HashKeyIndexStrategy(final int size); @Override String getId(); @Override byte[] toBinary(); @Override void fromBinary(final byte[] bytes); byte[][] getPartitionKeys(); @Override int getPartitionKeyLength(); @Override List<IndexMetaData> createMetaData(); @Override byte[][] getInsertionPartitionKeys(final MultiDimensionalNumericData insertionData); @Override byte[][] getQueryPartitionKeys(
      final MultiDimensionalNumericData queryData,
      final IndexMetaData... hints); @Override byte[][] getPredefinedSplits();  }