hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [12/19] hbase-site git commit: Published site at db04a9f9d910caf3976f8a86cdd8bacbafcd78e4.
Date Mon, 14 May 2018 14:47:35 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/c4fbf0df/devapidocs/src-html/org/apache/hadoop/hbase/CellComparatorImpl.MetaCellComparator.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/CellComparatorImpl.MetaCellComparator.html b/devapidocs/src-html/org/apache/hadoop/hbase/CellComparatorImpl.MetaCellComparator.html
index 9084ff5..b727931 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/CellComparatorImpl.MetaCellComparator.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/CellComparatorImpl.MetaCellComparator.html
@@ -78,315 +78,399 @@
 <span class="sourceLineNo">070</span>   * @return 0 if equal, -1 if a &amp;lt; b, and +1 if a &amp;gt; b.<a name="line.70"></a>
 <span class="sourceLineNo">071</span>   */<a name="line.71"></a>
 <span class="sourceLineNo">072</span>  public final int compare(final Cell a, final Cell b, boolean ignoreSequenceid) {<a name="line.72"></a>
-<span class="sourceLineNo">073</span>    // row<a name="line.73"></a>
-<span class="sourceLineNo">074</span>    int c = compareRows(a, b);<a name="line.74"></a>
-<span class="sourceLineNo">075</span>    if (c != 0) return c;<a name="line.75"></a>
-<span class="sourceLineNo">076</span><a name="line.76"></a>
-<span class="sourceLineNo">077</span>    c = compareWithoutRow(a, b);<a name="line.77"></a>
-<span class="sourceLineNo">078</span>    if(c != 0) return c;<a name="line.78"></a>
-<span class="sourceLineNo">079</span><a name="line.79"></a>
-<span class="sourceLineNo">080</span>    if (!ignoreSequenceid) {<a name="line.80"></a>
-<span class="sourceLineNo">081</span>      // Negate following comparisons so later edits show up first<a name="line.81"></a>
-<span class="sourceLineNo">082</span>      // mvccVersion: later sorts first<a name="line.82"></a>
-<span class="sourceLineNo">083</span>      return Longs.compare(b.getSequenceId(), a.getSequenceId());<a name="line.83"></a>
-<span class="sourceLineNo">084</span>    } else {<a name="line.84"></a>
-<span class="sourceLineNo">085</span>      return c;<a name="line.85"></a>
-<span class="sourceLineNo">086</span>    }<a name="line.86"></a>
-<span class="sourceLineNo">087</span>  }<a name="line.87"></a>
-<span class="sourceLineNo">088</span><a name="line.88"></a>
-<span class="sourceLineNo">089</span>  /**<a name="line.89"></a>
-<span class="sourceLineNo">090</span>   * Compares the family and qualifier part of the cell<a name="line.90"></a>
-<span class="sourceLineNo">091</span>   * @param left the left cell<a name="line.91"></a>
-<span class="sourceLineNo">092</span>   * @param right the right cell<a name="line.92"></a>
-<span class="sourceLineNo">093</span>   * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise<a name="line.93"></a>
-<span class="sourceLineNo">094</span>   */<a name="line.94"></a>
-<span class="sourceLineNo">095</span>  public final int compareColumns(final Cell left, final Cell right) {<a name="line.95"></a>
-<span class="sourceLineNo">096</span>    int diff = compareFamilies(left, right);<a name="line.96"></a>
-<span class="sourceLineNo">097</span>    if (diff != 0) {<a name="line.97"></a>
-<span class="sourceLineNo">098</span>      return diff;<a name="line.98"></a>
-<span class="sourceLineNo">099</span>    }<a name="line.99"></a>
-<span class="sourceLineNo">100</span>    return compareQualifiers(left, right);<a name="line.100"></a>
-<span class="sourceLineNo">101</span>  }<a name="line.101"></a>
-<span class="sourceLineNo">102</span><a name="line.102"></a>
-<span class="sourceLineNo">103</span>  /**<a name="line.103"></a>
-<span class="sourceLineNo">104</span>   * Compare the families of left and right cell<a name="line.104"></a>
-<span class="sourceLineNo">105</span>   * @param left<a name="line.105"></a>
-<span class="sourceLineNo">106</span>   * @param right<a name="line.106"></a>
-<span class="sourceLineNo">107</span>   * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise<a name="line.107"></a>
-<span class="sourceLineNo">108</span>   */<a name="line.108"></a>
-<span class="sourceLineNo">109</span>  @Override<a name="line.109"></a>
-<span class="sourceLineNo">110</span>  public final int compareFamilies(Cell left, Cell right) {<a name="line.110"></a>
-<span class="sourceLineNo">111</span>    if (left instanceof ByteBufferExtendedCell &amp;&amp; right instanceof ByteBufferExtendedCell) {<a name="line.111"></a>
-<span class="sourceLineNo">112</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),<a name="line.112"></a>
-<span class="sourceLineNo">113</span>          ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(),<a name="line.113"></a>
-<span class="sourceLineNo">114</span>          ((ByteBufferExtendedCell) right).getFamilyByteBuffer(),<a name="line.114"></a>
-<span class="sourceLineNo">115</span>          ((ByteBufferExtendedCell) right).getFamilyPosition(), right.getFamilyLength());<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    }<a name="line.116"></a>
-<span class="sourceLineNo">117</span>    if (left instanceof ByteBufferExtendedCell) {<a name="line.117"></a>
-<span class="sourceLineNo">118</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),<a name="line.118"></a>
-<span class="sourceLineNo">119</span>          ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(),<a name="line.119"></a>
-<span class="sourceLineNo">120</span>          right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    }<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    if (right instanceof ByteBufferExtendedCell) {<a name="line.122"></a>
-<span class="sourceLineNo">123</span>      // Notice how we flip the order of the compare here. We used to negate the return value but<a name="line.123"></a>
-<span class="sourceLineNo">124</span>      // see what FindBugs says<a name="line.124"></a>
-<span class="sourceLineNo">125</span>      // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO<a name="line.125"></a>
-<span class="sourceLineNo">126</span>      // It suggest flipping the order to get same effect and 'safer'.<a name="line.126"></a>
-<span class="sourceLineNo">127</span>      return ByteBufferUtils.compareTo(<a name="line.127"></a>
-<span class="sourceLineNo">128</span>          left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),<a name="line.128"></a>
-<span class="sourceLineNo">129</span>          ((ByteBufferExtendedCell)right).getFamilyByteBuffer(),<a name="line.129"></a>
-<span class="sourceLineNo">130</span>          ((ByteBufferExtendedCell)right).getFamilyPosition(), right.getFamilyLength());<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    }<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),<a name="line.132"></a>
-<span class="sourceLineNo">133</span>        right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());<a name="line.133"></a>
-<span class="sourceLineNo">134</span>  }<a name="line.134"></a>
-<span class="sourceLineNo">135</span><a name="line.135"></a>
-<span class="sourceLineNo">136</span>  /**<a name="line.136"></a>
-<span class="sourceLineNo">137</span>   * Compare the qualifiers part of the left and right cells.<a name="line.137"></a>
-<span class="sourceLineNo">138</span>   * @param left<a name="line.138"></a>
-<span class="sourceLineNo">139</span>   * @param right<a name="line.139"></a>
-<span class="sourceLineNo">140</span>   * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise<a name="line.140"></a>
-<span class="sourceLineNo">141</span>   */<a name="line.141"></a>
-<span class="sourceLineNo">142</span>  @Override<a name="line.142"></a>
-<span class="sourceLineNo">143</span>  public final int compareQualifiers(Cell left, Cell right) {<a name="line.143"></a>
-<span class="sourceLineNo">144</span>    if (left instanceof ByteBufferExtendedCell &amp;&amp; right instanceof ByteBufferExtendedCell) {<a name="line.144"></a>
-<span class="sourceLineNo">145</span>      return ByteBufferUtils<a name="line.145"></a>
-<span class="sourceLineNo">146</span>          .compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),<a name="line.146"></a>
-<span class="sourceLineNo">147</span>              ((ByteBufferExtendedCell) left).getQualifierPosition(),<a name="line.147"></a>
-<span class="sourceLineNo">148</span>              left.getQualifierLength(), ((ByteBufferExtendedCell) right).getQualifierByteBuffer(),<a name="line.148"></a>
-<span class="sourceLineNo">149</span>              ((ByteBufferExtendedCell) right).getQualifierPosition(),<a name="line.149"></a>
-<span class="sourceLineNo">150</span>              right.getQualifierLength());<a name="line.150"></a>
-<span class="sourceLineNo">151</span>    }<a name="line.151"></a>
-<span class="sourceLineNo">152</span>    if (left instanceof ByteBufferExtendedCell) {<a name="line.152"></a>
-<span class="sourceLineNo">153</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),<a name="line.153"></a>
-<span class="sourceLineNo">154</span>          ((ByteBufferExtendedCell) left).getQualifierPosition(), left.getQualifierLength(),<a name="line.154"></a>
-<span class="sourceLineNo">155</span>          right.getQualifierArray(), right.getQualifierOffset(), right.getQualifierLength());<a name="line.155"></a>
-<span class="sourceLineNo">156</span>    }<a name="line.156"></a>
-<span class="sourceLineNo">157</span>    if (right instanceof ByteBufferExtendedCell) {<a name="line.157"></a>
-<span class="sourceLineNo">158</span>      // Notice how we flip the order of the compare here. We used to negate the return value but<a name="line.158"></a>
-<span class="sourceLineNo">159</span>      // see what FindBugs says<a name="line.159"></a>
-<span class="sourceLineNo">160</span>      // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO<a name="line.160"></a>
-<span class="sourceLineNo">161</span>      // It suggest flipping the order to get same effect and 'safer'.<a name="line.161"></a>
-<span class="sourceLineNo">162</span>      return ByteBufferUtils.compareTo(left.getQualifierArray(),<a name="line.162"></a>
-<span class="sourceLineNo">163</span>          left.getQualifierOffset(), left.getQualifierLength(),<a name="line.163"></a>
-<span class="sourceLineNo">164</span>          ((ByteBufferExtendedCell)right).getQualifierByteBuffer(),<a name="line.164"></a>
-<span class="sourceLineNo">165</span>          ((ByteBufferExtendedCell)right).getQualifierPosition(), right.getQualifierLength());<a name="line.165"></a>
-<span class="sourceLineNo">166</span>    }<a name="line.166"></a>
-<span class="sourceLineNo">167</span>    return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(),<a name="line.167"></a>
-<span class="sourceLineNo">168</span>        left.getQualifierLength(), right.getQualifierArray(), right.getQualifierOffset(),<a name="line.168"></a>
-<span class="sourceLineNo">169</span>        right.getQualifierLength());<a name="line.169"></a>
-<span class="sourceLineNo">170</span>  }<a name="line.170"></a>
-<span class="sourceLineNo">171</span><a name="line.171"></a>
-<span class="sourceLineNo">172</span>  /**<a name="line.172"></a>
-<span class="sourceLineNo">173</span>   * Compares the rows of the left and right cell.<a name="line.173"></a>
-<span class="sourceLineNo">174</span>   * For the hbase:meta case this method is overridden such that it can handle hbase:meta cells.<a name="line.174"></a>
-<span class="sourceLineNo">175</span>   * The caller should ensure using the appropriate comparator for hbase:meta.<a name="line.175"></a>
-<span class="sourceLineNo">176</span>   * @param left<a name="line.176"></a>
-<span class="sourceLineNo">177</span>   * @param right<a name="line.177"></a>
-<span class="sourceLineNo">178</span>   * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise<a name="line.178"></a>
-<span class="sourceLineNo">179</span>   */<a name="line.179"></a>
-<span class="sourceLineNo">180</span>  @Override<a name="line.180"></a>
-<span class="sourceLineNo">181</span>  public int compareRows(final Cell left, final Cell right) {<a name="line.181"></a>
-<span class="sourceLineNo">182</span>    // left and right can be exactly the same at the beginning of a row<a name="line.182"></a>
-<span class="sourceLineNo">183</span>    if (left == right) {<a name="line.183"></a>
-<span class="sourceLineNo">184</span>      return 0;<a name="line.184"></a>
-<span class="sourceLineNo">185</span>    }<a name="line.185"></a>
-<span class="sourceLineNo">186</span>    if (left instanceof ByteBufferExtendedCell &amp;&amp; right instanceof ByteBufferExtendedCell) {<a name="line.186"></a>
-<span class="sourceLineNo">187</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(),<a name="line.187"></a>
-<span class="sourceLineNo">188</span>          ((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(),<a name="line.188"></a>
-<span class="sourceLineNo">189</span>          ((ByteBufferExtendedCell) right).getRowByteBuffer(),<a name="line.189"></a>
-<span class="sourceLineNo">190</span>          ((ByteBufferExtendedCell) right).getRowPosition(), right.getRowLength());<a name="line.190"></a>
-<span class="sourceLineNo">191</span>    }<a name="line.191"></a>
-<span class="sourceLineNo">192</span>    if (left instanceof ByteBufferExtendedCell) {<a name="line.192"></a>
-<span class="sourceLineNo">193</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(),<a name="line.193"></a>
-<span class="sourceLineNo">194</span>          ((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(),<a name="line.194"></a>
-<span class="sourceLineNo">195</span>          right.getRowArray(), right.getRowOffset(), right.getRowLength());<a name="line.195"></a>
-<span class="sourceLineNo">196</span>    }<a name="line.196"></a>
-<span class="sourceLineNo">197</span>    if (right instanceof ByteBufferExtendedCell) {<a name="line.197"></a>
-<span class="sourceLineNo">198</span>      // Notice how we flip the order of the compare here. We used to negate the return value but<a name="line.198"></a>
-<span class="sourceLineNo">199</span>      // see what FindBugs says<a name="line.199"></a>
-<span class="sourceLineNo">200</span>      // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO<a name="line.200"></a>
-<span class="sourceLineNo">201</span>      // It suggest flipping the order to get same effect and 'safer'.<a name="line.201"></a>
-<span class="sourceLineNo">202</span>      return ByteBufferUtils.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(),<a name="line.202"></a>
-<span class="sourceLineNo">203</span>          ((ByteBufferExtendedCell)right).getRowByteBuffer(),<a name="line.203"></a>
-<span class="sourceLineNo">204</span>          ((ByteBufferExtendedCell)right).getRowPosition(), right.getRowLength());<a name="line.204"></a>
-<span class="sourceLineNo">205</span>    }<a name="line.205"></a>
-<span class="sourceLineNo">206</span>    return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(),<a name="line.206"></a>
-<span class="sourceLineNo">207</span>        right.getRowArray(), right.getRowOffset(), right.getRowLength());<a name="line.207"></a>
-<span class="sourceLineNo">208</span>  }<a name="line.208"></a>
-<span class="sourceLineNo">209</span><a name="line.209"></a>
-<span class="sourceLineNo">210</span>  /**<a name="line.210"></a>
-<span class="sourceLineNo">211</span>   * Compares the row part of the cell with a simple plain byte[] like the<a name="line.211"></a>
-<span class="sourceLineNo">212</span>   * stopRow in Scan. This should be used with context where for hbase:meta<a name="line.212"></a>
-<span class="sourceLineNo">213</span>   * cells the {{@link #META_COMPARATOR} should be used<a name="line.213"></a>
-<span class="sourceLineNo">214</span>   *<a name="line.214"></a>
-<span class="sourceLineNo">215</span>   * @param left<a name="line.215"></a>
-<span class="sourceLineNo">216</span>   *          the cell to be compared<a name="line.216"></a>
+<span class="sourceLineNo">073</span>    int diff = 0;<a name="line.73"></a>
+<span class="sourceLineNo">074</span>    if (a instanceof ByteBufferKeyValue &amp;&amp; b instanceof ByteBufferKeyValue) {<a name="line.74"></a>
+<span class="sourceLineNo">075</span>      diff = compareByteBufferKeyValue((ByteBufferKeyValue)a, (ByteBufferKeyValue)b);<a name="line.75"></a>
+<span class="sourceLineNo">076</span>      if (diff != 0) {<a name="line.76"></a>
+<span class="sourceLineNo">077</span>        return diff;<a name="line.77"></a>
+<span class="sourceLineNo">078</span>      }<a name="line.78"></a>
+<span class="sourceLineNo">079</span>    } else {<a name="line.79"></a>
+<span class="sourceLineNo">080</span>      diff = compareRows(a, b);<a name="line.80"></a>
+<span class="sourceLineNo">081</span>      if (diff != 0) {<a name="line.81"></a>
+<span class="sourceLineNo">082</span>        return diff;<a name="line.82"></a>
+<span class="sourceLineNo">083</span>      }<a name="line.83"></a>
+<span class="sourceLineNo">084</span><a name="line.84"></a>
+<span class="sourceLineNo">085</span>      diff = compareWithoutRow(a, b);<a name="line.85"></a>
+<span class="sourceLineNo">086</span>      if (diff != 0) {<a name="line.86"></a>
+<span class="sourceLineNo">087</span>        return diff;<a name="line.87"></a>
+<span class="sourceLineNo">088</span>      }<a name="line.88"></a>
+<span class="sourceLineNo">089</span>    }<a name="line.89"></a>
+<span class="sourceLineNo">090</span><a name="line.90"></a>
+<span class="sourceLineNo">091</span>    // Negate following comparisons so later edits show up first mvccVersion: later sorts first<a name="line.91"></a>
+<span class="sourceLineNo">092</span>    return ignoreSequenceid? diff: Longs.compare(b.getSequenceId(), a.getSequenceId());<a name="line.92"></a>
+<span class="sourceLineNo">093</span>  }<a name="line.93"></a>
+<span class="sourceLineNo">094</span><a name="line.94"></a>
+<span class="sourceLineNo">095</span>  /**<a name="line.95"></a>
+<span class="sourceLineNo">096</span>   * Specialized comparator for the ByteBufferKeyValue type exclusivesly.<a name="line.96"></a>
+<span class="sourceLineNo">097</span>   * Caches deserialized lengths of rows and families, etc., and reuses them where it can<a name="line.97"></a>
+<span class="sourceLineNo">098</span>   * (ByteBufferKeyValue has been changed to be amenable to our providing pre-made lengths, etc.)<a name="line.98"></a>
+<span class="sourceLineNo">099</span>   */<a name="line.99"></a>
+<span class="sourceLineNo">100</span>  private final int compareByteBufferKeyValue(ByteBufferKeyValue left, ByteBufferKeyValue right) {<a name="line.100"></a>
+<span class="sourceLineNo">101</span>    // Compare Rows. Cache row length.<a name="line.101"></a>
+<span class="sourceLineNo">102</span>    int leftRowLength = left.getRowLength();<a name="line.102"></a>
+<span class="sourceLineNo">103</span>    int rightRowLength = right.getRowLength();<a name="line.103"></a>
+<span class="sourceLineNo">104</span>    int diff = ByteBufferUtils.compareTo(<a name="line.104"></a>
+<span class="sourceLineNo">105</span>        left.getRowByteBuffer(), left.getRowPosition(), leftRowLength,<a name="line.105"></a>
+<span class="sourceLineNo">106</span>        right.getRowByteBuffer(), right.getRowPosition(), rightRowLength);<a name="line.106"></a>
+<span class="sourceLineNo">107</span>    if (diff != 0) {<a name="line.107"></a>
+<span class="sourceLineNo">108</span>      return diff;<a name="line.108"></a>
+<span class="sourceLineNo">109</span>    }<a name="line.109"></a>
+<span class="sourceLineNo">110</span><a name="line.110"></a>
+<span class="sourceLineNo">111</span>    // If the column is not specified, the "minimum" key type appears the<a name="line.111"></a>
+<span class="sourceLineNo">112</span>    // latest in the sorted order, regardless of the timestamp. This is used<a name="line.112"></a>
+<span class="sourceLineNo">113</span>    // for specifying the last key/value in a given row, because there is no<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    // "lexicographically last column" (it would be infinitely long). The<a name="line.114"></a>
+<span class="sourceLineNo">115</span>    // "maximum" key type does not need this behavior.<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    // Copied from KeyValue. This is bad in that we can't do memcmp w/ special rules like this.<a name="line.116"></a>
+<span class="sourceLineNo">117</span>    // I tried to get rid of the above but scanners depend on it. TODO.<a name="line.117"></a>
+<span class="sourceLineNo">118</span>    int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength);<a name="line.118"></a>
+<span class="sourceLineNo">119</span>    int leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition);<a name="line.119"></a>
+<span class="sourceLineNo">120</span>    int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength);<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition);<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    int leftKeyLength = left.getKeyLength();<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength,<a name="line.123"></a>
+<span class="sourceLineNo">124</span>        leftFamilyLength);<a name="line.124"></a>
+<span class="sourceLineNo">125</span>    byte leftType = left.getTypeByte(leftKeyLength);<a name="line.125"></a>
+<span class="sourceLineNo">126</span>    if (leftFamilyLength + leftQualifierLength == 0 &amp;&amp; leftType == Type.Minimum.getCode()) {<a name="line.126"></a>
+<span class="sourceLineNo">127</span>      // left is "bigger", i.e. it appears later in the sorted order<a name="line.127"></a>
+<span class="sourceLineNo">128</span>      return 1;<a name="line.128"></a>
+<span class="sourceLineNo">129</span>    }<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    int rightKeyLength = right.getKeyLength();<a name="line.130"></a>
+<span class="sourceLineNo">131</span>    int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength,<a name="line.131"></a>
+<span class="sourceLineNo">132</span>        rightFamilyLength);<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    byte rightType = right.getTypeByte(rightKeyLength);<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    if (rightFamilyLength + rightQualifierLength == 0 &amp;&amp; rightType == Type.Minimum.getCode()) {<a name="line.134"></a>
+<span class="sourceLineNo">135</span>      return -1;<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    }<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    // Compare families.<a name="line.137"></a>
+<span class="sourceLineNo">138</span>    int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition);<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition);<a name="line.139"></a>
+<span class="sourceLineNo">140</span>    diff = ByteBufferUtils.compareTo(<a name="line.140"></a>
+<span class="sourceLineNo">141</span>        left.getFamilyByteBuffer(), leftFamilyPosition, leftFamilyLength,<a name="line.141"></a>
+<span class="sourceLineNo">142</span>        right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength);<a name="line.142"></a>
+<span class="sourceLineNo">143</span>    if (diff != 0) {<a name="line.143"></a>
+<span class="sourceLineNo">144</span>      return diff;<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    }<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    // Compare qualifiers<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    diff = ByteBufferUtils.compareTo(left.getQualifierByteBuffer(),<a name="line.147"></a>
+<span class="sourceLineNo">148</span>        left.getQualifierPosition(leftFamilyPosition, leftFamilyLength), leftQualifierLength,<a name="line.148"></a>
+<span class="sourceLineNo">149</span>        right.getQualifierByteBuffer(),<a name="line.149"></a>
+<span class="sourceLineNo">150</span>        right.getQualifierPosition(rightFamilyPosition, rightFamilyLength),<a name="line.150"></a>
+<span class="sourceLineNo">151</span>        rightQualifierLength);<a name="line.151"></a>
+<span class="sourceLineNo">152</span>    if (diff != 0) {<a name="line.152"></a>
+<span class="sourceLineNo">153</span>      return diff;<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    }<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    // Timestamps.<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    diff = compareTimestamps(left.getTimestamp(leftKeyLength), right.getTimestamp(rightKeyLength));<a name="line.156"></a>
+<span class="sourceLineNo">157</span>    if (diff != 0) {<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      return diff;<a name="line.158"></a>
+<span class="sourceLineNo">159</span>    }<a name="line.159"></a>
+<span class="sourceLineNo">160</span>    // Compare types. Let the delete types sort ahead of puts; i.e. types<a name="line.160"></a>
+<span class="sourceLineNo">161</span>    // of higher numbers sort before those of lesser numbers. Maximum (255)<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    // appears ahead of everything, and minimum (0) appears after<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    // everything.<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    return (0xff &amp; rightType) - (0xff &amp; leftType);<a name="line.164"></a>
+<span class="sourceLineNo">165</span>  }<a name="line.165"></a>
+<span class="sourceLineNo">166</span><a name="line.166"></a>
+<span class="sourceLineNo">167</span>  /**<a name="line.167"></a>
+<span class="sourceLineNo">168</span>   * Compares the family and qualifier part of the cell<a name="line.168"></a>
+<span class="sourceLineNo">169</span>   * @param left the left cell<a name="line.169"></a>
+<span class="sourceLineNo">170</span>   * @param right the right cell<a name="line.170"></a>
+<span class="sourceLineNo">171</span>   * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise<a name="line.171"></a>
+<span class="sourceLineNo">172</span>   */<a name="line.172"></a>
+<span class="sourceLineNo">173</span>  public final int compareColumns(final Cell left, final Cell right) {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    int diff = compareFamilies(left, right);<a name="line.174"></a>
+<span class="sourceLineNo">175</span>    if (diff != 0) {<a name="line.175"></a>
+<span class="sourceLineNo">176</span>      return diff;<a name="line.176"></a>
+<span class="sourceLineNo">177</span>    }<a name="line.177"></a>
+<span class="sourceLineNo">178</span>    return compareQualifiers(left, right);<a name="line.178"></a>
+<span class="sourceLineNo">179</span>  }<a name="line.179"></a>
+<span class="sourceLineNo">180</span><a name="line.180"></a>
+<span class="sourceLineNo">181</span>  /**<a name="line.181"></a>
+<span class="sourceLineNo">182</span>   * Compare the families of left and right cell<a name="line.182"></a>
+<span class="sourceLineNo">183</span>   * @param left<a name="line.183"></a>
+<span class="sourceLineNo">184</span>   * @param right<a name="line.184"></a>
+<span class="sourceLineNo">185</span>   * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise<a name="line.185"></a>
+<span class="sourceLineNo">186</span>   */<a name="line.186"></a>
+<span class="sourceLineNo">187</span>  @Override<a name="line.187"></a>
+<span class="sourceLineNo">188</span>  public final int compareFamilies(Cell left, Cell right) {<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    if (left instanceof ByteBufferExtendedCell &amp;&amp; right instanceof ByteBufferExtendedCell) {<a name="line.189"></a>
+<span class="sourceLineNo">190</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),<a name="line.190"></a>
+<span class="sourceLineNo">191</span>          ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(),<a name="line.191"></a>
+<span class="sourceLineNo">192</span>          ((ByteBufferExtendedCell) right).getFamilyByteBuffer(),<a name="line.192"></a>
+<span class="sourceLineNo">193</span>          ((ByteBufferExtendedCell) right).getFamilyPosition(), right.getFamilyLength());<a name="line.193"></a>
+<span class="sourceLineNo">194</span>    }<a name="line.194"></a>
+<span class="sourceLineNo">195</span>    if (left instanceof ByteBufferExtendedCell) {<a name="line.195"></a>
+<span class="sourceLineNo">196</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),<a name="line.196"></a>
+<span class="sourceLineNo">197</span>          ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(),<a name="line.197"></a>
+<span class="sourceLineNo">198</span>          right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());<a name="line.198"></a>
+<span class="sourceLineNo">199</span>    }<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    if (right instanceof ByteBufferExtendedCell) {<a name="line.200"></a>
+<span class="sourceLineNo">201</span>      // Notice how we flip the order of the compare here. We used to negate the return value but<a name="line.201"></a>
+<span class="sourceLineNo">202</span>      // see what FindBugs says<a name="line.202"></a>
+<span class="sourceLineNo">203</span>      // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO<a name="line.203"></a>
+<span class="sourceLineNo">204</span>      // It suggest flipping the order to get same effect and 'safer'.<a name="line.204"></a>
+<span class="sourceLineNo">205</span>      return ByteBufferUtils.compareTo(<a name="line.205"></a>
+<span class="sourceLineNo">206</span>          left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),<a name="line.206"></a>
+<span class="sourceLineNo">207</span>          ((ByteBufferExtendedCell)right).getFamilyByteBuffer(),<a name="line.207"></a>
+<span class="sourceLineNo">208</span>          ((ByteBufferExtendedCell)right).getFamilyPosition(), right.getFamilyLength());<a name="line.208"></a>
+<span class="sourceLineNo">209</span>    }<a name="line.209"></a>
+<span class="sourceLineNo">210</span>    return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),<a name="line.210"></a>
+<span class="sourceLineNo">211</span>        right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());<a name="line.211"></a>
+<span class="sourceLineNo">212</span>  }<a name="line.212"></a>
+<span class="sourceLineNo">213</span><a name="line.213"></a>
+<span class="sourceLineNo">214</span>  /**<a name="line.214"></a>
+<span class="sourceLineNo">215</span>   * Compare the qualifiers part of the left and right cells.<a name="line.215"></a>
+<span class="sourceLineNo">216</span>   * @param left<a name="line.216"></a>
 <span class="sourceLineNo">217</span>   * @param right<a name="line.217"></a>
-<span class="sourceLineNo">218</span>   *          the kv serialized byte[] to be compared with<a name="line.218"></a>
-<span class="sourceLineNo">219</span>   * @param roffset<a name="line.219"></a>
-<span class="sourceLineNo">220</span>   *          the offset in the byte[]<a name="line.220"></a>
-<span class="sourceLineNo">221</span>   * @param rlength<a name="line.221"></a>
-<span class="sourceLineNo">222</span>   *          the length in the byte[]<a name="line.222"></a>
-<span class="sourceLineNo">223</span>   * @return 0 if both cell and the byte[] are equal, 1 if the cell is bigger<a name="line.223"></a>
-<span class="sourceLineNo">224</span>   *         than byte[], -1 otherwise<a name="line.224"></a>
-<span class="sourceLineNo">225</span>   */<a name="line.225"></a>
-<span class="sourceLineNo">226</span>  @Override<a name="line.226"></a>
-<span class="sourceLineNo">227</span>  public int compareRows(Cell left, byte[] right, int roffset, int rlength) {<a name="line.227"></a>
-<span class="sourceLineNo">228</span>    if (left instanceof ByteBufferExtendedCell) {<a name="line.228"></a>
-<span class="sourceLineNo">229</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(),<a name="line.229"></a>
-<span class="sourceLineNo">230</span>          ((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(), right,<a name="line.230"></a>
-<span class="sourceLineNo">231</span>          roffset, rlength);<a name="line.231"></a>
-<span class="sourceLineNo">232</span>    }<a name="line.232"></a>
-<span class="sourceLineNo">233</span>    return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right,<a name="line.233"></a>
-<span class="sourceLineNo">234</span>        roffset, rlength);<a name="line.234"></a>
-<span class="sourceLineNo">235</span>  }<a name="line.235"></a>
-<span class="sourceLineNo">236</span><a name="line.236"></a>
-<span class="sourceLineNo">237</span>  @Override<a name="line.237"></a>
-<span class="sourceLineNo">238</span>  public final int compareWithoutRow(final Cell left, final Cell right) {<a name="line.238"></a>
-<span class="sourceLineNo">239</span>    // If the column is not specified, the "minimum" key type appears the<a name="line.239"></a>
-<span class="sourceLineNo">240</span>    // latest in the sorted order, regardless of the timestamp. This is used<a name="line.240"></a>
-<span class="sourceLineNo">241</span>    // for specifying the last key/value in a given row, because there is no<a name="line.241"></a>
-<span class="sourceLineNo">242</span>    // "lexicographically last column" (it would be infinitely long). The<a name="line.242"></a>
-<span class="sourceLineNo">243</span>    // "maximum" key type does not need this behavior.<a name="line.243"></a>
-<span class="sourceLineNo">244</span>    // Copied from KeyValue. This is bad in that we can't do memcmp w/ special rules like this.<a name="line.244"></a>
-<span class="sourceLineNo">245</span>    int lFamLength = left.getFamilyLength();<a name="line.245"></a>
-<span class="sourceLineNo">246</span>    int rFamLength = right.getFamilyLength();<a name="line.246"></a>
-<span class="sourceLineNo">247</span>    int lQualLength = left.getQualifierLength();<a name="line.247"></a>
-<span class="sourceLineNo">248</span>    int rQualLength = right.getQualifierLength();<a name="line.248"></a>
-<span class="sourceLineNo">249</span>    if (lFamLength + lQualLength == 0<a name="line.249"></a>
-<span class="sourceLineNo">250</span>          &amp;&amp; left.getTypeByte() == Type.Minimum.getCode()) {<a name="line.250"></a>
-<span class="sourceLineNo">251</span>      // left is "bigger", i.e. it appears later in the sorted order<a name="line.251"></a>
-<span class="sourceLineNo">252</span>      return 1;<a name="line.252"></a>
-<span class="sourceLineNo">253</span>    }<a name="line.253"></a>
-<span class="sourceLineNo">254</span>    if (rFamLength + rQualLength == 0<a name="line.254"></a>
-<span class="sourceLineNo">255</span>        &amp;&amp; right.getTypeByte() == Type.Minimum.getCode()) {<a name="line.255"></a>
-<span class="sourceLineNo">256</span>      return -1;<a name="line.256"></a>
-<span class="sourceLineNo">257</span>    }<a name="line.257"></a>
-<span class="sourceLineNo">258</span>    if (lFamLength != rFamLength) {<a name="line.258"></a>
-<span class="sourceLineNo">259</span>      // comparing column family is enough.<a name="line.259"></a>
-<span class="sourceLineNo">260</span>      return compareFamilies(left, right);<a name="line.260"></a>
-<span class="sourceLineNo">261</span>    }<a name="line.261"></a>
-<span class="sourceLineNo">262</span>    // Compare cf:qualifier<a name="line.262"></a>
-<span class="sourceLineNo">263</span>    int diff = compareColumns(left, right);<a name="line.263"></a>
-<span class="sourceLineNo">264</span>    if (diff != 0) return diff;<a name="line.264"></a>
-<span class="sourceLineNo">265</span><a name="line.265"></a>
-<span class="sourceLineNo">266</span>    diff = compareTimestamps(left, right);<a name="line.266"></a>
-<span class="sourceLineNo">267</span>    if (diff != 0) return diff;<a name="line.267"></a>
-<span class="sourceLineNo">268</span><a name="line.268"></a>
-<span class="sourceLineNo">269</span>    // Compare types. Let the delete types sort ahead of puts; i.e. types<a name="line.269"></a>
-<span class="sourceLineNo">270</span>    // of higher numbers sort before those of lesser numbers. Maximum (255)<a name="line.270"></a>
-<span class="sourceLineNo">271</span>    // appears ahead of everything, and minimum (0) appears after<a name="line.271"></a>
-<span class="sourceLineNo">272</span>    // everything.<a name="line.272"></a>
-<span class="sourceLineNo">273</span>    return (0xff &amp; right.getTypeByte()) - (0xff &amp; left.getTypeByte());<a name="line.273"></a>
-<span class="sourceLineNo">274</span>  }<a name="line.274"></a>
-<span class="sourceLineNo">275</span><a name="line.275"></a>
-<span class="sourceLineNo">276</span>  /**<a name="line.276"></a>
-<span class="sourceLineNo">277</span>   * Compares cell's timestamps in DESCENDING order.<a name="line.277"></a>
-<span class="sourceLineNo">278</span>   * The below older timestamps sorting ahead of newer timestamps looks<a name="line.278"></a>
-<span class="sourceLineNo">279</span>   * wrong but it is intentional. This way, newer timestamps are first<a name="line.279"></a>
-<span class="sourceLineNo">280</span>   * found when we iterate over a memstore and newer versions are the<a name="line.280"></a>
-<span class="sourceLineNo">281</span>   * first we trip over when reading from a store file.<a name="line.281"></a>
-<span class="sourceLineNo">282</span>   * @return 1 if left's timestamp &amp;lt; right's timestamp<a name="line.282"></a>
-<span class="sourceLineNo">283</span>   *         -1 if left's timestamp &amp;gt; right's timestamp<a name="line.283"></a>
-<span class="sourceLineNo">284</span>   *         0 if both timestamps are equal<a name="line.284"></a>
-<span class="sourceLineNo">285</span>   */<a name="line.285"></a>
-<span class="sourceLineNo">286</span>  @Override<a name="line.286"></a>
-<span class="sourceLineNo">287</span>  public int compareTimestamps(final Cell left, final Cell right) {<a name="line.287"></a>
-<span class="sourceLineNo">288</span>    return compareTimestamps(left.getTimestamp(), right.getTimestamp());<a name="line.288"></a>
-<span class="sourceLineNo">289</span>  }<a name="line.289"></a>
-<span class="sourceLineNo">290</span><a name="line.290"></a>
-<span class="sourceLineNo">291</span><a name="line.291"></a>
-<span class="sourceLineNo">292</span>  /**<a name="line.292"></a>
-<span class="sourceLineNo">293</span>   * Compares timestamps in DESCENDING order.<a name="line.293"></a>
-<span class="sourceLineNo">294</span>   * The below older timestamps sorting ahead of newer timestamps looks<a name="line.294"></a>
-<span class="sourceLineNo">295</span>   * wrong but it is intentional. This way, newer timestamps are first<a name="line.295"></a>
-<span class="sourceLineNo">296</span>   * found when we iterate over a memstore and newer versions are the<a name="line.296"></a>
-<span class="sourceLineNo">297</span>   * first we trip over when reading from a store file.<a name="line.297"></a>
-<span class="sourceLineNo">298</span>   * @return 1 if left timestamp &amp;lt; right timestamp<a name="line.298"></a>
-<span class="sourceLineNo">299</span>   *         -1 if left timestamp &amp;gt; right timestamp<a name="line.299"></a>
-<span class="sourceLineNo">300</span>   *         0 if both timestamps are equal<a name="line.300"></a>
-<span class="sourceLineNo">301</span>   */<a name="line.301"></a>
-<span class="sourceLineNo">302</span>  @Override<a name="line.302"></a>
-<span class="sourceLineNo">303</span>  public int compareTimestamps(final long ltimestamp, final long rtimestamp) {<a name="line.303"></a>
-<span class="sourceLineNo">304</span>    if (ltimestamp &lt; rtimestamp) {<a name="line.304"></a>
-<span class="sourceLineNo">305</span>      return 1;<a name="line.305"></a>
-<span class="sourceLineNo">306</span>    } else if (ltimestamp &gt; rtimestamp) {<a name="line.306"></a>
-<span class="sourceLineNo">307</span>      return -1;<a name="line.307"></a>
-<span class="sourceLineNo">308</span>    }<a name="line.308"></a>
-<span class="sourceLineNo">309</span>    return 0;<a name="line.309"></a>
-<span class="sourceLineNo">310</span>  }<a name="line.310"></a>
-<span class="sourceLineNo">311</span><a name="line.311"></a>
-<span class="sourceLineNo">312</span>  /**<a name="line.312"></a>
-<span class="sourceLineNo">313</span>   * A {@link CellComparatorImpl} for &lt;code&gt;hbase:meta&lt;/code&gt; catalog table<a name="line.313"></a>
-<span class="sourceLineNo">314</span>   * {@link KeyValue}s.<a name="line.314"></a>
-<span class="sourceLineNo">315</span>   */<a name="line.315"></a>
-<span class="sourceLineNo">316</span>  public static class MetaCellComparator extends CellComparatorImpl {<a name="line.316"></a>
-<span class="sourceLineNo">317</span><a name="line.317"></a>
-<span class="sourceLineNo">318</span>    @Override<a name="line.318"></a>
-<span class="sourceLineNo">319</span>    public int compareRows(final Cell left, final Cell right) {<a name="line.319"></a>
-<span class="sourceLineNo">320</span>      return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(),<a name="line.320"></a>
-<span class="sourceLineNo">321</span>          right.getRowArray(), right.getRowOffset(), right.getRowLength());<a name="line.321"></a>
-<span class="sourceLineNo">322</span>    }<a name="line.322"></a>
-<span class="sourceLineNo">323</span><a name="line.323"></a>
-<span class="sourceLineNo">324</span>    @Override<a name="line.324"></a>
-<span class="sourceLineNo">325</span>    public int compareRows(Cell left, byte[] right, int roffset, int rlength) {<a name="line.325"></a>
-<span class="sourceLineNo">326</span>      return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right,<a name="line.326"></a>
-<span class="sourceLineNo">327</span>          roffset, rlength);<a name="line.327"></a>
-<span class="sourceLineNo">328</span>    }<a name="line.328"></a>
-<span class="sourceLineNo">329</span><a name="line.329"></a>
-<span class="sourceLineNo">330</span>    private int compareRows(byte[] left, int loffset, int llength, byte[] right, int roffset,<a name="line.330"></a>
-<span class="sourceLineNo">331</span>        int rlength) {<a name="line.331"></a>
-<span class="sourceLineNo">332</span>      int leftDelimiter = Bytes.searchDelimiterIndex(left, loffset, llength, HConstants.DELIMITER);<a name="line.332"></a>
-<span class="sourceLineNo">333</span>      int rightDelimiter = Bytes<a name="line.333"></a>
-<span class="sourceLineNo">334</span>          .searchDelimiterIndex(right, roffset, rlength, HConstants.DELIMITER);<a name="line.334"></a>
-<span class="sourceLineNo">335</span>      // Compare up to the delimiter<a name="line.335"></a>
-<span class="sourceLineNo">336</span>      int lpart = (leftDelimiter &lt; 0 ? llength : leftDelimiter - loffset);<a name="line.336"></a>
-<span class="sourceLineNo">337</span>      int rpart = (rightDelimiter &lt; 0 ? rlength : rightDelimiter - roffset);<a name="line.337"></a>
-<span class="sourceLineNo">338</span>      int result = Bytes.compareTo(left, loffset, lpart, right, roffset, rpart);<a name="line.338"></a>
-<span class="sourceLineNo">339</span>      if (result != 0) {<a name="line.339"></a>
-<span class="sourceLineNo">340</span>        return result;<a name="line.340"></a>
-<span class="sourceLineNo">341</span>      } else {<a name="line.341"></a>
-<span class="sourceLineNo">342</span>        if (leftDelimiter &lt; 0 &amp;&amp; rightDelimiter &gt;= 0) {<a name="line.342"></a>
-<span class="sourceLineNo">343</span>          return -1;<a name="line.343"></a>
-<span class="sourceLineNo">344</span>        } else if (rightDelimiter &lt; 0 &amp;&amp; leftDelimiter &gt;= 0) {<a name="line.344"></a>
-<span class="sourceLineNo">345</span>          return 1;<a name="line.345"></a>
-<span class="sourceLineNo">346</span>        } else if (leftDelimiter &lt; 0 &amp;&amp; rightDelimiter &lt; 0) {<a name="line.346"></a>
-<span class="sourceLineNo">347</span>          return 0;<a name="line.347"></a>
-<span class="sourceLineNo">348</span>        }<a name="line.348"></a>
-<span class="sourceLineNo">349</span>      }<a name="line.349"></a>
-<span class="sourceLineNo">350</span>      // Compare middle bit of the row.<a name="line.350"></a>
-<span class="sourceLineNo">351</span>      // Move past delimiter<a name="line.351"></a>
-<span class="sourceLineNo">352</span>      leftDelimiter++;<a name="line.352"></a>
-<span class="sourceLineNo">353</span>      rightDelimiter++;<a name="line.353"></a>
-<span class="sourceLineNo">354</span>      int leftFarDelimiter = Bytes.searchDelimiterIndexInReverse(left, leftDelimiter, llength<a name="line.354"></a>
-<span class="sourceLineNo">355</span>          - (leftDelimiter - loffset), HConstants.DELIMITER);<a name="line.355"></a>
-<span class="sourceLineNo">356</span>      int rightFarDelimiter = Bytes.searchDelimiterIndexInReverse(right, rightDelimiter, rlength<a name="line.356"></a>
-<span class="sourceLineNo">357</span>          - (rightDelimiter - roffset), HConstants.DELIMITER);<a name="line.357"></a>
-<span class="sourceLineNo">358</span>      // Now compare middlesection of row.<a name="line.358"></a>
-<span class="sourceLineNo">359</span>      lpart = (leftFarDelimiter &lt; 0 ? llength + loffset : leftFarDelimiter) - leftDelimiter;<a name="line.359"></a>
-<span class="sourceLineNo">360</span>      rpart = (rightFarDelimiter &lt; 0 ? rlength + roffset : rightFarDelimiter) - rightDelimiter;<a name="line.360"></a>
-<span class="sourceLineNo">361</span>      result = Bytes.compareTo(left, leftDelimiter, lpart, right, rightDelimiter, rpart);<a name="line.361"></a>
-<span class="sourceLineNo">362</span>      if (result != 0) {<a name="line.362"></a>
-<span class="sourceLineNo">363</span>        return result;<a name="line.363"></a>
-<span class="sourceLineNo">364</span>      } else {<a name="line.364"></a>
-<span class="sourceLineNo">365</span>        if (leftDelimiter &lt; 0 &amp;&amp; rightDelimiter &gt;= 0) {<a name="line.365"></a>
-<span class="sourceLineNo">366</span>          return -1;<a name="line.366"></a>
-<span class="sourceLineNo">367</span>        } else if (rightDelimiter &lt; 0 &amp;&amp; leftDelimiter &gt;= 0) {<a name="line.367"></a>
-<span class="sourceLineNo">368</span>          return 1;<a name="line.368"></a>
-<span class="sourceLineNo">369</span>        } else if (leftDelimiter &lt; 0 &amp;&amp; rightDelimiter &lt; 0) {<a name="line.369"></a>
-<span class="sourceLineNo">370</span>          return 0;<a name="line.370"></a>
-<span class="sourceLineNo">371</span>        }<a name="line.371"></a>
-<span class="sourceLineNo">372</span>      }<a name="line.372"></a>
-<span class="sourceLineNo">373</span>      // Compare last part of row, the rowid.<a name="line.373"></a>
-<span class="sourceLineNo">374</span>      leftFarDelimiter++;<a name="line.374"></a>
-<span class="sourceLineNo">375</span>      rightFarDelimiter++;<a name="line.375"></a>
-<span class="sourceLineNo">376</span>      result = Bytes.compareTo(left, leftFarDelimiter, llength - (leftFarDelimiter - loffset),<a name="line.376"></a>
-<span class="sourceLineNo">377</span>          right, rightFarDelimiter, rlength - (rightFarDelimiter - roffset));<a name="line.377"></a>
-<span class="sourceLineNo">378</span>      return result;<a name="line.378"></a>
-<span class="sourceLineNo">379</span>    }<a name="line.379"></a>
-<span class="sourceLineNo">380</span>  }<a name="line.380"></a>
-<span class="sourceLineNo">381</span>}<a name="line.381"></a>
+<span class="sourceLineNo">218</span>   * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise<a name="line.218"></a>
+<span class="sourceLineNo">219</span>   */<a name="line.219"></a>
+<span class="sourceLineNo">220</span>  @Override<a name="line.220"></a>
+<span class="sourceLineNo">221</span>  public final int compareQualifiers(Cell left, Cell right) {<a name="line.221"></a>
+<span class="sourceLineNo">222</span>    if (left instanceof ByteBufferExtendedCell &amp;&amp; right instanceof ByteBufferExtendedCell) {<a name="line.222"></a>
+<span class="sourceLineNo">223</span>      return ByteBufferUtils<a name="line.223"></a>
+<span class="sourceLineNo">224</span>          .compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),<a name="line.224"></a>
+<span class="sourceLineNo">225</span>              ((ByteBufferExtendedCell) left).getQualifierPosition(),<a name="line.225"></a>
+<span class="sourceLineNo">226</span>              left.getQualifierLength(), ((ByteBufferExtendedCell) right).getQualifierByteBuffer(),<a name="line.226"></a>
+<span class="sourceLineNo">227</span>              ((ByteBufferExtendedCell) right).getQualifierPosition(),<a name="line.227"></a>
+<span class="sourceLineNo">228</span>              right.getQualifierLength());<a name="line.228"></a>
+<span class="sourceLineNo">229</span>    }<a name="line.229"></a>
+<span class="sourceLineNo">230</span>    if (left instanceof ByteBufferExtendedCell) {<a name="line.230"></a>
+<span class="sourceLineNo">231</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),<a name="line.231"></a>
+<span class="sourceLineNo">232</span>          ((ByteBufferExtendedCell) left).getQualifierPosition(), left.getQualifierLength(),<a name="line.232"></a>
+<span class="sourceLineNo">233</span>          right.getQualifierArray(), right.getQualifierOffset(), right.getQualifierLength());<a name="line.233"></a>
+<span class="sourceLineNo">234</span>    }<a name="line.234"></a>
+<span class="sourceLineNo">235</span>    if (right instanceof ByteBufferExtendedCell) {<a name="line.235"></a>
+<span class="sourceLineNo">236</span>      // Notice how we flip the order of the compare here. We used to negate the return value but<a name="line.236"></a>
+<span class="sourceLineNo">237</span>      // see what FindBugs says<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO<a name="line.238"></a>
+<span class="sourceLineNo">239</span>      // It suggest flipping the order to get same effect and 'safer'.<a name="line.239"></a>
+<span class="sourceLineNo">240</span>      return ByteBufferUtils.compareTo(left.getQualifierArray(),<a name="line.240"></a>
+<span class="sourceLineNo">241</span>          left.getQualifierOffset(), left.getQualifierLength(),<a name="line.241"></a>
+<span class="sourceLineNo">242</span>          ((ByteBufferExtendedCell)right).getQualifierByteBuffer(),<a name="line.242"></a>
+<span class="sourceLineNo">243</span>          ((ByteBufferExtendedCell)right).getQualifierPosition(), right.getQualifierLength());<a name="line.243"></a>
+<span class="sourceLineNo">244</span>    }<a name="line.244"></a>
+<span class="sourceLineNo">245</span>    return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(),<a name="line.245"></a>
+<span class="sourceLineNo">246</span>        left.getQualifierLength(), right.getQualifierArray(), right.getQualifierOffset(),<a name="line.246"></a>
+<span class="sourceLineNo">247</span>        right.getQualifierLength());<a name="line.247"></a>
+<span class="sourceLineNo">248</span>  }<a name="line.248"></a>
+<span class="sourceLineNo">249</span><a name="line.249"></a>
+<span class="sourceLineNo">250</span>  /**<a name="line.250"></a>
+<span class="sourceLineNo">251</span>   * Compares the rows of the left and right cell.<a name="line.251"></a>
+<span class="sourceLineNo">252</span>   * For the hbase:meta case this method is overridden such that it can handle hbase:meta cells.<a name="line.252"></a>
+<span class="sourceLineNo">253</span>   * The caller should ensure using the appropriate comparator for hbase:meta.<a name="line.253"></a>
+<span class="sourceLineNo">254</span>   * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise<a name="line.254"></a>
+<span class="sourceLineNo">255</span>   */<a name="line.255"></a>
+<span class="sourceLineNo">256</span>  @Override<a name="line.256"></a>
+<span class="sourceLineNo">257</span>  public int compareRows(final Cell left, final Cell right) {<a name="line.257"></a>
+<span class="sourceLineNo">258</span>    return compareRows(left, left.getRowLength(), right, right.getRowLength());<a name="line.258"></a>
+<span class="sourceLineNo">259</span>  }<a name="line.259"></a>
+<span class="sourceLineNo">260</span><a name="line.260"></a>
+<span class="sourceLineNo">261</span>  int compareRows(final Cell left, int leftRowLength, final Cell right, int rightRowLength) {<a name="line.261"></a>
+<span class="sourceLineNo">262</span>    // left and right can be exactly the same at the beginning of a row<a name="line.262"></a>
+<span class="sourceLineNo">263</span>    if (left == right) {<a name="line.263"></a>
+<span class="sourceLineNo">264</span>      return 0;<a name="line.264"></a>
+<span class="sourceLineNo">265</span>    }<a name="line.265"></a>
+<span class="sourceLineNo">266</span>    if (left instanceof ByteBufferExtendedCell &amp;&amp; right instanceof ByteBufferExtendedCell) {<a name="line.266"></a>
+<span class="sourceLineNo">267</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(),<a name="line.267"></a>
+<span class="sourceLineNo">268</span>          ((ByteBufferExtendedCell) left).getRowPosition(), leftRowLength,<a name="line.268"></a>
+<span class="sourceLineNo">269</span>          ((ByteBufferExtendedCell) right).getRowByteBuffer(),<a name="line.269"></a>
+<span class="sourceLineNo">270</span>          ((ByteBufferExtendedCell) right).getRowPosition(), rightRowLength);<a name="line.270"></a>
+<span class="sourceLineNo">271</span>    }<a name="line.271"></a>
+<span class="sourceLineNo">272</span>    if (left instanceof ByteBufferExtendedCell) {<a name="line.272"></a>
+<span class="sourceLineNo">273</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(),<a name="line.273"></a>
+<span class="sourceLineNo">274</span>          ((ByteBufferExtendedCell) left).getRowPosition(), leftRowLength,<a name="line.274"></a>
+<span class="sourceLineNo">275</span>          right.getRowArray(), right.getRowOffset(), rightRowLength);<a name="line.275"></a>
+<span class="sourceLineNo">276</span>    }<a name="line.276"></a>
+<span class="sourceLineNo">277</span>    if (right instanceof ByteBufferExtendedCell) {<a name="line.277"></a>
+<span class="sourceLineNo">278</span>      // Notice how we flip the order of the compare here. We used to negate the return value but<a name="line.278"></a>
+<span class="sourceLineNo">279</span>      // see what FindBugs says<a name="line.279"></a>
+<span class="sourceLineNo">280</span>      // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO<a name="line.280"></a>
+<span class="sourceLineNo">281</span>      // It suggest flipping the order to get same effect and 'safer'.<a name="line.281"></a>
+<span class="sourceLineNo">282</span>      return ByteBufferUtils.compareTo(left.getRowArray(), left.getRowOffset(), leftRowLength,<a name="line.282"></a>
+<span class="sourceLineNo">283</span>          ((ByteBufferExtendedCell)right).getRowByteBuffer(),<a name="line.283"></a>
+<span class="sourceLineNo">284</span>          ((ByteBufferExtendedCell)right).getRowPosition(), rightRowLength);<a name="line.284"></a>
+<span class="sourceLineNo">285</span>    }<a name="line.285"></a>
+<span class="sourceLineNo">286</span>    return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(),<a name="line.286"></a>
+<span class="sourceLineNo">287</span>        right.getRowArray(), right.getRowOffset(), right.getRowLength());<a name="line.287"></a>
+<span class="sourceLineNo">288</span>  }<a name="line.288"></a>
+<span class="sourceLineNo">289</span><a name="line.289"></a>
+<span class="sourceLineNo">290</span>  /**<a name="line.290"></a>
+<span class="sourceLineNo">291</span>   * Compares the row part of the cell with a simple plain byte[] like the<a name="line.291"></a>
+<span class="sourceLineNo">292</span>   * stopRow in Scan. This should be used with context where for hbase:meta<a name="line.292"></a>
+<span class="sourceLineNo">293</span>   * cells the {{@link #META_COMPARATOR} should be used<a name="line.293"></a>
+<span class="sourceLineNo">294</span>   *<a name="line.294"></a>
+<span class="sourceLineNo">295</span>   * @param left<a name="line.295"></a>
+<span class="sourceLineNo">296</span>   *          the cell to be compared<a name="line.296"></a>
+<span class="sourceLineNo">297</span>   * @param right<a name="line.297"></a>
+<span class="sourceLineNo">298</span>   *          the kv serialized byte[] to be compared with<a name="line.298"></a>
+<span class="sourceLineNo">299</span>   * @param roffset<a name="line.299"></a>
+<span class="sourceLineNo">300</span>   *          the offset in the byte[]<a name="line.300"></a>
+<span class="sourceLineNo">301</span>   * @param rlength<a name="line.301"></a>
+<span class="sourceLineNo">302</span>   *          the length in the byte[]<a name="line.302"></a>
+<span class="sourceLineNo">303</span>   * @return 0 if both cell and the byte[] are equal, 1 if the cell is bigger<a name="line.303"></a>
+<span class="sourceLineNo">304</span>   *         than byte[], -1 otherwise<a name="line.304"></a>
+<span class="sourceLineNo">305</span>   */<a name="line.305"></a>
+<span class="sourceLineNo">306</span>  @Override<a name="line.306"></a>
+<span class="sourceLineNo">307</span>  public int compareRows(Cell left, byte[] right, int roffset, int rlength) {<a name="line.307"></a>
+<span class="sourceLineNo">308</span>    if (left instanceof ByteBufferExtendedCell) {<a name="line.308"></a>
+<span class="sourceLineNo">309</span>      return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(),<a name="line.309"></a>
+<span class="sourceLineNo">310</span>          ((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(), right,<a name="line.310"></a>
+<span class="sourceLineNo">311</span>          roffset, rlength);<a name="line.311"></a>
+<span class="sourceLineNo">312</span>    }<a name="line.312"></a>
+<span class="sourceLineNo">313</span>    return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right,<a name="line.313"></a>
+<span class="sourceLineNo">314</span>        roffset, rlength);<a name="line.314"></a>
+<span class="sourceLineNo">315</span>  }<a name="line.315"></a>
+<span class="sourceLineNo">316</span><a name="line.316"></a>
+<span class="sourceLineNo">317</span>  @Override<a name="line.317"></a>
+<span class="sourceLineNo">318</span>  public final int compareWithoutRow(final Cell left, final Cell right) {<a name="line.318"></a>
+<span class="sourceLineNo">319</span>    // If the column is not specified, the "minimum" key type appears the<a name="line.319"></a>
+<span class="sourceLineNo">320</span>    // latest in the sorted order, regardless of the timestamp. This is used<a name="line.320"></a>
+<span class="sourceLineNo">321</span>    // for specifying the last key/value in a given row, because there is no<a name="line.321"></a>
+<span class="sourceLineNo">322</span>    // "lexicographically last column" (it would be infinitely long). The<a name="line.322"></a>
+<span class="sourceLineNo">323</span>    // "maximum" key type does not need this behavior.<a name="line.323"></a>
+<span class="sourceLineNo">324</span>    // Copied from KeyValue. This is bad in that we can't do memcmp w/ special rules like this.<a name="line.324"></a>
+<span class="sourceLineNo">325</span>    int lFamLength = left.getFamilyLength();<a name="line.325"></a>
+<span class="sourceLineNo">326</span>    int rFamLength = right.getFamilyLength();<a name="line.326"></a>
+<span class="sourceLineNo">327</span>    int lQualLength = left.getQualifierLength();<a name="line.327"></a>
+<span class="sourceLineNo">328</span>    int rQualLength = right.getQualifierLength();<a name="line.328"></a>
+<span class="sourceLineNo">329</span>    if (lFamLength + lQualLength == 0<a name="line.329"></a>
+<span class="sourceLineNo">330</span>          &amp;&amp; left.getTypeByte() == Type.Minimum.getCode()) {<a name="line.330"></a>
+<span class="sourceLineNo">331</span>      // left is "bigger", i.e. it appears later in the sorted order<a name="line.331"></a>
+<span class="sourceLineNo">332</span>      return 1;<a name="line.332"></a>
+<span class="sourceLineNo">333</span>    }<a name="line.333"></a>
+<span class="sourceLineNo">334</span>    if (rFamLength + rQualLength == 0<a name="line.334"></a>
+<span class="sourceLineNo">335</span>        &amp;&amp; right.getTypeByte() == Type.Minimum.getCode()) {<a name="line.335"></a>
+<span class="sourceLineNo">336</span>      return -1;<a name="line.336"></a>
+<span class="sourceLineNo">337</span>    }<a name="line.337"></a>
+<span class="sourceLineNo">338</span>    if (lFamLength != rFamLength) {<a name="line.338"></a>
+<span class="sourceLineNo">339</span>      // comparing column family is enough.<a name="line.339"></a>
+<span class="sourceLineNo">340</span>      return compareFamilies(left, right);<a name="line.340"></a>
+<span class="sourceLineNo">341</span>    }<a name="line.341"></a>
+<span class="sourceLineNo">342</span>    // Compare cf:qualifier<a name="line.342"></a>
+<span class="sourceLineNo">343</span>    int diff = compareColumns(left, right);<a name="line.343"></a>
+<span class="sourceLineNo">344</span>    if (diff != 0) {<a name="line.344"></a>
+<span class="sourceLineNo">345</span>      return diff;<a name="line.345"></a>
+<span class="sourceLineNo">346</span>    }<a name="line.346"></a>
+<span class="sourceLineNo">347</span><a name="line.347"></a>
+<span class="sourceLineNo">348</span>    diff = compareTimestamps(left, right);<a name="line.348"></a>
+<span class="sourceLineNo">349</span>    if (diff != 0) {<a name="line.349"></a>
+<span class="sourceLineNo">350</span>      return diff;<a name="line.350"></a>
+<span class="sourceLineNo">351</span>    }<a name="line.351"></a>
+<span class="sourceLineNo">352</span><a name="line.352"></a>
+<span class="sourceLineNo">353</span>    // Compare types. Let the delete types sort ahead of puts; i.e. types<a name="line.353"></a>
+<span class="sourceLineNo">354</span>    // of higher numbers sort before those of lesser numbers. Maximum (255)<a name="line.354"></a>
+<span class="sourceLineNo">355</span>    // appears ahead of everything, and minimum (0) appears after<a name="line.355"></a>
+<span class="sourceLineNo">356</span>    // everything.<a name="line.356"></a>
+<span class="sourceLineNo">357</span>    return (0xff &amp; right.getTypeByte()) - (0xff &amp; left.getTypeByte());<a name="line.357"></a>
+<span class="sourceLineNo">358</span>  }<a name="line.358"></a>
+<span class="sourceLineNo">359</span><a name="line.359"></a>
+<span class="sourceLineNo">360</span>  /**<a name="line.360"></a>
+<span class="sourceLineNo">361</span>   * Compares cell's timestamps in DESCENDING order.<a name="line.361"></a>
+<span class="sourceLineNo">362</span>   * The below older timestamps sorting ahead of newer timestamps looks<a name="line.362"></a>
+<span class="sourceLineNo">363</span>   * wrong but it is intentional. This way, newer timestamps are first<a name="line.363"></a>
+<span class="sourceLineNo">364</span>   * found when we iterate over a memstore and newer versions are the<a name="line.364"></a>
+<span class="sourceLineNo">365</span>   * first we trip over when reading from a store file.<a name="line.365"></a>
+<span class="sourceLineNo">366</span>   * @return 1 if left's timestamp &amp;lt; right's timestamp<a name="line.366"></a>
+<span class="sourceLineNo">367</span>   *         -1 if left's timestamp &amp;gt; right's timestamp<a name="line.367"></a>
+<span class="sourceLineNo">368</span>   *         0 if both timestamps are equal<a name="line.368"></a>
+<span class="sourceLineNo">369</span>   */<a name="line.369"></a>
+<span class="sourceLineNo">370</span>  @Override<a name="line.370"></a>
+<span class="sourceLineNo">371</span>  public int compareTimestamps(final Cell left, final Cell right) {<a name="line.371"></a>
+<span class="sourceLineNo">372</span>    return compareTimestamps(left.getTimestamp(), right.getTimestamp());<a name="line.372"></a>
+<span class="sourceLineNo">373</span>  }<a name="line.373"></a>
+<span class="sourceLineNo">374</span><a name="line.374"></a>
+<span class="sourceLineNo">375</span><a name="line.375"></a>
+<span class="sourceLineNo">376</span>  /**<a name="line.376"></a>
+<span class="sourceLineNo">377</span>   * Compares timestamps in DESCENDING order.<a name="line.377"></a>
+<span class="sourceLineNo">378</span>   * The below older timestamps sorting ahead of newer timestamps looks<a name="line.378"></a>
+<span class="sourceLineNo">379</span>   * wrong but it is intentional. This way, newer timestamps are first<a name="line.379"></a>
+<span class="sourceLineNo">380</span>   * found when we iterate over a memstore and newer versions are the<a name="line.380"></a>
+<span class="sourceLineNo">381</span>   * first we trip over when reading from a store file.<a name="line.381"></a>
+<span class="sourceLineNo">382</span>   * @return 1 if left timestamp &amp;lt; right timestamp<a name="line.382"></a>
+<span class="sourceLineNo">383</span>   *         -1 if left timestamp &amp;gt; right timestamp<a name="line.383"></a>
+<span class="sourceLineNo">384</span>   *         0 if both timestamps are equal<a name="line.384"></a>
+<span class="sourceLineNo">385</span>   */<a name="line.385"></a>
+<span class="sourceLineNo">386</span>  @Override<a name="line.386"></a>
+<span class="sourceLineNo">387</span>  public int compareTimestamps(final long ltimestamp, final long rtimestamp) {<a name="line.387"></a>
+<span class="sourceLineNo">388</span>    if (ltimestamp &lt; rtimestamp) {<a name="line.388"></a>
+<span class="sourceLineNo">389</span>      return 1;<a name="line.389"></a>
+<span class="sourceLineNo">390</span>    } else if (ltimestamp &gt; rtimestamp) {<a name="line.390"></a>
+<span class="sourceLineNo">391</span>      return -1;<a name="line.391"></a>
+<span class="sourceLineNo">392</span>    }<a name="line.392"></a>
+<span class="sourceLineNo">393</span>    return 0;<a name="line.393"></a>
+<span class="sourceLineNo">394</span>  }<a name="line.394"></a>
+<span class="sourceLineNo">395</span><a name="line.395"></a>
+<span class="sourceLineNo">396</span>  /**<a name="line.396"></a>
+<span class="sourceLineNo">397</span>   * A {@link CellComparatorImpl} for &lt;code&gt;hbase:meta&lt;/code&gt; catalog table<a name="line.397"></a>
+<span class="sourceLineNo">398</span>   * {@link KeyValue}s.<a name="line.398"></a>
+<span class="sourceLineNo">399</span>   */<a name="line.399"></a>
+<span class="sourceLineNo">400</span>  public static class MetaCellComparator extends CellComparatorImpl {<a name="line.400"></a>
+<span class="sourceLineNo">401</span><a name="line.401"></a>
+<span class="sourceLineNo">402</span>    @Override<a name="line.402"></a>
+<span class="sourceLineNo">403</span>    public int compareRows(final Cell left, final Cell right) {<a name="line.403"></a>
+<span class="sourceLineNo">404</span>      return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(),<a name="line.404"></a>
+<span class="sourceLineNo">405</span>          right.getRowArray(), right.getRowOffset(), right.getRowLength());<a name="line.405"></a>
+<span class="sourceLineNo">406</span>    }<a name="line.406"></a>
+<span class="sourceLineNo">407</span><a name="line.407"></a>
+<span class="sourceLineNo">408</span>    @Override<a name="line.408"></a>
+<span class="sourceLineNo">409</span>    public int compareRows(Cell left, byte[] right, int roffset, int rlength) {<a name="line.409"></a>
+<span class="sourceLineNo">410</span>      return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right,<a name="line.410"></a>
+<span class="sourceLineNo">411</span>          roffset, rlength);<a name="line.411"></a>
+<span class="sourceLineNo">412</span>    }<a name="line.412"></a>
+<span class="sourceLineNo">413</span><a name="line.413"></a>
+<span class="sourceLineNo">414</span>    private int compareRows(byte[] left, int loffset, int llength, byte[] right, int roffset,<a name="line.414"></a>
+<span class="sourceLineNo">415</span>        int rlength) {<a name="line.415"></a>
+<span class="sourceLineNo">416</span>      int leftDelimiter = Bytes.searchDelimiterIndex(left, loffset, llength, HConstants.DELIMITER);<a name="line.416"></a>
+<span class="sourceLineNo">417</span>      int rightDelimiter = Bytes<a name="line.417"></a>
+<span class="sourceLineNo">418</span>          .searchDelimiterIndex(right, roffset, rlength, HConstants.DELIMITER);<a name="line.418"></a>
+<span class="sourceLineNo">419</span>      // Compare up to the delimiter<a name="line.419"></a>
+<span class="sourceLineNo">420</span>      int lpart = (leftDelimiter &lt; 0 ? llength : leftDelimiter - loffset);<a name="line.420"></a>
+<span class="sourceLineNo">421</span>      int rpart = (rightDelimiter &lt; 0 ? rlength : rightDelimiter - roffset);<a name="line.421"></a>
+<span class="sourceLineNo">422</span>      int result = Bytes.compareTo(left, loffset, lpart, right, roffset, rpart);<a name="line.422"></a>
+<span class="sourceLineNo">423</span>      if (result != 0) {<a name="line.423"></a>
+<span class="sourceLineNo">424</span>        return result;<a name="line.424"></a>
+<span class="sourceLineNo">425</span>      } else {<a name="line.425"></a>
+<span class="sourceLineNo">426</span>        if (leftDelimiter &lt; 0 &amp;&amp; rightDelimiter &gt;= 0) {<a name="line.426"></a>
+<span class="sourceLineNo">427</span>          return -1;<a name="line.427"></a>
+<span class="sourceLineNo">428</span>        } else if (rightDelimiter &lt; 0 &amp;&amp; leftDelimiter &gt;= 0) {<a name="line.428"></a>
+<span class="sourceLineNo">429</span>          return 1;<a name="line.429"></a>
+<span class="sourceLineNo">430</span>        } else if (leftDelimiter &lt; 0 &amp;&amp; rightDelimiter &lt; 0) {<a name="line.430"></a>
+<span class="sourceLineNo">431</span>          return 0;<a name="line.431"></a>
+<span class="sourceLineNo">432</span>        }<a name="line.432"></a>
+<span class="sourceLineNo">433</span>      }<a name="line.433"></a>
+<span class="sourceLineNo">434</span>      // Compare middle bit of the row.<a name="line.434"></a>
+<span class="sourceLineNo">435</span>      // Move past delimiter<a name="line.435"></a>
+<span class="sourceLineNo">436</span>      leftDelimiter++;<a name="line.436"></a>
+<span class="sourceLineNo">437</span>      rightDelimiter++;<a name="line.437"></a>
+<span class="sourceLineNo">438</span>      int leftFarDelimiter = Bytes.searchDelimiterIndexInReverse(left, leftDelimiter, llength<a name="line.438"></a>
+<span class="sourceLineNo">439</span>          - (leftDelimiter - loffset), HConstants.DELIMITER);<a name="line.439"></a>
+<span class="sourceLineNo">440</span>      int rightFarDelimiter = Bytes.searchDelimiterIndexInReverse(right, rightDelimiter, rlength<a name="line.440"></a>
+<span class="sourceLineNo">441</span>          - (rightDelimiter - roffset), HConstants.DELIMITER);<a name="line.441"></a>
+<span class="sourceLineNo">442</span>      // Now compare middlesection of row.<a name="line.442"></a>
+<span class="sourceLineNo">443</span>      lpart = (leftFarDelimiter &lt; 0 ? llength + loffset : leftFarDelimiter) - leftDelimiter;<a name="line.443"></a>
+<span class="sourceLineNo">444</span>      rpart = (rightFarDelimiter &lt; 0 ? rlength + roffset : rightFarDelimiter) - rightDelimiter;<a name="line.444"></a>
+<span class="sourceLineNo">445</span>      result = Bytes.compareTo(left, leftDelimiter, lpart, right, rightDelimiter, rpart);<a name="line.445"></a>
+<span class="sourceLineNo">446</span>      if (result != 0) {<a name="line.446"></a>
+<span class="sourceLineNo">447</span>        return result;<a name="line.447"></a>
+<span class="sourceLineNo">448</span>      } else {<a name="line.448"></a>
+<span class="sourceLineNo">449</span>        if (leftDelimiter &lt; 0 &amp;&amp; rightDelimiter &gt;= 0) {<a name="line.449"></a>
+<span class="sourceLineNo">450</span>          return -1;<a name="line.450"></a>
+<span class="sourceLineNo">451</span>        } else if (rightDelimiter &lt; 0 &amp;&amp; leftDelimiter &gt;= 0) {<a name="line.451"></a>
+<span class="sourceLineNo">452</span>          return 1;<a name="line.452"></a>
+<span class="sourceLineNo">453</span>        } else if (leftDelimiter &lt; 0 &amp;&amp; rightDelimiter &lt; 0) {<a name="line.453"></a>
+<span class="sourceLineNo">454</span>          return 0;<a name="line.454"></a>
+<span class="sourceLineNo">455</span>        }<a name="line.455"></a>
+<span class="sourceLineNo">456</span>      }<a name="line.456"></a>
+<span class="sourceLineNo">457</span>      // Compare last part of row, the rowid.<a name="line.457"></a>
+<span class="sourceLineNo">458</span>      leftFarDelimiter++;<a name="line.458"></a>
+<span class="sourceLineNo">459</span>      rightFarDelimiter++;<a name="line.459"></a>
+<span class="sourceLineNo">460</span>      result = Bytes.compareTo(left, leftFarDelimiter, llength - (leftFarDelimiter - loffset),<a name="line.460"></a>
+<span class="sourceLineNo">461</span>          right, rightFarDelimiter, rlength - (rightFarDelimiter - roffset));<a name="line.461"></a>
+<span class="sourceLineNo">462</span>      return result;<a name="line.462"></a>
+<span class="sourceLineNo">463</span>    }<a name="line.463"></a>
+<span class="sourceLineNo">464</span>  }<a name="line.464"></a>
+<span class="sourceLineNo">465</span>}<a name="line.465"></a>
 
 
 


Mime
View raw message