hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [47/51] [partial] hbase git commit: Published site at 8bf70144e40650ef972f005e2465bd0e2a087c40.
Date Mon, 07 Dec 2015 17:55:57 GMT
http://git-wip-us.apache.org/repos/asf/hbase/blob/2dc53cb9/apidocs/src-html/org/apache/hadoop/hbase/CellUtil.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/CellUtil.html b/apidocs/src-html/org/apache/hadoop/hbase/CellUtil.html
index e1fe6bf..95bf4e1 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/CellUtil.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/CellUtil.html
@@ -603,1424 +603,1584 @@
 <span class="sourceLineNo">595</span>  }<a name="line.595"></a>
 <span class="sourceLineNo">596</span><a name="line.596"></a>
 <span class="sourceLineNo">597</span>  public static boolean matchingValue(final Cell left, final Cell right) {<a name="line.597"></a>
-<span class="sourceLineNo">598</span>    int lvlength = left.getValueLength();<a name="line.598"></a>
-<span class="sourceLineNo">599</span>    int rvlength = right.getValueLength();<a name="line.599"></a>
-<span class="sourceLineNo">600</span>    if (left instanceof ByteBufferedCell &amp;&amp; right instanceof ByteBufferedCell) {<a name="line.600"></a>
-<span class="sourceLineNo">601</span>      return ByteBufferUtils.equals(((ByteBufferedCell) left).getValueByteBuffer(),<a name="line.601"></a>
-<span class="sourceLineNo">602</span>          ((ByteBufferedCell) left).getValuePosition(), lvlength,<a name="line.602"></a>
-<span class="sourceLineNo">603</span>          ((ByteBufferedCell) right).getValueByteBuffer(),<a name="line.603"></a>
-<span class="sourceLineNo">604</span>          ((ByteBufferedCell) right).getValuePosition(), rvlength);<a name="line.604"></a>
-<span class="sourceLineNo">605</span>    }<a name="line.605"></a>
-<span class="sourceLineNo">606</span>    if (left instanceof ByteBufferedCell) {<a name="line.606"></a>
-<span class="sourceLineNo">607</span>      return ByteBufferUtils.equals(((ByteBufferedCell) left).getValueByteBuffer(),<a name="line.607"></a>
-<span class="sourceLineNo">608</span>          ((ByteBufferedCell) left).getValuePosition(), lvlength,<a name="line.608"></a>
-<span class="sourceLineNo">609</span>          right.getValueArray(), right.getValueOffset(), rvlength);<a name="line.609"></a>
-<span class="sourceLineNo">610</span>    }<a name="line.610"></a>
-<span class="sourceLineNo">611</span>    if (right instanceof ByteBufferedCell) {<a name="line.611"></a>
-<span class="sourceLineNo">612</span>      return ByteBufferUtils.equals(((ByteBufferedCell) right).getValueByteBuffer(),<a name="line.612"></a>
-<span class="sourceLineNo">613</span>          ((ByteBufferedCell) right).getValuePosition(), rvlength,<a name="line.613"></a>
-<span class="sourceLineNo">614</span>          left.getValueArray(), left.getValueOffset(), lvlength);<a name="line.614"></a>
-<span class="sourceLineNo">615</span>    }<a name="line.615"></a>
-<span class="sourceLineNo">616</span>    return Bytes.equals(left.getValueArray(), left.getValueOffset(), lvlength,<a name="line.616"></a>
-<span class="sourceLineNo">617</span>        right.getValueArray(), right.getValueOffset(), rvlength);<a name="line.617"></a>
-<span class="sourceLineNo">618</span>  }<a name="line.618"></a>
-<span class="sourceLineNo">619</span><a name="line.619"></a>
-<span class="sourceLineNo">620</span>  public static boolean matchingValue(final Cell left, final byte[] buf) {<a name="line.620"></a>
-<span class="sourceLineNo">621</span>    if (left instanceof ByteBufferedCell) {<a name="line.621"></a>
-<span class="sourceLineNo">622</span>      return ByteBufferUtils.compareTo(((ByteBufferedCell) left).getValueByteBuffer(),<a name="line.622"></a>
-<span class="sourceLineNo">623</span>          ((ByteBufferedCell) left).getValuePosition(), left.getValueLength(), buf, 0,<a name="line.623"></a>
-<span class="sourceLineNo">624</span>          buf.length) == 0;<a name="line.624"></a>
-<span class="sourceLineNo">625</span>    }<a name="line.625"></a>
-<span class="sourceLineNo">626</span>    return Bytes.equals(left.getValueArray(), left.getValueOffset(), left.getValueLength(), buf, 0,<a name="line.626"></a>
-<span class="sourceLineNo">627</span>        buf.length);<a name="line.627"></a>
-<span class="sourceLineNo">628</span>  }<a name="line.628"></a>
-<span class="sourceLineNo">629</span><a name="line.629"></a>
-<span class="sourceLineNo">630</span>  /**<a name="line.630"></a>
-<span class="sourceLineNo">631</span>   * @return True if a delete type, a {@link KeyValue.Type#Delete} or a<a name="line.631"></a>
-<span class="sourceLineNo">632</span>   *         {KeyValue.Type#DeleteFamily} or a<a name="line.632"></a>
-<span class="sourceLineNo">633</span>   *         {@link KeyValue.Type#DeleteColumn} KeyValue type.<a name="line.633"></a>
-<span class="sourceLineNo">634</span>   */<a name="line.634"></a>
-<span class="sourceLineNo">635</span>  public static boolean isDelete(final Cell cell) {<a name="line.635"></a>
-<span class="sourceLineNo">636</span>    return isDelete(cell.getTypeByte());<a name="line.636"></a>
-<span class="sourceLineNo">637</span>  }<a name="line.637"></a>
-<span class="sourceLineNo">638</span><a name="line.638"></a>
-<span class="sourceLineNo">639</span>  /**<a name="line.639"></a>
-<span class="sourceLineNo">640</span>   * @return True if a delete type, a {@link KeyValue.Type#Delete} or a<a name="line.640"></a>
-<span class="sourceLineNo">641</span>   *         {KeyValue.Type#DeleteFamily} or a<a name="line.641"></a>
-<span class="sourceLineNo">642</span>   *         {@link KeyValue.Type#DeleteColumn} KeyValue type.<a name="line.642"></a>
-<span class="sourceLineNo">643</span>   */<a name="line.643"></a>
-<span class="sourceLineNo">644</span>  public static boolean isDelete(final byte type) {<a name="line.644"></a>
-<span class="sourceLineNo">645</span>    return Type.Delete.getCode() &lt;= type<a name="line.645"></a>
-<span class="sourceLineNo">646</span>        &amp;&amp; type &lt;= Type.DeleteFamily.getCode();<a name="line.646"></a>
-<span class="sourceLineNo">647</span>  }<a name="line.647"></a>
-<span class="sourceLineNo">648</span><a name="line.648"></a>
-<span class="sourceLineNo">649</span>  /**<a name="line.649"></a>
-<span class="sourceLineNo">650</span>   * @return True if this cell is a {@link KeyValue.Type#Delete} type.<a name="line.650"></a>
-<span class="sourceLineNo">651</span>   */<a name="line.651"></a>
-<span class="sourceLineNo">652</span>  public static boolean isDeleteType(Cell cell) {<a name="line.652"></a>
-<span class="sourceLineNo">653</span>    return cell.getTypeByte() == Type.Delete.getCode();<a name="line.653"></a>
-<span class="sourceLineNo">654</span>  }<a name="line.654"></a>
-<span class="sourceLineNo">655</span><a name="line.655"></a>
-<span class="sourceLineNo">656</span>  public static boolean isDeleteFamily(final Cell cell) {<a name="line.656"></a>
-<span class="sourceLineNo">657</span>    return cell.getTypeByte() == Type.DeleteFamily.getCode();<a name="line.657"></a>
-<span class="sourceLineNo">658</span>  }<a name="line.658"></a>
-<span class="sourceLineNo">659</span><a name="line.659"></a>
-<span class="sourceLineNo">660</span>  public static boolean isDeleteFamilyVersion(final Cell cell) {<a name="line.660"></a>
-<span class="sourceLineNo">661</span>    return cell.getTypeByte() == Type.DeleteFamilyVersion.getCode();<a name="line.661"></a>
-<span class="sourceLineNo">662</span>  }<a name="line.662"></a>
-<span class="sourceLineNo">663</span><a name="line.663"></a>
-<span class="sourceLineNo">664</span>  public static boolean isDeleteColumns(final Cell cell) {<a name="line.664"></a>
-<span class="sourceLineNo">665</span>    return cell.getTypeByte() == Type.DeleteColumn.getCode();<a name="line.665"></a>
-<span class="sourceLineNo">666</span>  }<a name="line.666"></a>
-<span class="sourceLineNo">667</span><a name="line.667"></a>
-<span class="sourceLineNo">668</span>  public static boolean isDeleteColumnVersion(final Cell cell) {<a name="line.668"></a>
-<span class="sourceLineNo">669</span>    return cell.getTypeByte() == Type.Delete.getCode();<a name="line.669"></a>
-<span class="sourceLineNo">670</span>  }<a name="line.670"></a>
-<span class="sourceLineNo">671</span><a name="line.671"></a>
-<span class="sourceLineNo">672</span>  /**<a name="line.672"></a>
-<span class="sourceLineNo">673</span>   *<a name="line.673"></a>
-<span class="sourceLineNo">674</span>   * @return True if this cell is a delete family or column type.<a name="line.674"></a>
-<span class="sourceLineNo">675</span>   */<a name="line.675"></a>
-<span class="sourceLineNo">676</span>  public static boolean isDeleteColumnOrFamily(Cell cell) {<a name="line.676"></a>
-<span class="sourceLineNo">677</span>    int t = cell.getTypeByte();<a name="line.677"></a>
-<span class="sourceLineNo">678</span>    return t == Type.DeleteColumn.getCode() || t == Type.DeleteFamily.getCode();<a name="line.678"></a>
-<span class="sourceLineNo">679</span>  }<a name="line.679"></a>
-<span class="sourceLineNo">680</span><a name="line.680"></a>
-<span class="sourceLineNo">681</span>  /**<a name="line.681"></a>
-<span class="sourceLineNo">682</span>   * @param cell<a name="line.682"></a>
-<span class="sourceLineNo">683</span>   * @return Estimate of the &lt;code&gt;cell&lt;/code&gt; size in bytes.<a name="line.683"></a>
-<span class="sourceLineNo">684</span>   */<a name="line.684"></a>
-<span class="sourceLineNo">685</span>  public static int estimatedSerializedSizeOf(final Cell cell) {<a name="line.685"></a>
-<span class="sourceLineNo">686</span>    // If a KeyValue, we can give a good estimate of size.<a name="line.686"></a>
-<span class="sourceLineNo">687</span>    if (cell instanceof KeyValue) {<a name="line.687"></a>
-<span class="sourceLineNo">688</span>      return ((KeyValue)cell).getLength() + Bytes.SIZEOF_INT;<a name="line.688"></a>
-<span class="sourceLineNo">689</span>    }<a name="line.689"></a>
-<span class="sourceLineNo">690</span>    // TODO: Should we add to Cell a sizeOf?  Would it help? Does it make sense if Cell is<a name="line.690"></a>
-<span class="sourceLineNo">691</span>    // prefix encoded or compressed?<a name="line.691"></a>
-<span class="sourceLineNo">692</span>    return getSumOfCellElementLengths(cell) +<a name="line.692"></a>
-<span class="sourceLineNo">693</span>      // Use the KeyValue's infrastructure size presuming that another implementation would have<a name="line.693"></a>
-<span class="sourceLineNo">694</span>      // same basic cost.<a name="line.694"></a>
-<span class="sourceLineNo">695</span>      KeyValue.KEY_INFRASTRUCTURE_SIZE +<a name="line.695"></a>
-<span class="sourceLineNo">696</span>      // Serialization is probably preceded by a length (it is in the KeyValueCodec at least).<a name="line.696"></a>
-<span class="sourceLineNo">697</span>      Bytes.SIZEOF_INT;<a name="line.697"></a>
-<span class="sourceLineNo">698</span>  }<a name="line.698"></a>
-<span class="sourceLineNo">699</span><a name="line.699"></a>
-<span class="sourceLineNo">700</span>  /**<a name="line.700"></a>
-<span class="sourceLineNo">701</span>   * @param cell<a name="line.701"></a>
-<span class="sourceLineNo">702</span>   * @return Sum of the lengths of all the elements in a Cell; does not count in any infrastructure<a name="line.702"></a>
-<span class="sourceLineNo">703</span>   */<a name="line.703"></a>
-<span class="sourceLineNo">704</span>  private static int getSumOfCellElementLengths(final Cell cell) {<a name="line.704"></a>
-<span class="sourceLineNo">705</span>    return getSumOfCellKeyElementLengths(cell) + cell.getValueLength() + cell.getTagsLength();<a name="line.705"></a>
-<span class="sourceLineNo">706</span>  }<a name="line.706"></a>
-<span class="sourceLineNo">707</span><a name="line.707"></a>
-<span class="sourceLineNo">708</span>  /**<a name="line.708"></a>
-<span class="sourceLineNo">709</span>   * @param cell<a name="line.709"></a>
-<span class="sourceLineNo">710</span>   * @return Sum of all elements that make up a key; does not include infrastructure, tags or<a name="line.710"></a>
-<span class="sourceLineNo">711</span>   * values.<a name="line.711"></a>
-<span class="sourceLineNo">712</span>   */<a name="line.712"></a>
-<span class="sourceLineNo">713</span>  private static int getSumOfCellKeyElementLengths(final Cell cell) {<a name="line.713"></a>
-<span class="sourceLineNo">714</span>    return cell.getRowLength() + cell.getFamilyLength() +<a name="line.714"></a>
-<span class="sourceLineNo">715</span>    cell.getQualifierLength() +<a name="line.715"></a>
-<span class="sourceLineNo">716</span>    KeyValue.TIMESTAMP_TYPE_SIZE;<a name="line.716"></a>
-<span class="sourceLineNo">717</span>  }<a name="line.717"></a>
-<span class="sourceLineNo">718</span><a name="line.718"></a>
-<span class="sourceLineNo">719</span>  public static int estimatedSerializedSizeOfKey(final Cell cell) {<a name="line.719"></a>
-<span class="sourceLineNo">720</span>    if (cell instanceof KeyValue) return ((KeyValue)cell).getKeyLength();<a name="line.720"></a>
-<span class="sourceLineNo">721</span>    // This will be a low estimate.  Will do for now.<a name="line.721"></a>
-<span class="sourceLineNo">722</span>    return getSumOfCellKeyElementLengths(cell);<a name="line.722"></a>
-<span class="sourceLineNo">723</span>  }<a name="line.723"></a>
-<span class="sourceLineNo">724</span><a name="line.724"></a>
-<span class="sourceLineNo">725</span>  /**<a name="line.725"></a>
-<span class="sourceLineNo">726</span>   * This is an estimate of the heap space occupied by a cell. When the cell is of type<a name="line.726"></a>
-<span class="sourceLineNo">727</span>   * {@link HeapSize} we call {@link HeapSize#heapSize()} so cell can give a correct value. In other<a name="line.727"></a>
-<span class="sourceLineNo">728</span>   * cases we just consider the bytes occupied by the cell components ie. row, CF, qualifier,<a name="line.728"></a>
-<span class="sourceLineNo">729</span>   * timestamp, type, value and tags.<a name="line.729"></a>
-<span class="sourceLineNo">730</span>   * @param cell<a name="line.730"></a>
-<span class="sourceLineNo">731</span>   * @return estimate of the heap space<a name="line.731"></a>
-<span class="sourceLineNo">732</span>   */<a name="line.732"></a>
-<span class="sourceLineNo">733</span>  public static long estimatedHeapSizeOf(final Cell cell) {<a name="line.733"></a>
-<span class="sourceLineNo">734</span>    if (cell instanceof HeapSize) {<a name="line.734"></a>
-<span class="sourceLineNo">735</span>      return ((HeapSize) cell).heapSize();<a name="line.735"></a>
-<span class="sourceLineNo">736</span>    }<a name="line.736"></a>
-<span class="sourceLineNo">737</span>    // TODO: Add sizing of references that hold the row, family, etc., arrays.<a name="line.737"></a>
-<span class="sourceLineNo">738</span>    return estimatedSerializedSizeOf(cell);<a name="line.738"></a>
-<span class="sourceLineNo">739</span>  }<a name="line.739"></a>
-<span class="sourceLineNo">740</span><a name="line.740"></a>
-<span class="sourceLineNo">741</span>  /********************* tags *************************************/<a name="line.741"></a>
-<span class="sourceLineNo">742</span>  /**<a name="line.742"></a>
-<span class="sourceLineNo">743</span>   * Util method to iterate through the tags<a name="line.743"></a>
-<span class="sourceLineNo">744</span>   *<a name="line.744"></a>
-<span class="sourceLineNo">745</span>   * @param tags<a name="line.745"></a>
-<span class="sourceLineNo">746</span>   * @param offset<a name="line.746"></a>
-<span class="sourceLineNo">747</span>   * @param length<a name="line.747"></a>
-<span class="sourceLineNo">748</span>   * @return iterator for the tags<a name="line.748"></a>
-<span class="sourceLineNo">749</span>   */<a name="line.749"></a>
-<span class="sourceLineNo">750</span>  public static Iterator&lt;Tag&gt; tagsIterator(final byte[] tags, final int offset, final int length) {<a name="line.750"></a>
-<span class="sourceLineNo">751</span>    return new Iterator&lt;Tag&gt;() {<a name="line.751"></a>
-<span class="sourceLineNo">752</span>      private int pos = offset;<a name="line.752"></a>
-<span class="sourceLineNo">753</span>      private int endOffset = offset + length - 1;<a name="line.753"></a>
-<span class="sourceLineNo">754</span><a name="line.754"></a>
-<span class="sourceLineNo">755</span>      @Override<a name="line.755"></a>
-<span class="sourceLineNo">756</span>      public boolean hasNext() {<a name="line.756"></a>
-<span class="sourceLineNo">757</span>        return this.pos &lt; endOffset;<a name="line.757"></a>
-<span class="sourceLineNo">758</span>      }<a name="line.758"></a>
-<span class="sourceLineNo">759</span><a name="line.759"></a>
-<span class="sourceLineNo">760</span>      @Override<a name="line.760"></a>
-<span class="sourceLineNo">761</span>      public Tag next() {<a name="line.761"></a>
-<span class="sourceLineNo">762</span>        if (hasNext()) {<a name="line.762"></a>
-<span class="sourceLineNo">763</span>          int curTagLen = Bytes.readAsInt(tags, this.pos, Tag.TAG_LENGTH_SIZE);<a name="line.763"></a>
-<span class="sourceLineNo">764</span>          Tag tag = new Tag(tags, pos, curTagLen + Tag.TAG_LENGTH_SIZE);<a name="line.764"></a>
-<span class="sourceLineNo">765</span>          this.pos += Bytes.SIZEOF_SHORT + curTagLen;<a name="line.765"></a>
-<span class="sourceLineNo">766</span>          return tag;<a name="line.766"></a>
-<span class="sourceLineNo">767</span>        }<a name="line.767"></a>
-<span class="sourceLineNo">768</span>        return null;<a name="line.768"></a>
-<span class="sourceLineNo">769</span>      }<a name="line.769"></a>
-<span class="sourceLineNo">770</span><a name="line.770"></a>
-<span class="sourceLineNo">771</span>      @Override<a name="line.771"></a>
-<span class="sourceLineNo">772</span>      public void remove() {<a name="line.772"></a>
-<span class="sourceLineNo">773</span>        throw new UnsupportedOperationException();<a name="line.773"></a>
-<span class="sourceLineNo">774</span>      }<a name="line.774"></a>
-<span class="sourceLineNo">775</span>    };<a name="line.775"></a>
-<span class="sourceLineNo">776</span>  }<a name="line.776"></a>
-<span class="sourceLineNo">777</span><a name="line.777"></a>
-<span class="sourceLineNo">778</span>  /**<a name="line.778"></a>
-<span class="sourceLineNo">779</span>   * Returns true if the first range start1...end1 overlaps with the second range<a name="line.779"></a>
-<span class="sourceLineNo">780</span>   * start2...end2, assuming the byte arrays represent row keys<a name="line.780"></a>
-<span class="sourceLineNo">781</span>   */<a name="line.781"></a>
-<span class="sourceLineNo">782</span>  public static boolean overlappingKeys(final byte[] start1, final byte[] end1,<a name="line.782"></a>
-<span class="sourceLineNo">783</span>      final byte[] start2, final byte[] end2) {<a name="line.783"></a>
-<span class="sourceLineNo">784</span>    return (end2.length == 0 || start1.length == 0 || Bytes.compareTo(start1,<a name="line.784"></a>
-<span class="sourceLineNo">785</span>        end2) &lt; 0)<a name="line.785"></a>
-<span class="sourceLineNo">786</span>        &amp;&amp; (end1.length == 0 || start2.length == 0 || Bytes.compareTo(start2,<a name="line.786"></a>
-<span class="sourceLineNo">787</span>            end1) &lt; 0);<a name="line.787"></a>
-<span class="sourceLineNo">788</span>  }<a name="line.788"></a>
-<span class="sourceLineNo">789</span><a name="line.789"></a>
-<span class="sourceLineNo">790</span>  /**<a name="line.790"></a>
-<span class="sourceLineNo">791</span>   * Sets the given seqId to the cell.<a name="line.791"></a>
-<span class="sourceLineNo">792</span>   * Marked as audience Private as of 1.2.0.<a name="line.792"></a>
-<span class="sourceLineNo">793</span>   * Setting a Cell sequenceid is an internal implementation detail not for general public use.<a name="line.793"></a>
-<span class="sourceLineNo">794</span>   * @param cell<a name="line.794"></a>
-<span class="sourceLineNo">795</span>   * @param seqId<a name="line.795"></a>
-<span class="sourceLineNo">796</span>   * @throws IOException when the passed cell is not of type {@link SettableSequenceId}<a name="line.796"></a>
-<span class="sourceLineNo">797</span>   */<a name="line.797"></a>
-<span class="sourceLineNo">798</span>  @InterfaceAudience.Private<a name="line.798"></a>
-<span class="sourceLineNo">799</span>  public static void setSequenceId(Cell cell, long seqId) throws IOException {<a name="line.799"></a>
-<span class="sourceLineNo">800</span>    if (cell instanceof SettableSequenceId) {<a name="line.800"></a>
-<span class="sourceLineNo">801</span>      ((SettableSequenceId) cell).setSequenceId(seqId);<a name="line.801"></a>
-<span class="sourceLineNo">802</span>    } else {<a name="line.802"></a>
-<span class="sourceLineNo">803</span>      throw new IOException(new UnsupportedOperationException("Cell is not of type "<a name="line.803"></a>
-<span class="sourceLineNo">804</span>          + SettableSequenceId.class.getName()));<a name="line.804"></a>
-<span class="sourceLineNo">805</span>    }<a name="line.805"></a>
-<span class="sourceLineNo">806</span>  }<a name="line.806"></a>
-<span class="sourceLineNo">807</span><a name="line.807"></a>
-<span class="sourceLineNo">808</span>  /**<a name="line.808"></a>
-<span class="sourceLineNo">809</span>   * Sets the given timestamp to the cell.<a name="line.809"></a>
-<span class="sourceLineNo">810</span>   * @param cell<a name="line.810"></a>
-<span class="sourceLineNo">811</span>   * @param ts<a name="line.811"></a>
-<span class="sourceLineNo">812</span>   * @throws IOException when the passed cell is not of type {@link SettableTimestamp}<a name="line.812"></a>
-<span class="sourceLineNo">813</span>   */<a name="line.813"></a>
-<span class="sourceLineNo">814</span>  public static void setTimestamp(Cell cell, long ts) throws IOException {<a name="line.814"></a>
-<span class="sourceLineNo">815</span>    if (cell instanceof SettableTimestamp) {<a name="line.815"></a>
-<span class="sourceLineNo">816</span>      ((SettableTimestamp) cell).setTimestamp(ts);<a name="line.816"></a>
-<span class="sourceLineNo">817</span>    } else {<a name="line.817"></a>
-<span class="sourceLineNo">818</span>      throw new IOException(new UnsupportedOperationException("Cell is not of type "<a name="line.818"></a>
-<span class="sourceLineNo">819</span>          + SettableTimestamp.class.getName()));<a name="line.819"></a>
-<span class="sourceLineNo">820</span>    }<a name="line.820"></a>
-<span class="sourceLineNo">821</span>  }<a name="line.821"></a>
-<span class="sourceLineNo">822</span><a name="line.822"></a>
-<span class="sourceLineNo">823</span>  /**<a name="line.823"></a>
-<span class="sourceLineNo">824</span>   * Sets the given timestamp to the cell.<a name="line.824"></a>
-<span class="sourceLineNo">825</span>   * @param cell<a name="line.825"></a>
-<span class="sourceLineNo">826</span>   * @param ts buffer containing the timestamp value<a name="line.826"></a>
-<span class="sourceLineNo">827</span>   * @param tsOffset offset to the new timestamp<a name="line.827"></a>
-<span class="sourceLineNo">828</span>   * @throws IOException when the passed cell is not of type {@link SettableTimestamp}<a name="line.828"></a>
-<span class="sourceLineNo">829</span>   */<a name="line.829"></a>
-<span class="sourceLineNo">830</span>  public static void setTimestamp(Cell cell, byte[] ts, int tsOffset) throws IOException {<a name="line.830"></a>
-<span class="sourceLineNo">831</span>    if (cell instanceof SettableTimestamp) {<a name="line.831"></a>
-<span class="sourceLineNo">832</span>      ((SettableTimestamp) cell).setTimestamp(ts, tsOffset);<a name="line.832"></a>
-<span class="sourceLineNo">833</span>    } else {<a name="line.833"></a>
-<span class="sourceLineNo">834</span>      throw new IOException(new UnsupportedOperationException("Cell is not of type "<a name="line.834"></a>
-<span class="sourceLineNo">835</span>          + SettableTimestamp.class.getName()));<a name="line.835"></a>
-<span class="sourceLineNo">836</span>    }<a name="line.836"></a>
-<span class="sourceLineNo">837</span>  }<a name="line.837"></a>
-<span class="sourceLineNo">838</span><a name="line.838"></a>
-<span class="sourceLineNo">839</span>  /**<a name="line.839"></a>
-<span class="sourceLineNo">840</span>   * Sets the given timestamp to the cell iff current timestamp is<a name="line.840"></a>
-<span class="sourceLineNo">841</span>   * {@link HConstants#LATEST_TIMESTAMP}.<a name="line.841"></a>
-<span class="sourceLineNo">842</span>   * @param cell<a name="line.842"></a>
-<span class="sourceLineNo">843</span>   * @param ts<a name="line.843"></a>
-<span class="sourceLineNo">844</span>   * @return True if cell timestamp is modified.<a name="line.844"></a>
-<span class="sourceLineNo">845</span>   * @throws IOException when the passed cell is not of type {@link SettableTimestamp}<a name="line.845"></a>
-<span class="sourceLineNo">846</span>   */<a name="line.846"></a>
-<span class="sourceLineNo">847</span>  public static boolean updateLatestStamp(Cell cell, long ts) throws IOException {<a name="line.847"></a>
-<span class="sourceLineNo">848</span>    if (cell.getTimestamp() == HConstants.LATEST_TIMESTAMP) {<a name="line.848"></a>
-<span class="sourceLineNo">849</span>      setTimestamp(cell, ts);<a name="line.849"></a>
-<span class="sourceLineNo">850</span>      return true;<a name="line.850"></a>
-<span class="sourceLineNo">851</span>    }<a name="line.851"></a>
-<span class="sourceLineNo">852</span>    return false;<a name="line.852"></a>
-<span class="sourceLineNo">853</span>  }<a name="line.853"></a>
-<span class="sourceLineNo">854</span><a name="line.854"></a>
-<span class="sourceLineNo">855</span>  /**<a name="line.855"></a>
-<span class="sourceLineNo">856</span>   * Sets the given timestamp to the cell iff current timestamp is<a name="line.856"></a>
-<span class="sourceLineNo">857</span>   * {@link HConstants#LATEST_TIMESTAMP}.<a name="line.857"></a>
-<span class="sourceLineNo">858</span>   * @param cell<a name="line.858"></a>
-<span class="sourceLineNo">859</span>   * @param ts buffer containing the timestamp value<a name="line.859"></a>
-<span class="sourceLineNo">860</span>   * @param tsOffset offset to the new timestamp<a name="line.860"></a>
-<span class="sourceLineNo">861</span>   * @return True if cell timestamp is modified.<a name="line.861"></a>
-<span class="sourceLineNo">862</span>   * @throws IOException when the passed cell is not of type {@link SettableTimestamp}<a name="line.862"></a>
-<span class="sourceLineNo">863</span>   */<a name="line.863"></a>
-<span class="sourceLineNo">864</span>  public static boolean updateLatestStamp(Cell cell, byte[] ts, int tsOffset) throws IOException {<a name="line.864"></a>
-<span class="sourceLineNo">865</span>    if (cell.getTimestamp() == HConstants.LATEST_TIMESTAMP) {<a name="line.865"></a>
-<span class="sourceLineNo">866</span>      setTimestamp(cell, ts, tsOffset);<a name="line.866"></a>
-<span class="sourceLineNo">867</span>      return true;<a name="line.867"></a>
-<span class="sourceLineNo">868</span>    }<a name="line.868"></a>
-<span class="sourceLineNo">869</span>    return false;<a name="line.869"></a>
-<span class="sourceLineNo">870</span>  }<a name="line.870"></a>
-<span class="sourceLineNo">871</span><a name="line.871"></a>
-<span class="sourceLineNo">872</span>  /**<a name="line.872"></a>
-<span class="sourceLineNo">873</span>   * Writes the Cell's key part as it would have serialized in a KeyValue. The format is &amp;lt;2 bytes<a name="line.873"></a>
-<span class="sourceLineNo">874</span>   * rk len&amp;gt;&amp;lt;rk&amp;gt;&amp;lt;1 byte cf len&amp;gt;&amp;lt;cf&amp;gt;&amp;lt;qualifier&amp;gt;&amp;lt;8 bytes<a name="line.874"></a>
-<span class="sourceLineNo">875</span>   * timestamp&amp;gt;&amp;lt;1 byte type&amp;gt;<a name="line.875"></a>
-<span class="sourceLineNo">876</span>   * @param cell<a name="line.876"></a>
-<span class="sourceLineNo">877</span>   * @param out<a name="line.877"></a>
-<span class="sourceLineNo">878</span>   * @throws IOException<a name="line.878"></a>
-<span class="sourceLineNo">879</span>   */<a name="line.879"></a>
-<span class="sourceLineNo">880</span>  public static void writeFlatKey(Cell cell, DataOutputStream out) throws IOException {<a name="line.880"></a>
-<span class="sourceLineNo">881</span>    short rowLen = cell.getRowLength();<a name="line.881"></a>
-<span class="sourceLineNo">882</span>    out.writeShort(rowLen);<a name="line.882"></a>
-<span class="sourceLineNo">883</span>    out.write(cell.getRowArray(), cell.getRowOffset(), rowLen);<a name="line.883"></a>
-<span class="sourceLineNo">884</span>    byte fLen = cell.getFamilyLength();<a name="line.884"></a>
-<span class="sourceLineNo">885</span>    out.writeByte(fLen);<a name="line.885"></a>
-<span class="sourceLineNo">886</span>    out.write(cell.getFamilyArray(), cell.getFamilyOffset(), fLen);<a name="line.886"></a>
-<span class="sourceLineNo">887</span>    out.write(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());<a name="line.887"></a>
-<span class="sourceLineNo">888</span>    out.writeLong(cell.getTimestamp());<a name="line.888"></a>
-<span class="sourceLineNo">889</span>    out.writeByte(cell.getTypeByte());<a name="line.889"></a>
-<span class="sourceLineNo">890</span>  }<a name="line.890"></a>
-<span class="sourceLineNo">891</span><a name="line.891"></a>
-<span class="sourceLineNo">892</span>  /**<a name="line.892"></a>
-<span class="sourceLineNo">893</span>   * @param cell<a name="line.893"></a>
-<span class="sourceLineNo">894</span>   * @return The Key portion of the passed &lt;code&gt;cell&lt;/code&gt; as a String.<a name="line.894"></a>
-<span class="sourceLineNo">895</span>   */<a name="line.895"></a>
-<span class="sourceLineNo">896</span>  public static String getCellKeyAsString(Cell cell) {<a name="line.896"></a>
-<span class="sourceLineNo">897</span>    StringBuilder sb = new StringBuilder(Bytes.toStringBinary(<a name="line.897"></a>
-<span class="sourceLineNo">898</span>      cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));<a name="line.898"></a>
-<span class="sourceLineNo">899</span>    sb.append('/');<a name="line.899"></a>
-<span class="sourceLineNo">900</span>    sb.append(cell.getFamilyLength() == 0? "":<a name="line.900"></a>
-<span class="sourceLineNo">901</span>      Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()));<a name="line.901"></a>
-<span class="sourceLineNo">902</span>    // KeyValue only added ':' if family is non-null.  Do same.<a name="line.902"></a>
-<span class="sourceLineNo">903</span>    if (cell.getFamilyLength() &gt; 0) sb.append(':');<a name="line.903"></a>
-<span class="sourceLineNo">904</span>    sb.append(cell.getQualifierLength() == 0? "":<a name="line.904"></a>
-<span class="sourceLineNo">905</span>      Bytes.toStringBinary(cell.getQualifierArray(), cell.getQualifierOffset(),<a name="line.905"></a>
-<span class="sourceLineNo">906</span>        cell.getQualifierLength()));<a name="line.906"></a>
-<span class="sourceLineNo">907</span>    sb.append('/');<a name="line.907"></a>
-<span class="sourceLineNo">908</span>    sb.append(KeyValue.humanReadableTimestamp(cell.getTimestamp()));<a name="line.908"></a>
-<span class="sourceLineNo">909</span>    sb.append('/');<a name="line.909"></a>
-<span class="sourceLineNo">910</span>    sb.append(Type.codeToType(cell.getTypeByte()));<a name="line.910"></a>
-<span class="sourceLineNo">911</span>    if (!(cell instanceof KeyValue.KeyOnlyKeyValue)) {<a name="line.911"></a>
-<span class="sourceLineNo">912</span>      sb.append("/vlen=");<a name="line.912"></a>
-<span class="sourceLineNo">913</span>      sb.append(cell.getValueLength());<a name="line.913"></a>
-<span class="sourceLineNo">914</span>    }<a name="line.914"></a>
-<span class="sourceLineNo">915</span>    sb.append("/seqid=");<a name="line.915"></a>
-<span class="sourceLineNo">916</span>    sb.append(cell.getSequenceId());<a name="line.916"></a>
-<span class="sourceLineNo">917</span>    return sb.toString();<a name="line.917"></a>
-<span class="sourceLineNo">918</span>  }<a name="line.918"></a>
-<span class="sourceLineNo">919</span><a name="line.919"></a>
-<span class="sourceLineNo">920</span>  /**<a name="line.920"></a>
-<span class="sourceLineNo">921</span>   * This method exists just to encapsulate how we serialize keys.  To be replaced by a factory<a name="line.921"></a>
-<span class="sourceLineNo">922</span>   * that we query to figure what the Cell implementation is and then, what serialization engine<a name="line.922"></a>
-<span class="sourceLineNo">923</span>   * to use and further, how to serialize the key for inclusion in hfile index. TODO.<a name="line.923"></a>
-<span class="sourceLineNo">924</span>   * @param cell<a name="line.924"></a>
-<span class="sourceLineNo">925</span>   * @return The key portion of the Cell serialized in the old-school KeyValue way or null if<a name="line.925"></a>
-<span class="sourceLineNo">926</span>   * passed a null &lt;code&gt;cell&lt;/code&gt;<a name="line.926"></a>
-<span class="sourceLineNo">927</span>   */<a name="line.927"></a>
-<span class="sourceLineNo">928</span>  public static byte [] getCellKeySerializedAsKeyValueKey(final Cell cell) {<a name="line.928"></a>
-<span class="sourceLineNo">929</span>    if (cell == null) return null;<a name="line.929"></a>
-<span class="sourceLineNo">930</span>    byte [] b = new byte[KeyValueUtil.keyLength(cell)];<a name="line.930"></a>
-<span class="sourceLineNo">931</span>    KeyValueUtil.appendKeyTo(cell, b, 0);<a name="line.931"></a>
-<span class="sourceLineNo">932</span>    return b;<a name="line.932"></a>
-<span class="sourceLineNo">933</span>  }<a name="line.933"></a>
-<span class="sourceLineNo">934</span><a name="line.934"></a>
-<span class="sourceLineNo">935</span>  /**<a name="line.935"></a>
-<span class="sourceLineNo">936</span>   * Write rowkey excluding the common part.<a name="line.936"></a>
-<span class="sourceLineNo">937</span>   * @param cell<a name="line.937"></a>
-<span class="sourceLineNo">938</span>   * @param rLen<a name="line.938"></a>
-<span class="sourceLineNo">939</span>   * @param commonPrefix<a name="line.939"></a>
-<span class="sourceLineNo">940</span>   * @param out<a name="line.940"></a>
-<span class="sourceLineNo">941</span>   * @throws IOException<a name="line.941"></a>
-<span class="sourceLineNo">942</span>   */<a name="line.942"></a>
-<span class="sourceLineNo">943</span>  public static void writeRowKeyExcludingCommon(Cell cell, short rLen, int commonPrefix,<a name="line.943"></a>
-<span class="sourceLineNo">944</span>      DataOutputStream out) throws IOException {<a name="line.944"></a>
-<span class="sourceLineNo">945</span>    if (commonPrefix == 0) {<a name="line.945"></a>
-<span class="sourceLineNo">946</span>      out.writeShort(rLen);<a name="line.946"></a>
-<span class="sourceLineNo">947</span>    } else if (commonPrefix == 1) {<a name="line.947"></a>
-<span class="sourceLineNo">948</span>      out.writeByte((byte) rLen);<a name="line.948"></a>
-<span class="sourceLineNo">949</span>      commonPrefix--;<a name="line.949"></a>
-<span class="sourceLineNo">950</span>    } else {<a name="line.950"></a>
-<span class="sourceLineNo">951</span>      commonPrefix -= KeyValue.ROW_LENGTH_SIZE;<a name="line.951"></a>
-<span class="sourceLineNo">952</span>    }<a name="line.952"></a>
-<span class="sourceLineNo">953</span>    if (rLen &gt; commonPrefix) {<a name="line.953"></a>
-<span class="sourceLineNo">954</span>      out.write(cell.getRowArray(), cell.getRowOffset() + commonPrefix, rLen - commonPrefix);<a name="line.954"></a>
+<span class="sourceLineNo">598</span>    return matchingValue(left, right, left.getValueLength(), right.getValueLength());<a name="line.598"></a>
+<span class="sourceLineNo">599</span>  }<a name="line.599"></a>
+<span class="sourceLineNo">600</span><a name="line.600"></a>
+<span class="sourceLineNo">601</span>  public static boolean matchingValue(final Cell left, final Cell right, int lvlength,<a name="line.601"></a>
+<span class="sourceLineNo">602</span>      int rvlength) {<a name="line.602"></a>
+<span class="sourceLineNo">603</span>    if (left instanceof ByteBufferedCell &amp;&amp; right instanceof ByteBufferedCell) {<a name="line.603"></a>
+<span class="sourceLineNo">604</span>      return ByteBufferUtils.equals(((ByteBufferedCell) left).getValueByteBuffer(),<a name="line.604"></a>
+<span class="sourceLineNo">605</span>        ((ByteBufferedCell) left).getValuePosition(), lvlength,<a name="line.605"></a>
+<span class="sourceLineNo">606</span>        ((ByteBufferedCell) right).getValueByteBuffer(),<a name="line.606"></a>
+<span class="sourceLineNo">607</span>        ((ByteBufferedCell) right).getValuePosition(), rvlength);<a name="line.607"></a>
+<span class="sourceLineNo">608</span>    }<a name="line.608"></a>
+<span class="sourceLineNo">609</span>    if (left instanceof ByteBufferedCell) {<a name="line.609"></a>
+<span class="sourceLineNo">610</span>      return ByteBufferUtils.equals(((ByteBufferedCell) left).getValueByteBuffer(),<a name="line.610"></a>
+<span class="sourceLineNo">611</span>        ((ByteBufferedCell) left).getValuePosition(), lvlength, right.getValueArray(),<a name="line.611"></a>
+<span class="sourceLineNo">612</span>        right.getValueOffset(), rvlength);<a name="line.612"></a>
+<span class="sourceLineNo">613</span>    }<a name="line.613"></a>
+<span class="sourceLineNo">614</span>    if (right instanceof ByteBufferedCell) {<a name="line.614"></a>
+<span class="sourceLineNo">615</span>      return ByteBufferUtils.equals(((ByteBufferedCell) right).getValueByteBuffer(),<a name="line.615"></a>
+<span class="sourceLineNo">616</span>        ((ByteBufferedCell) right).getValuePosition(), rvlength, left.getValueArray(),<a name="line.616"></a>
+<span class="sourceLineNo">617</span>        left.getValueOffset(), lvlength);<a name="line.617"></a>
+<span class="sourceLineNo">618</span>    }<a name="line.618"></a>
+<span class="sourceLineNo">619</span>    return Bytes.equals(left.getValueArray(), left.getValueOffset(), lvlength,<a name="line.619"></a>
+<span class="sourceLineNo">620</span>      right.getValueArray(), right.getValueOffset(), rvlength);<a name="line.620"></a>
+<span class="sourceLineNo">621</span>  }<a name="line.621"></a>
+<span class="sourceLineNo">622</span><a name="line.622"></a>
+<span class="sourceLineNo">623</span>  public static boolean matchingValue(final Cell left, final byte[] buf) {<a name="line.623"></a>
+<span class="sourceLineNo">624</span>    if (left instanceof ByteBufferedCell) {<a name="line.624"></a>
+<span class="sourceLineNo">625</span>      return ByteBufferUtils.compareTo(((ByteBufferedCell) left).getValueByteBuffer(),<a name="line.625"></a>
+<span class="sourceLineNo">626</span>          ((ByteBufferedCell) left).getValuePosition(), left.getValueLength(), buf, 0,<a name="line.626"></a>
+<span class="sourceLineNo">627</span>          buf.length) == 0;<a name="line.627"></a>
+<span class="sourceLineNo">628</span>    }<a name="line.628"></a>
+<span class="sourceLineNo">629</span>    return Bytes.equals(left.getValueArray(), left.getValueOffset(), left.getValueLength(), buf, 0,<a name="line.629"></a>
+<span class="sourceLineNo">630</span>        buf.length);<a name="line.630"></a>
+<span class="sourceLineNo">631</span>  }<a name="line.631"></a>
+<span class="sourceLineNo">632</span><a name="line.632"></a>
+<span class="sourceLineNo">633</span>  /**<a name="line.633"></a>
+<span class="sourceLineNo">634</span>   * @return True if a delete type, a {@link KeyValue.Type#Delete} or a<a name="line.634"></a>
+<span class="sourceLineNo">635</span>   *         {KeyValue.Type#DeleteFamily} or a<a name="line.635"></a>
+<span class="sourceLineNo">636</span>   *         {@link KeyValue.Type#DeleteColumn} KeyValue type.<a name="line.636"></a>
+<span class="sourceLineNo">637</span>   */<a name="line.637"></a>
+<span class="sourceLineNo">638</span>  public static boolean isDelete(final Cell cell) {<a name="line.638"></a>
+<span class="sourceLineNo">639</span>    return isDelete(cell.getTypeByte());<a name="line.639"></a>
+<span class="sourceLineNo">640</span>  }<a name="line.640"></a>
+<span class="sourceLineNo">641</span><a name="line.641"></a>
+<span class="sourceLineNo">642</span>  /**<a name="line.642"></a>
+<span class="sourceLineNo">643</span>   * @return True if a delete type, a {@link KeyValue.Type#Delete} or a<a name="line.643"></a>
+<span class="sourceLineNo">644</span>   *         {KeyValue.Type#DeleteFamily} or a<a name="line.644"></a>
+<span class="sourceLineNo">645</span>   *         {@link KeyValue.Type#DeleteColumn} KeyValue type.<a name="line.645"></a>
+<span class="sourceLineNo">646</span>   */<a name="line.646"></a>
+<span class="sourceLineNo">647</span>  public static boolean isDelete(final byte type) {<a name="line.647"></a>
+<span class="sourceLineNo">648</span>    return Type.Delete.getCode() &lt;= type<a name="line.648"></a>
+<span class="sourceLineNo">649</span>        &amp;&amp; type &lt;= Type.DeleteFamily.getCode();<a name="line.649"></a>
+<span class="sourceLineNo">650</span>  }<a name="line.650"></a>
+<span class="sourceLineNo">651</span><a name="line.651"></a>
+<span class="sourceLineNo">652</span>  /**<a name="line.652"></a>
+<span class="sourceLineNo">653</span>   * @return True if this cell is a {@link KeyValue.Type#Delete} type.<a name="line.653"></a>
+<span class="sourceLineNo">654</span>   */<a name="line.654"></a>
+<span class="sourceLineNo">655</span>  public static boolean isDeleteType(Cell cell) {<a name="line.655"></a>
+<span class="sourceLineNo">656</span>    return cell.getTypeByte() == Type.Delete.getCode();<a name="line.656"></a>
+<span class="sourceLineNo">657</span>  }<a name="line.657"></a>
+<span class="sourceLineNo">658</span><a name="line.658"></a>
+<span class="sourceLineNo">659</span>  public static boolean isDeleteFamily(final Cell cell) {<a name="line.659"></a>
+<span class="sourceLineNo">660</span>    return cell.getTypeByte() == Type.DeleteFamily.getCode();<a name="line.660"></a>
+<span class="sourceLineNo">661</span>  }<a name="line.661"></a>
+<span class="sourceLineNo">662</span><a name="line.662"></a>
+<span class="sourceLineNo">663</span>  public static boolean isDeleteFamilyVersion(final Cell cell) {<a name="line.663"></a>
+<span class="sourceLineNo">664</span>    return cell.getTypeByte() == Type.DeleteFamilyVersion.getCode();<a name="line.664"></a>
+<span class="sourceLineNo">665</span>  }<a name="line.665"></a>
+<span class="sourceLineNo">666</span><a name="line.666"></a>
+<span class="sourceLineNo">667</span>  public static boolean isDeleteColumns(final Cell cell) {<a name="line.667"></a>
+<span class="sourceLineNo">668</span>    return cell.getTypeByte() == Type.DeleteColumn.getCode();<a name="line.668"></a>
+<span class="sourceLineNo">669</span>  }<a name="line.669"></a>
+<span class="sourceLineNo">670</span><a name="line.670"></a>
+<span class="sourceLineNo">671</span>  public static boolean isDeleteColumnVersion(final Cell cell) {<a name="line.671"></a>
+<span class="sourceLineNo">672</span>    return cell.getTypeByte() == Type.Delete.getCode();<a name="line.672"></a>
+<span class="sourceLineNo">673</span>  }<a name="line.673"></a>
+<span class="sourceLineNo">674</span><a name="line.674"></a>
+<span class="sourceLineNo">675</span>  /**<a name="line.675"></a>
+<span class="sourceLineNo">676</span>   *<a name="line.676"></a>
+<span class="sourceLineNo">677</span>   * @return True if this cell is a delete family or column type.<a name="line.677"></a>
+<span class="sourceLineNo">678</span>   */<a name="line.678"></a>
+<span class="sourceLineNo">679</span>  public static boolean isDeleteColumnOrFamily(Cell cell) {<a name="line.679"></a>
+<span class="sourceLineNo">680</span>    int t = cell.getTypeByte();<a name="line.680"></a>
+<span class="sourceLineNo">681</span>    return t == Type.DeleteColumn.getCode() || t == Type.DeleteFamily.getCode();<a name="line.681"></a>
+<span class="sourceLineNo">682</span>  }<a name="line.682"></a>
+<span class="sourceLineNo">683</span><a name="line.683"></a>
+<span class="sourceLineNo">684</span>  /**<a name="line.684"></a>
+<span class="sourceLineNo">685</span>   * @param cell<a name="line.685"></a>
+<span class="sourceLineNo">686</span>   * @return Estimate of the &lt;code&gt;cell&lt;/code&gt; size in bytes.<a name="line.686"></a>
+<span class="sourceLineNo">687</span>   */<a name="line.687"></a>
+<span class="sourceLineNo">688</span>  public static int estimatedSerializedSizeOf(final Cell cell) {<a name="line.688"></a>
+<span class="sourceLineNo">689</span>    // If a KeyValue, we can give a good estimate of size.<a name="line.689"></a>
+<span class="sourceLineNo">690</span>    if (cell instanceof KeyValue) {<a name="line.690"></a>
+<span class="sourceLineNo">691</span>      return ((KeyValue)cell).getLength() + Bytes.SIZEOF_INT;<a name="line.691"></a>
+<span class="sourceLineNo">692</span>    }<a name="line.692"></a>
+<span class="sourceLineNo">693</span>    // TODO: Should we add to Cell a sizeOf?  Would it help? Does it make sense if Cell is<a name="line.693"></a>
+<span class="sourceLineNo">694</span>    // prefix encoded or compressed?<a name="line.694"></a>
+<span class="sourceLineNo">695</span>    return getSumOfCellElementLengths(cell) +<a name="line.695"></a>
+<span class="sourceLineNo">696</span>      // Use the KeyValue's infrastructure size presuming that another implementation would have<a name="line.696"></a>
+<span class="sourceLineNo">697</span>      // same basic cost.<a name="line.697"></a>
+<span class="sourceLineNo">698</span>      KeyValue.KEY_INFRASTRUCTURE_SIZE +<a name="line.698"></a>
+<span class="sourceLineNo">699</span>      // Serialization is probably preceded by a length (it is in the KeyValueCodec at least).<a name="line.699"></a>
+<span class="sourceLineNo">700</span>      Bytes.SIZEOF_INT;<a name="line.700"></a>
+<span class="sourceLineNo">701</span>  }<a name="line.701"></a>
+<span class="sourceLineNo">702</span><a name="line.702"></a>
+<span class="sourceLineNo">703</span>  /**<a name="line.703"></a>
+<span class="sourceLineNo">704</span>   * @param cell<a name="line.704"></a>
+<span class="sourceLineNo">705</span>   * @return Sum of the lengths of all the elements in a Cell; does not count in any infrastructure<a name="line.705"></a>
+<span class="sourceLineNo">706</span>   */<a name="line.706"></a>
+<span class="sourceLineNo">707</span>  private static int getSumOfCellElementLengths(final Cell cell) {<a name="line.707"></a>
+<span class="sourceLineNo">708</span>    return getSumOfCellKeyElementLengths(cell) + cell.getValueLength() + cell.getTagsLength();<a name="line.708"></a>
+<span class="sourceLineNo">709</span>  }<a name="line.709"></a>
+<span class="sourceLineNo">710</span><a name="line.710"></a>
+<span class="sourceLineNo">711</span>  /**<a name="line.711"></a>
+<span class="sourceLineNo">712</span>   * @param cell<a name="line.712"></a>
+<span class="sourceLineNo">713</span>   * @return Sum of all elements that make up a key; does not include infrastructure, tags or<a name="line.713"></a>
+<span class="sourceLineNo">714</span>   * values.<a name="line.714"></a>
+<span class="sourceLineNo">715</span>   */<a name="line.715"></a>
+<span class="sourceLineNo">716</span>  private static int getSumOfCellKeyElementLengths(final Cell cell) {<a name="line.716"></a>
+<span class="sourceLineNo">717</span>    return cell.getRowLength() + cell.getFamilyLength() +<a name="line.717"></a>
+<span class="sourceLineNo">718</span>    cell.getQualifierLength() +<a name="line.718"></a>
+<span class="sourceLineNo">719</span>    KeyValue.TIMESTAMP_TYPE_SIZE;<a name="line.719"></a>
+<span class="sourceLineNo">720</span>  }<a name="line.720"></a>
+<span class="sourceLineNo">721</span><a name="line.721"></a>
+<span class="sourceLineNo">722</span>  public static int estimatedSerializedSizeOfKey(final Cell cell) {<a name="line.722"></a>
+<span class="sourceLineNo">723</span>    if (cell instanceof KeyValue) return ((KeyValue)cell).getKeyLength();<a name="line.723"></a>
+<span class="sourceLineNo">724</span>    // This will be a low estimate.  Will do for now.<a name="line.724"></a>
+<span class="sourceLineNo">725</span>    return getSumOfCellKeyElementLengths(cell);<a name="line.725"></a>
+<span class="sourceLineNo">726</span>  }<a name="line.726"></a>
+<span class="sourceLineNo">727</span><a name="line.727"></a>
+<span class="sourceLineNo">728</span>  /**<a name="line.728"></a>
+<span class="sourceLineNo">729</span>   * This is an estimate of the heap space occupied by a cell. When the cell is of type<a name="line.729"></a>
+<span class="sourceLineNo">730</span>   * {@link HeapSize} we call {@link HeapSize#heapSize()} so cell can give a correct value. In other<a name="line.730"></a>
+<span class="sourceLineNo">731</span>   * cases we just consider the bytes occupied by the cell components ie. row, CF, qualifier,<a name="line.731"></a>
+<span class="sourceLineNo">732</span>   * timestamp, type, value and tags.<a name="line.732"></a>
+<span class="sourceLineNo">733</span>   * @param cell<a name="line.733"></a>
+<span class="sourceLineNo">734</span>   * @return estimate of the heap space<a name="line.734"></a>
+<span class="sourceLineNo">735</span>   */<a name="line.735"></a>
+<span class="sourceLineNo">736</span>  public static long estimatedHeapSizeOf(final Cell cell) {<a name="line.736"></a>
+<span class="sourceLineNo">737</span>    if (cell instanceof HeapSize) {<a name="line.737"></a>
+<span class="sourceLineNo">738</span>      return ((HeapSize) cell).heapSize();<a name="line.738"></a>
+<span class="sourceLineNo">739</span>    }<a name="line.739"></a>
+<span class="sourceLineNo">740</span>    // TODO: Add sizing of references that hold the row, family, etc., arrays.<a name="line.740"></a>
+<span class="sourceLineNo">741</span>    return estimatedSerializedSizeOf(cell);<a name="line.741"></a>
+<span class="sourceLineNo">742</span>  }<a name="line.742"></a>
+<span class="sourceLineNo">743</span><a name="line.743"></a>
+<span class="sourceLineNo">744</span>  /********************* tags *************************************/<a name="line.744"></a>
+<span class="sourceLineNo">745</span>  /**<a name="line.745"></a>
+<span class="sourceLineNo">746</span>   * Util method to iterate through the tags<a name="line.746"></a>
+<span class="sourceLineNo">747</span>   *<a name="line.747"></a>
+<span class="sourceLineNo">748</span>   * @param tags<a name="line.748"></a>
+<span class="sourceLineNo">749</span>   * @param offset<a name="line.749"></a>
+<span class="sourceLineNo">750</span>   * @param length<a name="line.750"></a>
+<span class="sourceLineNo">751</span>   * @return iterator for the tags<a name="line.751"></a>
+<span class="sourceLineNo">752</span>   */<a name="line.752"></a>
+<span class="sourceLineNo">753</span>  public static Iterator&lt;Tag&gt; tagsIterator(final byte[] tags, final int offset, final int length) {<a name="line.753"></a>
+<span class="sourceLineNo">754</span>    return new Iterator&lt;Tag&gt;() {<a name="line.754"></a>
+<span class="sourceLineNo">755</span>      private int pos = offset;<a name="line.755"></a>
+<span class="sourceLineNo">756</span>      private int endOffset = offset + length - 1;<a name="line.756"></a>
+<span class="sourceLineNo">757</span><a name="line.757"></a>
+<span class="sourceLineNo">758</span>      @Override<a name="line.758"></a>
+<span class="sourceLineNo">759</span>      public boolean hasNext() {<a name="line.759"></a>
+<span class="sourceLineNo">760</span>        return this.pos &lt; endOffset;<a name="line.760"></a>
+<span class="sourceLineNo">761</span>      }<a name="line.761"></a>
+<span class="sourceLineNo">762</span><a name="line.762"></a>
+<span class="sourceLineNo">763</span>      @Override<a name="line.763"></a>
+<span class="sourceLineNo">764</span>      public Tag next() {<a name="line.764"></a>
+<span class="sourceLineNo">765</span>        if (hasNext()) {<a name="line.765"></a>
+<span class="sourceLineNo">766</span>          int curTagLen = Bytes.readAsInt(tags, this.pos, Tag.TAG_LENGTH_SIZE);<a name="line.766"></a>
+<span class="sourceLineNo">767</span>          Tag tag = new Tag(tags, pos, curTagLen + Tag.TAG_LENGTH_SIZE);<a name="line.767"></a>
+<span class="sourceLineNo">768</span>          this.pos += Bytes.SIZEOF_SHORT + curTagLen;<a name="line.768"></a>
+<span class="sourceLineNo">769</span>          return tag;<a name="line.769"></a>
+<span class="sourceLineNo">770</span>        }<a name="line.770"></a>
+<span class="sourceLineNo">771</span>        return null;<a name="line.771"></a>
+<span class="sourceLineNo">772</span>      }<a name="line.772"></a>
+<span class="sourceLineNo">773</span><a name="line.773"></a>
+<span class="sourceLineNo">774</span>      @Override<a name="line.774"></a>
+<span class="sourceLineNo">775</span>      public void remove() {<a name="line.775"></a>
+<span class="sourceLineNo">776</span>        throw new UnsupportedOperationException();<a name="line.776"></a>
+<span class="sourceLineNo">777</span>      }<a name="line.777"></a>
+<span class="sourceLineNo">778</span>    };<a name="line.778"></a>
+<span class="sourceLineNo">779</span>  }<a name="line.779"></a>
+<span class="sourceLineNo">780</span><a name="line.780"></a>
+<span class="sourceLineNo">781</span>  /**<a name="line.781"></a>
+<span class="sourceLineNo">782</span>   * Returns true if the first range start1...end1 overlaps with the second range<a name="line.782"></a>
+<span class="sourceLineNo">783</span>   * start2...end2, assuming the byte arrays represent row keys<a name="line.783"></a>
+<span class="sourceLineNo">784</span>   */<a name="line.784"></a>
+<span class="sourceLineNo">785</span>  public static boolean overlappingKeys(final byte[] start1, final byte[] end1,<a name="line.785"></a>
+<span class="sourceLineNo">786</span>      final byte[] start2, final byte[] end2) {<a name="line.786"></a>
+<span class="sourceLineNo">787</span>    return (end2.length == 0 || start1.length == 0 || Bytes.compareTo(start1,<a name="line.787"></a>
+<span class="sourceLineNo">788</span>        end2) &lt; 0)<a name="line.788"></a>
+<span class="sourceLineNo">789</span>        &amp;&amp; (end1.length == 0 || start2.length == 0 || Bytes.compareTo(start2,<a name="line.789"></a>
+<span class="sourceLineNo">790</span>            end1) &lt; 0);<a name="line.790"></a>
+<span class="sourceLineNo">791</span>  }<a name="line.791"></a>
+<span class="sourceLineNo">792</span><a name="line.792"></a>
+<span class="sourceLineNo">793</span>  /**<a name="line.793"></a>
+<span class="sourceLineNo">794</span>   * Sets the given seqId to the cell.<a name="line.794"></a>
+<span class="sourceLineNo">795</span>   * Marked as audience Private as of 1.2.0.<a name="line.795"></a>
+<span class="sourceLineNo">796</span>   * Setting a Cell sequenceid is an internal implementation detail not for general public use.<a name="line.796"></a>
+<span class="sourceLineNo">797</span>   * @param cell<a name="line.797"></a>
+<span class="sourceLineNo">798</span>   * @param seqId<a name="line.798"></a>
+<span class="sourceLineNo">799</span>   * @throws IOException when the passed cell is not of type {@link SettableSequenceId}<a name="line.799"></a>
+<span class="sourceLineNo">800</span>   */<a name="line.800"></a>
+<span class="sourceLineNo">801</span>  @InterfaceAudience.Private<a name="line.801"></a>
+<span class="sourceLineNo">802</span>  public static void setSequenceId(Cell cell, long seqId) throws IOException {<a name="line.802"></a>
+<span class="sourceLineNo">803</span>    if (cell instanceof SettableSequenceId) {<a name="line.803"></a>
+<span class="sourceLineNo">804</span>      ((SettableSequenceId) cell).setSequenceId(seqId);<a name="line.804"></a>
+<span class="sourceLineNo">805</span>    } else {<a name="line.805"></a>
+<span class="sourceLineNo">806</span>      throw new IOException(new UnsupportedOperationException("Cell is not of type "<a name="line.806"></a>
+<span class="sourceLineNo">807</span>          + SettableSequenceId.class.getName()));<a name="line.807"></a>
+<span class="sourceLineNo">808</span>    }<a name="line.808"></a>
+<span class="sourceLineNo">809</span>  }<a name="line.809"></a>
+<span class="sourceLineNo">810</span><a name="line.810"></a>
+<span class="sourceLineNo">811</span>  /**<a name="line.811"></a>
+<span class="sourceLineNo">812</span>   * Sets the given timestamp to the cell.<a name="line.812"></a>
+<span class="sourceLineNo">813</span>   * @param cell<a name="line.813"></a>
+<span class="sourceLineNo">814</span>   * @param ts<a name="line.814"></a>
+<span class="sourceLineNo">815</span>   * @throws IOException when the passed cell is not of type {@link SettableTimestamp}<a name="line.815"></a>
+<span class="sourceLineNo">816</span>   */<a name="line.816"></a>
+<span class="sourceLineNo">817</span>  public static void setTimestamp(Cell cell, long ts) throws IOException {<a name="line.817"></a>
+<span class="sourceLineNo">818</span>    if (cell instanceof SettableTimestamp) {<a name="line.818"></a>
+<span class="sourceLineNo">819</span>      ((SettableTimestamp) cell).setTimestamp(ts);<a name="line.819"></a>
+<span class="sourceLineNo">820</span>    } else {<a name="line.820"></a>
+<span class="sourceLineNo">821</span>      throw new IOException(new UnsupportedOperationException("Cell is not of type "<a name="line.821"></a>
+<span class="sourceLineNo">822</span>          + SettableTimestamp.class.getName()));<a name="line.822"></a>
+<span class="sourceLineNo">823</span>    }<a name="line.823"></a>
+<span class="sourceLineNo">824</span>  }<a name="line.824"></a>
+<span class="sourceLineNo">825</span><a name="line.825"></a>
+<span class="sourceLineNo">826</span>  /**<a name="line.826"></a>
+<span class="sourceLineNo">827</span>   * Sets the given timestamp to the cell.<a name="line.827"></a>
+<span class="sourceLineNo">828</span>   * @param cell<a name="line.828"></a>
+<span class="sourceLineNo">829</span>   * @param ts buffer containing the timestamp value<a name="line.829"></a>
+<span class="sourceLineNo">830</span>   * @param tsOffset offset to the new timestamp<a name="line.830"></a>
+<span class="sourceLineNo">831</span>   * @throws IOException when the passed cell is not of type {@link SettableTimestamp}<a name="line.831"></a>
+<span class="sourceLineNo">832</span>   */<a name="line.832"></a>
+<span class="sourceLineNo">833</span>  public static void setTimestamp(Cell cell, byte[] ts, int tsOffset) throws IOException {<a name="line.833"></a>
+<span class="sourceLineNo">834</span>    if (cell instanceof SettableTimestamp) {<a name="line.834"></a>
+<span class="sourceLineNo">835</span>      ((SettableTimestamp) cell).setTimestamp(ts, tsOffset);<a name="line.835"></a>
+<span class="sourceLineNo">836</span>    } else {<a name="line.836"></a>
+<span class="sourceLineNo">837</span>      throw new IOException(new UnsupportedOperationException("Cell is not of type "<a name="line.837"></a>
+<span class="sourceLineNo">838</span>          + SettableTimestamp.class.getName()));<a name="line.838"></a>
+<span class="sourceLineNo">839</span>    }<a name="line.839"></a>
+<span class="sourceLineNo">840</span>  }<a name="line.840"></a>
+<span class="sourceLineNo">841</span><a name="line.841"></a>
+<span class="sourceLineNo">842</span>  /**<a name="line.842"></a>
+<span class="sourceLineNo">843</span>   * Sets the given timestamp to the cell iff current timestamp is<a name="line.843"></a>
+<span class="sourceLineNo">844</span>   * {@link HConstants#LATEST_TIMESTAMP}.<a name="line.844"></a>
+<span class="sourceLineNo">845</span>   * @param cell<a name="line.845"></a>
+<span class="sourceLineNo">846</span>   * @param ts<a name="line.846"></a>
+<span class="sourceLineNo">847</span>   * @return True if cell timestamp is modified.<a name="line.847"></a>
+<span class="sourceLineNo">848</span>   * @throws IOException when the passed cell is not of type {@link SettableTimestamp}<a name="line.848"></a>
+<span class="sourceLineNo">849</span>   */<a name="line.849"></a>
+<span class="sourceLineNo">850</span>  public static boolean updateLatestStamp(Cell cell, long ts) throws IOException {<a name="line.850"></a>
+<span class="sourceLineNo">851</span>    if (cell.getTimestamp() == HConstants.LATEST_TIMESTAMP) {<a name="line.851"></a>
+<span class="sourceLineNo">852</span>      setTimestamp(cell, ts);<a name="line.852"></a>
+<span class="sourceLineNo">853</span>      return true;<a name="line.853"></a>
+<span class="sourceLineNo">854</span>    }<a name="line.854"></a>
+<span class="sourceLineNo">855</span>    return false;<a name="line.855"></a>
+<span class="sourceLineNo">856</span>  }<a name="line.856"></a>
+<span class="sourceLineNo">857</span><a name="line.857"></a>
+<span class="sourceLineNo">858</span>  /**<a name="line.858"></a>
+<span class="sourceLineNo">859</span>   * Sets the given timestamp to the cell iff current timestamp is<a name="line.859"></a>
+<span class="sourceLineNo">860</span>   * {@link HConstants#LATEST_TIMESTAMP}.<a name="line.860"></a>
+<span class="sourceLineNo">861</span>   * @param cell<a name="line.861"></a>
+<span class="sourceLineNo">862</span>   * @param ts buffer containing the timestamp value<a name="line.862"></a>
+<span class="sourceLineNo">863</span>   * @param tsOffset offset to the new timestamp<a name="line.863"></a>
+<span class="sourceLineNo">864</span>   * @return True if cell timestamp is modified.<a name="line.864"></a>
+<span class="sourceLineNo">865</span>   * @throws IOException when the passed cell is not of type {@link SettableTimestamp}<a name="line.865"></a>
+<span class="sourceLineNo">866</span>   */<a name="line.866"></a>
+<span class="sourceLineNo">867</span>  public static boolean updateLatestStamp(Cell cell, byte[] ts, int tsOffset) throws IOException {<a name="line.867"></a>
+<span class="sourceLineNo">868</span>    if (cell.getTimestamp() == HConstants.LATEST_TIMESTAMP) {<a name="line.868"></a>
+<span class="sourceLineNo">869</span>      setTimestamp(cell, ts, tsOffset);<a name="line.869"></a>
+<span class="sourceLineNo">870</span>      return true;<a name="line.870"></a>
+<span class="sourceLineNo">871</span>    }<a name="line.871"></a>
+<span class="sourceLineNo">872</span>    return false;<a name="line.872"></a>
+<span class="sourceLineNo">873</span>  }<a name="line.873"></a>
+<span class="sourceLineNo">874</span><a name="line.874"></a>
+<span class="sourceLineNo">875</span>  /**<a name="line.875"></a>
+<span class="sourceLineNo">876</span>   * Writes the Cell's key part as it would have serialized in a KeyValue. The format is &amp;lt;2 bytes<a name="line.876"></a>
+<span class="sourceLineNo">877</span>   * rk len&amp;gt;&amp;lt;rk&amp;gt;&amp;lt;1 byte cf len&amp;gt;&amp;lt;cf&amp;gt;&amp;lt;qualifier&amp;gt;&amp;lt;8 bytes<a name="line.877"></a>
+<span class="sourceLineNo">878</span>   * timestamp&amp;gt;&amp;lt;1 byte type&amp;gt;<a name="line.878"></a>
+<span class="sourceLineNo">879</span>   * @param cell<a name="line.879"></a>
+<span class="sourceLineNo">880</span>   * @param out<a name="line.880"></a>
+<span class="sourceLineNo">881</span>   * @throws IOException<a name="line.881"></a>
+<span class="sourceLineNo">882</span>   */<a name="line.882"></a>
+<span class="sourceLineNo">883</span>  public static void writeFlatKey(Cell cell, DataOutputStream out) throws IOException {<a name="line.883"></a>
+<span class="sourceLineNo">884</span>    short rowLen = cell.getRowLength();<a name="line.884"></a>
+<span class="sourceLineNo">885</span>    byte fLen = cell.getFamilyLength();<a name="line.885"></a>
+<span class="sourceLineNo">886</span>    int qLen = cell.getQualifierLength();<a name="line.886"></a>
+<span class="sourceLineNo">887</span>    // Using just one if/else loop instead of every time checking before writing every<a name="line.887"></a>
+<span class="sourceLineNo">888</span>    // component of cell<a name="line.888"></a>
+<span class="sourceLineNo">889</span>    if (cell instanceof ByteBufferedCell) {<a name="line.889"></a>
+<span class="sourceLineNo">890</span>      out.writeShort(rowLen);<a name="line.890"></a>
+<span class="sourceLineNo">891</span>      ByteBufferUtils.copyBufferToStream(out, ((ByteBufferedCell) cell).getRowByteBuffer(),<a name="line.891"></a>
+<span class="sourceLineNo">892</span>        ((ByteBufferedCell) cell).getRowPosition(), rowLen);<a name="line.892"></a>
+<span class="sourceLineNo">893</span>      out.writeByte(fLen);<a name="line.893"></a>
+<span class="sourceLineNo">894</span>      ByteBufferUtils.copyBufferToStream(out, ((ByteBufferedCell) cell).getFamilyByteBuffer(),<a name="line.894"></a>
+<span class="sourceLineNo">895</span>        ((ByteBufferedCell) cell).getFamilyPosition(), fLen);<a name="line.895"></a>
+<span class="sourceLineNo">896</span>      ByteBufferUtils.copyBufferToStream(out, ((ByteBufferedCell) cell).getQualifierByteBuffer(),<a name="line.896"></a>
+<span class="sourceLineNo">897</span>        ((ByteBufferedCell) cell).getQualifierPosition(), qLen);<a name="line.897"></a>
+<span class="sourceLineNo">898</span>    } else {<a name="line.898"></a>
+<span class="sourceLineNo">899</span>      out.writeShort(rowLen);<a name="line.899"></a>
+<span class="sourceLineNo">900</span>      out.write(cell.getRowArray(), cell.getRowOffset(), rowLen);<a name="line.900"></a>
+<span class="sourceLineNo">901</span>      out.writeByte(fLen);<a name="line.901"></a>
+<span class="sourceLineNo">902</span>      out.write(cell.getFamilyArray(), cell.getFamilyOffset(), fLen);<a name="line.902"></a>
+<span class="sourceLineNo">903</span>      out.write(cell.getQualifierArray(), cell.getQualifierOffset(), qLen);<a name="line.903"></a>
+<span class="sourceLineNo">904</span>    }<a name="line.904"></a>
+<span class="sourceLineNo">905</span>    out.writeLong(cell.getTimestamp());<a name="line.905"></a>
+<span class="sourceLineNo">906</span>    out.writeByte(cell.getTypeByte());<a name="line.906"></a>
+<span class="sourceLineNo">907</span>  }<a name="line.907"></a>
+<span class="sourceLineNo">908</span><a name="line.908"></a>
+<span class="sourceLineNo">909</span>  /**<a name="line.909"></a>
+<span class="sourceLineNo">910</span>   * Writes the row from the given cell to the output stream<a name="line.910"></a>
+<span class="sourceLineNo">911</span>   * @param out The dataoutputstream to which the data has to be written<a name="line.911"></a>
+<span class="sourceLineNo">912</span>   * @param cell The cell whose contents has to be written<a name="line.912"></a>
+<span class="sourceLineNo">913</span>   * @param rlength the row length<a name="line.913"></a>
+<span class="sourceLineNo">914</span>   * @throws IOException<a name="line.914"></a>
+<span class="sourceLineNo">915</span>   */<a name="line.915"></a>
+<span class="sourceLineNo">916</span>  public static void writeRow(DataOutputStream out, Cell cell, short rlength) throws IOException {<a name="line.916"></a>
+<span class="sourceLineNo">917</span>    if (cell instanceof ByteBufferedCell) {<a name="line.917"></a>
+<span class="sourceLineNo">918</span>      ByteBufferUtils.copyBufferToStream(out, ((ByteBufferedCell) cell).getRowByteBuffer(),<a name="line.918"></a>
+<span class="sourceLineNo">919</span>        ((ByteBufferedCell) cell).getRowPosition(), rlength);<a name="line.919"></a>
+<span class="sourceLineNo">920</span>    } else {<a name="line.920"></a>
+<span class="sourceLineNo">921</span>      out.write(cell.getRowArray(), cell.getRowOffset(), rlength);<a name="line.921"></a>
+<span class="sourceLineNo">922</span>    }<a name="line.922"></a>
+<span class="sourceLineNo">923</span>  }<a name="line.923"></a>
+<span class="sourceLineNo">924</span><a name="line.924"></a>
+<span class="sourceLineNo">925</span>  /**<a name="line.925"></a>
+<span class="sourceLineNo">926</span>   * Writes the row from the given cell to the output stream excluding the common prefix<a name="line.926"></a>
+<span class="sourceLineNo">927</span>   * @param out The dataoutputstream to which the data has to be written<a name="line.927"></a>
+<span class="sourceLineNo">928</span>   * @param cell The cell whose contents has to be written<a name="line.928"></a>
+<span class="sourceLineNo">929</span>   * @param rlength the row length<a name="line.929"></a>
+<span class="sourceLineNo">930</span>   * @throws IOException<a name="line.930"></a>
+<span class="sourceLineNo">931</span>   */<a name="line.931"></a>
+<span class="sourceLineNo">932</span>  public static void writeRowSkippingBytes(DataOutputStream out, Cell cell, short rlength,<a name="line.932"></a>
+<span class="sourceLineNo">933</span>      int commonPrefix) throws IOException {<a name="line.933"></a>
+<span class="sourceLineNo">934</span>    if (cell instanceof ByteBufferedCell) {<a name="line.934"></a>
+<span class="sourceLineNo">935</span>      ByteBufferUtils.copyBufferToStream(out, ((ByteBufferedCell) cell).getRowByteBuffer(),<a name="line.935"></a>
+<span class="sourceLineNo">936</span>        ((ByteBufferedCell) cell).getRowPosition() + commonPrefix, rlength - commonPrefix);<a name="line.936"></a>
+<span class="sourceLineNo">937</span>    } else {<a name="line.937"></a>
+<span class="sourceLineNo">938</span>      out.write(cell.getRowArray(), cell.getRowOffset() + commonPrefix, rlength - commonPrefix);<a name="line.938"></a>
+<span class="sourceLineNo">939</span>    }<a name="line.939"></a>
+<span class="sourceLineNo">940</span>  }<a name="line.940"></a>
+<span class="sourceLineNo">941</span><a name="line.941"></a>
+<span class="sourceLineNo">942</span>  /**<a name="line.942"></a>
+<span class="sourceLineNo">943</span>   * Writes the family from the given cell to the output stream<a name="line.943"></a>
+<span class="sourceLineNo">944</span>   * @param out The dataoutputstream to which the data has to be written<a name="line.944"></a>
+<span class="sourceLineNo">945</span>   * @param cell The cell whose contents has to be written<a name="line.945"></a>
+<span class="sourceLineNo">946</span>   * @param flength the family length<a name="line.946"></a>
+<span class="sourceLineNo">947</span>   * @throws IOException<a name="line.947"></a>
+<span class="sourceLineNo">948</span>   */<a name="line.948"></a>
+<span class="sourceLineNo">949</span>  public static void writeFamily(DataOutputStream out, Cell cell, byte flength) throws IOException {<a name="line.949"></a>
+<span class="sourceLineNo">950</span>    if (cell instanceof ByteBufferedCell) {<a name="line.950"></a>
+<span class="sourceLineNo">951</span>      ByteBufferUtils.copyBufferToStream(out, ((ByteBufferedCell) cell).getFamilyByteBuffer(),<a name="line.951"></a>
+<span class="sourceLineNo">952</span>        ((ByteBufferedCell) cell).getFamilyPosition(), flength);<a name="line.952"></a>
+<span class="sourceLineNo">953</span>    } else {<a name="line.953"></a>
+<span class="sourceLineNo">954</span>      out.write(cell.getFamilyArray(), cell.getFamilyOffset(), flength);<a name="line.954"></a>
 <span class="sourceLineNo">955</span>    }<a name="line.955"></a>
 <span class="sourceLineNo">956</span>  }<a name="line.956"></a>
 <span class="sourceLineNo">957</span><a name="line.957"></a>
 <span class="sourceLineNo">958</span>  /**<a name="line.958"></a>
-<span class="sourceLineNo">959</span>   * Find length of common prefix in keys of the cells, considering key as byte[] if serialized in<a name="line.959"></a>
-<span class="sourceLineNo">960</span>   * {@link KeyValue}. The key format is &amp;lt;2 bytes rk len&amp;gt;&amp;lt;rk&amp;gt;&amp;lt;1 byte cf<a name="line.960"></a>
-<span class="sourceLineNo">961</span>   * len&amp;gt;&amp;lt;cf&amp;gt;&amp;lt;qualifier&amp;gt;&amp;lt;8 bytes timestamp&amp;gt;&amp;lt;1 byte type&amp;gt;<a name="line.961"></a>
-<span class="sourceLineNo">962</span>   * @param c1<a name="line.962"></a>
-<span class="sourceLineNo">963</span>   *          the cell<a name="line.963"></a>
-<span class="sourceLineNo">964</span>   * @param c2<a name="line.964"></a>
-<span class="sourceLineNo">965</span>   *          the cell<a name="line.965"></a>
-<span class="sourceLineNo">966</span>   * @param bypassFamilyCheck<a name="line.966"></a>
-<span class="sourceLineNo">967</span>   *          when true assume the family bytes same in both cells. Pass it as true when dealing<a name="line.967"></a>
-<span class="sourceLineNo">968</span>   *          with Cells in same CF so as to avoid some checks<a name="line.968"></a>
-<span class="sourceLineNo">969</span>   * @param withTsType<a name="line.969"></a>
-<span class="sourceLineNo">970</span>   *          when true check timestamp and type bytes also.<a name="line.970"></a>
-<span class="sourceLineNo">971</span>   * @return length of common prefix<a name="line.971"></a>
-<span class="sourceLineNo">972</span>   */<a name="line.972"></a>
-<span class="sourceLineNo">973</span>  public static int findCommonPrefixInFlatKey(Cell c1, Cell c2, boolean bypassFamilyCheck,<a name="line.973"></a>
-<span class="sourceLineNo">974</span>      boolean withTsType) {<a name="line.974"></a>
-<span class="sourceLineNo">975</span>    // Compare the 2 bytes in RK length part<a name="line.975"></a>
-<span class="sourceLineNo">976</span>    short rLen1 = c1.getRowLength();<a name="line.976"></a>
-<span class="sourceLineNo">977</span>    short rLen2 = c2.getRowLength();<a name="line.977"></a>
-<span class="sourceLineNo">978</span>    int commonPrefix = KeyValue.ROW_LENGTH_SIZE;<a name="line.978"></a>
-<span class="sourceLineNo">979</span>    if (rLen1 != rLen2) {<a name="line.979"></a>
-<span class="sourceLineNo">980</span>      // early out when the RK length itself is not matching<a name="line.980"></a>
-<span class="sourceLineNo">981</span>      return ByteBufferUtils.findCommonPrefix(Bytes.toBytes(rLen1), 0, KeyValue.ROW_LENGTH_SIZE,<a name="line.981"></a>
-<span class="sourceLineNo">982</span>          Bytes.toBytes(rLen2), 0, KeyValue.ROW_LENGTH_SIZE);<a name="line.982"></a>
-<span class="sourceLineNo">983</span>    }<a name="line.983"></a>
-<span class="sourceLineNo">984</span>    // Compare the RKs<a name="line.984"></a>
-<span class="sourceLineNo">985</span>    int rkCommonPrefix = ByteBufferUtils.findCommonPrefix(c1.getRowArray(), c1.getRowOffset(),<a name="line.985"></a>
-<span class="sourceLineNo">986</span>        rLen1, c2.getRowArray(), c2.getRowOffset(), rLen2);<a name="line.986"></a>
-<span class="sourceLineNo">987</span>    commonPrefix += rkCommonPrefix;<a name="line.987"></a>
-<span class="sourceLineNo">988</span>    if (rkCommonPrefix != rLen1) {<a name="line.988"></a>
-<span class="sourceLineNo">989</span>      // Early out when RK is not fully matching.<a name="line.989"></a>
-<span class="sourceLineNo">990</span>      return commonPrefix;<a name="line.990"></a>
-<span class="sourceLineNo">991</span>    }<a name="line.991"></a>
-<span class="sourceLineNo">992</span>    // Compare 1 byte CF length part<a name="line.992"></a>
-<span class="sourceLineNo">993</span>    byte fLen1 = c1.getFamilyLength();<a name="line.993"></a>
-<span class="sourceLineNo">994</span>    if (bypassFamilyCheck) {<a name="line.994"></a>
-<span class="sourceLineNo">995</span>      // This flag will be true when caller is sure that the family will be same for both the cells<a name="line.995"></a>
-<span class="sourceLineNo">996</span>      // Just make commonPrefix to increment by the family part<a name="line.996"></a>
-<span class="sourceLineNo">997</span>      commonPrefix += KeyValue.FAMILY_LENGTH_SIZE + fLen1;<a name="line.997"></a>
-<span class="sourceLineNo">998</span>    } else {<a name="line.998"></a>
-<span class="sourceLineNo">999</span>      byte fLen2 = c2.getFamilyLength();<a name="line.999"></a>
-<span class="sourceLineNo">1000</span>      if (fLen1 != fLen2) {<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>        // early out when the CF length itself is not matching<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span>        return commonPrefix;<a name="line.1002"></a>
-<span class="sourceLineNo">1003</span>      }<a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>      // CF lengths are same so there is one more byte common in key part<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>      commonPrefix += KeyValue.FAMILY_LENGTH_SIZE;<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>      // Compare the CF names<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span>      int fCommonPrefix = ByteBufferUtils.findCommonPrefix(c1.getFamilyArray(),<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>          c1.getFamilyOffset(), fLen1, c2.getFamilyArray(), c2.getFamilyOffset(), fLen2);<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>      commonPrefix += fCommonPrefix;<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>      if (fCommonPrefix != fLen1) {<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>        return commonPrefix;<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>      }<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>    }<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>    // Compare the Qualifiers<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span>    int qLen1 = c1.getQualifierLength();<a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>    int qLen2 = c2.getQualifierLength();<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span>    int qCommon = ByteBufferUtils.findCommonPrefix(c1.getQualifierArray(), c1.getQualifierOffset(),<a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>        qLen1, c2.getQualifierArray(), c2.getQualifierOffset(), qLen2);<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>    commonPrefix += qCommon;<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span>    if (!withTsType || Math.max(qLen1, qLen2) != qCommon) {<a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>      return commonPrefix;<a name="line.1021"></a>
+<span class="sourceLineNo">959</span>   * Writes the qualifier from the given cell to the output stream<a name="line.959"></a>
+<span class="sourceLineNo">960</span>   * @param out The dataoutputstream to which the data has to be written<a name="line.960"></a>
+<span class="sourceLineNo">961</span>   * @param cell The cell whose contents has to be written<a name="line.961"></a>
+<span class="sourceLineNo">962</span>   * @param qlength the qualifier length<a name="line.962"></a>
+<span class="sourceLineNo">963</span>   * @throws IOException<a name="line.963"></a>
+<span class="sourceLineNo">964</span>   */<a name="line.964"></a>
+<span class="sourceLineNo">965</span>  public static void writeQualifier(DataOutputStream out, Cell cell, int qlength)<a name="line.965"></a>
+<span class="sourceLineNo">966</span>      throws IOException {<a name="line.966"></a>
+<span class="sourceLineNo">967</span>    if (cell instanceof ByteBufferedCell) {<a name="line.967"></a>
+<span class="sourceLineNo">968</span>      ByteBufferUtils.copyBufferToStream(out, ((ByteBufferedCell) cell).getQualifierByteBuffer(),<a name="line.968"></a>
+<span class="sourceLineNo">969</span>        ((ByteBufferedCell) cell).getQualifierPosition(), qlength);<a name="line.969"></a>
+<span class="sourceLineNo">970</span>    } else {<a name="line.970"></a>
+<span class="sourceLineNo">971</span>      out.write(cell.getQualifierArray(), cell.getQualifierOffset(), qlength);<a name="line.971"></a>
+<span class="sourceLineNo">972</span>    }<a name="line.972"></a>
+<span class="sourceLineNo">973</span>  }<a name="line.973"></a>
+<span class="sourceLineNo">974</span><a name="line.974"></a>
+<span class="sourceLineNo">975</span>  /**<a name="line.975"></a>
+<span class="sourceLineNo">976</span>   * Writes the qualifier from the given cell to the output stream excluding the common prefix<a name="line.976"></a>
+<span class="sourceLineNo">977</span>   * @param out The dataoutputstream to which the data has to be written<a name="line.977"></a>
+<span class="sourceLineNo">978</span>   * @param cell The cell whose contents has to be written<a name="line.978"></a>
+<span class="sourceLineNo">979</span>   * @param qlength the qualifier length<a name="line.979"></a>
+<span class="sourceLineNo">980</span>   * @throws IOException<a name="line.980"></a>
+<span class="sourceLineNo">981</span>   */<a name="line.981"></a>
+<span class="sourceLineNo">982</span>  public static void writeQualifierSkippingBytes(DataOutputStream out, Cell cell,<a name="line.982"></a>
+<span class="sourceLineNo">983</span>      int qlength, int commonPrefix) throws IOException {<a name="line.983"></a>
+<span class="sourceLineNo">984</span>    if (cell instanceof ByteBufferedCell) {<a name="line.984"></a>
+<span class="sourceLineNo">985</span>      ByteBufferUtils.copyBufferToStream(out, ((ByteBufferedCell) cell).getQualifierByteBuffer(),<a name="line.985"></a>
+<span class="sourceLineNo">986</span>        ((ByteBufferedCell) cell).getQualifierPosition() + commonPrefix, qlength - commonPrefix);<a name="line.986"></a>
+<span class="sourceLineNo">987</span>    } else {<a name="line.987"></a>
+<span class="sourceLineNo">988</span>      out.write(cell.getQualifierArray(), cell.getQualifierOffset() + commonPrefix,<a name="line.988"></a>
+<span class="sourceLineNo">989</span>        qlength - commonPrefix);<a name="line.989"></a>
+<span class="sourceLineNo">990</span>    }<a name="line.990"></a>
+<span class="sourceLineNo">991</span>  }<a name="line.991"></a>
+<span class="sourceLineNo">992</span><a name="line.992"></a>
+<span class="sourceLineNo">993</span>  /**<a name="line.993"></a>
+<span class="sourceLineNo">994</span>   * Writes the value from the given cell to the output stream<a name="line.994"></a>
+<span class="sourceLineNo">995</span>   * @param out The dataoutputstream to which the data has to be written<a name="line.995"></a>
+<span class="sourceLineNo">996</span>   * @param cell The cell whose contents has to be written<a name="line.996"></a>
+<span class="sourceLineNo">997</span>   * @param vlength the value length<a name="line.997"></a>
+<span class="sourceLineNo">998</span>   * @throws IOException<a name="line.998"></a>
+<span class="sourceLineNo">999</span>   */<a name="line.999"></a>
+<span class="sourceLineNo">1000</span>  public static void writeValue(DataOutputStream out, Cell cell, int vlength) throws IOException {<a name="line.1000"></a>
+<span class="sourceLineNo">1001</span>    if (cell instanceof ByteBufferedCell) {<a name="line.1001"></a>
+<span class="sourceLineNo">1002</span>      ByteBufferUtils.copyBufferToStream(out, ((ByteBufferedCell) cell).getValueByteBuffer(),<a name="line.1002"></a>
+<span class="sourceLineNo">1003</span>        ((ByteBufferedCell) cell).getValuePosition(), vlength);<a name="line.1003"></a>
+<span class="sourceLineNo">1004</span>    } else {<a name="line.1004"></a>
+<span class="sourceLineNo">1005</span>      out.write(cell.getValueArray(), cell.getValueOffset(), vlength);<a name="line.1005"></a>
+<span class="sourceLineNo">1006</span>    }<a name="line.1006"></a>
+<span class="sourceLineNo">1007</span>  }<a name="line.1007"></a>
+<span class="sourceLineNo">1008</span><a name="line.1008"></a>
+<span class="sourceLineNo">1009</span>  /**<a name="line.1009"></a>
+<span class="sourceLineNo">1010</span>   * Writes the tag from the given cell to the output stream<a name="line.1010"></a>
+<span class="sourceLineNo">1011</span>   * @param out The dataoutputstream to which the data has to be written<a name="line.1011"></a>
+<span class="sourceLineNo">1012</span>   * @param cell The cell whose contents has to be written<a name="line.1012"></a>
+<span class="sourceLineNo">1013</span>   * @param tagsLength the tag length<a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>   * @throws IOException<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>   */<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span>  public static void writeTags(DataOutputStream out, Cell cell, int tagsLength) throws IOException {<a name="line.1016"></a>
+<span class="sourceLineNo">1017</span>    if (cell instanceof ByteBufferedCell) {<a name="line.1017"></a>
+<span class="sourceLineNo">1018</span>      ByteBufferUtils.copyBufferToStream(out, ((ByteBufferedCell) cell).getTagsByteBuffer(),<a name="line.1018"></a>
+<span class="sourceLineNo">1019</span>        ((ByteBufferedCell) cell).getTagsPosition(), tagsLength);<a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>    } else {<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>      out.write(cell.getTagsArray(), cell.getTagsOffset(), tagsLength);<a name="line.1021"></a>
 <span class="sourceLineNo">1022</span>    }<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>    // Compare the timestamp parts<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>    int tsCommonPrefix = ByteBufferUtils.findCommonPrefix(Bytes.toBytes(c1.getTimestamp()), 0,<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>        KeyValue.TIMESTAMP_SIZE, Bytes.toBytes(c2.getTimestamp()), 0, KeyValue.TIMESTAMP_SIZE);<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>    commonPrefix += tsCommonPrefix;<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>    if (tsCommonPrefix != KeyValue.TIMESTAMP_SIZE) {<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>      return commonPrefix;<a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>    }<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span>    // Compare the type<a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>    if (c1.getTypeByte() == c2.getTypeByte()) {<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>      commonPrefix += KeyValue.TYPE_SIZE;<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>    }<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>    return commonPrefix;<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>  }<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span><a name="line.1036"></a>
-<span class="sourceLineNo">1037</span>  /** Returns a string representation of the cell */<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>  public static String toString(Cell cell, boolean verbose) {<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span>    if (cell == null) {<a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>      return "";<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>    }<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>    StringBuilder builder = new StringBuilder();<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>    String keyStr = getCellKeyAsString(cell);<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span><a name="line.1044"></a>
-<span class="sourceLineNo">1045</span>    String tag = null;<a name="line.1045"></a>
-<span class="sourceLineNo">1046</span>    String value = null;<a name="line.1046"></a>
-<span class="sourceLineNo">1047</span>    if (verbose) {<a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>      // TODO: pretty print tags as well<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>      if (cell.getTagsLength() &gt; 0) {<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>        tag = Bytes.toStringBinary(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength());<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>      }<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>      if (!(cell instanceof KeyValue.KeyOnlyKeyValue)) {<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>        value = Bytes.toStringBinary(cell.getValueArray(), cell.getValueOffset(),<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>            cell.getValueLength());<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>      }<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>    }<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span><a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>    builder<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>      .append(keyStr);<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span>    if (tag != null &amp;&amp; !tag.isEmpty()) {<a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>      builder.append("/").append(tag);<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span>    }<a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>    if (value != null) {<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>      builder.append("/").append(value);<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>    }<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span><a nam

<TRUNCATED>

Mime
View raw message