left and right Cells match
*/
public static boolean matchingRow(final Cell left, final Cell right) {
- return Bytes.equals(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
- right.getRowArray(), right.getRowOffset(), right.getRowLength());
+ return Bytes.equals(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
+ right.getRowArray(), right.getRowOffset(), right.getRowLength());
}
public static boolean matchingRow(final Cell left, final byte[] buf) {
- return Bytes.equals(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
- buf, 0, buf.length);
+ return Bytes.equals(left.getRowArray(), left.getRowOffset(), left.getRowLength(), buf, 0,
+ buf.length);
+ }
+
+ public static boolean matchingRow(final Cell left, final byte[] buf, final int offset,
+ final int length) {
+ return Bytes.equals(left.getRowArray(), left.getRowOffset(), left.getRowLength(), buf, offset,
+ length);
}
public static boolean matchingFamily(final Cell left, final Cell right) {
@@ -319,20 +325,57 @@ public final class CellUtil {
}
public static boolean matchingFamily(final Cell left, final byte[] buf) {
- return Bytes.equals(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),
- buf, 0, buf.length);
+ return Bytes.equals(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(), buf,
+ 0, buf.length);
+ }
+
+ public static boolean matchingFamily(final Cell left, final byte[] buf, final int offset,
+ final int length) {
+ return Bytes.equals(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(), buf,
+ offset, length);
}
public static boolean matchingQualifier(final Cell left, final Cell right) {
- return Bytes.equals(left.getQualifierArray(), left.getQualifierOffset(), left.getQualifierLength(),
- right.getQualifierArray(), right.getQualifierOffset(), right.getQualifierLength());
+ return Bytes.equals(left.getQualifierArray(), left.getQualifierOffset(),
+ left.getQualifierLength(), right.getQualifierArray(), right.getQualifierOffset(),
+ right.getQualifierLength());
}
public static boolean matchingQualifier(final Cell left, final byte[] buf) {
- return Bytes.equals(left.getQualifierArray(), left.getQualifierOffset(), left.getQualifierLength(),
- buf, 0, buf.length);
+ if (buf == null) {
+ return left.getQualifierLength() == 0;
+ }
+ return Bytes.equals(left.getQualifierArray(), left.getQualifierOffset(),
+ left.getQualifierLength(), buf, 0, buf.length);
+ }
+
+ public static boolean matchingQualifier(final Cell left, final byte[] buf, final int offset,
+ final int length) {
+ if (buf == null) {
+ return left.getQualifierLength() == 0;
+ }
+ return Bytes.equals(left.getQualifierArray(), left.getQualifierOffset(),
+ left.getQualifierLength(), buf, offset, length);
}
+ public static boolean matchingColumn(final Cell left, final byte[] fam, final byte[] qual) {
+ if (!matchingFamily(left, fam))
+ return false;
+ return matchingQualifier(left, qual);
+ }
+
+ public static boolean matchingColumn(final Cell left, final byte[] fam, final int foffset,
+ final int flength, final byte[] qual, final int qoffset, final int qlength) {
+ if (!matchingFamily(left, fam, foffset, flength))
+ return false;
+ return matchingQualifier(left, qual, qoffset, qlength);
+ }
+
+ public static boolean matchingColumn(final Cell left, final Cell right) {
+ if (!matchingFamily(left, right))
+ return false;
+ return matchingQualifier(left, right);
+ }
public static boolean matchingValue(final Cell left, final Cell right) {
return Bytes.equals(left.getValueArray(), left.getValueOffset(), left.getValueLength(),
@@ -340,13 +383,14 @@ public final class CellUtil {
}
public static boolean matchingValue(final Cell left, final byte[] buf) {
- return Bytes.equals(left.getValueArray(), left.getValueOffset(), left.getValueLength(),
- buf, 0, buf.length);
+ return Bytes.equals(left.getValueArray(), left.getValueOffset(), left.getValueLength(), buf, 0,
+ buf.length);
}
+
/**
- * @return True if a delete type, a {@link KeyValue.Type#Delete} or
- * a {KeyValue.Type#DeleteFamily} or a {@link KeyValue.Type#DeleteColumn}
- * KeyValue type.
+ * @return True if a delete type, a {@link KeyValue.Type#Delete} or a
+ * {KeyValue.Type#DeleteFamily} or a
+ * {@link KeyValue.Type#DeleteColumn} KeyValue type.
*/
public static boolean isDelete(final Cell cell) {
return KeyValue.isDelete(cell.getTypeByte());
@@ -356,6 +400,10 @@ public final class CellUtil {
return cell.getTypeByte() == Type.DeleteFamily.getCode();
}
+ public static boolean isDeleteFamilyVersion(final Cell cell) {
+ return cell.getTypeByte() == Type.DeleteFamilyVersion.getCode();
+ }
+
/**
* @param cell
* @return Estimate of the cell size in bytes.
diff --git hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
index cd30b57..4cca2d4 100644
--- hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
+++ hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
@@ -863,7 +863,7 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
* @throws IllegalArgumentException an illegal value was passed or there is insufficient space
* remaining in the buffer
*/
- private static int writeByteArray(byte [] buffer, final int boffset,
+ public static int writeByteArray(byte [] buffer, final int boffset,
final byte [] row, final int roffset, final int rlength,
final byte [] family, final int foffset, int flength,
final byte [] qualifier, final int qoffset, int qlength,
@@ -1618,94 +1618,6 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
return bytes;
}
- //---------------------------------------------------------------------------
- //
- // Compare specified fields against those contained in this KeyValue
- //
- //---------------------------------------------------------------------------
-
- /**
- * @param family
- * @return True if matching families.
- */
- public boolean matchingFamily(final byte [] family) {
- if (this.length == 0 || this.bytes.length == 0) {
- return false;
- }
- return Bytes.equals(family, 0, family.length,
- this.bytes, getFamilyOffset(), getFamilyLength());
- }
-
- /**
- * @param qualifier
- * @return True if matching qualifiers.
- */
- public boolean matchingQualifier(final byte [] qualifier) {
- return matchingQualifier(qualifier, 0, qualifier.length);
- }
-
- public boolean matchingQualifier(final byte [] qualifier, int offset, int length) {
- return Bytes.equals(qualifier, offset, length,
- this.bytes, getQualifierOffset(), getQualifierLength());
- }
-
- public boolean matchingQualifier(final KeyValue other) {
- return matchingQualifier(other.getQualifierArray(), other.getQualifierOffset(),
- other.getQualifierLength());
- }
-
- public boolean matchingRow(final byte [] row) {
- return matchingRow(row, 0, row.length);
- }
-
- public boolean matchingRow(final byte[] row, int offset, int length) {
- return Bytes.equals(row, offset, length,
- this.bytes, getRowOffset(), getRowLength());
- }
-
- public boolean matchingRow(KeyValue other) {
- return matchingRow(other.getRowArray(), other.getRowOffset(),
- other.getRowLength());
- }
-
- /**
- *
- * @param family column family
- * @param qualifier column qualifier
- * @return True if column matches
- */
- public boolean matchingColumn(final byte[] family, final byte[] qualifier) {
- return matchingColumn(family, 0, len(family), qualifier, 0, len(qualifier));
- }
-
- /**
- * Checks if column matches.
- *
- * @param family family name
- * @param foffset family offset
- * @param flength family length
- * @param qualifier column qualifier
- * @param qoffset qualifier offset
- * @param qlength qualifier length
- *
- * @return True if column matches
- */
- public boolean matchingColumn(final byte [] family, final int foffset, final int flength,
- final byte [] qualifier, final int qoffset, final int qlength) {
- int rl = getRowLength();
- int o = getFamilyOffset(rl);
- int fl = getFamilyLength(o);
- if (!Bytes.equals(family, foffset, flength, this.bytes, o, fl)) {
- return false;
- }
-
- int ql = getQualifierLength(rl, fl);
- if (qualifier == null || qlength == 0) {
- return (ql == 0);
- }
- return Bytes.equals(qualifier, qoffset, qlength, this.bytes, o + fl, ql);
- }
-
/**
* Creates a new KeyValue that only contains the key portion (the value is
* set to be null).
@@ -2399,247 +2311,6 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
}
/**
- * Creates a KeyValue that is last on the specified row id. That is,
- * every other possible KeyValue for the given row would compareTo()
- * less than the result of this call.
- * @param row row key
- * @return Last possible KeyValue on passed row
- */
- public static KeyValue createLastOnRow(final byte[] row) {
- return new KeyValue(row, null, null, HConstants.LATEST_TIMESTAMP, Type.Minimum);
- }
-
- /**
- * Create a KeyValue that is smaller than all other possible KeyValues
- * for the given row. That is any (valid) KeyValue on 'row' would sort
- * _after_ the result.
- *
- * @param row - row key (arbitrary byte array)
- * @return First possible KeyValue on passed row
- */
- public static KeyValue createFirstOnRow(final byte [] row) {
- return createFirstOnRow(row, HConstants.LATEST_TIMESTAMP);
- }
-
- /**
- * Create a KeyValue that is smaller than all other possible KeyValues
- * for the given row. That is any (valid) KeyValue on 'row' would sort
- * _after_ the result.
- *
- * @param row - row key (arbitrary byte array)
- * @return First possible KeyValue on passed row
- */
- public static KeyValue createFirstOnRow(final byte [] row, int roffset, short rlength) {
- return new KeyValue(row, roffset, rlength,
- null, 0, 0, null, 0, 0, HConstants.LATEST_TIMESTAMP, Type.Maximum, null, 0, 0);
- }
-
- /**
- * Creates a KeyValue that is smaller than all other KeyValues that
- * are older than the passed timestamp.
- * @param row - row key (arbitrary byte array)
- * @param ts - timestamp
- * @return First possible key on passed row and timestamp.
- */
- public static KeyValue createFirstOnRow(final byte [] row,
- final long ts) {
- return new KeyValue(row, null, null, ts, Type.Maximum);
- }
-
- /**
- * Create a KeyValue for the specified row, family and qualifier that would be
- * smaller than all other possible KeyValues that have the same row,family,qualifier.
- * Used for seeking.
- * @param row - row key (arbitrary byte array)
- * @param family - family name
- * @param qualifier - column qualifier
- * @return First possible key on passed row, and column.
- */
- public static KeyValue createFirstOnRow(final byte [] row, final byte [] family,
- final byte [] qualifier) {
- return new KeyValue(row, family, qualifier, HConstants.LATEST_TIMESTAMP, Type.Maximum);
- }
-
- /**
- * Create a Delete Family KeyValue for the specified row and family that would
- * be smaller than all other possible Delete Family KeyValues that have the
- * same row and family.
- * Used for seeking.
- * @param row - row key (arbitrary byte array)
- * @param family - family name
- * @return First Delete Family possible key on passed row.
- */
- public static KeyValue createFirstDeleteFamilyOnRow(final byte [] row,
- final byte [] family) {
- return new KeyValue(row, family, null, HConstants.LATEST_TIMESTAMP,
- Type.DeleteFamily);
- }
-
- /**
- * @param row - row key (arbitrary byte array)
- * @param f - family name
- * @param q - column qualifier
- * @param ts - timestamp
- * @return First possible key on passed row, column and timestamp
- */
- public static KeyValue createFirstOnRow(final byte [] row, final byte [] f,
- final byte [] q, final long ts) {
- return new KeyValue(row, f, q, ts, Type.Maximum);
- }
-
- /**
- * Create a KeyValue for the specified row, family and qualifier that would be
- * smaller than all other possible KeyValues that have the same row,
- * family, qualifier.
- * Used for seeking.
- * @param row row key
- * @param roffset row offset
- * @param rlength row length
- * @param family family name
- * @param foffset family offset
- * @param flength family length
- * @param qualifier column qualifier
- * @param qoffset qualifier offset
- * @param qlength qualifier length
- * @return First possible key on passed Row, Family, Qualifier.
- */
- public static KeyValue createFirstOnRow(final byte [] row,
- final int roffset, final int rlength, final byte [] family,
- final int foffset, final int flength, final byte [] qualifier,
- final int qoffset, final int qlength) {
- return new KeyValue(row, roffset, rlength, family,
- foffset, flength, qualifier, qoffset, qlength,
- HConstants.LATEST_TIMESTAMP, Type.Maximum, null, 0, 0);
- }
-
- /**
- * Create a KeyValue for the specified row, family and qualifier that would be
- * smaller than all other possible KeyValues that have the same row,
- * family, qualifier.
- * Used for seeking.
- *
- * @param buffer the buffer to use for the new KeyValue object
- * @param row the value key
- * @param family family name
- * @param qualifier column qualifier
- *
- * @return First possible key on passed Row, Family, Qualifier.
- *
- * @throws IllegalArgumentException The resulting KeyValue object would be larger
- * than the provided buffer or than Integer.MAX_VALUE
- */
- public static KeyValue createFirstOnRow(byte [] buffer, final byte [] row,
- final byte [] family, final byte [] qualifier)
- throws IllegalArgumentException {
-
- return createFirstOnRow(buffer, 0, row, 0, row.length,
- family, 0, family.length,
- qualifier, 0, qualifier.length);
- }
-
- /**
- * Create a KeyValue for the specified row, family and qualifier that would be
- * smaller than all other possible KeyValues that have the same row,
- * family, qualifier.
- * Used for seeking.
- *
- * @param buffer the buffer to use for the new KeyValue object
- * @param boffset buffer offset
- * @param row the value key
- * @param roffset row offset
- * @param rlength row length
- * @param family family name
- * @param foffset family offset
- * @param flength family length
- * @param qualifier column qualifier
- * @param qoffset qualifier offset
- * @param qlength qualifier length
- *
- * @return First possible key on passed Row, Family, Qualifier.
- *
- * @throws IllegalArgumentException The resulting KeyValue object would be larger
- * than the provided buffer or than Integer.MAX_VALUE
- */
- public static KeyValue createFirstOnRow(byte [] buffer, final int boffset,
- final byte [] row, final int roffset, final int rlength,
- final byte [] family, final int foffset, final int flength,
- final byte [] qualifier, final int qoffset, final int qlength)
- throws IllegalArgumentException {
-
- long lLength = getKeyValueDataStructureSize(rlength, flength, qlength, 0);
-
- if (lLength > Integer.MAX_VALUE) {
- throw new IllegalArgumentException("KeyValue length " + lLength + " > " + Integer.MAX_VALUE);
- }
- int iLength = (int) lLength;
- if (buffer.length - boffset < iLength) {
- throw new IllegalArgumentException("Buffer size " + (buffer.length - boffset) + " < " +
- iLength);
- }
-
- int len = writeByteArray(buffer, boffset, row, roffset, rlength, family, foffset, flength,
- qualifier, qoffset, qlength, HConstants.LATEST_TIMESTAMP, KeyValue.Type.Maximum,
- null, 0, 0, null);
- return new KeyValue(buffer, boffset, len);
- }
-
- /**
- * Create a KeyValue for the specified row, family and qualifier that would be
- * larger than or equal to all other possible KeyValues that have the same
- * row, family, qualifier.
- * Used for reseeking.
- * @param row row key
- * @param roffset row offset
- * @param rlength row length
- * @param family family name
- * @param foffset family offset
- * @param flength family length
- * @param qualifier column qualifier
- * @param qoffset qualifier offset
- * @param qlength qualifier length
- * @return Last possible key on passed row, family, qualifier.
- */
- public static KeyValue createLastOnRow(final byte [] row,
- final int roffset, final int rlength, final byte [] family,
- final int foffset, final int flength, final byte [] qualifier,
- final int qoffset, final int qlength) {
- return new KeyValue(row, roffset, rlength, family,
- foffset, flength, qualifier, qoffset, qlength,
- HConstants.OLDEST_TIMESTAMP, Type.Minimum, null, 0, 0);
- }
-
- /**
- * Similar to {@link #createLastOnRow(byte[], int, int, byte[], int, int,
- * byte[], int, int)} but creates the last key on the row/column of this KV
- * (the value part of the returned KV is always empty). Used in creating
- * "fake keys" for the multi-column Bloom filter optimization to skip the
- * row/column we already know is not in the file.
- * @return the last key on the row/column of the given key-value pair
- */
- public KeyValue createLastOnRowCol() {
- return new KeyValue(
- bytes, getRowOffset(), getRowLength(),
- bytes, getFamilyOffset(), getFamilyLength(),
- bytes, getQualifierOffset(), getQualifierLength(),
- HConstants.OLDEST_TIMESTAMP, Type.Minimum, null, 0, 0);
- }
-
- /**
- * Creates the first KV with the row/family/qualifier of this KV and the
- * given timestamp. Uses the "maximum" KV type that guarantees that the new
- * KV is the lowest possible for this combination of row, family, qualifier,
- * and timestamp. This KV's own timestamp is ignored. While this function
- * copies the value from this KV, it is normally used on key-only KVs.
- */
- public KeyValue createFirstOnRowColTS(long ts) {
- return new KeyValue(
- bytes, getRowOffset(), getRowLength(),
- bytes, getFamilyOffset(), getFamilyLength(),
- bytes, getQualifierOffset(), getQualifierLength(),
- ts, Type.Maximum, bytes, getValueOffset(), getValueLength());
- }
-
- /**
* @param b
* @return A KeyValue made of a byte array that holds the key-only part.
* Needed to convert hfile index members to KeyValues.
diff --git hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
index aa56f74..4026b1b 100644
--- hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
+++ hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.KeyValue.Type;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.IterableUtils;
@@ -189,7 +190,7 @@ public class KeyValueUtil {
byte[] nextRow = new byte[in.getRowLength() + 1];
System.arraycopy(in.getRowArray(), in.getRowOffset(), nextRow, 0, in.getRowLength());
nextRow[nextRow.length - 1] = 0;//maybe not necessary
- return KeyValue.createFirstOnRow(nextRow);
+ return createFirstOnRow(nextRow);
}
/**
@@ -199,7 +200,7 @@ public class KeyValueUtil {
byte[] thisRow = new SimpleByteRange(in.getRowArray(), in.getRowOffset(), in.getRowLength())
.deepCopyToNewArray();
byte[] nextRow = Bytes.unsignedCopyAndIncrement(thisRow);
- return KeyValue.createFirstOnRow(nextRow);
+ return createFirstOnRow(nextRow);
}
/**
@@ -210,9 +211,287 @@ public class KeyValueUtil {
* @return previous key
*/
public static KeyValue previousKey(final KeyValue in) {
- return KeyValue.createFirstOnRow(CellUtil.cloneRow(in), CellUtil.cloneFamily(in),
+ return createFirstOnRow(CellUtil.cloneRow(in), CellUtil.cloneFamily(in),
CellUtil.cloneQualifier(in), in.getTimestamp() - 1);
}
+
+
+ /**
+ * Create a KeyValue for the specified row, family and qualifier that would be
+ * larger than or equal to all other possible KeyValues that have the same
+ * row, family, qualifier. Used for reseeking.
+ *
+ * @param row
+ * row key
+ * @param roffset
+ * row offset
+ * @param rlength
+ * row length
+ * @param family
+ * family name
+ * @param foffset
+ * family offset
+ * @param flength
+ * family length
+ * @param qualifier
+ * column qualifier
+ * @param qoffset
+ * qualifier offset
+ * @param qlength
+ * qualifier length
+ * @return Last possible key on passed row, family, qualifier.
+ */
+ public static KeyValue createLastOnRow(final byte[] row, final int roffset, final int rlength,
+ final byte[] family, final int foffset, final int flength, final byte[] qualifier,
+ final int qoffset, final int qlength) {
+ return new KeyValue(row, roffset, rlength, family, foffset, flength, qualifier, qoffset,
+ qlength, HConstants.OLDEST_TIMESTAMP, Type.Minimum, null, 0, 0);
+ }
+
+ /**
+ * Creates a keyValue for the specified keyvalue larger than or equal to all other possible
+ * KeyValues that have the same row, family, qualifer. Used for reseeking
+ * @param kv
+ * @return KeyValue
+ */
+ public static KeyValue createLastOnRow(Cell kv) {
+ return createLastOnRow(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(), null, 0, 0,
+ null, 0, 0);
+ }
+
+ /**
+ * Similar to
+ * {@link #createLastOnRow(byte[], int, int, byte[], int, int, byte[], int, int)}
+ * but creates the last key on the row/column of this KV (the value part of
+ * the returned KV is always empty). Used in creating "fake keys" for the
+ * multi-column Bloom filter optimization to skip the row/column we already
+ * know is not in the file.
+ *
+ * @param kv - cell
+ * @return the last key on the row/column of the given key-value pair
+ */
+ public static KeyValue createLastOnRowCol(Cell kv) {
+ return new KeyValue(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(),
+ kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength(), kv.getQualifierArray(),
+ kv.getQualifierOffset(), kv.getQualifierLength(), HConstants.OLDEST_TIMESTAMP,
+ Type.Minimum, null, 0, 0);
+ }
+
+ /**
+ * Creates the first KV with the row/family/qualifier of this KV and the given
+ * timestamp. Uses the "maximum" KV type that guarantees that the new KV is
+ * the lowest possible for this combination of row, family, qualifier, and
+ * timestamp. This KV's own timestamp is ignored. While this function copies
+ * the value from this KV, it is normally used on key-only KVs.
+ *
+ * @param kv - cell
+ * @param ts
+ */
+ public static KeyValue createFirstOnRowColTS(Cell kv, long ts) {
+ return new KeyValue(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(),
+ kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength(), kv.getQualifierArray(),
+ kv.getQualifierOffset(), kv.getQualifierLength(), ts, Type.Maximum, kv.getValueArray(),
+ kv.getValueOffset(), kv.getValueLength());
+ }
+
+ /**
+ * Create a KeyValue that is smaller than all other possible KeyValues
+ * for the given row. That is any (valid) KeyValue on 'row' would sort
+ * _after_ the result.
+ *
+ * @param row - row key (arbitrary byte array)
+ * @return First possible KeyValue on passed row
+ */
+ public static KeyValue createFirstOnRow(final byte [] row, int roffset, short rlength) {
+ return new KeyValue(row, roffset, rlength,
+ null, 0, 0, null, 0, 0, HConstants.LATEST_TIMESTAMP, Type.Maximum, null, 0, 0);
+ }
+
+
+ /**
+ * Creates a KeyValue that is last on the specified row id. That is,
+ * every other possible KeyValue for the given row would compareTo()
+ * less than the result of this call.
+ * @param row row key
+ * @return Last possible KeyValue on passed row
+ */
+ public static KeyValue createLastOnRow(final byte[] row) {
+ return new KeyValue(row, null, null, HConstants.LATEST_TIMESTAMP, Type.Minimum);
+ }
+
+ /**
+ * Create a KeyValue that is smaller than all other possible KeyValues
+ * for the given row. That is any (valid) KeyValue on 'row' would sort
+ * _after_ the result.
+ *
+ * @param row - row key (arbitrary byte array)
+ * @return First possible KeyValue on passed row
+ */
+ public static KeyValue createFirstOnRow(final byte [] row) {
+ return createFirstOnRow(row, HConstants.LATEST_TIMESTAMP);
+ }
+
+ /**
+ * Creates a KeyValue that is smaller than all other KeyValues that
+ * are older than the passed timestamp.
+ * @param row - row key (arbitrary byte array)
+ * @param ts - timestamp
+ * @return First possible key on passed row and timestamp.
+ */
+ public static KeyValue createFirstOnRow(final byte [] row,
+ final long ts) {
+ return new KeyValue(row, null, null, ts, Type.Maximum);
+ }
+
+ /**
+ * Create a KeyValue for the specified row, family and qualifier that would be
+ * smaller than all other possible KeyValues that have the same row,family,qualifier.
+ * Used for seeking.
+ * @param row - row key (arbitrary byte array)
+ * @param family - family name
+ * @param qualifier - column qualifier
+ * @return First possible key on passed row, and column.
+ */
+ public static KeyValue createFirstOnRow(final byte [] row, final byte [] family,
+ final byte [] qualifier) {
+ return new KeyValue(row, family, qualifier, HConstants.LATEST_TIMESTAMP, Type.Maximum);
+ }
+
+ /**
+ * Create a Delete Family KeyValue for the specified row and family that would
+ * be smaller than all other possible Delete Family KeyValues that have the
+ * same row and family.
+ * Used for seeking.
+ * @param row - row key (arbitrary byte array)
+ * @param family - family name
+ * @return First Delete Family possible key on passed row.
+ */
+ public static KeyValue createFirstDeleteFamilyOnRow(final byte [] row,
+ final byte [] family) {
+ return new KeyValue(row, family, null, HConstants.LATEST_TIMESTAMP,
+ Type.DeleteFamily);
+ }
+
+ /**
+ * @param row - row key (arbitrary byte array)
+ * @param f - family name
+ * @param q - column qualifier
+ * @param ts - timestamp
+ * @return First possible key on passed row, column and timestamp
+ */
+ public static KeyValue createFirstOnRow(final byte [] row, final byte [] f,
+ final byte [] q, final long ts) {
+ return new KeyValue(row, f, q, ts, Type.Maximum);
+ }
+
+ /**
+ * Create a KeyValue for the specified row, family and qualifier that would be
+ * smaller than all other possible KeyValues that have the same row,
+ * family, qualifier.
+ * Used for seeking.
+ * @param row row key
+ * @param roffset row offset
+ * @param rlength row length
+ * @param family family name
+ * @param foffset family offset
+ * @param flength family length
+ * @param qualifier column qualifier
+ * @param qoffset qualifier offset
+ * @param qlength qualifier length
+ * @return First possible key on passed Row, Family, Qualifier.
+ */
+ public static KeyValue createFirstOnRow(final byte [] row,
+ final int roffset, final int rlength, final byte [] family,
+ final int foffset, final int flength, final byte [] qualifier,
+ final int qoffset, final int qlength) {
+ return new KeyValue(row, roffset, rlength, family,
+ foffset, flength, qualifier, qoffset, qlength,
+ HConstants.LATEST_TIMESTAMP, Type.Maximum, null, 0, 0);
+ }
+
+ /**
+ * Create a KeyValue for the specified row, family and qualifier that would be
+ * smaller than all other possible KeyValues that have the same row,
+ * family, qualifier.
+ * Used for seeking.
+ *
+ * @param buffer the buffer to use for the new KeyValue object
+ * @param row the value key
+ * @param family family name
+ * @param qualifier column qualifier
+ *
+ * @return First possible key on passed Row, Family, Qualifier.
+ *
+ * @throws IllegalArgumentException The resulting KeyValue object would be larger
+ * than the provided buffer or than Integer.MAX_VALUE
+ */
+ public static KeyValue createFirstOnRow(byte [] buffer, final byte [] row,
+ final byte [] family, final byte [] qualifier)
+ throws IllegalArgumentException {
+ return createFirstOnRow(buffer, 0, row, 0, row.length,
+ family, 0, family.length,
+ qualifier, 0, qualifier.length);
+ }
+
+ /**
+ * Create a KeyValue for the specified row, family and qualifier that would be
+ * smaller than all other possible KeyValues that have the same row,
+ * family, qualifier.
+ * Used for seeking.
+ *
+ * @param buffer the buffer to use for the new KeyValue object
+ * @param boffset buffer offset
+ * @param row the value key
+ * @param roffset row offset
+ * @param rlength row length
+ * @param family family name
+ * @param foffset family offset
+ * @param flength family length
+ * @param qualifier column qualifier
+ * @param qoffset qualifier offset
+ * @param qlength qualifier length
+ *
+ * @return First possible key on passed Row, Family, Qualifier.
+ *
+ * @throws IllegalArgumentException The resulting KeyValue object would be larger
+ * than the provided buffer or than Integer.MAX_VALUE
+ */
+ public static KeyValue createFirstOnRow(byte[] buffer, final int boffset, final byte[] row,
+ final int roffset, final int rlength, final byte[] family, final int foffset,
+ final int flength, final byte[] qualifier, final int qoffset, final int qlength)
+ throws IllegalArgumentException {
+
+ long lLength = KeyValue.getKeyValueDataStructureSize(rlength, flength, qlength, 0);
+
+ if (lLength > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("KeyValue length " + lLength + " > " + Integer.MAX_VALUE);
+ }
+ int iLength = (int) lLength;
+ if (buffer.length - boffset < iLength) {
+ throw new IllegalArgumentException("Buffer size " + (buffer.length - boffset) + " < "
+ + iLength);
+ }
+
+ int len = KeyValue.writeByteArray(buffer, boffset, row, roffset, rlength, family, foffset,
+ flength, qualifier, qoffset, qlength, HConstants.LATEST_TIMESTAMP, KeyValue.Type.Maximum,
+ null, 0, 0, null);
+ return new KeyValue(buffer, boffset, len);
+ }
+
+ /**
+ * Creates the first KV with the row/family/qualifier of this KV and the
+ * given timestamp. Uses the "maximum" KV type that guarantees that the new
+ * KV is the lowest possible for this combination of row, family, qualifier,
+ * and timestamp. This KV's own timestamp is ignored. While this function
+ * copies the value from this KV, it is normally used on key-only KVs.
+ */
+ public static KeyValue createFirstOnRowColTS(KeyValue kv, long ts) {
+ return new KeyValue(
+ kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(),
+ kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength(),
+ kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength(),
+ ts, Type.Maximum, kv.getValueArray(), kv.getValueOffset(), kv.getValueLength());
+ }
/*************** misc **********************************/
/**
@@ -233,4 +512,5 @@ public class KeyValueUtil {
});
return new ArrayListkv is expired.
*/
- boolean isExpired(final KeyValue kv) {
+ boolean isExpired(final Cell kv) {
return HStore.isExpired(kv, this.oldestts);
}
@@ -90,20 +92,20 @@ class GetClosestRowBeforeTracker {
* Add the specified KeyValue to the list of deletes.
* @param kv
*/
- private void addDelete(final KeyValue kv) {
+ private void addDelete(final Cell kv) {
NavigableSetk from candidates.
*/
- boolean handleDeletes(final KeyValue kv) {
+ boolean handleDeletes(final Cell kv) {
addDelete(kv);
boolean deleted = false;
if (!hasCandidate()) return deleted;
@@ -194,8 +196,8 @@ class GetClosestRowBeforeTracker {
* @param kv
* @return True if we added a candidate
*/
- boolean handle(final KeyValue kv) {
- if (kv.isDelete()) {
+ boolean handle(final Cell kv) {
+ if (KeyValueUtil.ensureKeyValue(kv).isDelete()) {
handleDeletes(kv);
return false;
}
@@ -212,7 +214,7 @@ class GetClosestRowBeforeTracker {
/**
* @return Best candidate or null.
*/
- public KeyValue getCandidate() {
+ public Cell getCandidate() {
return this.candidate;
}
@@ -225,11 +227,11 @@ class GetClosestRowBeforeTracker {
* @param firstOnRow on row kv.
* @return True if we went too far, past the target key.
*/
- boolean isTooFar(final KeyValue kv, final KeyValue firstOnRow) {
+ boolean isTooFar(final Cell kv, final Cell firstOnRow) {
return this.kvcomparator.compareRows(kv, firstOnRow) > 0;
}
- boolean isTargetTable(final KeyValue kv) {
+ boolean isTargetTable(final Cell kv) {
if (!metaregion) return true;
// Compare start of keys row. Compare including delimiter. Saves having
// to calculate where tablename ends in the candidate kv.
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index c2c2813..0ff88e8 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -102,7 +102,6 @@ import org.apache.hadoop.hbase.exceptions.RegionInRecoveryException;
import org.apache.hadoop.hbase.exceptions.UnknownProtocolException;
import org.apache.hadoop.hbase.filter.ByteArrayComparable;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
-import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.FilterWrapper;
import org.apache.hadoop.hbase.filter.IncompatibleFilterException;
import org.apache.hadoop.hbase.io.HeapSize;
@@ -3214,7 +3213,7 @@ public class HRegion implements HeapSize { // , Writable{
for (KeyValue kv: val.getKeyValues()) {
// Check this edit is for me. Also, guard against writing the special
// METACOLUMN info such as HBASE::CACHEFLUSH entries
- if (kv.matchingFamily(WALEdit.METAFAMILY) ||
+ if (CellUtil.matchingFamily(kv, WALEdit.METAFAMILY) ||
!Bytes.equals(key.getEncodedRegionName(),
this.getRegionInfo().getEncodedNameAsBytes())) {
//this is a special edit, we should handle it
@@ -3228,7 +3227,7 @@ public class HRegion implements HeapSize { // , Writable{
continue;
}
// Figure which store the edit is meant for.
- if (store == null || !kv.matchingFamily(store.getFamily().getName())) {
+ if (store == null || !CellUtil.matchingFamily(kv, store.getFamily().getName())) {
store = this.stores.get(kv.getFamily());
}
if (store == null) {
@@ -3632,7 +3631,7 @@ public class HRegion implements HeapSize { // , Writable{
/**
* If the joined heap data gathering is interrupted due to scan limits, this will
* contain the row for which we are populating the values.*/
- protected KeyValue joinedContinuationRow = null;
+ protected Cell joinedContinuationRow = null;
// KeyValue indicating that limit is reached when scanning
private final KeyValue KV_LIMIT = new KeyValue();
protected final byte[] stopRow;
@@ -3795,7 +3794,7 @@ public class HRegion implements HeapSize { // , Writable{
private void populateFromJoinedHeap(List
- * This function (and {@link #reseek(KeyValue)}) does not do multi-column
+ * This function (and {@link #reseek(Cell)}) does not do multi-column
* Bloom filter and lazy-seek optimizations. To enable those, call
- * {@link #requestSeek(KeyValue, boolean, boolean)}.
+ * {@link #requestSeek(Cell, boolean, boolean)}.
* @param seekKey KeyValue to seek at or after
* @return true if KeyValues exist at or after specified key, false if not
* @throws IOException
*/
@Override
- public boolean seek(KeyValue seekKey) throws IOException {
+ public boolean seek(Cell seekKey) throws IOException {
return generalizedSeek(false, // This is not a lazy seek
seekKey,
false, // forward (false: this is not a reseek)
@@ -249,11 +248,11 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
}
/**
- * This function is identical to the {@link #seek(KeyValue)} function except
+ * This function is identical to the {@link #seek(Cell)} function except
* that scanner.seek(seekKey) is changed to scanner.reseek(seekKey).
*/
@Override
- public boolean reseek(KeyValue seekKey) throws IOException {
+ public boolean reseek(Cell seekKey) throws IOException {
return generalizedSeek(false, // This is not a lazy seek
seekKey,
true, // forward (true because this is reseek)
@@ -264,7 +263,7 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
* {@inheritDoc}
*/
@Override
- public boolean requestSeek(KeyValue key, boolean forward,
+ public boolean requestSeek(Cell key, boolean forward,
boolean useBloom) throws IOException {
return generalizedSeek(true, key, forward, useBloom);
}
@@ -277,7 +276,7 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
* @param forward whether to seek forward (also known as reseek)
* @param useBloom whether to optimize seeks using Bloom filters
*/
- private boolean generalizedSeek(boolean isLazy, KeyValue seekKey,
+ private boolean generalizedSeek(boolean isLazy, Cell seekKey,
boolean forward, boolean useBloom) throws IOException {
if (!isLazy && useBloom) {
throw new IllegalArgumentException("Multi-column Bloom filter " +
@@ -292,7 +291,7 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
KeyValueScanner scanner;
while ((scanner = heap.poll()) != null) {
- KeyValue topKey = scanner.peek();
+ Cell topKey = scanner.peek();
if (comparator.getComparator().compare(seekKey, topKey) <= 0) {
// Top KeyValue is at-or-after Seek KeyValue. We only know that all
// scanners are at or after seekKey (because fake keys of
@@ -345,7 +344,7 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
while (kvScanner != null && !kvScanner.realSeekDone()) {
if (kvScanner.peek() != null) {
kvScanner.enforceSeek();
- KeyValue curKV = kvScanner.peek();
+ Cell curKV = kvScanner.peek();
if (curKV != null) {
KeyValueScanner nextEarliestScanner = heap.peek();
if (nextEarliestScanner == null) {
@@ -355,7 +354,7 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
// Compare the current scanner to the next scanner. We try to avoid
// putting the current one back into the heap if possible.
- KeyValue nextKV = nextEarliestScanner.peek();
+ Cell nextKV = nextEarliestScanner.peek();
if (nextKV == null || comparator.compare(curKV, nextKV) < 0) {
// We already have the scanner with the earliest KV, so return it.
return kvScanner;
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueScanner.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueScanner.java
index 2814a37..6183c97 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueScanner.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueScanner.java
@@ -22,7 +22,7 @@ import java.io.IOException;
import java.util.SortedSet;
import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.client.Scan;
/**
@@ -31,23 +31,23 @@ import org.apache.hadoop.hbase.client.Scan;
@InterfaceAudience.Private
public interface KeyValueScanner {
/**
- * Look at the next KeyValue in this scanner, but do not iterate scanner.
- * @return the next KeyValue
+ * Look at the next Cell in this scanner, but do not iterate scanner.
+ * @return the next Cell
*/
- KeyValue peek();
+ Cell peek();
/**
- * Return the next KeyValue in this scanner, iterating the scanner
- * @return the next KeyValue
+ * Return the next Cell in this scanner, iterating the scanner
+ * @return the next Cell
*/
- KeyValue next() throws IOException;
+ Cell next() throws IOException;
/**
* Seek the scanner at or after the specified KeyValue.
* @param key seek value
* @return true if scanner has values left, false if end of scanner
*/
- boolean seek(KeyValue key) throws IOException;
+ boolean seek(Cell key) throws IOException;
/**
* Reseek the scanner at or after the specified KeyValue.
@@ -57,7 +57,7 @@ public interface KeyValueScanner {
* @param key seek value (should be non-null)
* @return true if scanner has values left, false if end of scanner
*/
- boolean reseek(KeyValue key) throws IOException;
+ boolean reseek(Cell key) throws IOException;
/**
* Get the sequence id associated with this KeyValueScanner. This is required
@@ -98,7 +98,7 @@ public interface KeyValueScanner {
* @param forward do a forward-only "reseek" instead of a random-access seek
* @param useBloom whether to enable multi-column Bloom filter optimization
*/
- boolean requestSeek(KeyValue kv, boolean forward, boolean useBloom)
+ boolean requestSeek(Cell kv, boolean forward, boolean useBloom)
throws IOException;
/**
@@ -126,10 +126,10 @@ public interface KeyValueScanner {
// Support for "Reversed Scanner"
/**
- * Seek the scanner at or before the row of specified KeyValue, it firstly
- * tries to seek the scanner at or after the specified KeyValue, return if
- * peek KeyValue of scanner has the same row with specified KeyValue,
- * otherwise seek the scanner at the first KeyValue of the row which is the
+ * Seek the scanner at or before the row of specified Cell, it firstly
+ * tries to seek the scanner at or after the specified Cell, return if
+ * peek KeyValue of scanner has the same row with specified Cell,
+ * otherwise seek the scanner at the first Cell of the row which is the
* previous row of specified KeyValue
*
* @param key seek KeyValue
@@ -137,16 +137,16 @@ public interface KeyValueScanner {
* KeyValue does not exist
*
*/
- public boolean backwardSeek(KeyValue key) throws IOException;
+ public boolean backwardSeek(Cell key) throws IOException;
/**
- * Seek the scanner at the first KeyValue of the row which is the previous row
+ * Seek the scanner at the first Cell of the row which is the previous row
* of specified key
* @param key seek value
- * @return true if the scanner at the first valid KeyValue of previous row,
- * false if not existing such KeyValue
+ * @return true if the scanner at the first valid Cell of previous row,
+ * false if not existing such Cell
*/
- public boolean seekToPreviousRow(KeyValue key) throws IOException;
+ public boolean seekToPreviousRow(Cell key) throws IOException;
/**
* Seek the scanner at the first KeyValue of last row
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NonLazyKeyValueScanner.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NonLazyKeyValueScanner.java
index 32c7e9e..bc19064 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NonLazyKeyValueScanner.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NonLazyKeyValueScanner.java
@@ -23,7 +23,7 @@ import java.util.SortedSet;
import org.apache.commons.lang.NotImplementedException;
import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.client.Scan;
/**
@@ -34,7 +34,7 @@ import org.apache.hadoop.hbase.client.Scan;
public abstract class NonLazyKeyValueScanner implements KeyValueScanner {
@Override
- public boolean requestSeek(KeyValue kv, boolean forward, boolean useBloom)
+ public boolean requestSeek(Cell kv, boolean forward, boolean useBloom)
throws IOException {
return doRealSeek(this, kv, forward);
}
@@ -51,7 +51,7 @@ public abstract class NonLazyKeyValueScanner implements KeyValueScanner {
}
public static boolean doRealSeek(KeyValueScanner scanner,
- KeyValue kv, boolean forward) throws IOException {
+ Cell kv, boolean forward) throws IOException {
return forward ? scanner.reseek(kv) : scanner.seek(kv);
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NonReversedNonLazyKeyValueScanner.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NonReversedNonLazyKeyValueScanner.java
index 4caae98..14d5ae3 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NonReversedNonLazyKeyValueScanner.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NonReversedNonLazyKeyValueScanner.java
@@ -22,7 +22,7 @@ import java.io.IOException;
import org.apache.commons.lang.NotImplementedException;
import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.Cell;
/**
* A "non-reversed & non-lazy" scanner which does not support backward scanning
@@ -34,13 +34,13 @@ public abstract class NonReversedNonLazyKeyValueScanner extends
NonLazyKeyValueScanner {
@Override
- public boolean backwardSeek(KeyValue key) throws IOException {
+ public boolean backwardSeek(Cell key) throws IOException {
throw new NotImplementedException("backwardSeek must not be called on a "
+ "non-reversed scanner");
}
@Override
- public boolean seekToPreviousRow(KeyValue key) throws IOException {
+ public boolean seekToPreviousRow(Cell key) throws IOException {
throw new NotImplementedException("seekToPreviousRow must not be called on a "
+ "non-reversed scanner");
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedKeyValueHeap.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedKeyValueHeap.java
index 19cd6cc..ba4f309 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedKeyValueHeap.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedKeyValueHeap.java
@@ -23,7 +23,8 @@ import java.util.List;
import org.apache.commons.lang.NotImplementedException;
import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.KeyValue.KVComparator;
/**
@@ -47,26 +48,26 @@ public class ReversedKeyValueHeap extends KeyValueHeap {
}
@Override
- public boolean seek(KeyValue seekKey) throws IOException {
+ public boolean seek(Cell seekKey) throws IOException {
throw new IllegalStateException(
"seek cannot be called on ReversedKeyValueHeap");
}
@Override
- public boolean reseek(KeyValue seekKey) throws IOException {
+ public boolean reseek(Cell seekKey) throws IOException {
throw new IllegalStateException(
"reseek cannot be called on ReversedKeyValueHeap");
}
@Override
- public boolean requestSeek(KeyValue key, boolean forward, boolean useBloom)
+ public boolean requestSeek(Cell key, boolean forward, boolean useBloom)
throws IOException {
throw new IllegalStateException(
"requestSeek cannot be called on ReversedKeyValueHeap");
}
@Override
- public boolean seekToPreviousRow(KeyValue seekKey) throws IOException {
+ public boolean seekToPreviousRow(Cell seekKey) throws IOException {
if (current == null) {
return false;
}
@@ -75,7 +76,7 @@ public class ReversedKeyValueHeap extends KeyValueHeap {
KeyValueScanner scanner;
while ((scanner = heap.poll()) != null) {
- KeyValue topKey = scanner.peek();
+ Cell topKey = scanner.peek();
if (comparator.getComparator().compareRows(topKey.getRowArray(),
topKey.getRowOffset(), topKey.getRowLength(), seekKey.getRowArray(),
seekKey.getRowOffset(), seekKey.getRowLength()) < 0) {
@@ -97,7 +98,7 @@ public class ReversedKeyValueHeap extends KeyValueHeap {
}
@Override
- public boolean backwardSeek(KeyValue seekKey) throws IOException {
+ public boolean backwardSeek(Cell seekKey) throws IOException {
if (current == null) {
return false;
}
@@ -106,8 +107,8 @@ public class ReversedKeyValueHeap extends KeyValueHeap {
KeyValueScanner scanner;
while ((scanner = heap.poll()) != null) {
- KeyValue topKey = scanner.peek();
- if ((comparator.getComparator().matchingRows(seekKey, topKey) && comparator
+ Cell topKey = scanner.peek();
+ if ((CellUtil.matchingRow(seekKey, topKey) && comparator
.getComparator().compare(seekKey, topKey) <= 0)
|| comparator.getComparator().compareRows(seekKey, topKey) > 0) {
heap.add(scanner);
@@ -124,12 +125,12 @@ public class ReversedKeyValueHeap extends KeyValueHeap {
}
@Override
- public KeyValue next() throws IOException {
+ public Cell next() throws IOException {
if (this.current == null) {
return null;
}
- KeyValue kvReturn = this.current.next();
- KeyValue kvNext = this.current.peek();
+ Cell kvReturn = this.current.next();
+ Cell kvNext = this.current.peek();
if (kvNext == null
|| this.comparator.kvComparator.compareRows(kvNext, kvReturn) > 0) {
if (this.current.seekToPreviousRow(kvReturn)) {
@@ -180,7 +181,7 @@ public class ReversedKeyValueHeap extends KeyValueHeap {
* @param right
* @return less than 0 if left is smaller, 0 if equal etc..
*/
- public int compareRows(KeyValue left, KeyValue right) {
+ public int compareRows(Cell left, Cell right) {
return super.kvComparator.compareRows(left, right);
}
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedRegionScannerImpl.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedRegionScannerImpl.java
index 41f93c8..b84f292 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedRegionScannerImpl.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedRegionScannerImpl.java
@@ -22,7 +22,7 @@ import java.io.IOException;
import java.util.List;
import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.regionserver.HRegion.RegionScannerImpl;
@@ -68,7 +68,7 @@ class ReversedRegionScannerImpl extends RegionScannerImpl {
assert super.joinedContinuationRow == null : "Trying to go to next row during joinedHeap read.";
byte row[] = new byte[length];
System.arraycopy(currentRow, offset, row, 0, length);
- this.storeHeap.seekToPreviousRow(KeyValue.createFirstOnRow(row));
+ this.storeHeap.seekToPreviousRow(KeyValueUtil.createFirstOnRow(row));
resetFilters();
// Calling the hook in CP which allows it to do a fast forward
if (this.region.getCoprocessorHost() != null) {
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedStoreScanner.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedStoreScanner.java
index 7ff9ffb..f224d0f 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedStoreScanner.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedStoreScanner.java
@@ -23,6 +23,8 @@ import java.util.List;
import java.util.NavigableSet;
import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValue.KVComparator;
@@ -68,11 +70,11 @@ class ReversedStoreScanner extends StoreScanner implements KeyValueScanner {
@Override
protected void seekScanners(List extends KeyValueScanner> scanners,
- KeyValue seekKey, boolean isLazy, boolean isParallelSeek)
+ Cell seekKey, boolean isLazy, boolean isParallelSeek)
throws IOException {
// Seek all scanners to the start of the Row (or if the exact matching row
// key does not exist, then to the start of the previous matching Row).
- if (seekKey.matchingRow(HConstants.EMPTY_START_ROW)) {
+ if (CellUtil.matchingRow(seekKey, HConstants.EMPTY_START_ROW)) {
for (KeyValueScanner scanner : scanners) {
scanner.seekToLastRow();
}
@@ -84,7 +86,7 @@ class ReversedStoreScanner extends StoreScanner implements KeyValueScanner {
}
@Override
- protected boolean seekToNextRow(KeyValue kv) throws IOException {
+ protected boolean seekToNextRow(Cell kv) throws IOException {
return seekToPreviousRow(kv);
}
@@ -97,7 +99,7 @@ class ReversedStoreScanner extends StoreScanner implements KeyValueScanner {
}
@Override
- protected void checkScanOrder(KeyValue prevKV, KeyValue kv,
+ protected void checkScanOrder(Cell prevKV, Cell kv,
KeyValue.KVComparator comparator) throws IOException {
// Check that the heap gives us KVs in an increasing order for same row and
// decreasing order for different rows.
@@ -109,19 +111,19 @@ class ReversedStoreScanner extends StoreScanner implements KeyValueScanner {
}
@Override
- public boolean reseek(KeyValue kv) throws IOException {
+ public boolean reseek(Cell kv) throws IOException {
throw new IllegalStateException(
"reseek cannot be called on ReversedStoreScanner");
}
@Override
- public boolean seek(KeyValue key) throws IOException {
+ public boolean seek(Cell key) throws IOException {
throw new IllegalStateException(
"seek cannot be called on ReversedStoreScanner");
}
@Override
- public boolean seekToPreviousRow(KeyValue key) throws IOException {
+ public boolean seekToPreviousRow(Cell key) throws IOException {
lock.lock();
try {
checkReseek();
@@ -133,7 +135,7 @@ class ReversedStoreScanner extends StoreScanner implements KeyValueScanner {
}
@Override
- public boolean backwardSeek(KeyValue key) throws IOException {
+ public boolean backwardSeek(Cell key) throws IOException {
lock.lock();
try {
checkReseek();
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
index 7ba5e6e..0bb2f42 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
@@ -26,6 +26,7 @@ import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.Filter.ReturnCode;
@@ -151,7 +152,7 @@ public class ScanQueryMatcher {
this.rowComparator = scanInfo.getComparator();
this.deletes = new ScanDeleteTracker();
this.stopRow = scan.getStopRow();
- this.startKey = KeyValue.createFirstDeleteFamilyOnRow(scan.getStartRow(),
+ this.startKey = KeyValueUtil.createFirstDeleteFamilyOnRow(scan.getStartRow(),
scanInfo.getFamily());
this.filter = scan.getFilter();
this.earliestPutTs = earliestPutTs;
@@ -535,12 +536,12 @@ public class ScanQueryMatcher {
public KeyValue getKeyForNextColumn(KeyValue kv) {
ColumnCount nextColumn = columns.getColumnHint();
if (nextColumn == null) {
- return KeyValue.createLastOnRow(
+ return KeyValueUtil.createLastOnRow(
kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(),
kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength(),
kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength());
} else {
- return KeyValue.createFirstOnRow(
+ return KeyValueUtil.createFirstOnRow(
kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(),
kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength(),
nextColumn.getBuffer(), nextColumn.getOffset(), nextColumn.getLength());
@@ -548,7 +549,7 @@ public class ScanQueryMatcher {
}
public KeyValue getKeyForNextRow(KeyValue kv) {
- return KeyValue.createLastOnRow(
+ return KeyValueUtil.createLastOnRow(
kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(),
null, 0, 0,
null, 0, 0);
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
index 23addb8..31a26ab 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
@@ -41,9 +41,9 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValue.KVComparator;
+import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.FSDataInputStreamWrapper;
-import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
import org.apache.hadoop.hbase.io.hfile.BlockType;
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.hadoop.hbase.io.hfile.HFile;
@@ -1311,11 +1311,11 @@ public class StoreFile {
&& Bytes.equals(scan.getStopRow(), HConstants.EMPTY_END_ROW)) {
return true;
}
- KeyValue smallestScanKeyValue = scan.isReversed() ? KeyValue
- .createFirstOnRow(scan.getStopRow()) : KeyValue.createFirstOnRow(scan
+ KeyValue smallestScanKeyValue = scan.isReversed() ? KeyValueUtil
+ .createFirstOnRow(scan.getStopRow()) : KeyValueUtil.createFirstOnRow(scan
.getStartRow());
- KeyValue largestScanKeyValue = scan.isReversed() ? KeyValue
- .createLastOnRow(scan.getStartRow()) : KeyValue.createLastOnRow(scan
+ KeyValue largestScanKeyValue = scan.isReversed() ? KeyValueUtil
+ .createLastOnRow(scan.getStartRow()) : KeyValueUtil.createLastOnRow(scan
.getStopRow());
boolean nonOverLapping = (getComparator().compareFlatKey(
this.getFirstKey(), largestScanKeyValue.getKey()) > 0 && !Bytes
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
index 0440102..442dea5 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
@@ -29,8 +29,11 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.hfile.HFileScanner;
import org.apache.hadoop.hbase.regionserver.StoreFile.Reader;
@@ -47,11 +50,11 @@ public class StoreFileScanner implements KeyValueScanner {
// the reader it comes from:
private final StoreFile.Reader reader;
private final HFileScanner hfs;
- private KeyValue cur = null;
+ private Cell cur = null;
private boolean realSeekDone;
private boolean delayedReseek;
- private KeyValue delayedSeekKV;
+ private Cell delayedSeekKV;
private boolean enforceMVCC = false;
private boolean hasMVCCInfo = false;
@@ -124,12 +127,12 @@ public class StoreFileScanner implements KeyValueScanner {
return "StoreFileScanner[" + hfs.toString() + ", cur=" + cur + "]";
}
- public KeyValue peek() {
+ public Cell peek() {
return cur;
}
- public KeyValue next() throws IOException {
- KeyValue retKey = cur;
+ public Cell next() throws IOException {
+ Cell retKey = cur;
try {
// only seek if we aren't at the end. cur == null implies 'end'.
@@ -145,7 +148,7 @@ public class StoreFileScanner implements KeyValueScanner {
return retKey;
}
- public boolean seek(KeyValue key) throws IOException {
+ public boolean seek(Cell key) throws IOException {
if (seekCount != null) seekCount.incrementAndGet();
try {
@@ -166,7 +169,7 @@ public class StoreFileScanner implements KeyValueScanner {
}
}
- public boolean reseek(KeyValue key) throws IOException {
+ public boolean reseek(Cell key) throws IOException {
if (seekCount != null) seekCount.incrementAndGet();
try {
@@ -190,7 +193,7 @@ public class StoreFileScanner implements KeyValueScanner {
protected boolean skipKVsNewerThanReadpoint() throws IOException {
// We want to ignore all key-values that are newer than our current
// readPoint
- KeyValue startKV = cur;
+ Cell startKV = cur;
while(enforceMVCC
&& cur != null
&& (cur.getMvccVersion() > readPt)) {
@@ -216,7 +219,7 @@ public class StoreFileScanner implements KeyValueScanner {
// not old enough during flush). Make sure that we set it correctly now,
// so that the comparision order does not change.
if (cur.getMvccVersion() <= readPt) {
- cur.setMvccVersion(0);
+ KeyValueUtil.ensureKeyValue(cur).setMvccVersion(0);
}
return true;
}
@@ -233,7 +236,7 @@ public class StoreFileScanner implements KeyValueScanner {
* @return false if not found or if k is after the end.
* @throws IOException
*/
- public static boolean seekAtOrAfter(HFileScanner s, KeyValue k)
+ public static boolean seekAtOrAfter(HFileScanner s, Cell k)
throws IOException {
int result = s.seekTo(k);
if(result < 0) {
@@ -252,7 +255,7 @@ public class StoreFileScanner implements KeyValueScanner {
return true;
}
- static boolean reseekAtOrAfter(HFileScanner s, KeyValue k)
+ static boolean reseekAtOrAfter(HFileScanner s, Cell k)
throws IOException {
//This function is similar to seekAtOrAfter function
int result = s.reseekTo(k);
@@ -294,7 +297,7 @@ public class StoreFileScanner implements KeyValueScanner {
* row/column and use OLDEST_TIMESTAMP in the seek key.
*/
@Override
- public boolean requestSeek(KeyValue kv, boolean forward, boolean useBloom)
+ public boolean requestSeek(Cell kv, boolean forward, boolean useBloom)
throws IOException {
if (kv.getFamilyLength() == 0) {
useBloom = false;
@@ -308,7 +311,7 @@ public class StoreFileScanner implements KeyValueScanner {
kv.getRowOffset(), kv.getRowLength(), kv.getQualifierArray(),
kv.getQualifierOffset(), kv.getQualifierLength());
} else if (this.matcher != null && !matcher.hasNullColumnInQuery() &&
- (kv.isDeleteFamily() || kv.isDeleteFamilyVersion())) {
+ ((CellUtil.isDeleteFamily(kv) || CellUtil.isDeleteFamilyVersion(kv)))) {
// if there is no such delete family kv in the store file,
// then no need to seek.
haveToSeek = reader.passesDeleteFamilyBloomFilter(kv.getRowArray(),
@@ -332,7 +335,7 @@ public class StoreFileScanner implements KeyValueScanner {
// a higher timestamp than the max timestamp in this file. We know that
// the next point when we have to consider this file again is when we
// pass the max timestamp of this file (with the same row/column).
- cur = kv.createFirstOnRowColTS(maxTimestampInFile);
+ cur = KeyValueUtil.createFirstOnRowColTS(kv, maxTimestampInFile);
} else {
// This will be the case e.g. when we need to seek to the next
// row/column, and we don't know exactly what they are, so we set the
@@ -350,7 +353,7 @@ public class StoreFileScanner implements KeyValueScanner {
// key/value and the store scanner will progress to the next column. This
// is obviously not a "real real" seek, but unlike the fake KV earlier in
// this method, we want this to be propagated to ScanQueryMatcher.
- cur = kv.createLastOnRowCol();
+ cur = KeyValueUtil.createLastOnRowCol(kv);
realSeekDone = true;
return true;
@@ -402,18 +405,19 @@ public class StoreFileScanner implements KeyValueScanner {
}
@Override
- public boolean seekToPreviousRow(KeyValue key) throws IOException {
+ public boolean seekToPreviousRow(Cell key) throws IOException {
try {
try {
- KeyValue seekKey = KeyValue.createFirstOnRow(key.getRow());
+ KeyValue seekKey = KeyValueUtil.createFirstOnRow(key.getRowArray(), key.getRowOffset(),
+ key.getRowLength());
if (seekCount != null) seekCount.incrementAndGet();
if (!hfs.seekBefore(seekKey.getBuffer(), seekKey.getKeyOffset(),
seekKey.getKeyLength())) {
close();
return false;
}
- KeyValue firstKeyOfPreviousRow = KeyValue.createFirstOnRow(hfs
- .getKeyValue().getRow());
+ KeyValue firstKeyOfPreviousRow = KeyValueUtil.createFirstOnRow(hfs.getKeyValue()
+ .getRowArray(), hfs.getKeyValue().getRowOffset(), hfs.getKeyValue().getRowLength());
if (seekCount != null) seekCount.incrementAndGet();
if (!seekAtOrAfter(hfs, firstKeyOfPreviousRow)) {
@@ -430,10 +434,7 @@ public class StoreFileScanner implements KeyValueScanner {
this.stopSkippingKVsIfNextRow = false;
}
if (!resultOfSkipKVs
- || Bytes.compareTo(cur.getBuffer(), cur.getRowOffset(),
- cur.getRowLength(), firstKeyOfPreviousRow.getBuffer(),
- firstKeyOfPreviousRow.getRowOffset(),
- firstKeyOfPreviousRow.getRowLength()) > 0) {
+ || KeyValue.COMPARATOR.compareRows(cur, firstKeyOfPreviousRow) > 0) {
return seekToPreviousRow(firstKeyOfPreviousRow);
}
@@ -453,7 +454,7 @@ public class StoreFileScanner implements KeyValueScanner {
if (lastRow == null) {
return false;
}
- KeyValue seekKey = KeyValue.createFirstOnRow(lastRow);
+ KeyValue seekKey = KeyValueUtil.createFirstOnRow(lastRow);
if (seek(seekKey)) {
return true;
} else {
@@ -462,7 +463,7 @@ public class StoreFileScanner implements KeyValueScanner {
}
@Override
- public boolean backwardSeek(KeyValue key) throws IOException {
+ public boolean backwardSeek(Cell key) throws IOException {
seek(key);
if (cur == null
|| Bytes.compareTo(cur.getRowArray(), cur.getRowOffset(),
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
index 6818af9..451e653 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
@@ -82,7 +82,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
* KVs skipped via seeking to next row/column. TODO: estimate them?
*/
private long kvsScanned = 0;
- private KeyValue prevKV = null;
+ private Cell prevKV = null;
/** We don't ever expect to change this, the constant is just for clarity. */
static final boolean LAZY_SEEK_ENABLED_BY_DEFAULT = true;
@@ -94,7 +94,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
LAZY_SEEK_ENABLED_BY_DEFAULT;
// if heap == null and lastTop != null, you need to reseek given the key below
- protected KeyValue lastTop = null;
+ protected Cell lastTop = null;
// A flag whether use pread for scan
private boolean scanUsePread = false;
@@ -301,7 +301,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
* @throws IOException
*/
protected void seekScanners(List extends KeyValueScanner> scanners,
- KeyValue seekKey, boolean isLazy, boolean isParallelSeek)
+ Cell seekKey, boolean isLazy, boolean isParallelSeek)
throws IOException {
// Seek all scanners to the start of the Row (or if the exact matching row
// key does not exist, then to the start of the next matching Row).
@@ -368,7 +368,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
}
@Override
- public KeyValue peek() {
+ public Cell peek() {
lock.lock();
try {
if (this.heap == null) {
@@ -405,7 +405,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
}
@Override
- public boolean seek(KeyValue key) throws IOException {
+ public boolean seek(Cell key) throws IOException {
lock.lock();
try {
// reset matcher state, in case that underlying store changed
@@ -437,7 +437,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
return false;
}
- KeyValue peeked = this.heap.peek();
+ Cell peeked = this.heap.peek();
if (peeked == null) {
close();
return false;
@@ -454,7 +454,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
matcher.setRow(row, offset, length);
}
- KeyValue kv;
+ Cell kv;
// Only do a sanity-check if store and comparator are available.
KeyValue.KVComparator comparator =
@@ -466,7 +466,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
checkScanOrder(prevKV, kv, comparator);
prevKV = kv;
- ScanQueryMatcher.MatchCode qcode = matcher.match(kv);
+ ScanQueryMatcher.MatchCode qcode = matcher.match(KeyValueUtil.ensureKeyValue(kv));
switch(qcode) {
case INCLUDE:
case INCLUDE_AND_SEEK_NEXT_ROW:
@@ -482,7 +482,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
if (storeLimit > -1 &&
this.countPerRow > (storeLimit + storeOffset)) {
// do what SEEK_NEXT_ROW does.
- if (!matcher.moreRowsMayExistAfter(kv)) {
+ if (!matcher.moreRowsMayExistAfter(KeyValueUtil.ensureKeyValue(kv))) {
return false;
}
seekToNextRow(kv);
@@ -497,12 +497,12 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
}
if (qcode == ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_ROW) {
- if (!matcher.moreRowsMayExistAfter(kv)) {
+ if (!matcher.moreRowsMayExistAfter(KeyValueUtil.ensureKeyValue(kv))) {
return false;
}
seekToNextRow(kv);
} else if (qcode == ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_COL) {
- seekAsDirection(matcher.getKeyForNextColumn(kv));
+ seekAsDirection(matcher.getKeyForNextColumn(KeyValueUtil.ensureKeyValue(kv)));
} else {
this.heap.next();
}
@@ -522,7 +522,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
case SEEK_NEXT_ROW:
// This is just a relatively simple end of scan fix, to short-cut end
// us if there is an endKey in the scan.
- if (!matcher.moreRowsMayExistAfter(kv)) {
+ if (!matcher.moreRowsMayExistAfter(KeyValueUtil.ensureKeyValue(kv))) {
return false;
}
@@ -530,7 +530,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
break;
case SEEK_NEXT_COL:
- seekAsDirection(matcher.getKeyForNextColumn(kv));
+ seekAsDirection(matcher.getKeyForNextColumn(KeyValueUtil.ensureKeyValue(kv)));
break;
case SKIP:
@@ -619,7 +619,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
return false;
}
- protected void resetScannerStack(KeyValue lastTopKey) throws IOException {
+ protected void resetScannerStack(Cell lastTopKey) throws IOException {
if (heap != null) {
throw new RuntimeException("StoreScanner.reseek run on an existing heap!");
}
@@ -638,7 +638,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
// Reset the state of the Query Matcher and set to top row.
// Only reset and call setRow if the row changes; avoids confusing the
// query matcher if scanning intra-row.
- KeyValue kv = heap.peek();
+ Cell kv = heap.peek();
if (kv == null) {
kv = lastTopKey;
}
@@ -660,7 +660,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
* @param comparator
* @throws IOException
*/
- protected void checkScanOrder(KeyValue prevKV, KeyValue kv,
+ protected void checkScanOrder(Cell prevKV, Cell kv,
KeyValue.KVComparator comparator) throws IOException {
// Check that the heap gives us KVs in an increasing order.
assert prevKV == null || comparator == null
@@ -668,8 +668,8 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
+ " followed by a " + "smaller key " + kv + " in cf " + store;
}
- protected boolean seekToNextRow(KeyValue kv) throws IOException {
- return reseek(matcher.getKeyForNextRow(kv));
+ protected boolean seekToNextRow(Cell kv) throws IOException {
+ return reseek(KeyValueUtil.createLastOnRow(kv));
}
/**
@@ -684,7 +684,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
}
@Override
- public boolean reseek(KeyValue kv) throws IOException {
+ public boolean reseek(Cell kv) throws IOException {
lock.lock();
try {
//Heap will not be null, if this is called from next() which.
@@ -712,7 +712,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
* @throws IOException
*/
private void parallelSeek(final List extends KeyValueScanner>
- scanners, final KeyValue kv) throws IOException {
+ scanners, final Cell kv) throws IOException {
if (scanners.isEmpty()) return;
int storeFileScannerCount = scanners.size();
CountDownLatch latch = new CountDownLatch(storeFileScannerCount);
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StripeMultiFileWriter.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StripeMultiFileWriter.java
index 588ccc0..e0baf61 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StripeMultiFileWriter.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StripeMultiFileWriter.java
@@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.regionserver;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/ParallelSeekHandler.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/ParallelSeekHandler.java
index 658d703..56c8969 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/ParallelSeekHandler.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/ParallelSeekHandler.java
@@ -24,11 +24,10 @@ import java.util.concurrent.CountDownLatch;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.executor.EventHandler;
import org.apache.hadoop.hbase.executor.EventType;
import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
-import org.apache.hadoop.hbase.regionserver.MultiVersionConsistencyControl;
/**
* Handler to seek storefiles in parallel.
@@ -37,12 +36,12 @@ import org.apache.hadoop.hbase.regionserver.MultiVersionConsistencyControl;
public class ParallelSeekHandler extends EventHandler {
private static final Log LOG = LogFactory.getLog(ParallelSeekHandler.class);
private KeyValueScanner scanner;
- private KeyValue keyValue;
+ private Cell keyValue;
private long readPoint;
private CountDownLatch latch;
private Throwable err = null;
- public ParallelSeekHandler(KeyValueScanner scanner,KeyValue keyValue,
+ public ParallelSeekHandler(KeyValueScanner scanner,Cell keyValue,
long readPoint, CountDownLatch latch) {
super(null, EventType.RS_PARALLEL_SEEK);
this.scanner = scanner;
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java
index 064da83..fdf71cc 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java
@@ -1437,7 +1437,7 @@ public class HLogSplitter {
// We don't handle HBASE-2231 because we may or may not replay a compaction event.
// Details at https://issues.apache.org/jira/browse/HBASE-2231?focusedCommentId=13647143&
// page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13647143
- if (kv.matchingFamily(WALEdit.METAFAMILY)) {
+ if (CellUtil.matchingFamily(kv, WALEdit.METAFAMILY)) {
skippedKVs.add(kv);
continue;
}
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java
index 7ae7a98..6e5d250 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java
@@ -29,6 +29,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.codec.Codec;
import org.apache.hadoop.hbase.io.HeapSize;
@@ -265,7 +266,7 @@ public class WALEdit implements Writable, HeapSize {
* @return deserialized CompactionDescriptor or null.
*/
public static CompactionDescriptor getCompaction(KeyValue kv) throws IOException {
- if (kv.matchingRow(METAROW) && kv.matchingColumn(METAFAMILY, COMPACTION)) {
+ if (CellUtil.matchingRow(kv, METAROW) && CellUtil.matchingColumn(kv, METAFAMILY, COMPACTION)) {
return CompactionDescriptor.parseFrom(kv.getValue());
}
return null;
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEditsReplaySink.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEditsReplaySink.java
index 0b3be7a..ffb79c1 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEditsReplaySink.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEditsReplaySink.java
@@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HRegionLocation;
@@ -230,7 +231,7 @@ public class WALEditsReplaySink {
List