return Arrays.copyOf(rightKey, rightKey.length); if (compareFlatKey(leftKey, rightKey) >= 0) { throw new IllegalArgumentException("Unexpected input, leftKey:" + Bytes.toString(leftKey) + ", rightKey:" + Bytes.toString(rightKey));
public byte[] calcIndexKey(byte[] lastKeyOfPreviousBlock, byte[] firstKeyInBlock) { byte[] fakeKey = getShortMidpointKey(lastKeyOfPreviousBlock, firstKeyInBlock); if (compareFlatKey(fakeKey, firstKeyInBlock) > 0) { LOG.error("Unexpected getShortMidpointKey result, fakeKey:" + Bytes.toStringBinary(fakeKey) + ", firstKeyInBlock:" + Bytes.toStringBinary(firstKeyInBlock)); return firstKeyInBlock; } if (lastKeyOfPreviousBlock != null && compareFlatKey(lastKeyOfPreviousBlock, fakeKey) >= 0) { LOG.error("Unexpected getShortMidpointKey result, lastKeyOfPreviousBlock:" + Bytes.toStringBinary(lastKeyOfPreviousBlock) + ", fakeKey:" + Bytes.toStringBinary(fakeKey)); return firstKeyInBlock; } return fakeKey; }
@Override public int compareKey(KVComparator comparator, byte[] key, int offset, int length) { return comparator.compareFlatKey(key, offset, length, blockBuffer.array(), blockBuffer.arrayOffset() + blockBuffer.position() + KEY_VALUE_LEN_SIZE, currKeyLen); }
/** * Checks whether the given scan rowkey range overlaps with the current storefile's * @param scan the scan specification. Used to determine the rowkey range. * @return true if there is overlap, false otherwise */ public boolean passesKeyRangeFilter(Scan scan) { if (this.getFirstKey() == null || this.getLastKey() == null) { // the file is empty return false; } if (Bytes.equals(scan.getStartRow(), HConstants.EMPTY_START_ROW) && Bytes.equals(scan.getStopRow(), HConstants.EMPTY_END_ROW)) { return true; } KeyValue smallestScanKeyValue = scan.isReversed() ? KeyValueUtil .createFirstOnRow(scan.getStopRow()) : KeyValueUtil.createFirstOnRow(scan .getStartRow()); KeyValue largestScanKeyValue = scan.isReversed() ? KeyValueUtil .createLastOnRow(scan.getStartRow()) : KeyValueUtil.createLastOnRow(scan .getStopRow()); boolean nonOverLapping = (getComparator().compareFlatKey( this.getFirstKey(), largestScanKeyValue.getKey()) > 0 && !Bytes .equals(scan.isReversed() ? scan.getStartRow() : scan.getStopRow(), HConstants.EMPTY_END_ROW)) || getComparator().compareFlatKey(this.getLastKey(), smallestScanKeyValue.getKey()) < 0; return !nonOverLapping; }
@Override public boolean seekTo() throws IOException { if (top) { int r = this.delegate.seekTo(new KeyValue.KeyOnlyKeyValue(splitkey, 0, splitkey.length)); if (r == HConstants.INDEX_KEY_MAGIC) { return true; } if (r < 0) { // midkey is < first key in file return this.delegate.seekTo(); } if (r > 0) { return this.delegate.next(); } return true; } boolean b = delegate.seekTo(); if (!b) { return b; } // Check key. ByteBuffer k = this.delegate.getKey(); return this.delegate.getReader().getComparator(). compareFlatKey(k.array(), k.arrayOffset(), k.limit(), splitkey, 0, splitkey.length) < 0; }
public boolean next() throws IOException { if (atEnd) return false; boolean b = delegate.next(); if (!b) { return b; } // constrain the bottom. if (!top) { ByteBuffer bb = getKey(); if (getComparator().compareFlatKey(bb.array(), bb.arrayOffset(), bb.limit(), splitkey, 0, splitkey.length) >= 0) { atEnd = true; return false; } } return true; }
public byte[] calcIndexKey(byte[] lastKeyOfPreviousBlock, byte[] firstKeyInBlock) { byte[] fakeKey = getShortMidpointKey(lastKeyOfPreviousBlock, firstKeyInBlock); if (compareFlatKey(fakeKey, firstKeyInBlock) > 0) { LOG.error("Unexpected getShortMidpointKey result, fakeKey:" + Bytes.toStringBinary(fakeKey) + ", firstKeyInBlock:" + Bytes.toStringBinary(firstKeyInBlock)); return firstKeyInBlock; } if (lastKeyOfPreviousBlock != null && compareFlatKey(lastKeyOfPreviousBlock, fakeKey) >= 0) { LOG.error("Unexpected getShortMidpointKey result, lastKeyOfPreviousBlock:" + Bytes.toStringBinary(lastKeyOfPreviousBlock) + ", fakeKey:" + Bytes.toStringBinary(fakeKey)); return firstKeyInBlock; } return fakeKey; }
public byte[] calcIndexKey(byte[] lastKeyOfPreviousBlock, byte[] firstKeyInBlock) { byte[] fakeKey = getShortMidpointKey(lastKeyOfPreviousBlock, firstKeyInBlock); if (compareFlatKey(fakeKey, firstKeyInBlock) > 0) { LOG.error("Unexpected getShortMidpointKey result, fakeKey:" + Bytes.toStringBinary(fakeKey) + ", firstKeyInBlock:" + Bytes.toStringBinary(firstKeyInBlock)); return firstKeyInBlock; } if (lastKeyOfPreviousBlock != null && compareFlatKey(lastKeyOfPreviousBlock, fakeKey) >= 0) { LOG.error("Unexpected getShortMidpointKey result, lastKeyOfPreviousBlock:" + Bytes.toStringBinary(lastKeyOfPreviousBlock) + ", fakeKey:" + Bytes.toStringBinary(fakeKey)); return firstKeyInBlock; } return fakeKey; }
public int compareFlatKey(byte[] left, byte[] right) { return compareFlatKey(left, 0, left.length, right, 0, right.length); }
public byte[] calcIndexKey(byte[] lastKeyOfPreviousBlock, byte[] firstKeyInBlock) { byte[] fakeKey = getShortMidpointKey(lastKeyOfPreviousBlock, firstKeyInBlock); if (compareFlatKey(fakeKey, firstKeyInBlock) > 0) { LOG.error("Unexpected getShortMidpointKey result, fakeKey:" + Bytes.toStringBinary(fakeKey) + ", firstKeyInBlock:" + Bytes.toStringBinary(firstKeyInBlock)); return firstKeyInBlock; } if (lastKeyOfPreviousBlock != null && compareFlatKey(lastKeyOfPreviousBlock, fakeKey) >= 0) { LOG.error("Unexpected getShortMidpointKey result, lastKeyOfPreviousBlock:" + Bytes.toStringBinary(lastKeyOfPreviousBlock) + ", fakeKey:" + Bytes.toStringBinary(fakeKey)); return firstKeyInBlock; } return fakeKey; }
@Override // RawComparator public int compare(byte[] l, int loff, int llen, byte[] r, int roff, int rlen) { return compareFlatKey(l,loff,llen, r,roff,rlen); }
@Override // RawComparator public int compare(byte[] l, int loff, int llen, byte[] r, int roff, int rlen) { return compareFlatKey(l,loff,llen, r,roff,rlen); }
@Override public int compareKey(KVComparator comparator, byte[] key, int offset, int length) { return comparator.compareFlatKey(key, offset, length, current.keyBuffer, 0, current.keyLength); }
public int compareFlatKey(byte[] left, byte[] right) { return compareFlatKey(left, 0, left.length, right, 0, right.length); }
@Override public int compareKey(KVComparator comparator, byte[] key, int offset, int length) { // can't optimize this, make a copy of the key ByteBuffer bb = getKeyDeepCopy(); return comparator.compareFlatKey(key, offset, length, bb.array(), bb.arrayOffset(), bb.limit()); }
public int compareFlatKey(byte[] left, byte[] right) { return compareFlatKey(left, 0, left.length, right, 0, right.length); }
@Override // RawComparator public int compare(byte[] l, int loff, int llen, byte[] r, int roff, int rlen) { return compareFlatKey(l,loff,llen, r,roff,rlen); }
@Override public int compareKey(KVComparator comparator, byte[] key, int offset, int length) { // can't optimize this, make a copy of the key ByteBuffer bb = getKeyDeepCopy(); return comparator.compareFlatKey(key, offset, length, bb.array(), bb.arrayOffset(), bb.limit()); }
public int compareFlatKey(byte[] left, byte[] right) { return compareFlatKey(left, 0, left.length, right, 0, right.length); }
@Override // RawComparator public int compare(byte[] l, int loff, int llen, byte[] r, int roff, int rlen) { return compareFlatKey(l,loff,llen, r,roff,rlen); }