@Override public int getPartition(final ImmutableBytesWritable key, final VALUE value, final int reduces) { if (reduces == 1) return 0; if (this.lastReduces != reduces) { this.splits = Bytes.split(this.startkey, this.endkey, reduces - 1); for (int i = 0; i < splits.length; i++) { LOG.info(Bytes.toStringBinary(splits[i])); } this.lastReduces = reduces; } int pos = Bytes.binarySearch(this.splits, key.get(), key.getOffset(), key.getLength()); // Below code is from hfile index search. if (pos < 0) { pos++; pos *= -1; if (pos == 0) { // falls before the beginning of the file. throw new RuntimeException("Key outside start/stop range: " + key.toString()); } pos--; } return pos; }
@Override public int getPartition(final ImmutableBytesWritable key, final VALUE value, final int reduces) { if (reduces == 1) return 0; if (this.lastReduces != reduces) { this.splits = Bytes.split(this.startkey, this.endkey, reduces - 1); for (int i = 0; i < splits.length; i++) { LOG.info(Bytes.toStringBinary(splits[i])); } } int pos = Bytes.binarySearch(this.splits, key.get(), key.getOffset(), key.getLength(), Bytes.BYTES_RAWCOMPARATOR); // Below code is from hfile index search. if (pos < 0) { pos++; pos *= -1; if (pos == 0) { // falls before the beginning of the file. throw new RuntimeException("Key outside start/stop range: " + key.toString()); } pos--; } return pos; }
@Override public int getPartition(final ImmutableBytesWritable key, final VALUE value, final int reduces) { if (reduces == 1) return 0; if (this.lastReduces != reduces) { this.splits = Bytes.split(this.startkey, this.endkey, reduces - 1); for (int i = 0; i < splits.length; i++) { LOG.info(Bytes.toStringBinary(splits[i])); } this.lastReduces = reduces; } int pos = Bytes.binarySearch(this.splits, key.get(), key.getOffset(), key.getLength()); // Below code is from hfile index search. if (pos < 0) { pos++; pos *= -1; if (pos == 0) { // falls before the beginning of the file. throw new RuntimeException("Key outside start/stop range: " + key.toString()); } pos--; } return pos; }
@Override public int getPartition(final ImmutableBytesWritable key, final VALUE value, final int reduces) { if (reduces == 1) return 0; if (this.lastReduces != reduces) { this.splits = Bytes.split(this.startkey, this.endkey, reduces - 1); for (int i = 0; i < splits.length; i++) { LOG.info(Bytes.toStringBinary(splits[i])); } this.lastReduces = reduces; } int pos = Bytes.binarySearch(this.splits, key.get(), key.getOffset(), key.getLength()); // Below code is from hfile index search. if (pos < 0) { pos++; pos *= -1; if (pos == 0) { // falls before the beginning of the file. throw new RuntimeException("Key outside start/stop range: " + key.toString()); } pos--; } return pos; }
@Override public int getPartition(final ImmutableBytesWritable key, final VALUE value, final int reduces) { if (reduces == 1) return 0; if (this.lastReduces != reduces) { this.splits = Bytes.split(this.startkey, this.endkey, reduces - 1); for (int i = 0; i < splits.length; i++) { LOG.info(Bytes.toStringBinary(splits[i])); } this.lastReduces = reduces; } int pos = Bytes.binarySearch(this.splits, key.get(), key.getOffset(), key.getLength(), Bytes.BYTES_RAWCOMPARATOR); // Below code is from hfile index search. if (pos < 0) { pos++; pos *= -1; if (pos == 0) { // falls before the beginning of the file. throw new RuntimeException("Key outside start/stop range: " + key.toString()); } pos--; } return pos; }