hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [38/52] [partial] hbase-site git commit: Published site at 424b789e0394fdc074b1725275e30b04e601b486.
Date Mon, 27 Jun 2016 17:20:05 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a0cdd2a9/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/KeyValueSerialization.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/KeyValueSerialization.html b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/KeyValueSerialization.html
new file mode 100644
index 0000000..dcc5d02
--- /dev/null
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/KeyValueSerialization.html
@@ -0,0 +1,162 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
+</head>
+<body>
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span>/**<a name="line.1"></a>
+<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.2"></a>
+<span class="sourceLineNo">003</span> * or more contributor license agreements.  See the NOTICE file<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * distributed with this work for additional information<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * regarding copyright ownership.  The ASF licenses this file<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * to you under the Apache License, Version 2.0 (the<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * "License"); you may not use this file except in compliance<a name="line.7"></a>
+<span class="sourceLineNo">008</span> * with the License.  You may obtain a copy of the License at<a name="line.8"></a>
+<span class="sourceLineNo">009</span> *<a name="line.9"></a>
+<span class="sourceLineNo">010</span> *     http://www.apache.org/licenses/LICENSE-2.0<a name="line.10"></a>
+<span class="sourceLineNo">011</span> *<a name="line.11"></a>
+<span class="sourceLineNo">012</span> * Unless required by applicable law or agreed to in writing, software<a name="line.12"></a>
+<span class="sourceLineNo">013</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * See the License for the specific language governing permissions and<a name="line.15"></a>
+<span class="sourceLineNo">016</span> * limitations under the License.<a name="line.16"></a>
+<span class="sourceLineNo">017</span> */<a name="line.17"></a>
+<span class="sourceLineNo">018</span>package org.apache.hadoop.hbase.mapreduce;<a name="line.18"></a>
+<span class="sourceLineNo">019</span><a name="line.19"></a>
+<span class="sourceLineNo">020</span>import java.io.DataInputStream;<a name="line.20"></a>
+<span class="sourceLineNo">021</span>import java.io.DataOutputStream;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.io.IOException;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.io.InputStream;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import java.io.OutputStream;<a name="line.24"></a>
+<span class="sourceLineNo">025</span><a name="line.25"></a>
+<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.KeyValue;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.KeyValueUtil;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.classification.InterfaceStability;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.io.serializer.Deserializer;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.io.serializer.Serialization;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.io.serializer.Serializer;<a name="line.32"></a>
+<span class="sourceLineNo">033</span><a name="line.33"></a>
+<span class="sourceLineNo">034</span>@InterfaceAudience.Public<a name="line.34"></a>
+<span class="sourceLineNo">035</span>@InterfaceStability.Evolving<a name="line.35"></a>
+<span class="sourceLineNo">036</span>public class KeyValueSerialization implements Serialization&lt;KeyValue&gt; {<a name="line.36"></a>
+<span class="sourceLineNo">037</span>  @Override<a name="line.37"></a>
+<span class="sourceLineNo">038</span>  public boolean accept(Class&lt;?&gt; c) {<a name="line.38"></a>
+<span class="sourceLineNo">039</span>    return KeyValue.class.isAssignableFrom(c);<a name="line.39"></a>
+<span class="sourceLineNo">040</span>  }<a name="line.40"></a>
+<span class="sourceLineNo">041</span><a name="line.41"></a>
+<span class="sourceLineNo">042</span>  @Override<a name="line.42"></a>
+<span class="sourceLineNo">043</span>  public KeyValueDeserializer getDeserializer(Class&lt;KeyValue&gt; t) {<a name="line.43"></a>
+<span class="sourceLineNo">044</span>    return new KeyValueDeserializer();<a name="line.44"></a>
+<span class="sourceLineNo">045</span>  }<a name="line.45"></a>
+<span class="sourceLineNo">046</span><a name="line.46"></a>
+<span class="sourceLineNo">047</span>  @Override<a name="line.47"></a>
+<span class="sourceLineNo">048</span>  public KeyValueSerializer getSerializer(Class&lt;KeyValue&gt; c) {<a name="line.48"></a>
+<span class="sourceLineNo">049</span>    return new KeyValueSerializer();<a name="line.49"></a>
+<span class="sourceLineNo">050</span>  }<a name="line.50"></a>
+<span class="sourceLineNo">051</span><a name="line.51"></a>
+<span class="sourceLineNo">052</span>  public static class KeyValueDeserializer implements Deserializer&lt;KeyValue&gt; {<a name="line.52"></a>
+<span class="sourceLineNo">053</span>    private DataInputStream dis;<a name="line.53"></a>
+<span class="sourceLineNo">054</span><a name="line.54"></a>
+<span class="sourceLineNo">055</span>    @Override<a name="line.55"></a>
+<span class="sourceLineNo">056</span>    public void close() throws IOException {<a name="line.56"></a>
+<span class="sourceLineNo">057</span>      this.dis.close();<a name="line.57"></a>
+<span class="sourceLineNo">058</span>    }<a name="line.58"></a>
+<span class="sourceLineNo">059</span><a name="line.59"></a>
+<span class="sourceLineNo">060</span>    @Override<a name="line.60"></a>
+<span class="sourceLineNo">061</span>    public KeyValue deserialize(KeyValue ignore) throws IOException {<a name="line.61"></a>
+<span class="sourceLineNo">062</span>      // I can't overwrite the passed in KV, not from a proto kv, not just yet.  TODO<a name="line.62"></a>
+<span class="sourceLineNo">063</span>      return KeyValueUtil.create(this.dis);<a name="line.63"></a>
+<span class="sourceLineNo">064</span>    }<a name="line.64"></a>
+<span class="sourceLineNo">065</span><a name="line.65"></a>
+<span class="sourceLineNo">066</span>    @Override<a name="line.66"></a>
+<span class="sourceLineNo">067</span>    public void open(InputStream is) throws IOException {<a name="line.67"></a>
+<span class="sourceLineNo">068</span>      this.dis = new DataInputStream(is);<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>  public static class KeyValueSerializer implements Serializer&lt;KeyValue&gt; {<a name="line.72"></a>
+<span class="sourceLineNo">073</span>    private DataOutputStream dos;<a name="line.73"></a>
+<span class="sourceLineNo">074</span><a name="line.74"></a>
+<span class="sourceLineNo">075</span>    @Override<a name="line.75"></a>
+<span class="sourceLineNo">076</span>    public void close() throws IOException {<a name="line.76"></a>
+<span class="sourceLineNo">077</span>      this.dos.close();<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    }<a name="line.78"></a>
+<span class="sourceLineNo">079</span><a name="line.79"></a>
+<span class="sourceLineNo">080</span>    @Override<a name="line.80"></a>
+<span class="sourceLineNo">081</span>    public void open(OutputStream os) throws IOException {<a name="line.81"></a>
+<span class="sourceLineNo">082</span>      this.dos = new DataOutputStream(os);<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>    @Override<a name="line.85"></a>
+<span class="sourceLineNo">086</span>    public void serialize(KeyValue kv) throws IOException {<a name="line.86"></a>
+<span class="sourceLineNo">087</span>      KeyValueUtil.write(kv, this.dos);<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>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</pre>
+</div>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a0cdd2a9/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MutationSerialization.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MutationSerialization.html b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MutationSerialization.html
new file mode 100644
index 0000000..d9b7c63
--- /dev/null
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MutationSerialization.html
@@ -0,0 +1,172 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
+</head>
+<body>
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span>/**<a name="line.1"></a>
+<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.2"></a>
+<span class="sourceLineNo">003</span> * or more contributor license agreements.  See the NOTICE file<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * distributed with this work for additional information<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * regarding copyright ownership.  The ASF licenses this file<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * to you under the Apache License, Version 2.0 (the<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * "License"); you may not use this file except in compliance<a name="line.7"></a>
+<span class="sourceLineNo">008</span> * with the License.  You may obtain a copy of the License at<a name="line.8"></a>
+<span class="sourceLineNo">009</span> *<a name="line.9"></a>
+<span class="sourceLineNo">010</span> *     http://www.apache.org/licenses/LICENSE-2.0<a name="line.10"></a>
+<span class="sourceLineNo">011</span> *<a name="line.11"></a>
+<span class="sourceLineNo">012</span> * Unless required by applicable law or agreed to in writing, software<a name="line.12"></a>
+<span class="sourceLineNo">013</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * See the License for the specific language governing permissions and<a name="line.15"></a>
+<span class="sourceLineNo">016</span> * limitations under the License.<a name="line.16"></a>
+<span class="sourceLineNo">017</span> */<a name="line.17"></a>
+<span class="sourceLineNo">018</span>package org.apache.hadoop.hbase.mapreduce;<a name="line.18"></a>
+<span class="sourceLineNo">019</span><a name="line.19"></a>
+<span class="sourceLineNo">020</span>import java.io.IOException;<a name="line.20"></a>
+<span class="sourceLineNo">021</span>import java.io.InputStream;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.io.OutputStream;<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.client.Delete;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.client.Mutation;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.client.Put;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.protobuf.ProtobufUtil;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.io.serializer.Deserializer;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.io.serializer.Serialization;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.io.serializer.Serializer;<a name="line.34"></a>
+<span class="sourceLineNo">035</span><a name="line.35"></a>
+<span class="sourceLineNo">036</span>@InterfaceAudience.Public<a name="line.36"></a>
+<span class="sourceLineNo">037</span>@InterfaceStability.Evolving<a name="line.37"></a>
+<span class="sourceLineNo">038</span>public class MutationSerialization implements Serialization&lt;Mutation&gt; {<a name="line.38"></a>
+<span class="sourceLineNo">039</span>  @Override<a name="line.39"></a>
+<span class="sourceLineNo">040</span>  public boolean accept(Class&lt;?&gt; c) {<a name="line.40"></a>
+<span class="sourceLineNo">041</span>    return Mutation.class.isAssignableFrom(c);<a name="line.41"></a>
+<span class="sourceLineNo">042</span>  }<a name="line.42"></a>
+<span class="sourceLineNo">043</span><a name="line.43"></a>
+<span class="sourceLineNo">044</span>  @Override<a name="line.44"></a>
+<span class="sourceLineNo">045</span>  public Deserializer&lt;Mutation&gt; getDeserializer(Class&lt;Mutation&gt; c) {<a name="line.45"></a>
+<span class="sourceLineNo">046</span>    return new MutationDeserializer();<a name="line.46"></a>
+<span class="sourceLineNo">047</span>  }<a name="line.47"></a>
+<span class="sourceLineNo">048</span><a name="line.48"></a>
+<span class="sourceLineNo">049</span>  @Override<a name="line.49"></a>
+<span class="sourceLineNo">050</span>  public Serializer&lt;Mutation&gt; getSerializer(Class&lt;Mutation&gt; c) {<a name="line.50"></a>
+<span class="sourceLineNo">051</span>    return new MutationSerializer();<a name="line.51"></a>
+<span class="sourceLineNo">052</span>  }<a name="line.52"></a>
+<span class="sourceLineNo">053</span><a name="line.53"></a>
+<span class="sourceLineNo">054</span>  private static class MutationDeserializer implements Deserializer&lt;Mutation&gt; {<a name="line.54"></a>
+<span class="sourceLineNo">055</span>    private InputStream in;<a name="line.55"></a>
+<span class="sourceLineNo">056</span><a name="line.56"></a>
+<span class="sourceLineNo">057</span>    @Override<a name="line.57"></a>
+<span class="sourceLineNo">058</span>    public void close() throws IOException {<a name="line.58"></a>
+<span class="sourceLineNo">059</span>      in.close();<a name="line.59"></a>
+<span class="sourceLineNo">060</span>    }<a name="line.60"></a>
+<span class="sourceLineNo">061</span><a name="line.61"></a>
+<span class="sourceLineNo">062</span>    @Override<a name="line.62"></a>
+<span class="sourceLineNo">063</span>    public Mutation deserialize(Mutation mutation) throws IOException {<a name="line.63"></a>
+<span class="sourceLineNo">064</span>      MutationProto proto = MutationProto.parseDelimitedFrom(in);<a name="line.64"></a>
+<span class="sourceLineNo">065</span>      return ProtobufUtil.toMutation(proto);<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    }<a name="line.66"></a>
+<span class="sourceLineNo">067</span><a name="line.67"></a>
+<span class="sourceLineNo">068</span>    @Override<a name="line.68"></a>
+<span class="sourceLineNo">069</span>    public void open(InputStream in) throws IOException {<a name="line.69"></a>
+<span class="sourceLineNo">070</span>      this.in = in;<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>  }<a name="line.73"></a>
+<span class="sourceLineNo">074</span>  private static class MutationSerializer implements Serializer&lt;Mutation&gt; {<a name="line.74"></a>
+<span class="sourceLineNo">075</span>    private OutputStream out;<a name="line.75"></a>
+<span class="sourceLineNo">076</span><a name="line.76"></a>
+<span class="sourceLineNo">077</span>    @Override<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    public void close() throws IOException {<a name="line.78"></a>
+<span class="sourceLineNo">079</span>      out.close();<a name="line.79"></a>
+<span class="sourceLineNo">080</span>    }<a name="line.80"></a>
+<span class="sourceLineNo">081</span><a name="line.81"></a>
+<span class="sourceLineNo">082</span>    @Override<a name="line.82"></a>
+<span class="sourceLineNo">083</span>    public void open(OutputStream out) throws IOException {<a name="line.83"></a>
+<span class="sourceLineNo">084</span>      this.out = out;<a name="line.84"></a>
+<span class="sourceLineNo">085</span>    }<a name="line.85"></a>
+<span class="sourceLineNo">086</span><a name="line.86"></a>
+<span class="sourceLineNo">087</span>    @Override<a name="line.87"></a>
+<span class="sourceLineNo">088</span>    public void serialize(Mutation mutation) throws IOException {<a name="line.88"></a>
+<span class="sourceLineNo">089</span>      MutationType type;<a name="line.89"></a>
+<span class="sourceLineNo">090</span>      if (mutation instanceof Put) {<a name="line.90"></a>
+<span class="sourceLineNo">091</span>        type = MutationType.PUT;<a name="line.91"></a>
+<span class="sourceLineNo">092</span>      } else if (mutation instanceof Delete) {<a name="line.92"></a>
+<span class="sourceLineNo">093</span>        type = MutationType.DELETE;<a name="line.93"></a>
+<span class="sourceLineNo">094</span>      } else {<a name="line.94"></a>
+<span class="sourceLineNo">095</span>        throw new IllegalArgumentException("Only Put and Delete are supported");<a name="line.95"></a>
+<span class="sourceLineNo">096</span>      }<a name="line.96"></a>
+<span class="sourceLineNo">097</span>      ProtobufUtil.toMutation(type, mutation).writeDelimitedTo(out);<a name="line.97"></a>
+<span class="sourceLineNo">098</span>    }<a name="line.98"></a>
+<span class="sourceLineNo">099</span>  }<a name="line.99"></a>
+<span class="sourceLineNo">100</span>}<a name="line.100"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</pre>
+</div>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a0cdd2a9/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/PutSortReducer.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/PutSortReducer.html b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/PutSortReducer.html
index a5f6e5e..ac18540 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/PutSortReducer.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/PutSortReducer.html
@@ -26,78 +26,135 @@
 <span class="sourceLineNo">018</span> */<a name="line.18"></a>
 <span class="sourceLineNo">019</span>package org.apache.hadoop.hbase.mapreduce;<a name="line.19"></a>
 <span class="sourceLineNo">020</span><a name="line.20"></a>
-<span class="sourceLineNo">021</span>import java.util.Iterator;<a name="line.21"></a>
-<span class="sourceLineNo">022</span>import java.util.List;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import java.util.TreeSet;<a name="line.23"></a>
-<span class="sourceLineNo">024</span><a name="line.24"></a>
-<span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.Cell;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.CellComparator;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.KeyValue;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.KeyValueUtil;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.classification.InterfaceStability;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.client.Put;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.io.ImmutableBytesWritable;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.mapreduce.Reducer;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.util.StringUtils;<a name="line.34"></a>
-<span class="sourceLineNo">035</span><a name="line.35"></a>
-<span class="sourceLineNo">036</span>/**<a name="line.36"></a>
-<span class="sourceLineNo">037</span> * Emits sorted Puts.<a name="line.37"></a>
-<span class="sourceLineNo">038</span> * Reads in all Puts from passed Iterator, sorts them, then emits<a name="line.38"></a>
-<span class="sourceLineNo">039</span> * Puts in sorted order.  If lots of columns per row, it will use lots of<a name="line.39"></a>
-<span class="sourceLineNo">040</span> * memory sorting.<a name="line.40"></a>
-<span class="sourceLineNo">041</span> * @see HFileOutputFormat2<a name="line.41"></a>
-<span class="sourceLineNo">042</span> * @see KeyValueSortReducer<a name="line.42"></a>
-<span class="sourceLineNo">043</span> */<a name="line.43"></a>
-<span class="sourceLineNo">044</span>@InterfaceAudience.Public<a name="line.44"></a>
-<span class="sourceLineNo">045</span>@InterfaceStability.Stable<a name="line.45"></a>
-<span class="sourceLineNo">046</span>public class PutSortReducer extends<a name="line.46"></a>
-<span class="sourceLineNo">047</span>    Reducer&lt;ImmutableBytesWritable, Put, ImmutableBytesWritable, KeyValue&gt; {<a name="line.47"></a>
-<span class="sourceLineNo">048</span>  <a name="line.48"></a>
-<span class="sourceLineNo">049</span>  @Override<a name="line.49"></a>
-<span class="sourceLineNo">050</span>  protected void reduce(<a name="line.50"></a>
-<span class="sourceLineNo">051</span>      ImmutableBytesWritable row,<a name="line.51"></a>
-<span class="sourceLineNo">052</span>      java.lang.Iterable&lt;Put&gt; puts,<a name="line.52"></a>
-<span class="sourceLineNo">053</span>      Reducer&lt;ImmutableBytesWritable, Put,<a name="line.53"></a>
-<span class="sourceLineNo">054</span>              ImmutableBytesWritable, KeyValue&gt;.Context context)<a name="line.54"></a>
-<span class="sourceLineNo">055</span>      throws java.io.IOException, InterruptedException<a name="line.55"></a>
-<span class="sourceLineNo">056</span>  {<a name="line.56"></a>
-<span class="sourceLineNo">057</span>    // although reduce() is called per-row, handle pathological case<a name="line.57"></a>
-<span class="sourceLineNo">058</span>    long threshold = context.getConfiguration().getLong(<a name="line.58"></a>
-<span class="sourceLineNo">059</span>        "putsortreducer.row.threshold", 1L * (1&lt;&lt;30));<a name="line.59"></a>
-<span class="sourceLineNo">060</span>    Iterator&lt;Put&gt; iter = puts.iterator();<a name="line.60"></a>
-<span class="sourceLineNo">061</span>    while (iter.hasNext()) {<a name="line.61"></a>
-<span class="sourceLineNo">062</span>      TreeSet&lt;KeyValue&gt; map = new TreeSet&lt;KeyValue&gt;(CellComparator.COMPARATOR);<a name="line.62"></a>
-<span class="sourceLineNo">063</span>      long curSize = 0;<a name="line.63"></a>
-<span class="sourceLineNo">064</span>      // stop at the end or the RAM threshold<a name="line.64"></a>
-<span class="sourceLineNo">065</span>      while (iter.hasNext() &amp;&amp; curSize &lt; threshold) {<a name="line.65"></a>
-<span class="sourceLineNo">066</span>        Put p = iter.next();<a name="line.66"></a>
-<span class="sourceLineNo">067</span>        for (List&lt;Cell&gt; cells: p.getFamilyCellMap().values()) {<a name="line.67"></a>
-<span class="sourceLineNo">068</span>          for (Cell cell: cells) {<a name="line.68"></a>
-<span class="sourceLineNo">069</span>            KeyValue kv = KeyValueUtil.ensureKeyValue(cell);<a name="line.69"></a>
-<span class="sourceLineNo">070</span>            if (map.add(kv)) {// don't count duplicated kv into size<a name="line.70"></a>
-<span class="sourceLineNo">071</span>              curSize += kv.heapSize();<a name="line.71"></a>
-<span class="sourceLineNo">072</span>            }<a name="line.72"></a>
-<span class="sourceLineNo">073</span>          }<a name="line.73"></a>
-<span class="sourceLineNo">074</span>        }<a name="line.74"></a>
-<span class="sourceLineNo">075</span>      }<a name="line.75"></a>
-<span class="sourceLineNo">076</span>      context.setStatus("Read " + map.size() + " entries of " + map.getClass()<a name="line.76"></a>
-<span class="sourceLineNo">077</span>          + "(" + StringUtils.humanReadableInt(curSize) + ")");<a name="line.77"></a>
-<span class="sourceLineNo">078</span>      int index = 0;<a name="line.78"></a>
-<span class="sourceLineNo">079</span>      for (KeyValue kv : map) {<a name="line.79"></a>
-<span class="sourceLineNo">080</span>        context.write(row, kv);<a name="line.80"></a>
-<span class="sourceLineNo">081</span>        if (++index % 100 == 0)<a name="line.81"></a>
-<span class="sourceLineNo">082</span>          context.setStatus("Wrote " + index);<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>      // if we have more entries to process<a name="line.85"></a>
-<span class="sourceLineNo">086</span>      if (iter.hasNext()) {<a name="line.86"></a>
-<span class="sourceLineNo">087</span>        // force flush because we cannot guarantee intra-row sorted order<a name="line.87"></a>
-<span class="sourceLineNo">088</span>        context.write(null, null);<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>  }<a name="line.91"></a>
-<span class="sourceLineNo">092</span>}<a name="line.92"></a>
+<span class="sourceLineNo">021</span>import java.io.IOException;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.util.ArrayList;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.util.Iterator;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import java.util.List;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import java.util.TreeSet;<a name="line.25"></a>
+<span class="sourceLineNo">026</span><a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.conf.Configuration;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.ArrayBackedTag;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.Cell;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.CellComparator;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.KeyValue;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.KeyValueUtil;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.Tag;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.TagType;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.TagUtil;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.classification.InterfaceStability;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.client.Put;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.exceptions.DeserializationException;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.io.ImmutableBytesWritable;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.security.visibility.CellVisibility;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.42"></a>
+<span class="sourceLineNo">043</span>import org.apache.hadoop.mapreduce.Reducer;<a name="line.43"></a>
+<span class="sourceLineNo">044</span>import org.apache.hadoop.util.StringUtils;<a name="line.44"></a>
+<span class="sourceLineNo">045</span><a name="line.45"></a>
+<span class="sourceLineNo">046</span>/**<a name="line.46"></a>
+<span class="sourceLineNo">047</span> * Emits sorted Puts.<a name="line.47"></a>
+<span class="sourceLineNo">048</span> * Reads in all Puts from passed Iterator, sorts them, then emits<a name="line.48"></a>
+<span class="sourceLineNo">049</span> * Puts in sorted order.  If lots of columns per row, it will use lots of<a name="line.49"></a>
+<span class="sourceLineNo">050</span> * memory sorting.<a name="line.50"></a>
+<span class="sourceLineNo">051</span> * @see HFileOutputFormat2<a name="line.51"></a>
+<span class="sourceLineNo">052</span> * @see KeyValueSortReducer<a name="line.52"></a>
+<span class="sourceLineNo">053</span> */<a name="line.53"></a>
+<span class="sourceLineNo">054</span>@InterfaceAudience.Public<a name="line.54"></a>
+<span class="sourceLineNo">055</span>@InterfaceStability.Stable<a name="line.55"></a>
+<span class="sourceLineNo">056</span>public class PutSortReducer extends<a name="line.56"></a>
+<span class="sourceLineNo">057</span>    Reducer&lt;ImmutableBytesWritable, Put, ImmutableBytesWritable, KeyValue&gt; {<a name="line.57"></a>
+<span class="sourceLineNo">058</span>  // the cell creator<a name="line.58"></a>
+<span class="sourceLineNo">059</span>  private CellCreator kvCreator;<a name="line.59"></a>
+<span class="sourceLineNo">060</span><a name="line.60"></a>
+<span class="sourceLineNo">061</span>  @Override<a name="line.61"></a>
+<span class="sourceLineNo">062</span>  protected void<a name="line.62"></a>
+<span class="sourceLineNo">063</span>      setup(Reducer&lt;ImmutableBytesWritable, Put, ImmutableBytesWritable, KeyValue&gt;.Context context)<a name="line.63"></a>
+<span class="sourceLineNo">064</span>          throws IOException, InterruptedException {<a name="line.64"></a>
+<span class="sourceLineNo">065</span>    Configuration conf = context.getConfiguration();<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    this.kvCreator = new CellCreator(conf);<a name="line.66"></a>
+<span class="sourceLineNo">067</span>  }<a name="line.67"></a>
+<span class="sourceLineNo">068</span><a name="line.68"></a>
+<span class="sourceLineNo">069</span>  @Override<a name="line.69"></a>
+<span class="sourceLineNo">070</span>  protected void reduce(<a name="line.70"></a>
+<span class="sourceLineNo">071</span>      ImmutableBytesWritable row,<a name="line.71"></a>
+<span class="sourceLineNo">072</span>      java.lang.Iterable&lt;Put&gt; puts,<a name="line.72"></a>
+<span class="sourceLineNo">073</span>      Reducer&lt;ImmutableBytesWritable, Put,<a name="line.73"></a>
+<span class="sourceLineNo">074</span>              ImmutableBytesWritable, KeyValue&gt;.Context context)<a name="line.74"></a>
+<span class="sourceLineNo">075</span>      throws java.io.IOException, InterruptedException<a name="line.75"></a>
+<span class="sourceLineNo">076</span>  {<a name="line.76"></a>
+<span class="sourceLineNo">077</span>    // although reduce() is called per-row, handle pathological case<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    long threshold = context.getConfiguration().getLong(<a name="line.78"></a>
+<span class="sourceLineNo">079</span>        "putsortreducer.row.threshold", 1L * (1&lt;&lt;30));<a name="line.79"></a>
+<span class="sourceLineNo">080</span>    Iterator&lt;Put&gt; iter = puts.iterator();<a name="line.80"></a>
+<span class="sourceLineNo">081</span>    while (iter.hasNext()) {<a name="line.81"></a>
+<span class="sourceLineNo">082</span>      TreeSet&lt;KeyValue&gt; map = new TreeSet&lt;KeyValue&gt;(CellComparator.COMPARATOR);<a name="line.82"></a>
+<span class="sourceLineNo">083</span>      long curSize = 0;<a name="line.83"></a>
+<span class="sourceLineNo">084</span>      // stop at the end or the RAM threshold<a name="line.84"></a>
+<span class="sourceLineNo">085</span>      List&lt;Tag&gt; tags = new ArrayList&lt;Tag&gt;();<a name="line.85"></a>
+<span class="sourceLineNo">086</span>      while (iter.hasNext() &amp;&amp; curSize &lt; threshold) {<a name="line.86"></a>
+<span class="sourceLineNo">087</span>        // clear the tags<a name="line.87"></a>
+<span class="sourceLineNo">088</span>        tags.clear();<a name="line.88"></a>
+<span class="sourceLineNo">089</span>        Put p = iter.next();<a name="line.89"></a>
+<span class="sourceLineNo">090</span>        long t = p.getTTL();<a name="line.90"></a>
+<span class="sourceLineNo">091</span>        if (t != Long.MAX_VALUE) {<a name="line.91"></a>
+<span class="sourceLineNo">092</span>          // add TTL tag if found<a name="line.92"></a>
+<span class="sourceLineNo">093</span>          tags.add(new ArrayBackedTag(TagType.TTL_TAG_TYPE, Bytes.toBytes(t)));<a name="line.93"></a>
+<span class="sourceLineNo">094</span>        }<a name="line.94"></a>
+<span class="sourceLineNo">095</span>        byte[] acl = p.getACL();<a name="line.95"></a>
+<span class="sourceLineNo">096</span>        if (acl != null) {<a name="line.96"></a>
+<span class="sourceLineNo">097</span>          // add ACL tag if found<a name="line.97"></a>
+<span class="sourceLineNo">098</span>          tags.add(new ArrayBackedTag(TagType.ACL_TAG_TYPE, acl));<a name="line.98"></a>
+<span class="sourceLineNo">099</span>        }<a name="line.99"></a>
+<span class="sourceLineNo">100</span>        try {<a name="line.100"></a>
+<span class="sourceLineNo">101</span>          CellVisibility cellVisibility = p.getCellVisibility();<a name="line.101"></a>
+<span class="sourceLineNo">102</span>          if (cellVisibility != null) {<a name="line.102"></a>
+<span class="sourceLineNo">103</span>            // add the visibility labels if any<a name="line.103"></a>
+<span class="sourceLineNo">104</span>            tags.addAll(kvCreator.getVisibilityExpressionResolver()<a name="line.104"></a>
+<span class="sourceLineNo">105</span>                .createVisibilityExpTags(cellVisibility.getExpression()));<a name="line.105"></a>
+<span class="sourceLineNo">106</span>          }<a name="line.106"></a>
+<span class="sourceLineNo">107</span>        } catch (DeserializationException e) {<a name="line.107"></a>
+<span class="sourceLineNo">108</span>          // We just throw exception here. Should we allow other mutations to proceed by<a name="line.108"></a>
+<span class="sourceLineNo">109</span>          // just ignoring the bad one?<a name="line.109"></a>
+<span class="sourceLineNo">110</span>          throw new IOException("Invalid visibility expression found in mutation " + p, e);<a name="line.110"></a>
+<span class="sourceLineNo">111</span>        }<a name="line.111"></a>
+<span class="sourceLineNo">112</span>        for (List&lt;Cell&gt; cells: p.getFamilyCellMap().values()) {<a name="line.112"></a>
+<span class="sourceLineNo">113</span>          for (Cell cell: cells) {<a name="line.113"></a>
+<span class="sourceLineNo">114</span>            // Creating the KV which needs to be directly written to HFiles. Using the Facade<a name="line.114"></a>
+<span class="sourceLineNo">115</span>            // KVCreator for creation of kvs.<a name="line.115"></a>
+<span class="sourceLineNo">116</span>            KeyValue kv = null;<a name="line.116"></a>
+<span class="sourceLineNo">117</span>            TagUtil.carryForwardTags(tags, cell);<a name="line.117"></a>
+<span class="sourceLineNo">118</span>            if (!tags.isEmpty()) {<a name="line.118"></a>
+<span class="sourceLineNo">119</span>              kv = (KeyValue) kvCreator.create(cell.getRowArray(), cell.getRowOffset(),<a name="line.119"></a>
+<span class="sourceLineNo">120</span>                cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(),<a name="line.120"></a>
+<span class="sourceLineNo">121</span>                cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(),<a name="line.121"></a>
+<span class="sourceLineNo">122</span>                cell.getQualifierLength(), cell.getTimestamp(), cell.getValueArray(),<a name="line.122"></a>
+<span class="sourceLineNo">123</span>                cell.getValueOffset(), cell.getValueLength(), tags);<a name="line.123"></a>
+<span class="sourceLineNo">124</span>            } else {<a name="line.124"></a>
+<span class="sourceLineNo">125</span>              kv = KeyValueUtil.ensureKeyValue(cell);<a name="line.125"></a>
+<span class="sourceLineNo">126</span>            }<a name="line.126"></a>
+<span class="sourceLineNo">127</span>            if (map.add(kv)) {// don't count duplicated kv into size<a name="line.127"></a>
+<span class="sourceLineNo">128</span>              curSize += kv.heapSize();<a name="line.128"></a>
+<span class="sourceLineNo">129</span>            }<a name="line.129"></a>
+<span class="sourceLineNo">130</span>          }<a name="line.130"></a>
+<span class="sourceLineNo">131</span>        }<a name="line.131"></a>
+<span class="sourceLineNo">132</span>      }<a name="line.132"></a>
+<span class="sourceLineNo">133</span>      context.setStatus("Read " + map.size() + " entries of " + map.getClass()<a name="line.133"></a>
+<span class="sourceLineNo">134</span>          + "(" + StringUtils.humanReadableInt(curSize) + ")");<a name="line.134"></a>
+<span class="sourceLineNo">135</span>      int index = 0;<a name="line.135"></a>
+<span class="sourceLineNo">136</span>      for (KeyValue kv : map) {<a name="line.136"></a>
+<span class="sourceLineNo">137</span>        context.write(row, kv);<a name="line.137"></a>
+<span class="sourceLineNo">138</span>        if (++index % 100 == 0)<a name="line.138"></a>
+<span class="sourceLineNo">139</span>          context.setStatus("Wrote " + index);<a name="line.139"></a>
+<span class="sourceLineNo">140</span>      }<a name="line.140"></a>
+<span class="sourceLineNo">141</span><a name="line.141"></a>
+<span class="sourceLineNo">142</span>      // if we have more entries to process<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      if (iter.hasNext()) {<a name="line.143"></a>
+<span class="sourceLineNo">144</span>        // force flush because we cannot guarantee intra-row sorted order<a name="line.144"></a>
+<span class="sourceLineNo">145</span>        context.write(null, null);<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>  }<a name="line.148"></a>
+<span class="sourceLineNo">149</span>}<a name="line.149"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a0cdd2a9/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/ResultSerialization.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/ResultSerialization.html b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/ResultSerialization.html
new file mode 100644
index 0000000..ea614d5
--- /dev/null
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/ResultSerialization.html
@@ -0,0 +1,232 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
+</head>
+<body>
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span>/**<a name="line.1"></a>
+<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.2"></a>
+<span class="sourceLineNo">003</span> * or more contributor license agreements.  See the NOTICE file<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * distributed with this work for additional information<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * regarding copyright ownership.  The ASF licenses this file<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * to you under the Apache License, Version 2.0 (the<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * "License"); you may not use this file except in compliance<a name="line.7"></a>
+<span class="sourceLineNo">008</span> * with the License.  You may obtain a copy of the License at<a name="line.8"></a>
+<span class="sourceLineNo">009</span> *<a name="line.9"></a>
+<span class="sourceLineNo">010</span> *     http://www.apache.org/licenses/LICENSE-2.0<a name="line.10"></a>
+<span class="sourceLineNo">011</span> *<a name="line.11"></a>
+<span class="sourceLineNo">012</span> * Unless required by applicable law or agreed to in writing, software<a name="line.12"></a>
+<span class="sourceLineNo">013</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * See the License for the specific language governing permissions and<a name="line.15"></a>
+<span class="sourceLineNo">016</span> * limitations under the License.<a name="line.16"></a>
+<span class="sourceLineNo">017</span> */<a name="line.17"></a>
+<span class="sourceLineNo">018</span>package org.apache.hadoop.hbase.mapreduce;<a name="line.18"></a>
+<span class="sourceLineNo">019</span><a name="line.19"></a>
+<span class="sourceLineNo">020</span>import java.io.DataInput;<a name="line.20"></a>
+<span class="sourceLineNo">021</span>import java.io.DataInputStream;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.io.IOException;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.io.InputStream;<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.ArrayList;<a name="line.25"></a>
+<span class="sourceLineNo">026</span>import java.util.List;<a name="line.26"></a>
+<span class="sourceLineNo">027</span><a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.commons.logging.Log;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.commons.logging.LogFactory;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.conf.Configuration;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.conf.Configured;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.Cell;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.KeyValue;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.classification.InterfaceStability;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.client.Result;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.protobuf.ProtobufUtil;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.protobuf.generated.ClientProtos;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.io.serializer.Deserializer;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.io.serializer.Serialization;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.io.serializer.Serializer;<a name="line.42"></a>
+<span class="sourceLineNo">043</span><a name="line.43"></a>
+<span class="sourceLineNo">044</span>@InterfaceAudience.Public<a name="line.44"></a>
+<span class="sourceLineNo">045</span>@InterfaceStability.Evolving<a name="line.45"></a>
+<span class="sourceLineNo">046</span>public class ResultSerialization extends Configured implements Serialization&lt;Result&gt; {<a name="line.46"></a>
+<span class="sourceLineNo">047</span>  private static final Log LOG = LogFactory.getLog(ResultSerialization.class);<a name="line.47"></a>
+<span class="sourceLineNo">048</span>  // The following configuration property indicates import file format version.<a name="line.48"></a>
+<span class="sourceLineNo">049</span>  public static final String IMPORT_FORMAT_VER = "hbase.import.version";<a name="line.49"></a>
+<span class="sourceLineNo">050</span><a name="line.50"></a>
+<span class="sourceLineNo">051</span>  @Override<a name="line.51"></a>
+<span class="sourceLineNo">052</span>  public boolean accept(Class&lt;?&gt; c) {<a name="line.52"></a>
+<span class="sourceLineNo">053</span>    return Result.class.isAssignableFrom(c);<a name="line.53"></a>
+<span class="sourceLineNo">054</span>  }<a name="line.54"></a>
+<span class="sourceLineNo">055</span><a name="line.55"></a>
+<span class="sourceLineNo">056</span>  @Override<a name="line.56"></a>
+<span class="sourceLineNo">057</span>  public Deserializer&lt;Result&gt; getDeserializer(Class&lt;Result&gt; c) {<a name="line.57"></a>
+<span class="sourceLineNo">058</span>    // check input format version<a name="line.58"></a>
+<span class="sourceLineNo">059</span>    Configuration conf = getConf();<a name="line.59"></a>
+<span class="sourceLineNo">060</span>    if (conf != null) {<a name="line.60"></a>
+<span class="sourceLineNo">061</span>      String inputVersion = conf.get(IMPORT_FORMAT_VER);<a name="line.61"></a>
+<span class="sourceLineNo">062</span>      if (inputVersion != null &amp;&amp; inputVersion.equals("0.94")) {<a name="line.62"></a>
+<span class="sourceLineNo">063</span>        LOG.info("Load exported file using deserializer for HBase 0.94 format");<a name="line.63"></a>
+<span class="sourceLineNo">064</span>        return new Result94Deserializer();<a name="line.64"></a>
+<span class="sourceLineNo">065</span>      }<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    }<a name="line.66"></a>
+<span class="sourceLineNo">067</span><a name="line.67"></a>
+<span class="sourceLineNo">068</span>    return new ResultDeserializer();<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>  @Override<a name="line.71"></a>
+<span class="sourceLineNo">072</span>  public Serializer&lt;Result&gt; getSerializer(Class&lt;Result&gt; c) {<a name="line.72"></a>
+<span class="sourceLineNo">073</span>    return new ResultSerializer();<a name="line.73"></a>
+<span class="sourceLineNo">074</span>  }<a name="line.74"></a>
+<span class="sourceLineNo">075</span><a name="line.75"></a>
+<span class="sourceLineNo">076</span>  /**<a name="line.76"></a>
+<span class="sourceLineNo">077</span>   * The following deserializer class is used to load exported file of 0.94<a name="line.77"></a>
+<span class="sourceLineNo">078</span>   */<a name="line.78"></a>
+<span class="sourceLineNo">079</span>  private static class Result94Deserializer implements Deserializer&lt;Result&gt; {<a name="line.79"></a>
+<span class="sourceLineNo">080</span>    private DataInputStream in;<a name="line.80"></a>
+<span class="sourceLineNo">081</span><a name="line.81"></a>
+<span class="sourceLineNo">082</span>    @Override<a name="line.82"></a>
+<span class="sourceLineNo">083</span>    public void close() throws IOException {<a name="line.83"></a>
+<span class="sourceLineNo">084</span>      in.close();<a name="line.84"></a>
+<span class="sourceLineNo">085</span>    }<a name="line.85"></a>
+<span class="sourceLineNo">086</span><a name="line.86"></a>
+<span class="sourceLineNo">087</span>    @Override<a name="line.87"></a>
+<span class="sourceLineNo">088</span>    public Result deserialize(Result mutation) throws IOException {<a name="line.88"></a>
+<span class="sourceLineNo">089</span>      int totalBuffer = in.readInt();<a name="line.89"></a>
+<span class="sourceLineNo">090</span>      if (totalBuffer == 0) {<a name="line.90"></a>
+<span class="sourceLineNo">091</span>        return Result.EMPTY_RESULT;<a name="line.91"></a>
+<span class="sourceLineNo">092</span>      }<a name="line.92"></a>
+<span class="sourceLineNo">093</span>      byte[] buf = new byte[totalBuffer];<a name="line.93"></a>
+<span class="sourceLineNo">094</span>      readChunked(in, buf, 0, totalBuffer);<a name="line.94"></a>
+<span class="sourceLineNo">095</span>      List&lt;Cell&gt; kvs = new ArrayList&lt;Cell&gt;();<a name="line.95"></a>
+<span class="sourceLineNo">096</span>      int offset = 0;<a name="line.96"></a>
+<span class="sourceLineNo">097</span>      while (offset &lt; totalBuffer) {<a name="line.97"></a>
+<span class="sourceLineNo">098</span>        int keyLength = Bytes.toInt(buf, offset);<a name="line.98"></a>
+<span class="sourceLineNo">099</span>        offset += Bytes.SIZEOF_INT;<a name="line.99"></a>
+<span class="sourceLineNo">100</span>        kvs.add(new KeyValue(buf, offset, keyLength));<a name="line.100"></a>
+<span class="sourceLineNo">101</span>        offset += keyLength;<a name="line.101"></a>
+<span class="sourceLineNo">102</span>      }<a name="line.102"></a>
+<span class="sourceLineNo">103</span>      return Result.create(kvs);<a name="line.103"></a>
+<span class="sourceLineNo">104</span>    }<a name="line.104"></a>
+<span class="sourceLineNo">105</span><a name="line.105"></a>
+<span class="sourceLineNo">106</span>    @Override<a name="line.106"></a>
+<span class="sourceLineNo">107</span>    public void open(InputStream in) throws IOException {<a name="line.107"></a>
+<span class="sourceLineNo">108</span>      if (!(in instanceof DataInputStream)) {<a name="line.108"></a>
+<span class="sourceLineNo">109</span>        throw new IOException("Wrong input stream instance passed in");<a name="line.109"></a>
+<span class="sourceLineNo">110</span>      }<a name="line.110"></a>
+<span class="sourceLineNo">111</span>      this.in = (DataInputStream) in;<a name="line.111"></a>
+<span class="sourceLineNo">112</span>    }<a name="line.112"></a>
+<span class="sourceLineNo">113</span><a name="line.113"></a>
+<span class="sourceLineNo">114</span>    private void readChunked(final DataInput in, byte[] dest, int ofs, int len) throws IOException {<a name="line.114"></a>
+<span class="sourceLineNo">115</span>      int maxRead = 8192;<a name="line.115"></a>
+<span class="sourceLineNo">116</span><a name="line.116"></a>
+<span class="sourceLineNo">117</span>      for (; ofs &lt; len; ofs += maxRead)<a name="line.117"></a>
+<span class="sourceLineNo">118</span>        in.readFully(dest, ofs, Math.min(len - ofs, maxRead));<a name="line.118"></a>
+<span class="sourceLineNo">119</span>    }<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>  private static class ResultDeserializer implements Deserializer&lt;Result&gt; {<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    private InputStream in;<a name="line.123"></a>
+<span class="sourceLineNo">124</span><a name="line.124"></a>
+<span class="sourceLineNo">125</span>    @Override<a name="line.125"></a>
+<span class="sourceLineNo">126</span>    public void close() throws IOException {<a name="line.126"></a>
+<span class="sourceLineNo">127</span>      in.close();<a name="line.127"></a>
+<span class="sourceLineNo">128</span>    }<a name="line.128"></a>
+<span class="sourceLineNo">129</span><a name="line.129"></a>
+<span class="sourceLineNo">130</span>    @Override<a name="line.130"></a>
+<span class="sourceLineNo">131</span>    public Result deserialize(Result mutation) throws IOException {<a name="line.131"></a>
+<span class="sourceLineNo">132</span>      ClientProtos.Result proto = ClientProtos.Result.parseDelimitedFrom(in);<a name="line.132"></a>
+<span class="sourceLineNo">133</span>      return ProtobufUtil.toResult(proto);<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>    @Override<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    public void open(InputStream in) throws IOException {<a name="line.137"></a>
+<span class="sourceLineNo">138</span>      this.in = in;<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    }<a name="line.139"></a>
+<span class="sourceLineNo">140</span>  }<a name="line.140"></a>
+<span class="sourceLineNo">141</span><a name="line.141"></a>
+<span class="sourceLineNo">142</span>  private static class ResultSerializer implements Serializer&lt;Result&gt; {<a name="line.142"></a>
+<span class="sourceLineNo">143</span>    private OutputStream out;<a name="line.143"></a>
+<span class="sourceLineNo">144</span><a name="line.144"></a>
+<span class="sourceLineNo">145</span>    @Override<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    public void close() throws IOException {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>      out.close();<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>    @Override<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    public void open(OutputStream out) throws IOException {<a name="line.151"></a>
+<span class="sourceLineNo">152</span>      this.out = out;<a name="line.152"></a>
+<span class="sourceLineNo">153</span>    }<a name="line.153"></a>
+<span class="sourceLineNo">154</span><a name="line.154"></a>
+<span class="sourceLineNo">155</span>    @Override<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    public void serialize(Result result) throws IOException {<a name="line.156"></a>
+<span class="sourceLineNo">157</span>      ProtobufUtil.toResult(result).writeDelimitedTo(out);<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>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</pre>
+</div>
+</body>
+</html>


Mime
View raw message