hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [21/52] [partial] hbase-site git commit: Published site at 950d547dae684155020edb879a343bee1bf18e97.
Date Mon, 29 Aug 2016 15:33:11 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/45a663dd/devapidocs/src-html/org/apache/hadoop/hbase/io/encoding/DataBlockEncoding.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/io/encoding/DataBlockEncoding.html b/devapidocs/src-html/org/apache/hadoop/hbase/io/encoding/DataBlockEncoding.html
index 25baad1..20ae1c1 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/io/encoding/DataBlockEncoding.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/io/encoding/DataBlockEncoding.html
@@ -24,14 +24,14 @@
 <span class="sourceLineNo">016</span> */<a name="line.16"></a>
 <span class="sourceLineNo">017</span>package org.apache.hadoop.hbase.io.encoding;<a name="line.17"></a>
 <span class="sourceLineNo">018</span><a name="line.18"></a>
-<span class="sourceLineNo">019</span>import java.io.IOException;<a name="line.19"></a>
-<span class="sourceLineNo">020</span>import java.io.OutputStream;<a name="line.20"></a>
-<span class="sourceLineNo">021</span>import java.util.HashMap;<a name="line.21"></a>
-<span class="sourceLineNo">022</span>import java.util.Map;<a name="line.22"></a>
-<span class="sourceLineNo">023</span><a name="line.23"></a>
-<span class="sourceLineNo">024</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.24"></a>
-<span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.classification.InterfaceStability;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.26"></a>
+<span class="sourceLineNo">019</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.19"></a>
+<span class="sourceLineNo">020</span>import org.apache.hadoop.hbase.classification.InterfaceStability;<a name="line.20"></a>
+<span class="sourceLineNo">021</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.21"></a>
+<span class="sourceLineNo">022</span><a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.io.IOException;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import java.io.OutputStream;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import java.util.HashMap;<a name="line.25"></a>
+<span class="sourceLineNo">026</span>import java.util.Map;<a name="line.26"></a>
 <span class="sourceLineNo">027</span><a name="line.27"></a>
 <span class="sourceLineNo">028</span>/**<a name="line.28"></a>
 <span class="sourceLineNo">029</span> * Provide access to all data block encoding algorithms. All of the algorithms<a name="line.29"></a>
@@ -51,157 +51,158 @@
 <span class="sourceLineNo">043</span>  FAST_DIFF(4, "org.apache.hadoop.hbase.io.encoding.FastDiffDeltaEncoder"),<a name="line.43"></a>
 <span class="sourceLineNo">044</span>  // id 5 is reserved for the COPY_KEY algorithm for benchmarking<a name="line.44"></a>
 <span class="sourceLineNo">045</span>  // COPY_KEY(5, "org.apache.hadoop.hbase.io.encoding.CopyKeyDataBlockEncoder"),<a name="line.45"></a>
-<span class="sourceLineNo">046</span>  PREFIX_TREE(6, "org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeCodec");<a name="line.46"></a>
-<span class="sourceLineNo">047</span><a name="line.47"></a>
-<span class="sourceLineNo">048</span>  private final short id;<a name="line.48"></a>
-<span class="sourceLineNo">049</span>  private final byte[] idInBytes;<a name="line.49"></a>
-<span class="sourceLineNo">050</span>  private DataBlockEncoder encoder;<a name="line.50"></a>
-<span class="sourceLineNo">051</span>  private final String encoderCls;<a name="line.51"></a>
-<span class="sourceLineNo">052</span><a name="line.52"></a>
-<span class="sourceLineNo">053</span>  public static final int ID_SIZE = Bytes.SIZEOF_SHORT;<a name="line.53"></a>
-<span class="sourceLineNo">054</span><a name="line.54"></a>
-<span class="sourceLineNo">055</span>  /** Maps data block encoding ids to enum instances. */<a name="line.55"></a>
-<span class="sourceLineNo">056</span>  private static Map&lt;Short, DataBlockEncoding&gt; idToEncoding =<a name="line.56"></a>
-<span class="sourceLineNo">057</span>      new HashMap&lt;Short, DataBlockEncoding&gt;();<a name="line.57"></a>
-<span class="sourceLineNo">058</span><a name="line.58"></a>
-<span class="sourceLineNo">059</span>  static {<a name="line.59"></a>
-<span class="sourceLineNo">060</span>    for (DataBlockEncoding algo : values()) {<a name="line.60"></a>
-<span class="sourceLineNo">061</span>      if (idToEncoding.containsKey(algo.id)) {<a name="line.61"></a>
-<span class="sourceLineNo">062</span>        throw new RuntimeException(String.format(<a name="line.62"></a>
-<span class="sourceLineNo">063</span>            "Two data block encoder algorithms '%s' and '%s' have " +<a name="line.63"></a>
-<span class="sourceLineNo">064</span>            "the same id %d",<a name="line.64"></a>
-<span class="sourceLineNo">065</span>            idToEncoding.get(algo.id).toString(), algo.toString(),<a name="line.65"></a>
-<span class="sourceLineNo">066</span>            (int) algo.id));<a name="line.66"></a>
-<span class="sourceLineNo">067</span>      }<a name="line.67"></a>
-<span class="sourceLineNo">068</span>      idToEncoding.put(algo.id, algo);<a name="line.68"></a>
-<span class="sourceLineNo">069</span>    }<a name="line.69"></a>
-<span class="sourceLineNo">070</span>  }<a name="line.70"></a>
-<span class="sourceLineNo">071</span><a name="line.71"></a>
-<span class="sourceLineNo">072</span>  private DataBlockEncoding(int id, String encoderClsName) {<a name="line.72"></a>
-<span class="sourceLineNo">073</span>    if (id &lt; Short.MIN_VALUE || id &gt; Short.MAX_VALUE) {<a name="line.73"></a>
-<span class="sourceLineNo">074</span>      throw new AssertionError(<a name="line.74"></a>
-<span class="sourceLineNo">075</span>          "Data block encoding algorithm id is out of range: " + id);<a name="line.75"></a>
-<span class="sourceLineNo">076</span>    }<a name="line.76"></a>
-<span class="sourceLineNo">077</span>    this.id = (short) id;<a name="line.77"></a>
-<span class="sourceLineNo">078</span>    this.idInBytes = Bytes.toBytes(this.id);<a name="line.78"></a>
-<span class="sourceLineNo">079</span>    if (idInBytes.length != ID_SIZE) {<a name="line.79"></a>
-<span class="sourceLineNo">080</span>      // White this may seem redundant, if we accidentally serialize<a name="line.80"></a>
-<span class="sourceLineNo">081</span>      // the id as e.g. an int instead of a short, all encoders will break.<a name="line.81"></a>
-<span class="sourceLineNo">082</span>      throw new RuntimeException("Unexpected length of encoder ID byte " +<a name="line.82"></a>
-<span class="sourceLineNo">083</span>          "representation: " + Bytes.toStringBinary(idInBytes));<a name="line.83"></a>
-<span class="sourceLineNo">084</span>    }<a name="line.84"></a>
-<span class="sourceLineNo">085</span>    this.encoderCls = encoderClsName;<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>   * @return name converted to bytes.<a name="line.89"></a>
-<span class="sourceLineNo">090</span>   */<a name="line.90"></a>
-<span class="sourceLineNo">091</span>  public byte[] getNameInBytes() {<a name="line.91"></a>
-<span class="sourceLineNo">092</span>    return Bytes.toBytes(toString());<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>   * @return The id of a data block encoder.<a name="line.96"></a>
-<span class="sourceLineNo">097</span>   */<a name="line.97"></a>
-<span class="sourceLineNo">098</span>  public short getId() {<a name="line.98"></a>
-<span class="sourceLineNo">099</span>    return id;<a name="line.99"></a>
-<span class="sourceLineNo">100</span>  }<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>   * Writes id in bytes.<a name="line.103"></a>
-<span class="sourceLineNo">104</span>   * @param stream where the id should be written.<a name="line.104"></a>
-<span class="sourceLineNo">105</span>   */<a name="line.105"></a>
-<span class="sourceLineNo">106</span>  public void writeIdInBytes(OutputStream stream) throws IOException {<a name="line.106"></a>
-<span class="sourceLineNo">107</span>    stream.write(idInBytes);<a name="line.107"></a>
-<span class="sourceLineNo">108</span>  }<a name="line.108"></a>
-<span class="sourceLineNo">109</span><a name="line.109"></a>
+<span class="sourceLineNo">046</span>  PREFIX_TREE(6, "org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeCodec"),<a name="line.46"></a>
+<span class="sourceLineNo">047</span>  ROW_INDEX_V1(7, "org.apache.hadoop.hbase.io.encoding.RowIndexCodecV1");<a name="line.47"></a>
+<span class="sourceLineNo">048</span><a name="line.48"></a>
+<span class="sourceLineNo">049</span>  private final short id;<a name="line.49"></a>
+<span class="sourceLineNo">050</span>  private final byte[] idInBytes;<a name="line.50"></a>
+<span class="sourceLineNo">051</span>  private DataBlockEncoder encoder;<a name="line.51"></a>
+<span class="sourceLineNo">052</span>  private final String encoderCls;<a name="line.52"></a>
+<span class="sourceLineNo">053</span><a name="line.53"></a>
+<span class="sourceLineNo">054</span>  public static final int ID_SIZE = Bytes.SIZEOF_SHORT;<a name="line.54"></a>
+<span class="sourceLineNo">055</span><a name="line.55"></a>
+<span class="sourceLineNo">056</span>  /** Maps data block encoding ids to enum instances. */<a name="line.56"></a>
+<span class="sourceLineNo">057</span>  private static Map&lt;Short, DataBlockEncoding&gt; idToEncoding =<a name="line.57"></a>
+<span class="sourceLineNo">058</span>      new HashMap&lt;Short, DataBlockEncoding&gt;();<a name="line.58"></a>
+<span class="sourceLineNo">059</span><a name="line.59"></a>
+<span class="sourceLineNo">060</span>  static {<a name="line.60"></a>
+<span class="sourceLineNo">061</span>    for (DataBlockEncoding algo : values()) {<a name="line.61"></a>
+<span class="sourceLineNo">062</span>      if (idToEncoding.containsKey(algo.id)) {<a name="line.62"></a>
+<span class="sourceLineNo">063</span>        throw new RuntimeException(String.format(<a name="line.63"></a>
+<span class="sourceLineNo">064</span>            "Two data block encoder algorithms '%s' and '%s' have " +<a name="line.64"></a>
+<span class="sourceLineNo">065</span>            "the same id %d",<a name="line.65"></a>
+<span class="sourceLineNo">066</span>            idToEncoding.get(algo.id).toString(), algo.toString(),<a name="line.66"></a>
+<span class="sourceLineNo">067</span>            (int) algo.id));<a name="line.67"></a>
+<span class="sourceLineNo">068</span>      }<a name="line.68"></a>
+<span class="sourceLineNo">069</span>      idToEncoding.put(algo.id, algo);<a name="line.69"></a>
+<span class="sourceLineNo">070</span>    }<a name="line.70"></a>
+<span class="sourceLineNo">071</span>  }<a name="line.71"></a>
+<span class="sourceLineNo">072</span><a name="line.72"></a>
+<span class="sourceLineNo">073</span>  private DataBlockEncoding(int id, String encoderClsName) {<a name="line.73"></a>
+<span class="sourceLineNo">074</span>    if (id &lt; Short.MIN_VALUE || id &gt; Short.MAX_VALUE) {<a name="line.74"></a>
+<span class="sourceLineNo">075</span>      throw new AssertionError(<a name="line.75"></a>
+<span class="sourceLineNo">076</span>          "Data block encoding algorithm id is out of range: " + id);<a name="line.76"></a>
+<span class="sourceLineNo">077</span>    }<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    this.id = (short) id;<a name="line.78"></a>
+<span class="sourceLineNo">079</span>    this.idInBytes = Bytes.toBytes(this.id);<a name="line.79"></a>
+<span class="sourceLineNo">080</span>    if (idInBytes.length != ID_SIZE) {<a name="line.80"></a>
+<span class="sourceLineNo">081</span>      // White this may seem redundant, if we accidentally serialize<a name="line.81"></a>
+<span class="sourceLineNo">082</span>      // the id as e.g. an int instead of a short, all encoders will break.<a name="line.82"></a>
+<span class="sourceLineNo">083</span>      throw new RuntimeException("Unexpected length of encoder ID byte " +<a name="line.83"></a>
+<span class="sourceLineNo">084</span>          "representation: " + Bytes.toStringBinary(idInBytes));<a name="line.84"></a>
+<span class="sourceLineNo">085</span>    }<a name="line.85"></a>
+<span class="sourceLineNo">086</span>    this.encoderCls = encoderClsName;<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>   * @return name converted to bytes.<a name="line.90"></a>
+<span class="sourceLineNo">091</span>   */<a name="line.91"></a>
+<span class="sourceLineNo">092</span>  public byte[] getNameInBytes() {<a name="line.92"></a>
+<span class="sourceLineNo">093</span>    return Bytes.toBytes(toString());<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>  /**<a name="line.96"></a>
+<span class="sourceLineNo">097</span>   * @return The id of a data block encoder.<a name="line.97"></a>
+<span class="sourceLineNo">098</span>   */<a name="line.98"></a>
+<span class="sourceLineNo">099</span>  public short getId() {<a name="line.99"></a>
+<span class="sourceLineNo">100</span>    return id;<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>   * Writes id in bytes.<a name="line.104"></a>
+<span class="sourceLineNo">105</span>   * @param stream where the id should be written.<a name="line.105"></a>
+<span class="sourceLineNo">106</span>   */<a name="line.106"></a>
+<span class="sourceLineNo">107</span>  public void writeIdInBytes(OutputStream stream) throws IOException {<a name="line.107"></a>
+<span class="sourceLineNo">108</span>    stream.write(idInBytes);<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>  /**<a name="line.111"></a>
-<span class="sourceLineNo">112</span>   * Writes id bytes to the given array starting from offset.<a name="line.112"></a>
-<span class="sourceLineNo">113</span>   *<a name="line.113"></a>
-<span class="sourceLineNo">114</span>   * @param dest output array<a name="line.114"></a>
-<span class="sourceLineNo">115</span>   * @param offset starting offset of the output array<a name="line.115"></a>
-<span class="sourceLineNo">116</span>   * @throws IOException<a name="line.116"></a>
-<span class="sourceLineNo">117</span>   */<a name="line.117"></a>
-<span class="sourceLineNo">118</span>  public void writeIdInBytes(byte[] dest, int offset) throws IOException {<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    System.arraycopy(idInBytes, 0, dest, offset, ID_SIZE);<a name="line.119"></a>
-<span class="sourceLineNo">120</span>  }<a name="line.120"></a>
-<span class="sourceLineNo">121</span><a name="line.121"></a>
-<span class="sourceLineNo">122</span>  /**<a name="line.122"></a>
-<span class="sourceLineNo">123</span>   * Return new data block encoder for given algorithm type.<a name="line.123"></a>
-<span class="sourceLineNo">124</span>   * @return data block encoder if algorithm is specified, null if none is<a name="line.124"></a>
-<span class="sourceLineNo">125</span>   *         selected.<a name="line.125"></a>
-<span class="sourceLineNo">126</span>   */<a name="line.126"></a>
-<span class="sourceLineNo">127</span>  public DataBlockEncoder getEncoder() {<a name="line.127"></a>
-<span class="sourceLineNo">128</span>    if (encoder == null &amp;&amp; id != 0) {<a name="line.128"></a>
-<span class="sourceLineNo">129</span>      // lazily create the encoder<a name="line.129"></a>
-<span class="sourceLineNo">130</span>      encoder = createEncoder(encoderCls);<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    }<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    return encoder;<a name="line.132"></a>
-<span class="sourceLineNo">133</span>  }<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>   * Find and create data block encoder for given id;<a name="line.136"></a>
-<span class="sourceLineNo">137</span>   * @param encoderId id of data block encoder.<a name="line.137"></a>
-<span class="sourceLineNo">138</span>   * @return Newly created data block encoder.<a name="line.138"></a>
-<span class="sourceLineNo">139</span>   */<a name="line.139"></a>
-<span class="sourceLineNo">140</span>  public static DataBlockEncoder getDataBlockEncoderById(short encoderId) {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>    if (!idToEncoding.containsKey(encoderId)) {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      throw new IllegalArgumentException(String.format(<a name="line.142"></a>
-<span class="sourceLineNo">143</span>          "There is no data block encoder for given id '%d'",<a name="line.143"></a>
-<span class="sourceLineNo">144</span>          (int) encoderId));<a name="line.144"></a>
-<span class="sourceLineNo">145</span>    }<a name="line.145"></a>
-<span class="sourceLineNo">146</span><a name="line.146"></a>
-<span class="sourceLineNo">147</span>    return idToEncoding.get(encoderId).getEncoder();<a name="line.147"></a>
-<span class="sourceLineNo">148</span>  }<a name="line.148"></a>
-<span class="sourceLineNo">149</span><a name="line.149"></a>
-<span class="sourceLineNo">150</span>  /**<a name="line.150"></a>
-<span class="sourceLineNo">151</span>   * Find and return the name of data block encoder for the given id.<a name="line.151"></a>
-<span class="sourceLineNo">152</span>   * @param encoderId id of data block encoder<a name="line.152"></a>
-<span class="sourceLineNo">153</span>   * @return name, same as used in options in column family<a name="line.153"></a>
-<span class="sourceLineNo">154</span>   */<a name="line.154"></a>
-<span class="sourceLineNo">155</span>  public static String getNameFromId(short encoderId) {<a name="line.155"></a>
-<span class="sourceLineNo">156</span>    return idToEncoding.get(encoderId).toString();<a name="line.156"></a>
-<span class="sourceLineNo">157</span>  }<a name="line.157"></a>
-<span class="sourceLineNo">158</span><a name="line.158"></a>
-<span class="sourceLineNo">159</span>  /**<a name="line.159"></a>
-<span class="sourceLineNo">160</span>   * Check if given encoder has this id.<a name="line.160"></a>
-<span class="sourceLineNo">161</span>   * @param encoder encoder which id will be checked<a name="line.161"></a>
-<span class="sourceLineNo">162</span>   * @param encoderId id which we except<a name="line.162"></a>
-<span class="sourceLineNo">163</span>   * @return true if id is right for given encoder, false otherwise<a name="line.163"></a>
-<span class="sourceLineNo">164</span>   * @exception IllegalArgumentException<a name="line.164"></a>
-<span class="sourceLineNo">165</span>   *            thrown when there is no matching data block encoder<a name="line.165"></a>
-<span class="sourceLineNo">166</span>   */<a name="line.166"></a>
-<span class="sourceLineNo">167</span>  public static boolean isCorrectEncoder(DataBlockEncoder encoder,<a name="line.167"></a>
-<span class="sourceLineNo">168</span>      short encoderId) {<a name="line.168"></a>
-<span class="sourceLineNo">169</span>    if (!idToEncoding.containsKey(encoderId)) {<a name="line.169"></a>
-<span class="sourceLineNo">170</span>      throw new IllegalArgumentException(String.format(<a name="line.170"></a>
-<span class="sourceLineNo">171</span>          "There is no data block encoder for given id '%d'",<a name="line.171"></a>
-<span class="sourceLineNo">172</span>          (int) encoderId));<a name="line.172"></a>
-<span class="sourceLineNo">173</span>    }<a name="line.173"></a>
-<span class="sourceLineNo">174</span><a name="line.174"></a>
-<span class="sourceLineNo">175</span>    DataBlockEncoding algorithm = idToEncoding.get(encoderId);<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    String encoderCls = encoder.getClass().getName();<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    return encoderCls.equals(algorithm.encoderCls);<a name="line.177"></a>
-<span class="sourceLineNo">178</span>  }<a name="line.178"></a>
-<span class="sourceLineNo">179</span><a name="line.179"></a>
-<span class="sourceLineNo">180</span>  public static DataBlockEncoding getEncodingById(short dataBlockEncodingId) {<a name="line.180"></a>
-<span class="sourceLineNo">181</span>    return idToEncoding.get(dataBlockEncodingId);<a name="line.181"></a>
-<span class="sourceLineNo">182</span>  }<a name="line.182"></a>
-<span class="sourceLineNo">183</span><a name="line.183"></a>
-<span class="sourceLineNo">184</span>  protected static DataBlockEncoder createEncoder(String fullyQualifiedClassName){<a name="line.184"></a>
-<span class="sourceLineNo">185</span>      try {<a name="line.185"></a>
-<span class="sourceLineNo">186</span>        return (DataBlockEncoder)Class.forName(fullyQualifiedClassName).newInstance();<a name="line.186"></a>
-<span class="sourceLineNo">187</span>      } catch (InstantiationException e) {<a name="line.187"></a>
-<span class="sourceLineNo">188</span>        throw new RuntimeException(e);<a name="line.188"></a>
-<span class="sourceLineNo">189</span>      } catch (IllegalAccessException e) {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>        throw new RuntimeException(e);<a name="line.190"></a>
-<span class="sourceLineNo">191</span>      } catch (ClassNotFoundException e) {<a name="line.191"></a>
-<span class="sourceLineNo">192</span>        throw new IllegalArgumentException(e);<a name="line.192"></a>
-<span class="sourceLineNo">193</span>      }<a name="line.193"></a>
-<span class="sourceLineNo">194</span>  }<a name="line.194"></a>
-<span class="sourceLineNo">195</span><a name="line.195"></a>
-<span class="sourceLineNo">196</span>}<a name="line.196"></a>
+<span class="sourceLineNo">111</span><a name="line.111"></a>
+<span class="sourceLineNo">112</span>  /**<a name="line.112"></a>
+<span class="sourceLineNo">113</span>   * Writes id bytes to the given array starting from offset.<a name="line.113"></a>
+<span class="sourceLineNo">114</span>   *<a name="line.114"></a>
+<span class="sourceLineNo">115</span>   * @param dest output array<a name="line.115"></a>
+<span class="sourceLineNo">116</span>   * @param offset starting offset of the output array<a name="line.116"></a>
+<span class="sourceLineNo">117</span>   * @throws IOException<a name="line.117"></a>
+<span class="sourceLineNo">118</span>   */<a name="line.118"></a>
+<span class="sourceLineNo">119</span>  public void writeIdInBytes(byte[] dest, int offset) throws IOException {<a name="line.119"></a>
+<span class="sourceLineNo">120</span>    System.arraycopy(idInBytes, 0, dest, offset, ID_SIZE);<a name="line.120"></a>
+<span class="sourceLineNo">121</span>  }<a name="line.121"></a>
+<span class="sourceLineNo">122</span><a name="line.122"></a>
+<span class="sourceLineNo">123</span>  /**<a name="line.123"></a>
+<span class="sourceLineNo">124</span>   * Return new data block encoder for given algorithm type.<a name="line.124"></a>
+<span class="sourceLineNo">125</span>   * @return data block encoder if algorithm is specified, null if none is<a name="line.125"></a>
+<span class="sourceLineNo">126</span>   *         selected.<a name="line.126"></a>
+<span class="sourceLineNo">127</span>   */<a name="line.127"></a>
+<span class="sourceLineNo">128</span>  public DataBlockEncoder getEncoder() {<a name="line.128"></a>
+<span class="sourceLineNo">129</span>    if (encoder == null &amp;&amp; id != 0) {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>      // lazily create the encoder<a name="line.130"></a>
+<span class="sourceLineNo">131</span>      encoder = createEncoder(encoderCls);<a name="line.131"></a>
+<span class="sourceLineNo">132</span>    }<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    return encoder;<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>   * Find and create data block encoder for given id;<a name="line.137"></a>
+<span class="sourceLineNo">138</span>   * @param encoderId id of data block encoder.<a name="line.138"></a>
+<span class="sourceLineNo">139</span>   * @return Newly created data block encoder.<a name="line.139"></a>
+<span class="sourceLineNo">140</span>   */<a name="line.140"></a>
+<span class="sourceLineNo">141</span>  public static DataBlockEncoder getDataBlockEncoderById(short encoderId) {<a name="line.141"></a>
+<span class="sourceLineNo">142</span>    if (!idToEncoding.containsKey(encoderId)) {<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      throw new IllegalArgumentException(String.format(<a name="line.143"></a>
+<span class="sourceLineNo">144</span>          "There is no data block encoder for given id '%d'",<a name="line.144"></a>
+<span class="sourceLineNo">145</span>          (int) encoderId));<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    }<a name="line.146"></a>
+<span class="sourceLineNo">147</span><a name="line.147"></a>
+<span class="sourceLineNo">148</span>    return idToEncoding.get(encoderId).getEncoder();<a name="line.148"></a>
+<span class="sourceLineNo">149</span>  }<a name="line.149"></a>
+<span class="sourceLineNo">150</span><a name="line.150"></a>
+<span class="sourceLineNo">151</span>  /**<a name="line.151"></a>
+<span class="sourceLineNo">152</span>   * Find and return the name of data block encoder for the given id.<a name="line.152"></a>
+<span class="sourceLineNo">153</span>   * @param encoderId id of data block encoder<a name="line.153"></a>
+<span class="sourceLineNo">154</span>   * @return name, same as used in options in column family<a name="line.154"></a>
+<span class="sourceLineNo">155</span>   */<a name="line.155"></a>
+<span class="sourceLineNo">156</span>  public static String getNameFromId(short encoderId) {<a name="line.156"></a>
+<span class="sourceLineNo">157</span>    return idToEncoding.get(encoderId).toString();<a name="line.157"></a>
+<span class="sourceLineNo">158</span>  }<a name="line.158"></a>
+<span class="sourceLineNo">159</span><a name="line.159"></a>
+<span class="sourceLineNo">160</span>  /**<a name="line.160"></a>
+<span class="sourceLineNo">161</span>   * Check if given encoder has this id.<a name="line.161"></a>
+<span class="sourceLineNo">162</span>   * @param encoder encoder which id will be checked<a name="line.162"></a>
+<span class="sourceLineNo">163</span>   * @param encoderId id which we except<a name="line.163"></a>
+<span class="sourceLineNo">164</span>   * @return true if id is right for given encoder, false otherwise<a name="line.164"></a>
+<span class="sourceLineNo">165</span>   * @exception IllegalArgumentException<a name="line.165"></a>
+<span class="sourceLineNo">166</span>   *            thrown when there is no matching data block encoder<a name="line.166"></a>
+<span class="sourceLineNo">167</span>   */<a name="line.167"></a>
+<span class="sourceLineNo">168</span>  public static boolean isCorrectEncoder(DataBlockEncoder encoder,<a name="line.168"></a>
+<span class="sourceLineNo">169</span>      short encoderId) {<a name="line.169"></a>
+<span class="sourceLineNo">170</span>    if (!idToEncoding.containsKey(encoderId)) {<a name="line.170"></a>
+<span class="sourceLineNo">171</span>      throw new IllegalArgumentException(String.format(<a name="line.171"></a>
+<span class="sourceLineNo">172</span>          "There is no data block encoder for given id '%d'",<a name="line.172"></a>
+<span class="sourceLineNo">173</span>          (int) encoderId));<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    }<a name="line.174"></a>
+<span class="sourceLineNo">175</span><a name="line.175"></a>
+<span class="sourceLineNo">176</span>    DataBlockEncoding algorithm = idToEncoding.get(encoderId);<a name="line.176"></a>
+<span class="sourceLineNo">177</span>    String encoderCls = encoder.getClass().getName();<a name="line.177"></a>
+<span class="sourceLineNo">178</span>    return encoderCls.equals(algorithm.encoderCls);<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>  public static DataBlockEncoding getEncodingById(short dataBlockEncodingId) {<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    return idToEncoding.get(dataBlockEncodingId);<a name="line.182"></a>
+<span class="sourceLineNo">183</span>  }<a name="line.183"></a>
+<span class="sourceLineNo">184</span><a name="line.184"></a>
+<span class="sourceLineNo">185</span>  protected static DataBlockEncoder createEncoder(String fullyQualifiedClassName){<a name="line.185"></a>
+<span class="sourceLineNo">186</span>      try {<a name="line.186"></a>
+<span class="sourceLineNo">187</span>        return (DataBlockEncoder)Class.forName(fullyQualifiedClassName).newInstance();<a name="line.187"></a>
+<span class="sourceLineNo">188</span>      } catch (InstantiationException e) {<a name="line.188"></a>
+<span class="sourceLineNo">189</span>        throw new RuntimeException(e);<a name="line.189"></a>
+<span class="sourceLineNo">190</span>      } catch (IllegalAccessException e) {<a name="line.190"></a>
+<span class="sourceLineNo">191</span>        throw new RuntimeException(e);<a name="line.191"></a>
+<span class="sourceLineNo">192</span>      } catch (ClassNotFoundException e) {<a name="line.192"></a>
+<span class="sourceLineNo">193</span>        throw new IllegalArgumentException(e);<a name="line.193"></a>
+<span class="sourceLineNo">194</span>      }<a name="line.194"></a>
+<span class="sourceLineNo">195</span>  }<a name="line.195"></a>
+<span class="sourceLineNo">196</span><a name="line.196"></a>
+<span class="sourceLineNo">197</span>}<a name="line.197"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/45a663dd/devapidocs/src-html/org/apache/hadoop/hbase/io/encoding/DiffKeyDeltaEncoder.DiffCompressionState.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/io/encoding/DiffKeyDeltaEncoder.DiffCompressionState.html b/devapidocs/src-html/org/apache/hadoop/hbase/io/encoding/DiffKeyDeltaEncoder.DiffCompressionState.html
index 54788f6..e372d03 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/io/encoding/DiffKeyDeltaEncoder.DiffCompressionState.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/io/encoding/DiffKeyDeltaEncoder.DiffCompressionState.html
@@ -375,167 +375,169 @@
 <span class="sourceLineNo">367</span>    private int rowLengthWithSize;<a name="line.367"></a>
 <span class="sourceLineNo">368</span>    private long timestamp;<a name="line.368"></a>
 <span class="sourceLineNo">369</span><a name="line.369"></a>
-<span class="sourceLineNo">370</span>    public DiffSeekerState(ObjectIntPair&lt;ByteBuffer&gt; tmpPair, boolean includeTags) {<a name="line.370"></a>
-<span class="sourceLineNo">371</span>      super(tmpPair, includeTags);<a name="line.371"></a>
-<span class="sourceLineNo">372</span>    }<a name="line.372"></a>
-<span class="sourceLineNo">373</span><a name="line.373"></a>
-<span class="sourceLineNo">374</span>    @Override<a name="line.374"></a>
-<span class="sourceLineNo">375</span>    protected void copyFromNext(SeekerState that) {<a name="line.375"></a>
-<span class="sourceLineNo">376</span>      super.copyFromNext(that);<a name="line.376"></a>
-<span class="sourceLineNo">377</span>      DiffSeekerState other = (DiffSeekerState) that;<a name="line.377"></a>
-<span class="sourceLineNo">378</span>      rowLengthWithSize = other.rowLengthWithSize;<a name="line.378"></a>
-<span class="sourceLineNo">379</span>      timestamp = other.timestamp;<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">382</span><a name="line.382"></a>
-<span class="sourceLineNo">383</span>  @Override<a name="line.383"></a>
-<span class="sourceLineNo">384</span>  public EncodedSeeker createSeeker(CellComparator comparator,<a name="line.384"></a>
-<span class="sourceLineNo">385</span>      HFileBlockDecodingContext decodingCtx) {<a name="line.385"></a>
-<span class="sourceLineNo">386</span>    return new BufferedEncodedSeeker&lt;DiffSeekerState&gt;(comparator, decodingCtx) {<a name="line.386"></a>
-<span class="sourceLineNo">387</span>      private byte[] familyNameWithSize;<a name="line.387"></a>
-<span class="sourceLineNo">388</span>      private static final int TIMESTAMP_WITH_TYPE_LENGTH =<a name="line.388"></a>
-<span class="sourceLineNo">389</span>          Bytes.SIZEOF_LONG + Bytes.SIZEOF_BYTE;<a name="line.389"></a>
-<span class="sourceLineNo">390</span><a name="line.390"></a>
-<span class="sourceLineNo">391</span>      private void decode(boolean isFirst) {<a name="line.391"></a>
-<span class="sourceLineNo">392</span>        byte flag = currentBuffer.get();<a name="line.392"></a>
-<span class="sourceLineNo">393</span>        byte type = 0;<a name="line.393"></a>
-<span class="sourceLineNo">394</span>        if ((flag &amp; FLAG_SAME_KEY_LENGTH) == 0) {<a name="line.394"></a>
-<span class="sourceLineNo">395</span>          if (!isFirst) {<a name="line.395"></a>
-<span class="sourceLineNo">396</span>            type = current.keyBuffer[current.keyLength - Bytes.SIZEOF_BYTE];<a name="line.396"></a>
-<span class="sourceLineNo">397</span>          }<a name="line.397"></a>
-<span class="sourceLineNo">398</span>          current.keyLength = ByteBuff.readCompressedInt(currentBuffer);<a name="line.398"></a>
-<span class="sourceLineNo">399</span>        }<a name="line.399"></a>
-<span class="sourceLineNo">400</span>        if ((flag &amp; FLAG_SAME_VALUE_LENGTH) == 0) {<a name="line.400"></a>
-<span class="sourceLineNo">401</span>          current.valueLength = ByteBuff.readCompressedInt(currentBuffer);<a name="line.401"></a>
-<span class="sourceLineNo">402</span>        }<a name="line.402"></a>
-<span class="sourceLineNo">403</span>        current.lastCommonPrefix = ByteBuff.readCompressedInt(currentBuffer);<a name="line.403"></a>
-<span class="sourceLineNo">404</span><a name="line.404"></a>
-<span class="sourceLineNo">405</span>        current.ensureSpaceForKey();<a name="line.405"></a>
-<span class="sourceLineNo">406</span><a name="line.406"></a>
-<span class="sourceLineNo">407</span>        if (current.lastCommonPrefix &lt; Bytes.SIZEOF_SHORT) {<a name="line.407"></a>
-<span class="sourceLineNo">408</span>          // length of row is different, copy everything except family<a name="line.408"></a>
-<span class="sourceLineNo">409</span><a name="line.409"></a>
-<span class="sourceLineNo">410</span>          // copy the row size<a name="line.410"></a>
-<span class="sourceLineNo">411</span>          currentBuffer.get(current.keyBuffer, current.lastCommonPrefix,<a name="line.411"></a>
-<span class="sourceLineNo">412</span>              Bytes.SIZEOF_SHORT - current.lastCommonPrefix);<a name="line.412"></a>
-<span class="sourceLineNo">413</span>          current.rowLengthWithSize = Bytes.toShort(current.keyBuffer, 0) +<a name="line.413"></a>
-<span class="sourceLineNo">414</span>              Bytes.SIZEOF_SHORT;<a name="line.414"></a>
-<span class="sourceLineNo">415</span><a name="line.415"></a>
-<span class="sourceLineNo">416</span>          // copy the rest of row<a name="line.416"></a>
-<span class="sourceLineNo">417</span>          currentBuffer.get(current.keyBuffer, Bytes.SIZEOF_SHORT,<a name="line.417"></a>
-<span class="sourceLineNo">418</span>              current.rowLengthWithSize - Bytes.SIZEOF_SHORT);<a name="line.418"></a>
-<span class="sourceLineNo">419</span><a name="line.419"></a>
-<span class="sourceLineNo">420</span>          // copy the column family<a name="line.420"></a>
-<span class="sourceLineNo">421</span>          System.arraycopy(familyNameWithSize, 0, current.keyBuffer,<a name="line.421"></a>
-<span class="sourceLineNo">422</span>              current.rowLengthWithSize, familyNameWithSize.length);<a name="line.422"></a>
-<span class="sourceLineNo">423</span><a name="line.423"></a>
-<span class="sourceLineNo">424</span>          // copy the qualifier<a name="line.424"></a>
-<span class="sourceLineNo">425</span>          currentBuffer.get(current.keyBuffer,<a name="line.425"></a>
-<span class="sourceLineNo">426</span>              current.rowLengthWithSize + familyNameWithSize.length,<a name="line.426"></a>
-<span class="sourceLineNo">427</span>              current.keyLength - current.rowLengthWithSize -<a name="line.427"></a>
-<span class="sourceLineNo">428</span>              familyNameWithSize.length - TIMESTAMP_WITH_TYPE_LENGTH);<a name="line.428"></a>
-<span class="sourceLineNo">429</span>        } else if (current.lastCommonPrefix &lt; current.rowLengthWithSize) {<a name="line.429"></a>
-<span class="sourceLineNo">430</span>          // we have to copy part of row and qualifier,<a name="line.430"></a>
-<span class="sourceLineNo">431</span>          // but column family is in right place<a name="line.431"></a>
-<span class="sourceLineNo">432</span><a name="line.432"></a>
-<span class="sourceLineNo">433</span>          // before column family (rest of row)<a name="line.433"></a>
-<span class="sourceLineNo">434</span>          currentBuffer.get(current.keyBuffer, current.lastCommonPrefix,<a name="line.434"></a>
-<span class="sourceLineNo">435</span>              current.rowLengthWithSize - current.lastCommonPrefix);<a name="line.435"></a>
-<span class="sourceLineNo">436</span><a name="line.436"></a>
-<span class="sourceLineNo">437</span>          // after column family (qualifier)<a name="line.437"></a>
-<span class="sourceLineNo">438</span>          currentBuffer.get(current.keyBuffer,<a name="line.438"></a>
-<span class="sourceLineNo">439</span>              current.rowLengthWithSize + familyNameWithSize.length,<a name="line.439"></a>
-<span class="sourceLineNo">440</span>              current.keyLength - current.rowLengthWithSize -<a name="line.440"></a>
-<span class="sourceLineNo">441</span>              familyNameWithSize.length - TIMESTAMP_WITH_TYPE_LENGTH);<a name="line.441"></a>
-<span class="sourceLineNo">442</span>        } else {<a name="line.442"></a>
-<span class="sourceLineNo">443</span>          // copy just the ending<a name="line.443"></a>
-<span class="sourceLineNo">444</span>          currentBuffer.get(current.keyBuffer, current.lastCommonPrefix,<a name="line.444"></a>
-<span class="sourceLineNo">445</span>              current.keyLength - TIMESTAMP_WITH_TYPE_LENGTH -<a name="line.445"></a>
-<span class="sourceLineNo">446</span>              current.lastCommonPrefix);<a name="line.446"></a>
-<span class="sourceLineNo">447</span>        }<a name="line.447"></a>
-<span class="sourceLineNo">448</span><a name="line.448"></a>
-<span class="sourceLineNo">449</span>        // timestamp<a name="line.449"></a>
-<span class="sourceLineNo">450</span>        int pos = current.keyLength - TIMESTAMP_WITH_TYPE_LENGTH;<a name="line.450"></a>
-<span class="sourceLineNo">451</span>        int timestampFitInBytes = 1 +<a name="line.451"></a>
-<span class="sourceLineNo">452</span>            ((flag &amp; MASK_TIMESTAMP_LENGTH) &gt;&gt;&gt; SHIFT_TIMESTAMP_LENGTH);<a name="line.452"></a>
-<span class="sourceLineNo">453</span>        long timestampOrDiff = ByteBuff.readLong(currentBuffer, timestampFitInBytes);<a name="line.453"></a>
-<span class="sourceLineNo">454</span>        if ((flag &amp; FLAG_TIMESTAMP_SIGN) != 0) {<a name="line.454"></a>
-<span class="sourceLineNo">455</span>          timestampOrDiff = -timestampOrDiff;<a name="line.455"></a>
-<span class="sourceLineNo">456</span>        }<a name="line.456"></a>
-<span class="sourceLineNo">457</span>        if ((flag &amp; FLAG_TIMESTAMP_IS_DIFF) == 0) { // it is timestamp<a name="line.457"></a>
-<span class="sourceLineNo">458</span>          current.timestamp = timestampOrDiff;<a name="line.458"></a>
-<span class="sourceLineNo">459</span>        } else { // it is diff<a name="line.459"></a>
-<span class="sourceLineNo">460</span>          current.timestamp = current.timestamp - timestampOrDiff;<a name="line.460"></a>
-<span class="sourceLineNo">461</span>        }<a name="line.461"></a>
-<span class="sourceLineNo">462</span>        Bytes.putLong(current.keyBuffer, pos, current.timestamp);<a name="line.462"></a>
-<span class="sourceLineNo">463</span>        pos += Bytes.SIZEOF_LONG;<a name="line.463"></a>
-<span class="sourceLineNo">464</span><a name="line.464"></a>
-<span class="sourceLineNo">465</span>        // type<a name="line.465"></a>
-<span class="sourceLineNo">466</span>        if ((flag &amp; FLAG_SAME_TYPE) == 0) {<a name="line.466"></a>
-<span class="sourceLineNo">467</span>          currentBuffer.get(current.keyBuffer, pos, Bytes.SIZEOF_BYTE);<a name="line.467"></a>
-<span class="sourceLineNo">468</span>        } else if ((flag &amp; FLAG_SAME_KEY_LENGTH) == 0) {<a name="line.468"></a>
-<span class="sourceLineNo">469</span>          current.keyBuffer[pos] = type;<a name="line.469"></a>
-<span class="sourceLineNo">470</span>        }<a name="line.470"></a>
-<span class="sourceLineNo">471</span><a name="line.471"></a>
-<span class="sourceLineNo">472</span>        current.valueOffset = currentBuffer.position();<a name="line.472"></a>
-<span class="sourceLineNo">473</span>        currentBuffer.skip(current.valueLength);<a name="line.473"></a>
-<span class="sourceLineNo">474</span><a name="line.474"></a>
-<span class="sourceLineNo">475</span>        if (includesTags()) {<a name="line.475"></a>
-<span class="sourceLineNo">476</span>          decodeTags();<a name="line.476"></a>
-<span class="sourceLineNo">477</span>        }<a name="line.477"></a>
-<span class="sourceLineNo">478</span>        if (includesMvcc()) {<a name="line.478"></a>
-<span class="sourceLineNo">479</span>          current.memstoreTS = ByteBuff.readVLong(currentBuffer);<a name="line.479"></a>
-<span class="sourceLineNo">480</span>        } else {<a name="line.480"></a>
-<span class="sourceLineNo">481</span>          current.memstoreTS = 0;<a name="line.481"></a>
-<span class="sourceLineNo">482</span>        }<a name="line.482"></a>
-<span class="sourceLineNo">483</span>        current.nextKvOffset = currentBuffer.position();<a name="line.483"></a>
-<span class="sourceLineNo">484</span>      }<a name="line.484"></a>
-<span class="sourceLineNo">485</span><a name="line.485"></a>
-<span class="sourceLineNo">486</span>      @Override<a name="line.486"></a>
-<span class="sourceLineNo">487</span>      protected void decodeFirst() {<a name="line.487"></a>
-<span class="sourceLineNo">488</span>        currentBuffer.skip(Bytes.SIZEOF_INT);<a name="line.488"></a>
-<span class="sourceLineNo">489</span><a name="line.489"></a>
-<span class="sourceLineNo">490</span>        // read column family<a name="line.490"></a>
-<span class="sourceLineNo">491</span>        byte familyNameLength = currentBuffer.get();<a name="line.491"></a>
-<span class="sourceLineNo">492</span>        familyNameWithSize = new byte[familyNameLength + Bytes.SIZEOF_BYTE];<a name="line.492"></a>
-<span class="sourceLineNo">493</span>        familyNameWithSize[0] = familyNameLength;<a name="line.493"></a>
-<span class="sourceLineNo">494</span>        currentBuffer.get(familyNameWithSize, Bytes.SIZEOF_BYTE,<a name="line.494"></a>
-<span class="sourceLineNo">495</span>            familyNameLength);<a name="line.495"></a>
-<span class="sourceLineNo">496</span>        decode(true);<a name="line.496"></a>
-<span class="sourceLineNo">497</span>      }<a name="line.497"></a>
-<span class="sourceLineNo">498</span><a name="line.498"></a>
-<span class="sourceLineNo">499</span>      @Override<a name="line.499"></a>
-<span class="sourceLineNo">500</span>      protected void decodeNext() {<a name="line.500"></a>
-<span class="sourceLineNo">501</span>        decode(false);<a name="line.501"></a>
-<span class="sourceLineNo">502</span>      }<a name="line.502"></a>
-<span class="sourceLineNo">503</span><a name="line.503"></a>
-<span class="sourceLineNo">504</span>      @Override<a name="line.504"></a>
-<span class="sourceLineNo">505</span>      protected DiffSeekerState createSeekerState() {<a name="line.505"></a>
-<span class="sourceLineNo">506</span>        return new DiffSeekerState(this.tmpPair, this.includesTags());<a name="line.506"></a>
-<span class="sourceLineNo">507</span>      }<a name="line.507"></a>
-<span class="sourceLineNo">508</span>    };<a name="line.508"></a>
-<span class="sourceLineNo">509</span>  }<a name="line.509"></a>
-<span class="sourceLineNo">510</span><a name="line.510"></a>
-<span class="sourceLineNo">511</span>  @Override<a name="line.511"></a>
-<span class="sourceLineNo">512</span>  protected ByteBuffer internalDecodeKeyValues(DataInputStream source, int allocateHeaderLength,<a name="line.512"></a>
-<span class="sourceLineNo">513</span>      int skipLastBytes, HFileBlockDefaultDecodingContext decodingCtx) throws IOException {<a name="line.513"></a>
-<span class="sourceLineNo">514</span>    int decompressedSize = source.readInt();<a name="line.514"></a>
-<span class="sourceLineNo">515</span>    ByteBuffer buffer = ByteBuffer.allocate(decompressedSize +<a name="line.515"></a>
-<span class="sourceLineNo">516</span>        allocateHeaderLength);<a name="line.516"></a>
-<span class="sourceLineNo">517</span>    buffer.position(allocateHeaderLength);<a name="line.517"></a>
-<span class="sourceLineNo">518</span>    DiffCompressionState state = new DiffCompressionState();<a name="line.518"></a>
-<span class="sourceLineNo">519</span>    while (source.available() &gt; skipLastBytes) {<a name="line.519"></a>
-<span class="sourceLineNo">520</span>      uncompressSingleKeyValue(source, buffer, state);<a name="line.520"></a>
-<span class="sourceLineNo">521</span>      afterDecodingKeyValue(source, buffer, decodingCtx);<a name="line.521"></a>
-<span class="sourceLineNo">522</span>    }<a name="line.522"></a>
-<span class="sourceLineNo">523</span><a name="line.523"></a>
-<span class="sourceLineNo">524</span>    if (source.available() != skipLastBytes) {<a name="line.524"></a>
-<span class="sourceLineNo">525</span>      throw new IllegalStateException("Read too much bytes.");<a name="line.525"></a>
-<span class="sourceLineNo">526</span>    }<a name="line.526"></a>
-<span class="sourceLineNo">527</span><a name="line.527"></a>
-<span class="sourceLineNo">528</span>    return buffer;<a name="line.528"></a>
-<span class="sourceLineNo">529</span>  }<a name="line.529"></a>
-<span class="sourceLineNo">530</span>}<a name="line.530"></a>
+<span class="sourceLineNo">370</span>    public DiffSeekerState(ObjectIntPair&lt;ByteBuffer&gt; tmpPair,<a name="line.370"></a>
+<span class="sourceLineNo">371</span>        boolean includeTags, boolean tagsCompressed) {<a name="line.371"></a>
+<span class="sourceLineNo">372</span>      super(tmpPair, includeTags, tagsCompressed);<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>    @Override<a name="line.375"></a>
+<span class="sourceLineNo">376</span>    protected void copyFromNext(SeekerState that) {<a name="line.376"></a>
+<span class="sourceLineNo">377</span>      super.copyFromNext(that);<a name="line.377"></a>
+<span class="sourceLineNo">378</span>      DiffSeekerState other = (DiffSeekerState) that;<a name="line.378"></a>
+<span class="sourceLineNo">379</span>      rowLengthWithSize = other.rowLengthWithSize;<a name="line.379"></a>
+<span class="sourceLineNo">380</span>      timestamp = other.timestamp;<a name="line.380"></a>
+<span class="sourceLineNo">381</span>    }<a name="line.381"></a>
+<span class="sourceLineNo">382</span>  }<a name="line.382"></a>
+<span class="sourceLineNo">383</span><a name="line.383"></a>
+<span class="sourceLineNo">384</span>  @Override<a name="line.384"></a>
+<span class="sourceLineNo">385</span>  public EncodedSeeker createSeeker(CellComparator comparator,<a name="line.385"></a>
+<span class="sourceLineNo">386</span>      HFileBlockDecodingContext decodingCtx) {<a name="line.386"></a>
+<span class="sourceLineNo">387</span>    return new BufferedEncodedSeeker&lt;DiffSeekerState&gt;(comparator, decodingCtx) {<a name="line.387"></a>
+<span class="sourceLineNo">388</span>      private byte[] familyNameWithSize;<a name="line.388"></a>
+<span class="sourceLineNo">389</span>      private static final int TIMESTAMP_WITH_TYPE_LENGTH =<a name="line.389"></a>
+<span class="sourceLineNo">390</span>          Bytes.SIZEOF_LONG + Bytes.SIZEOF_BYTE;<a name="line.390"></a>
+<span class="sourceLineNo">391</span><a name="line.391"></a>
+<span class="sourceLineNo">392</span>      private void decode(boolean isFirst) {<a name="line.392"></a>
+<span class="sourceLineNo">393</span>        byte flag = currentBuffer.get();<a name="line.393"></a>
+<span class="sourceLineNo">394</span>        byte type = 0;<a name="line.394"></a>
+<span class="sourceLineNo">395</span>        if ((flag &amp; FLAG_SAME_KEY_LENGTH) == 0) {<a name="line.395"></a>
+<span class="sourceLineNo">396</span>          if (!isFirst) {<a name="line.396"></a>
+<span class="sourceLineNo">397</span>            type = current.keyBuffer[current.keyLength - Bytes.SIZEOF_BYTE];<a name="line.397"></a>
+<span class="sourceLineNo">398</span>          }<a name="line.398"></a>
+<span class="sourceLineNo">399</span>          current.keyLength = ByteBuff.readCompressedInt(currentBuffer);<a name="line.399"></a>
+<span class="sourceLineNo">400</span>        }<a name="line.400"></a>
+<span class="sourceLineNo">401</span>        if ((flag &amp; FLAG_SAME_VALUE_LENGTH) == 0) {<a name="line.401"></a>
+<span class="sourceLineNo">402</span>          current.valueLength = ByteBuff.readCompressedInt(currentBuffer);<a name="line.402"></a>
+<span class="sourceLineNo">403</span>        }<a name="line.403"></a>
+<span class="sourceLineNo">404</span>        current.lastCommonPrefix = ByteBuff.readCompressedInt(currentBuffer);<a name="line.404"></a>
+<span class="sourceLineNo">405</span><a name="line.405"></a>
+<span class="sourceLineNo">406</span>        current.ensureSpaceForKey();<a name="line.406"></a>
+<span class="sourceLineNo">407</span><a name="line.407"></a>
+<span class="sourceLineNo">408</span>        if (current.lastCommonPrefix &lt; Bytes.SIZEOF_SHORT) {<a name="line.408"></a>
+<span class="sourceLineNo">409</span>          // length of row is different, copy everything except family<a name="line.409"></a>
+<span class="sourceLineNo">410</span><a name="line.410"></a>
+<span class="sourceLineNo">411</span>          // copy the row size<a name="line.411"></a>
+<span class="sourceLineNo">412</span>          currentBuffer.get(current.keyBuffer, current.lastCommonPrefix,<a name="line.412"></a>
+<span class="sourceLineNo">413</span>              Bytes.SIZEOF_SHORT - current.lastCommonPrefix);<a name="line.413"></a>
+<span class="sourceLineNo">414</span>          current.rowLengthWithSize = Bytes.toShort(current.keyBuffer, 0) +<a name="line.414"></a>
+<span class="sourceLineNo">415</span>              Bytes.SIZEOF_SHORT;<a name="line.415"></a>
+<span class="sourceLineNo">416</span><a name="line.416"></a>
+<span class="sourceLineNo">417</span>          // copy the rest of row<a name="line.417"></a>
+<span class="sourceLineNo">418</span>          currentBuffer.get(current.keyBuffer, Bytes.SIZEOF_SHORT,<a name="line.418"></a>
+<span class="sourceLineNo">419</span>              current.rowLengthWithSize - Bytes.SIZEOF_SHORT);<a name="line.419"></a>
+<span class="sourceLineNo">420</span><a name="line.420"></a>
+<span class="sourceLineNo">421</span>          // copy the column family<a name="line.421"></a>
+<span class="sourceLineNo">422</span>          System.arraycopy(familyNameWithSize, 0, current.keyBuffer,<a name="line.422"></a>
+<span class="sourceLineNo">423</span>              current.rowLengthWithSize, familyNameWithSize.length);<a name="line.423"></a>
+<span class="sourceLineNo">424</span><a name="line.424"></a>
+<span class="sourceLineNo">425</span>          // copy the qualifier<a name="line.425"></a>
+<span class="sourceLineNo">426</span>          currentBuffer.get(current.keyBuffer,<a name="line.426"></a>
+<span class="sourceLineNo">427</span>              current.rowLengthWithSize + familyNameWithSize.length,<a name="line.427"></a>
+<span class="sourceLineNo">428</span>              current.keyLength - current.rowLengthWithSize -<a name="line.428"></a>
+<span class="sourceLineNo">429</span>              familyNameWithSize.length - TIMESTAMP_WITH_TYPE_LENGTH);<a name="line.429"></a>
+<span class="sourceLineNo">430</span>        } else if (current.lastCommonPrefix &lt; current.rowLengthWithSize) {<a name="line.430"></a>
+<span class="sourceLineNo">431</span>          // we have to copy part of row and qualifier,<a name="line.431"></a>
+<span class="sourceLineNo">432</span>          // but column family is in right place<a name="line.432"></a>
+<span class="sourceLineNo">433</span><a name="line.433"></a>
+<span class="sourceLineNo">434</span>          // before column family (rest of row)<a name="line.434"></a>
+<span class="sourceLineNo">435</span>          currentBuffer.get(current.keyBuffer, current.lastCommonPrefix,<a name="line.435"></a>
+<span class="sourceLineNo">436</span>              current.rowLengthWithSize - current.lastCommonPrefix);<a name="line.436"></a>
+<span class="sourceLineNo">437</span><a name="line.437"></a>
+<span class="sourceLineNo">438</span>          // after column family (qualifier)<a name="line.438"></a>
+<span class="sourceLineNo">439</span>          currentBuffer.get(current.keyBuffer,<a name="line.439"></a>
+<span class="sourceLineNo">440</span>              current.rowLengthWithSize + familyNameWithSize.length,<a name="line.440"></a>
+<span class="sourceLineNo">441</span>              current.keyLength - current.rowLengthWithSize -<a name="line.441"></a>
+<span class="sourceLineNo">442</span>              familyNameWithSize.length - TIMESTAMP_WITH_TYPE_LENGTH);<a name="line.442"></a>
+<span class="sourceLineNo">443</span>        } else {<a name="line.443"></a>
+<span class="sourceLineNo">444</span>          // copy just the ending<a name="line.444"></a>
+<span class="sourceLineNo">445</span>          currentBuffer.get(current.keyBuffer, current.lastCommonPrefix,<a name="line.445"></a>
+<span class="sourceLineNo">446</span>              current.keyLength - TIMESTAMP_WITH_TYPE_LENGTH -<a name="line.446"></a>
+<span class="sourceLineNo">447</span>              current.lastCommonPrefix);<a name="line.447"></a>
+<span class="sourceLineNo">448</span>        }<a name="line.448"></a>
+<span class="sourceLineNo">449</span><a name="line.449"></a>
+<span class="sourceLineNo">450</span>        // timestamp<a name="line.450"></a>
+<span class="sourceLineNo">451</span>        int pos = current.keyLength - TIMESTAMP_WITH_TYPE_LENGTH;<a name="line.451"></a>
+<span class="sourceLineNo">452</span>        int timestampFitInBytes = 1 +<a name="line.452"></a>
+<span class="sourceLineNo">453</span>            ((flag &amp; MASK_TIMESTAMP_LENGTH) &gt;&gt;&gt; SHIFT_TIMESTAMP_LENGTH);<a name="line.453"></a>
+<span class="sourceLineNo">454</span>        long timestampOrDiff = ByteBuff.readLong(currentBuffer, timestampFitInBytes);<a name="line.454"></a>
+<span class="sourceLineNo">455</span>        if ((flag &amp; FLAG_TIMESTAMP_SIGN) != 0) {<a name="line.455"></a>
+<span class="sourceLineNo">456</span>          timestampOrDiff = -timestampOrDiff;<a name="line.456"></a>
+<span class="sourceLineNo">457</span>        }<a name="line.457"></a>
+<span class="sourceLineNo">458</span>        if ((flag &amp; FLAG_TIMESTAMP_IS_DIFF) == 0) { // it is timestamp<a name="line.458"></a>
+<span class="sourceLineNo">459</span>          current.timestamp = timestampOrDiff;<a name="line.459"></a>
+<span class="sourceLineNo">460</span>        } else { // it is diff<a name="line.460"></a>
+<span class="sourceLineNo">461</span>          current.timestamp = current.timestamp - timestampOrDiff;<a name="line.461"></a>
+<span class="sourceLineNo">462</span>        }<a name="line.462"></a>
+<span class="sourceLineNo">463</span>        Bytes.putLong(current.keyBuffer, pos, current.timestamp);<a name="line.463"></a>
+<span class="sourceLineNo">464</span>        pos += Bytes.SIZEOF_LONG;<a name="line.464"></a>
+<span class="sourceLineNo">465</span><a name="line.465"></a>
+<span class="sourceLineNo">466</span>        // type<a name="line.466"></a>
+<span class="sourceLineNo">467</span>        if ((flag &amp; FLAG_SAME_TYPE) == 0) {<a name="line.467"></a>
+<span class="sourceLineNo">468</span>          currentBuffer.get(current.keyBuffer, pos, Bytes.SIZEOF_BYTE);<a name="line.468"></a>
+<span class="sourceLineNo">469</span>        } else if ((flag &amp; FLAG_SAME_KEY_LENGTH) == 0) {<a name="line.469"></a>
+<span class="sourceLineNo">470</span>          current.keyBuffer[pos] = type;<a name="line.470"></a>
+<span class="sourceLineNo">471</span>        }<a name="line.471"></a>
+<span class="sourceLineNo">472</span><a name="line.472"></a>
+<span class="sourceLineNo">473</span>        current.valueOffset = currentBuffer.position();<a name="line.473"></a>
+<span class="sourceLineNo">474</span>        currentBuffer.skip(current.valueLength);<a name="line.474"></a>
+<span class="sourceLineNo">475</span><a name="line.475"></a>
+<span class="sourceLineNo">476</span>        if (includesTags()) {<a name="line.476"></a>
+<span class="sourceLineNo">477</span>          decodeTags();<a name="line.477"></a>
+<span class="sourceLineNo">478</span>        }<a name="line.478"></a>
+<span class="sourceLineNo">479</span>        if (includesMvcc()) {<a name="line.479"></a>
+<span class="sourceLineNo">480</span>          current.memstoreTS = ByteBuff.readVLong(currentBuffer);<a name="line.480"></a>
+<span class="sourceLineNo">481</span>        } else {<a name="line.481"></a>
+<span class="sourceLineNo">482</span>          current.memstoreTS = 0;<a name="line.482"></a>
+<span class="sourceLineNo">483</span>        }<a name="line.483"></a>
+<span class="sourceLineNo">484</span>        current.nextKvOffset = currentBuffer.position();<a name="line.484"></a>
+<span class="sourceLineNo">485</span>      }<a name="line.485"></a>
+<span class="sourceLineNo">486</span><a name="line.486"></a>
+<span class="sourceLineNo">487</span>      @Override<a name="line.487"></a>
+<span class="sourceLineNo">488</span>      protected void decodeFirst() {<a name="line.488"></a>
+<span class="sourceLineNo">489</span>        currentBuffer.skip(Bytes.SIZEOF_INT);<a name="line.489"></a>
+<span class="sourceLineNo">490</span><a name="line.490"></a>
+<span class="sourceLineNo">491</span>        // read column family<a name="line.491"></a>
+<span class="sourceLineNo">492</span>        byte familyNameLength = currentBuffer.get();<a name="line.492"></a>
+<span class="sourceLineNo">493</span>        familyNameWithSize = new byte[familyNameLength + Bytes.SIZEOF_BYTE];<a name="line.493"></a>
+<span class="sourceLineNo">494</span>        familyNameWithSize[0] = familyNameLength;<a name="line.494"></a>
+<span class="sourceLineNo">495</span>        currentBuffer.get(familyNameWithSize, Bytes.SIZEOF_BYTE,<a name="line.495"></a>
+<span class="sourceLineNo">496</span>            familyNameLength);<a name="line.496"></a>
+<span class="sourceLineNo">497</span>        decode(true);<a name="line.497"></a>
+<span class="sourceLineNo">498</span>      }<a name="line.498"></a>
+<span class="sourceLineNo">499</span><a name="line.499"></a>
+<span class="sourceLineNo">500</span>      @Override<a name="line.500"></a>
+<span class="sourceLineNo">501</span>      protected void decodeNext() {<a name="line.501"></a>
+<span class="sourceLineNo">502</span>        decode(false);<a name="line.502"></a>
+<span class="sourceLineNo">503</span>      }<a name="line.503"></a>
+<span class="sourceLineNo">504</span><a name="line.504"></a>
+<span class="sourceLineNo">505</span>      @Override<a name="line.505"></a>
+<span class="sourceLineNo">506</span>      protected DiffSeekerState createSeekerState() {<a name="line.506"></a>
+<span class="sourceLineNo">507</span>        return new DiffSeekerState(this.tmpPair, this.includesTags(),<a name="line.507"></a>
+<span class="sourceLineNo">508</span>            this.tagsCompressed());<a name="line.508"></a>
+<span class="sourceLineNo">509</span>      }<a name="line.509"></a>
+<span class="sourceLineNo">510</span>    };<a name="line.510"></a>
+<span class="sourceLineNo">511</span>  }<a name="line.511"></a>
+<span class="sourceLineNo">512</span><a name="line.512"></a>
+<span class="sourceLineNo">513</span>  @Override<a name="line.513"></a>
+<span class="sourceLineNo">514</span>  protected ByteBuffer internalDecodeKeyValues(DataInputStream source, int allocateHeaderLength,<a name="line.514"></a>
+<span class="sourceLineNo">515</span>      int skipLastBytes, HFileBlockDefaultDecodingContext decodingCtx) throws IOException {<a name="line.515"></a>
+<span class="sourceLineNo">516</span>    int decompressedSize = source.readInt();<a name="line.516"></a>
+<span class="sourceLineNo">517</span>    ByteBuffer buffer = ByteBuffer.allocate(decompressedSize +<a name="line.517"></a>
+<span class="sourceLineNo">518</span>        allocateHeaderLength);<a name="line.518"></a>
+<span class="sourceLineNo">519</span>    buffer.position(allocateHeaderLength);<a name="line.519"></a>
+<span class="sourceLineNo">520</span>    DiffCompressionState state = new DiffCompressionState();<a name="line.520"></a>
+<span class="sourceLineNo">521</span>    while (source.available() &gt; skipLastBytes) {<a name="line.521"></a>
+<span class="sourceLineNo">522</span>      uncompressSingleKeyValue(source, buffer, state);<a name="line.522"></a>
+<span class="sourceLineNo">523</span>      afterDecodingKeyValue(source, buffer, decodingCtx);<a name="line.523"></a>
+<span class="sourceLineNo">524</span>    }<a name="line.524"></a>
+<span class="sourceLineNo">525</span><a name="line.525"></a>
+<span class="sourceLineNo">526</span>    if (source.available() != skipLastBytes) {<a name="line.526"></a>
+<span class="sourceLineNo">527</span>      throw new IllegalStateException("Read too much bytes.");<a name="line.527"></a>
+<span class="sourceLineNo">528</span>    }<a name="line.528"></a>
+<span class="sourceLineNo">529</span><a name="line.529"></a>
+<span class="sourceLineNo">530</span>    return buffer;<a name="line.530"></a>
+<span class="sourceLineNo">531</span>  }<a name="line.531"></a>
+<span class="sourceLineNo">532</span>}<a name="line.532"></a>
 
 
 


Mime
View raw message