hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [09/52] [partial] hbase-site git commit: Published site at 1cfd22bf43c9b64afae35d9bf16f764d0da80cab.
Date Tue, 21 Mar 2017 16:36:05 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/22cff34f/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiHFileOutputFormat.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiHFileOutputFormat.html b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiHFileOutputFormat.html
index 39ebcf3..9340f9d 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiHFileOutputFormat.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiHFileOutputFormat.html
@@ -73,41 +73,40 @@
 <span class="sourceLineNo">065</span>    final FileSystem fs = outputDir.getFileSystem(conf);<a name="line.65"></a>
 <span class="sourceLineNo">066</span><a name="line.66"></a>
 <span class="sourceLineNo">067</span>    // Map of tables to writers<a name="line.67"></a>
-<span class="sourceLineNo">068</span>    final Map&lt;ImmutableBytesWritable, RecordWriter&lt;ImmutableBytesWritable, V&gt;&gt; tableWriters =<a name="line.68"></a>
-<span class="sourceLineNo">069</span>        new HashMap&lt;ImmutableBytesWritable, RecordWriter&lt;ImmutableBytesWritable, V&gt;&gt;();<a name="line.69"></a>
-<span class="sourceLineNo">070</span><a name="line.70"></a>
-<span class="sourceLineNo">071</span>    return new RecordWriter&lt;ImmutableBytesWritable, V&gt;() {<a name="line.71"></a>
-<span class="sourceLineNo">072</span>      @Override<a name="line.72"></a>
-<span class="sourceLineNo">073</span>      public void write(ImmutableBytesWritable tableName, V cell)<a name="line.73"></a>
-<span class="sourceLineNo">074</span>          throws IOException, InterruptedException {<a name="line.74"></a>
-<span class="sourceLineNo">075</span>        RecordWriter&lt;ImmutableBytesWritable, V&gt; tableWriter = tableWriters.get(tableName);<a name="line.75"></a>
-<span class="sourceLineNo">076</span>        // if there is new table, verify that table directory exists<a name="line.76"></a>
-<span class="sourceLineNo">077</span>        if (tableWriter == null) {<a name="line.77"></a>
-<span class="sourceLineNo">078</span>          // using table name as directory name<a name="line.78"></a>
-<span class="sourceLineNo">079</span>          final Path tableOutputDir = new Path(outputDir, Bytes.toString(tableName.copyBytes()));<a name="line.79"></a>
-<span class="sourceLineNo">080</span>          fs.mkdirs(tableOutputDir);<a name="line.80"></a>
-<span class="sourceLineNo">081</span>          LOG.info("Writing Table '" + tableName.toString() + "' data into following directory"<a name="line.81"></a>
-<span class="sourceLineNo">082</span>              + tableOutputDir.toString());<a name="line.82"></a>
-<span class="sourceLineNo">083</span><a name="line.83"></a>
-<span class="sourceLineNo">084</span>          // Create writer for one specific table<a name="line.84"></a>
-<span class="sourceLineNo">085</span>          tableWriter = new HFileOutputFormat2.HFileRecordWriter&lt;V&gt;(context, tableOutputDir);<a name="line.85"></a>
-<span class="sourceLineNo">086</span>          // Put table into map<a name="line.86"></a>
-<span class="sourceLineNo">087</span>          tableWriters.put(tableName, tableWriter);<a name="line.87"></a>
-<span class="sourceLineNo">088</span>        }<a name="line.88"></a>
-<span class="sourceLineNo">089</span>        // Write &lt;Row, Cell&gt; into tableWriter<a name="line.89"></a>
-<span class="sourceLineNo">090</span>        // in the original code, it does not use Row<a name="line.90"></a>
-<span class="sourceLineNo">091</span>        tableWriter.write(null, cell);<a name="line.91"></a>
-<span class="sourceLineNo">092</span>      }<a name="line.92"></a>
-<span class="sourceLineNo">093</span><a name="line.93"></a>
-<span class="sourceLineNo">094</span>      @Override<a name="line.94"></a>
-<span class="sourceLineNo">095</span>      public void close(TaskAttemptContext c) throws IOException, InterruptedException {<a name="line.95"></a>
-<span class="sourceLineNo">096</span>        for (RecordWriter&lt;ImmutableBytesWritable, V&gt; writer : tableWriters.values()) {<a name="line.96"></a>
-<span class="sourceLineNo">097</span>          writer.close(c);<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>
-<span class="sourceLineNo">101</span>  }<a name="line.101"></a>
-<span class="sourceLineNo">102</span>}<a name="line.102"></a>
+<span class="sourceLineNo">068</span>    final Map&lt;ImmutableBytesWritable, RecordWriter&lt;ImmutableBytesWritable, V&gt;&gt; tableWriters = new HashMap&lt;&gt;();<a name="line.68"></a>
+<span class="sourceLineNo">069</span><a name="line.69"></a>
+<span class="sourceLineNo">070</span>    return new RecordWriter&lt;ImmutableBytesWritable, V&gt;() {<a name="line.70"></a>
+<span class="sourceLineNo">071</span>      @Override<a name="line.71"></a>
+<span class="sourceLineNo">072</span>      public void write(ImmutableBytesWritable tableName, V cell)<a name="line.72"></a>
+<span class="sourceLineNo">073</span>          throws IOException, InterruptedException {<a name="line.73"></a>
+<span class="sourceLineNo">074</span>        RecordWriter&lt;ImmutableBytesWritable, V&gt; tableWriter = tableWriters.get(tableName);<a name="line.74"></a>
+<span class="sourceLineNo">075</span>        // if there is new table, verify that table directory exists<a name="line.75"></a>
+<span class="sourceLineNo">076</span>        if (tableWriter == null) {<a name="line.76"></a>
+<span class="sourceLineNo">077</span>          // using table name as directory name<a name="line.77"></a>
+<span class="sourceLineNo">078</span>          final Path tableOutputDir = new Path(outputDir, Bytes.toString(tableName.copyBytes()));<a name="line.78"></a>
+<span class="sourceLineNo">079</span>          fs.mkdirs(tableOutputDir);<a name="line.79"></a>
+<span class="sourceLineNo">080</span>          LOG.info("Writing Table '" + tableName.toString() + "' data into following directory"<a name="line.80"></a>
+<span class="sourceLineNo">081</span>              + tableOutputDir.toString());<a name="line.81"></a>
+<span class="sourceLineNo">082</span><a name="line.82"></a>
+<span class="sourceLineNo">083</span>          // Create writer for one specific table<a name="line.83"></a>
+<span class="sourceLineNo">084</span>          tableWriter = new HFileOutputFormat2.HFileRecordWriter&lt;&gt;(context, tableOutputDir);<a name="line.84"></a>
+<span class="sourceLineNo">085</span>          // Put table into map<a name="line.85"></a>
+<span class="sourceLineNo">086</span>          tableWriters.put(tableName, tableWriter);<a name="line.86"></a>
+<span class="sourceLineNo">087</span>        }<a name="line.87"></a>
+<span class="sourceLineNo">088</span>        // Write &lt;Row, Cell&gt; into tableWriter<a name="line.88"></a>
+<span class="sourceLineNo">089</span>        // in the original code, it does not use Row<a name="line.89"></a>
+<span class="sourceLineNo">090</span>        tableWriter.write(null, cell);<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">093</span>      @Override<a name="line.93"></a>
+<span class="sourceLineNo">094</span>      public void close(TaskAttemptContext c) throws IOException, InterruptedException {<a name="line.94"></a>
+<span class="sourceLineNo">095</span>        for (RecordWriter&lt;ImmutableBytesWritable, V&gt; writer : tableWriters.values()) {<a name="line.95"></a>
+<span class="sourceLineNo">096</span>          writer.close(c);<a name="line.96"></a>
+<span class="sourceLineNo">097</span>        }<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>
+<span class="sourceLineNo">101</span>}<a name="line.101"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/22cff34f/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormat.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormat.html b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormat.html
index f4e33a0..bb2a823 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormat.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormat.html
@@ -100,7 +100,7 @@
 <span class="sourceLineNo">092</span>      throw new IllegalArgumentException("There must be at least 1 scan configuration set to : "<a name="line.92"></a>
 <span class="sourceLineNo">093</span>          + SCANS);<a name="line.93"></a>
 <span class="sourceLineNo">094</span>    }<a name="line.94"></a>
-<span class="sourceLineNo">095</span>    List&lt;Scan&gt; scans = new ArrayList&lt;Scan&gt;();<a name="line.95"></a>
+<span class="sourceLineNo">095</span>    List&lt;Scan&gt; scans = new ArrayList&lt;&gt;();<a name="line.95"></a>
 <span class="sourceLineNo">096</span><a name="line.96"></a>
 <span class="sourceLineNo">097</span>    for (int i = 0; i &lt; rawScans.length; i++) {<a name="line.97"></a>
 <span class="sourceLineNo">098</span>      try {<a name="line.98"></a>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/22cff34f/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.html b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.html
index f32d89d..97b325f 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.html
@@ -171,7 +171,7 @@
 <span class="sourceLineNo">163</span>      throw new IOException("No scans were provided.");<a name="line.163"></a>
 <span class="sourceLineNo">164</span>    }<a name="line.164"></a>
 <span class="sourceLineNo">165</span><a name="line.165"></a>
-<span class="sourceLineNo">166</span>    Map&lt;TableName, List&lt;Scan&gt;&gt; tableMaps = new HashMap&lt;TableName, List&lt;Scan&gt;&gt;();<a name="line.166"></a>
+<span class="sourceLineNo">166</span>    Map&lt;TableName, List&lt;Scan&gt;&gt; tableMaps = new HashMap&lt;&gt;();<a name="line.166"></a>
 <span class="sourceLineNo">167</span>    for (Scan scan : scans) {<a name="line.167"></a>
 <span class="sourceLineNo">168</span>      byte[] tableNameBytes = scan.getAttribute(Scan.SCAN_ATTRIBUTES_TABLE_NAME);<a name="line.168"></a>
 <span class="sourceLineNo">169</span>      if (tableNameBytes == null)<a name="line.169"></a>
@@ -181,13 +181,13 @@
 <span class="sourceLineNo">173</span><a name="line.173"></a>
 <span class="sourceLineNo">174</span>      List&lt;Scan&gt; scanList = tableMaps.get(tableName);<a name="line.174"></a>
 <span class="sourceLineNo">175</span>      if (scanList == null) {<a name="line.175"></a>
-<span class="sourceLineNo">176</span>        scanList = new ArrayList&lt;Scan&gt;();<a name="line.176"></a>
+<span class="sourceLineNo">176</span>        scanList = new ArrayList&lt;&gt;();<a name="line.176"></a>
 <span class="sourceLineNo">177</span>        tableMaps.put(tableName, scanList);<a name="line.177"></a>
 <span class="sourceLineNo">178</span>      }<a name="line.178"></a>
 <span class="sourceLineNo">179</span>      scanList.add(scan);<a name="line.179"></a>
 <span class="sourceLineNo">180</span>    }<a name="line.180"></a>
 <span class="sourceLineNo">181</span><a name="line.181"></a>
-<span class="sourceLineNo">182</span>    List&lt;InputSplit&gt; splits = new ArrayList&lt;InputSplit&gt;();<a name="line.182"></a>
+<span class="sourceLineNo">182</span>    List&lt;InputSplit&gt; splits = new ArrayList&lt;&gt;();<a name="line.182"></a>
 <span class="sourceLineNo">183</span>    Iterator iter = tableMaps.entrySet().iterator();<a name="line.183"></a>
 <span class="sourceLineNo">184</span>    while (iter.hasNext()) {<a name="line.184"></a>
 <span class="sourceLineNo">185</span>      Map.Entry&lt;TableName, List&lt;Scan&gt;&gt; entry = (Map.Entry&lt;TableName, List&lt;Scan&gt;&gt;) iter.next();<a name="line.185"></a>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/22cff34f/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 ac18540..c880dfd 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/PutSortReducer.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/PutSortReducer.html
@@ -87,10 +87,10 @@
 <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">082</span>      TreeSet&lt;KeyValue&gt; map = new TreeSet&lt;&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">085</span>      List&lt;Tag&gt; tags = new ArrayList&lt;&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>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/22cff34f/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
index 2a0b51a..dcdd181 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/ResultSerialization.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/ResultSerialization.html
@@ -100,7 +100,7 @@
 <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">095</span>      List&lt;Cell&gt; kvs = new ArrayList&lt;&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>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/22cff34f/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.html b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.html
index 87c73d9..97fbe11 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.html
@@ -84,196 +84,195 @@
 <span class="sourceLineNo">076</span>     * @param values  The columns.<a name="line.76"></a>
 <span class="sourceLineNo">077</span>     * @param context  The current context.<a name="line.77"></a>
 <span class="sourceLineNo">078</span>     * @throws IOException When something is broken with the data.<a name="line.78"></a>
-<span class="sourceLineNo">079</span>     * @see org.apache.hadoop.mapreduce.Mapper#map(KEYIN, VALUEIN,<a name="line.79"></a>
-<span class="sourceLineNo">080</span>     *   org.apache.hadoop.mapreduce.Mapper.Context)<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 map(ImmutableBytesWritable row, Result values,<a name="line.83"></a>
-<span class="sourceLineNo">084</span>      Context context)<a name="line.84"></a>
-<span class="sourceLineNo">085</span>    throws IOException {<a name="line.85"></a>
-<span class="sourceLineNo">086</span>      // Count every row containing data, whether it's in qualifiers or values<a name="line.86"></a>
-<span class="sourceLineNo">087</span>      context.getCounter(Counters.ROWS).increment(1);<a name="line.87"></a>
-<span class="sourceLineNo">088</span>    }<a name="line.88"></a>
-<span class="sourceLineNo">089</span>  }<a name="line.89"></a>
-<span class="sourceLineNo">090</span><a name="line.90"></a>
-<span class="sourceLineNo">091</span>  /**<a name="line.91"></a>
-<span class="sourceLineNo">092</span>   * Sets up the actual job.<a name="line.92"></a>
-<span class="sourceLineNo">093</span>   *<a name="line.93"></a>
-<span class="sourceLineNo">094</span>   * @param conf  The current configuration.<a name="line.94"></a>
-<span class="sourceLineNo">095</span>   * @param args  The command line parameters.<a name="line.95"></a>
-<span class="sourceLineNo">096</span>   * @return The newly created job.<a name="line.96"></a>
-<span class="sourceLineNo">097</span>   * @throws IOException When setting up the job fails.<a name="line.97"></a>
-<span class="sourceLineNo">098</span>   */<a name="line.98"></a>
-<span class="sourceLineNo">099</span>  public static Job createSubmittableJob(Configuration conf, String[] args)<a name="line.99"></a>
-<span class="sourceLineNo">100</span>  throws IOException {<a name="line.100"></a>
-<span class="sourceLineNo">101</span>    String tableName = args[0];<a name="line.101"></a>
-<span class="sourceLineNo">102</span>    List&lt;MultiRowRangeFilter.RowRange&gt; rowRangeList = null;<a name="line.102"></a>
-<span class="sourceLineNo">103</span>    long startTime = 0;<a name="line.103"></a>
-<span class="sourceLineNo">104</span>    long endTime = 0;<a name="line.104"></a>
-<span class="sourceLineNo">105</span><a name="line.105"></a>
-<span class="sourceLineNo">106</span>    StringBuilder sb = new StringBuilder();<a name="line.106"></a>
-<span class="sourceLineNo">107</span><a name="line.107"></a>
-<span class="sourceLineNo">108</span>    final String rangeSwitch = "--range=";<a name="line.108"></a>
-<span class="sourceLineNo">109</span>    final String startTimeArgKey = "--starttime=";<a name="line.109"></a>
-<span class="sourceLineNo">110</span>    final String endTimeArgKey = "--endtime=";<a name="line.110"></a>
-<span class="sourceLineNo">111</span>    final String expectedCountArg = "--expected-count=";<a name="line.111"></a>
-<span class="sourceLineNo">112</span><a name="line.112"></a>
-<span class="sourceLineNo">113</span>    // First argument is table name, starting from second<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    for (int i = 1; i &lt; args.length; i++) {<a name="line.114"></a>
-<span class="sourceLineNo">115</span>      if (args[i].startsWith(rangeSwitch)) {<a name="line.115"></a>
-<span class="sourceLineNo">116</span>        try {<a name="line.116"></a>
-<span class="sourceLineNo">117</span>          rowRangeList = parseRowRangeParameter(args[i], rangeSwitch);<a name="line.117"></a>
-<span class="sourceLineNo">118</span>        } catch (IllegalArgumentException e) {<a name="line.118"></a>
-<span class="sourceLineNo">119</span>          return null;<a name="line.119"></a>
-<span class="sourceLineNo">120</span>        }<a name="line.120"></a>
-<span class="sourceLineNo">121</span>        continue;<a name="line.121"></a>
-<span class="sourceLineNo">122</span>      }<a name="line.122"></a>
-<span class="sourceLineNo">123</span>      if (args[i].startsWith(startTimeArgKey)) {<a name="line.123"></a>
-<span class="sourceLineNo">124</span>        startTime = Long.parseLong(args[i].substring(startTimeArgKey.length()));<a name="line.124"></a>
-<span class="sourceLineNo">125</span>        continue;<a name="line.125"></a>
-<span class="sourceLineNo">126</span>      }<a name="line.126"></a>
-<span class="sourceLineNo">127</span>      if (args[i].startsWith(endTimeArgKey)) {<a name="line.127"></a>
-<span class="sourceLineNo">128</span>        endTime = Long.parseLong(args[i].substring(endTimeArgKey.length()));<a name="line.128"></a>
-<span class="sourceLineNo">129</span>        continue;<a name="line.129"></a>
-<span class="sourceLineNo">130</span>      }<a name="line.130"></a>
-<span class="sourceLineNo">131</span>      if (args[i].startsWith(expectedCountArg)) {<a name="line.131"></a>
-<span class="sourceLineNo">132</span>        conf.setLong(EXPECTED_COUNT_KEY,<a name="line.132"></a>
-<span class="sourceLineNo">133</span>            Long.parseLong(args[i].substring(expectedCountArg.length())));<a name="line.133"></a>
-<span class="sourceLineNo">134</span>        continue;<a name="line.134"></a>
-<span class="sourceLineNo">135</span>      }<a name="line.135"></a>
-<span class="sourceLineNo">136</span>      // if no switch, assume column names<a name="line.136"></a>
-<span class="sourceLineNo">137</span>      sb.append(args[i]);<a name="line.137"></a>
-<span class="sourceLineNo">138</span>      sb.append(" ");<a name="line.138"></a>
-<span class="sourceLineNo">139</span>    }<a name="line.139"></a>
-<span class="sourceLineNo">140</span>    if (endTime &lt; startTime) {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      printUsage("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime);<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      return null;<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    }<a name="line.143"></a>
-<span class="sourceLineNo">144</span><a name="line.144"></a>
-<span class="sourceLineNo">145</span>    Job job = Job.getInstance(conf, conf.get(JOB_NAME_CONF_KEY, NAME + "_" + tableName));<a name="line.145"></a>
-<span class="sourceLineNo">146</span>    job.setJarByClass(RowCounter.class);<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    Scan scan = new Scan();<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    scan.setCacheBlocks(false);<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    setScanFilter(scan, rowRangeList);<a name="line.149"></a>
-<span class="sourceLineNo">150</span>    if (sb.length() &gt; 0) {<a name="line.150"></a>
-<span class="sourceLineNo">151</span>      for (String columnName : sb.toString().trim().split(" ")) {<a name="line.151"></a>
-<span class="sourceLineNo">152</span>        String family = StringUtils.substringBefore(columnName, ":");<a name="line.152"></a>
-<span class="sourceLineNo">153</span>        String qualifier = StringUtils.substringAfter(columnName, ":");<a name="line.153"></a>
-<span class="sourceLineNo">154</span><a name="line.154"></a>
-<span class="sourceLineNo">155</span>        if (StringUtils.isBlank(qualifier)) {<a name="line.155"></a>
-<span class="sourceLineNo">156</span>          scan.addFamily(Bytes.toBytes(family));<a name="line.156"></a>
-<span class="sourceLineNo">157</span>        }<a name="line.157"></a>
-<span class="sourceLineNo">158</span>        else {<a name="line.158"></a>
-<span class="sourceLineNo">159</span>          scan.addColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));<a name="line.159"></a>
-<span class="sourceLineNo">160</span>        }<a name="line.160"></a>
-<span class="sourceLineNo">161</span>      }<a name="line.161"></a>
-<span class="sourceLineNo">162</span>    }<a name="line.162"></a>
-<span class="sourceLineNo">163</span>    scan.setTimeRange(startTime, endTime == 0 ? HConstants.LATEST_TIMESTAMP : endTime);<a name="line.163"></a>
-<span class="sourceLineNo">164</span>    job.setOutputFormatClass(NullOutputFormat.class);<a name="line.164"></a>
-<span class="sourceLineNo">165</span>    TableMapReduceUtil.initTableMapperJob(tableName, scan,<a name="line.165"></a>
-<span class="sourceLineNo">166</span>      RowCounterMapper.class, ImmutableBytesWritable.class, Result.class, job);<a name="line.166"></a>
-<span class="sourceLineNo">167</span>    job.setNumReduceTasks(0);<a name="line.167"></a>
-<span class="sourceLineNo">168</span>    return job;<a name="line.168"></a>
-<span class="sourceLineNo">169</span>  }<a name="line.169"></a>
-<span class="sourceLineNo">170</span><a name="line.170"></a>
-<span class="sourceLineNo">171</span>  private static List&lt;MultiRowRangeFilter.RowRange&gt; parseRowRangeParameter(<a name="line.171"></a>
-<span class="sourceLineNo">172</span>    String arg, String rangeSwitch) {<a name="line.172"></a>
-<span class="sourceLineNo">173</span>    final String[] ranges = arg.substring(rangeSwitch.length()).split(";");<a name="line.173"></a>
-<span class="sourceLineNo">174</span>    final List&lt;MultiRowRangeFilter.RowRange&gt; rangeList = new ArrayList&lt;&gt;();<a name="line.174"></a>
-<span class="sourceLineNo">175</span>    for (String range : ranges) {<a name="line.175"></a>
-<span class="sourceLineNo">176</span>      String[] startEnd = range.split(",", 2);<a name="line.176"></a>
-<span class="sourceLineNo">177</span>      if (startEnd.length != 2 || startEnd[1].contains(",")) {<a name="line.177"></a>
-<span class="sourceLineNo">178</span>        printUsage("Please specify range in such format as \"--range=a,b\" " +<a name="line.178"></a>
-<span class="sourceLineNo">179</span>            "or, with only one boundary, \"--range=,b\" or \"--range=a,\"");<a name="line.179"></a>
-<span class="sourceLineNo">180</span>        throw new IllegalArgumentException("Wrong range specification: " + range);<a name="line.180"></a>
-<span class="sourceLineNo">181</span>      }<a name="line.181"></a>
-<span class="sourceLineNo">182</span>      String startKey = startEnd[0];<a name="line.182"></a>
-<span class="sourceLineNo">183</span>      String endKey = startEnd[1];<a name="line.183"></a>
-<span class="sourceLineNo">184</span>      rangeList.add(new MultiRowRangeFilter.RowRange(<a name="line.184"></a>
-<span class="sourceLineNo">185</span>        Bytes.toBytesBinary(startKey), true,<a name="line.185"></a>
-<span class="sourceLineNo">186</span>        Bytes.toBytesBinary(endKey), false));<a name="line.186"></a>
-<span class="sourceLineNo">187</span>    }<a name="line.187"></a>
-<span class="sourceLineNo">188</span>    return rangeList;<a name="line.188"></a>
-<span class="sourceLineNo">189</span>  }<a name="line.189"></a>
-<span class="sourceLineNo">190</span><a name="line.190"></a>
-<span class="sourceLineNo">191</span>  /**<a name="line.191"></a>
-<span class="sourceLineNo">192</span>   * Sets filter {@link FilterBase} to the {@link Scan} instance.<a name="line.192"></a>
-<span class="sourceLineNo">193</span>   * If provided rowRangeList contains more than one element,<a name="line.193"></a>
-<span class="sourceLineNo">194</span>   * method sets filter which is instance of {@link MultiRowRangeFilter}.<a name="line.194"></a>
-<span class="sourceLineNo">195</span>   * Otherwise, method sets filter which is instance of {@link FirstKeyOnlyFilter}.<a name="line.195"></a>
-<span class="sourceLineNo">196</span>   * If rowRangeList contains exactly one element, startRow and stopRow are set to the scan.<a name="line.196"></a>
-<span class="sourceLineNo">197</span>   * @param scan<a name="line.197"></a>
-<span class="sourceLineNo">198</span>   * @param rowRangeList<a name="line.198"></a>
-<span class="sourceLineNo">199</span>   */<a name="line.199"></a>
-<span class="sourceLineNo">200</span>  private static void setScanFilter(Scan scan, List&lt;MultiRowRangeFilter.RowRange&gt; rowRangeList) {<a name="line.200"></a>
-<span class="sourceLineNo">201</span>    final int size = rowRangeList == null ? 0 : rowRangeList.size();<a name="line.201"></a>
-<span class="sourceLineNo">202</span>    if (size &lt;= 1) {<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      scan.setFilter(new FirstKeyOnlyFilter());<a name="line.203"></a>
-<span class="sourceLineNo">204</span>    }<a name="line.204"></a>
-<span class="sourceLineNo">205</span>    if (size == 1) {<a name="line.205"></a>
-<span class="sourceLineNo">206</span>      MultiRowRangeFilter.RowRange range = rowRangeList.get(0);<a name="line.206"></a>
-<span class="sourceLineNo">207</span>      scan.setStartRow(range.getStartRow()); //inclusive<a name="line.207"></a>
-<span class="sourceLineNo">208</span>      scan.setStopRow(range.getStopRow());   //exclusive<a name="line.208"></a>
-<span class="sourceLineNo">209</span>    } else if (size &gt; 1) {<a name="line.209"></a>
-<span class="sourceLineNo">210</span>      scan.setFilter(new MultiRowRangeFilter(rowRangeList));<a name="line.210"></a>
-<span class="sourceLineNo">211</span>    }<a name="line.211"></a>
-<span class="sourceLineNo">212</span>  }<a name="line.212"></a>
-<span class="sourceLineNo">213</span><a name="line.213"></a>
-<span class="sourceLineNo">214</span>  /*<a name="line.214"></a>
-<span class="sourceLineNo">215</span>   * @param errorMessage Can attach a message when error occurs.<a name="line.215"></a>
-<span class="sourceLineNo">216</span>   */<a name="line.216"></a>
-<span class="sourceLineNo">217</span>  private static void printUsage(String errorMessage) {<a name="line.217"></a>
-<span class="sourceLineNo">218</span>    System.err.println("ERROR: " + errorMessage);<a name="line.218"></a>
-<span class="sourceLineNo">219</span>    printUsage();<a name="line.219"></a>
-<span class="sourceLineNo">220</span>  }<a name="line.220"></a>
-<span class="sourceLineNo">221</span><a name="line.221"></a>
-<span class="sourceLineNo">222</span>  /**<a name="line.222"></a>
-<span class="sourceLineNo">223</span>   * Prints usage without error message.<a name="line.223"></a>
-<span class="sourceLineNo">224</span>   * Note that we don't document --expected-count, because it's intended for test.<a name="line.224"></a>
-<span class="sourceLineNo">225</span>   */<a name="line.225"></a>
-<span class="sourceLineNo">226</span>  private static void printUsage() {<a name="line.226"></a>
-<span class="sourceLineNo">227</span>    System.err.println("Usage: RowCounter [options] &lt;tablename&gt; " +<a name="line.227"></a>
-<span class="sourceLineNo">228</span>        "[--starttime=[start] --endtime=[end] " +<a name="line.228"></a>
-<span class="sourceLineNo">229</span>        "[--range=[startKey],[endKey][;[startKey],[endKey]...]] [&lt;column1&gt; &lt;column2&gt;...]");<a name="line.229"></a>
-<span class="sourceLineNo">230</span>    System.err.println("For performance consider the following options:\n"<a name="line.230"></a>
-<span class="sourceLineNo">231</span>        + "-Dhbase.client.scanner.caching=100\n"<a name="line.231"></a>
-<span class="sourceLineNo">232</span>        + "-Dmapreduce.map.speculative=false");<a name="line.232"></a>
-<span class="sourceLineNo">233</span>  }<a name="line.233"></a>
-<span class="sourceLineNo">234</span><a name="line.234"></a>
-<span class="sourceLineNo">235</span>  @Override<a name="line.235"></a>
-<span class="sourceLineNo">236</span>  public int run(String[] args) throws Exception {<a name="line.236"></a>
-<span class="sourceLineNo">237</span>    if (args.length &lt; 1) {<a name="line.237"></a>
-<span class="sourceLineNo">238</span>      printUsage("Wrong number of parameters: " + args.length);<a name="line.238"></a>
-<span class="sourceLineNo">239</span>      return -1;<a name="line.239"></a>
-<span class="sourceLineNo">240</span>    }<a name="line.240"></a>
-<span class="sourceLineNo">241</span>    Job job = createSubmittableJob(getConf(), args);<a name="line.241"></a>
-<span class="sourceLineNo">242</span>    if (job == null) {<a name="line.242"></a>
-<span class="sourceLineNo">243</span>      return -1;<a name="line.243"></a>
-<span class="sourceLineNo">244</span>    }<a name="line.244"></a>
-<span class="sourceLineNo">245</span>    boolean success = job.waitForCompletion(true);<a name="line.245"></a>
-<span class="sourceLineNo">246</span>    final long expectedCount = getConf().getLong(EXPECTED_COUNT_KEY, -1);<a name="line.246"></a>
-<span class="sourceLineNo">247</span>    if (success &amp;&amp; expectedCount != -1) {<a name="line.247"></a>
-<span class="sourceLineNo">248</span>      final Counter counter = job.getCounters().findCounter(RowCounterMapper.Counters.ROWS);<a name="line.248"></a>
-<span class="sourceLineNo">249</span>      success = expectedCount == counter.getValue();<a name="line.249"></a>
-<span class="sourceLineNo">250</span>      if (!success) {<a name="line.250"></a>
-<span class="sourceLineNo">251</span>        LOG.error("Failing job because count of '" + counter.getValue() +<a name="line.251"></a>
-<span class="sourceLineNo">252</span>            "' does not match expected count of '" + expectedCount + "'");<a name="line.252"></a>
-<span class="sourceLineNo">253</span>      }<a name="line.253"></a>
-<span class="sourceLineNo">254</span>    }<a name="line.254"></a>
-<span class="sourceLineNo">255</span>    return (success ? 0 : 1);<a name="line.255"></a>
-<span class="sourceLineNo">256</span>  }<a name="line.256"></a>
-<span class="sourceLineNo">257</span><a name="line.257"></a>
-<span class="sourceLineNo">258</span>  /**<a name="line.258"></a>
-<span class="sourceLineNo">259</span>   * Main entry point.<a name="line.259"></a>
-<span class="sourceLineNo">260</span>   * @param args The command line parameters.<a name="line.260"></a>
-<span class="sourceLineNo">261</span>   * @throws Exception When running the job fails.<a name="line.261"></a>
-<span class="sourceLineNo">262</span>   */<a name="line.262"></a>
-<span class="sourceLineNo">263</span>  public static void main(String[] args) throws Exception {<a name="line.263"></a>
-<span class="sourceLineNo">264</span>    int errCode = ToolRunner.run(HBaseConfiguration.create(), new RowCounter(), args);<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    System.exit(errCode);<a name="line.265"></a>
-<span class="sourceLineNo">266</span>  }<a name="line.266"></a>
-<span class="sourceLineNo">267</span><a name="line.267"></a>
-<span class="sourceLineNo">268</span>}<a name="line.268"></a>
+<span class="sourceLineNo">079</span>     * @see org.apache.hadoop.mapreduce.Mapper#map(Object, Object, Context)<a name="line.79"></a>
+<span class="sourceLineNo">080</span>     */<a name="line.80"></a>
+<span class="sourceLineNo">081</span>    @Override<a name="line.81"></a>
+<span class="sourceLineNo">082</span>    public void map(ImmutableBytesWritable row, Result values,<a name="line.82"></a>
+<span class="sourceLineNo">083</span>      Context context)<a name="line.83"></a>
+<span class="sourceLineNo">084</span>    throws IOException {<a name="line.84"></a>
+<span class="sourceLineNo">085</span>      // Count every row containing data, whether it's in qualifiers or values<a name="line.85"></a>
+<span class="sourceLineNo">086</span>      context.getCounter(Counters.ROWS).increment(1);<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>  /**<a name="line.90"></a>
+<span class="sourceLineNo">091</span>   * Sets up the actual job.<a name="line.91"></a>
+<span class="sourceLineNo">092</span>   *<a name="line.92"></a>
+<span class="sourceLineNo">093</span>   * @param conf  The current configuration.<a name="line.93"></a>
+<span class="sourceLineNo">094</span>   * @param args  The command line parameters.<a name="line.94"></a>
+<span class="sourceLineNo">095</span>   * @return The newly created job.<a name="line.95"></a>
+<span class="sourceLineNo">096</span>   * @throws IOException When setting up the job fails.<a name="line.96"></a>
+<span class="sourceLineNo">097</span>   */<a name="line.97"></a>
+<span class="sourceLineNo">098</span>  public static Job createSubmittableJob(Configuration conf, String[] args)<a name="line.98"></a>
+<span class="sourceLineNo">099</span>  throws IOException {<a name="line.99"></a>
+<span class="sourceLineNo">100</span>    String tableName = args[0];<a name="line.100"></a>
+<span class="sourceLineNo">101</span>    List&lt;MultiRowRangeFilter.RowRange&gt; rowRangeList = null;<a name="line.101"></a>
+<span class="sourceLineNo">102</span>    long startTime = 0;<a name="line.102"></a>
+<span class="sourceLineNo">103</span>    long endTime = 0;<a name="line.103"></a>
+<span class="sourceLineNo">104</span><a name="line.104"></a>
+<span class="sourceLineNo">105</span>    StringBuilder sb = new StringBuilder();<a name="line.105"></a>
+<span class="sourceLineNo">106</span><a name="line.106"></a>
+<span class="sourceLineNo">107</span>    final String rangeSwitch = "--range=";<a name="line.107"></a>
+<span class="sourceLineNo">108</span>    final String startTimeArgKey = "--starttime=";<a name="line.108"></a>
+<span class="sourceLineNo">109</span>    final String endTimeArgKey = "--endtime=";<a name="line.109"></a>
+<span class="sourceLineNo">110</span>    final String expectedCountArg = "--expected-count=";<a name="line.110"></a>
+<span class="sourceLineNo">111</span><a name="line.111"></a>
+<span class="sourceLineNo">112</span>    // First argument is table name, starting from second<a name="line.112"></a>
+<span class="sourceLineNo">113</span>    for (int i = 1; i &lt; args.length; i++) {<a name="line.113"></a>
+<span class="sourceLineNo">114</span>      if (args[i].startsWith(rangeSwitch)) {<a name="line.114"></a>
+<span class="sourceLineNo">115</span>        try {<a name="line.115"></a>
+<span class="sourceLineNo">116</span>          rowRangeList = parseRowRangeParameter(args[i], rangeSwitch);<a name="line.116"></a>
+<span class="sourceLineNo">117</span>        } catch (IllegalArgumentException e) {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>          return null;<a name="line.118"></a>
+<span class="sourceLineNo">119</span>        }<a name="line.119"></a>
+<span class="sourceLineNo">120</span>        continue;<a name="line.120"></a>
+<span class="sourceLineNo">121</span>      }<a name="line.121"></a>
+<span class="sourceLineNo">122</span>      if (args[i].startsWith(startTimeArgKey)) {<a name="line.122"></a>
+<span class="sourceLineNo">123</span>        startTime = Long.parseLong(args[i].substring(startTimeArgKey.length()));<a name="line.123"></a>
+<span class="sourceLineNo">124</span>        continue;<a name="line.124"></a>
+<span class="sourceLineNo">125</span>      }<a name="line.125"></a>
+<span class="sourceLineNo">126</span>      if (args[i].startsWith(endTimeArgKey)) {<a name="line.126"></a>
+<span class="sourceLineNo">127</span>        endTime = Long.parseLong(args[i].substring(endTimeArgKey.length()));<a name="line.127"></a>
+<span class="sourceLineNo">128</span>        continue;<a name="line.128"></a>
+<span class="sourceLineNo">129</span>      }<a name="line.129"></a>
+<span class="sourceLineNo">130</span>      if (args[i].startsWith(expectedCountArg)) {<a name="line.130"></a>
+<span class="sourceLineNo">131</span>        conf.setLong(EXPECTED_COUNT_KEY,<a name="line.131"></a>
+<span class="sourceLineNo">132</span>            Long.parseLong(args[i].substring(expectedCountArg.length())));<a name="line.132"></a>
+<span class="sourceLineNo">133</span>        continue;<a name="line.133"></a>
+<span class="sourceLineNo">134</span>      }<a name="line.134"></a>
+<span class="sourceLineNo">135</span>      // if no switch, assume column names<a name="line.135"></a>
+<span class="sourceLineNo">136</span>      sb.append(args[i]);<a name="line.136"></a>
+<span class="sourceLineNo">137</span>      sb.append(" ");<a name="line.137"></a>
+<span class="sourceLineNo">138</span>    }<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    if (endTime &lt; startTime) {<a name="line.139"></a>
+<span class="sourceLineNo">140</span>      printUsage("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime);<a name="line.140"></a>
+<span class="sourceLineNo">141</span>      return null;<a name="line.141"></a>
+<span class="sourceLineNo">142</span>    }<a name="line.142"></a>
+<span class="sourceLineNo">143</span><a name="line.143"></a>
+<span class="sourceLineNo">144</span>    Job job = Job.getInstance(conf, conf.get(JOB_NAME_CONF_KEY, NAME + "_" + tableName));<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    job.setJarByClass(RowCounter.class);<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    Scan scan = new Scan();<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    scan.setCacheBlocks(false);<a name="line.147"></a>
+<span class="sourceLineNo">148</span>    setScanFilter(scan, rowRangeList);<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    if (sb.length() &gt; 0) {<a name="line.149"></a>
+<span class="sourceLineNo">150</span>      for (String columnName : sb.toString().trim().split(" ")) {<a name="line.150"></a>
+<span class="sourceLineNo">151</span>        String family = StringUtils.substringBefore(columnName, ":");<a name="line.151"></a>
+<span class="sourceLineNo">152</span>        String qualifier = StringUtils.substringAfter(columnName, ":");<a name="line.152"></a>
+<span class="sourceLineNo">153</span><a name="line.153"></a>
+<span class="sourceLineNo">154</span>        if (StringUtils.isBlank(qualifier)) {<a name="line.154"></a>
+<span class="sourceLineNo">155</span>          scan.addFamily(Bytes.toBytes(family));<a name="line.155"></a>
+<span class="sourceLineNo">156</span>        }<a name="line.156"></a>
+<span class="sourceLineNo">157</span>        else {<a name="line.157"></a>
+<span class="sourceLineNo">158</span>          scan.addColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));<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>    }<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    scan.setTimeRange(startTime, endTime == 0 ? HConstants.LATEST_TIMESTAMP : endTime);<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    job.setOutputFormatClass(NullOutputFormat.class);<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    TableMapReduceUtil.initTableMapperJob(tableName, scan,<a name="line.164"></a>
+<span class="sourceLineNo">165</span>      RowCounterMapper.class, ImmutableBytesWritable.class, Result.class, job);<a name="line.165"></a>
+<span class="sourceLineNo">166</span>    job.setNumReduceTasks(0);<a name="line.166"></a>
+<span class="sourceLineNo">167</span>    return job;<a name="line.167"></a>
+<span class="sourceLineNo">168</span>  }<a name="line.168"></a>
+<span class="sourceLineNo">169</span><a name="line.169"></a>
+<span class="sourceLineNo">170</span>  private static List&lt;MultiRowRangeFilter.RowRange&gt; parseRowRangeParameter(<a name="line.170"></a>
+<span class="sourceLineNo">171</span>    String arg, String rangeSwitch) {<a name="line.171"></a>
+<span class="sourceLineNo">172</span>    final String[] ranges = arg.substring(rangeSwitch.length()).split(";");<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    final List&lt;MultiRowRangeFilter.RowRange&gt; rangeList = new ArrayList&lt;&gt;();<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    for (String range : ranges) {<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      String[] startEnd = range.split(",", 2);<a name="line.175"></a>
+<span class="sourceLineNo">176</span>      if (startEnd.length != 2 || startEnd[1].contains(",")) {<a name="line.176"></a>
+<span class="sourceLineNo">177</span>        printUsage("Please specify range in such format as \"--range=a,b\" " +<a name="line.177"></a>
+<span class="sourceLineNo">178</span>            "or, with only one boundary, \"--range=,b\" or \"--range=a,\"");<a name="line.178"></a>
+<span class="sourceLineNo">179</span>        throw new IllegalArgumentException("Wrong range specification: " + range);<a name="line.179"></a>
+<span class="sourceLineNo">180</span>      }<a name="line.180"></a>
+<span class="sourceLineNo">181</span>      String startKey = startEnd[0];<a name="line.181"></a>
+<span class="sourceLineNo">182</span>      String endKey = startEnd[1];<a name="line.182"></a>
+<span class="sourceLineNo">183</span>      rangeList.add(new MultiRowRangeFilter.RowRange(<a name="line.183"></a>
+<span class="sourceLineNo">184</span>        Bytes.toBytesBinary(startKey), true,<a name="line.184"></a>
+<span class="sourceLineNo">185</span>        Bytes.toBytesBinary(endKey), false));<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    }<a name="line.186"></a>
+<span class="sourceLineNo">187</span>    return rangeList;<a name="line.187"></a>
+<span class="sourceLineNo">188</span>  }<a name="line.188"></a>
+<span class="sourceLineNo">189</span><a name="line.189"></a>
+<span class="sourceLineNo">190</span>  /**<a name="line.190"></a>
+<span class="sourceLineNo">191</span>   * Sets filter {@link FilterBase} to the {@link Scan} instance.<a name="line.191"></a>
+<span class="sourceLineNo">192</span>   * If provided rowRangeList contains more than one element,<a name="line.192"></a>
+<span class="sourceLineNo">193</span>   * method sets filter which is instance of {@link MultiRowRangeFilter}.<a name="line.193"></a>
+<span class="sourceLineNo">194</span>   * Otherwise, method sets filter which is instance of {@link FirstKeyOnlyFilter}.<a name="line.194"></a>
+<span class="sourceLineNo">195</span>   * If rowRangeList contains exactly one element, startRow and stopRow are set to the scan.<a name="line.195"></a>
+<span class="sourceLineNo">196</span>   * @param scan<a name="line.196"></a>
+<span class="sourceLineNo">197</span>   * @param rowRangeList<a name="line.197"></a>
+<span class="sourceLineNo">198</span>   */<a name="line.198"></a>
+<span class="sourceLineNo">199</span>  private static void setScanFilter(Scan scan, List&lt;MultiRowRangeFilter.RowRange&gt; rowRangeList) {<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    final int size = rowRangeList == null ? 0 : rowRangeList.size();<a name="line.200"></a>
+<span class="sourceLineNo">201</span>    if (size &lt;= 1) {<a name="line.201"></a>
+<span class="sourceLineNo">202</span>      scan.setFilter(new FirstKeyOnlyFilter());<a name="line.202"></a>
+<span class="sourceLineNo">203</span>    }<a name="line.203"></a>
+<span class="sourceLineNo">204</span>    if (size == 1) {<a name="line.204"></a>
+<span class="sourceLineNo">205</span>      MultiRowRangeFilter.RowRange range = rowRangeList.get(0);<a name="line.205"></a>
+<span class="sourceLineNo">206</span>      scan.setStartRow(range.getStartRow()); //inclusive<a name="line.206"></a>
+<span class="sourceLineNo">207</span>      scan.setStopRow(range.getStopRow());   //exclusive<a name="line.207"></a>
+<span class="sourceLineNo">208</span>    } else if (size &gt; 1) {<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      scan.setFilter(new MultiRowRangeFilter(rowRangeList));<a name="line.209"></a>
+<span class="sourceLineNo">210</span>    }<a name="line.210"></a>
+<span class="sourceLineNo">211</span>  }<a name="line.211"></a>
+<span class="sourceLineNo">212</span><a name="line.212"></a>
+<span class="sourceLineNo">213</span>  /*<a name="line.213"></a>
+<span class="sourceLineNo">214</span>   * @param errorMessage Can attach a message when error occurs.<a name="line.214"></a>
+<span class="sourceLineNo">215</span>   */<a name="line.215"></a>
+<span class="sourceLineNo">216</span>  private static void printUsage(String errorMessage) {<a name="line.216"></a>
+<span class="sourceLineNo">217</span>    System.err.println("ERROR: " + errorMessage);<a name="line.217"></a>
+<span class="sourceLineNo">218</span>    printUsage();<a name="line.218"></a>
+<span class="sourceLineNo">219</span>  }<a name="line.219"></a>
+<span class="sourceLineNo">220</span><a name="line.220"></a>
+<span class="sourceLineNo">221</span>  /**<a name="line.221"></a>
+<span class="sourceLineNo">222</span>   * Prints usage without error message.<a name="line.222"></a>
+<span class="sourceLineNo">223</span>   * Note that we don't document --expected-count, because it's intended for test.<a name="line.223"></a>
+<span class="sourceLineNo">224</span>   */<a name="line.224"></a>
+<span class="sourceLineNo">225</span>  private static void printUsage() {<a name="line.225"></a>
+<span class="sourceLineNo">226</span>    System.err.println("Usage: RowCounter [options] &lt;tablename&gt; " +<a name="line.226"></a>
+<span class="sourceLineNo">227</span>        "[--starttime=[start] --endtime=[end] " +<a name="line.227"></a>
+<span class="sourceLineNo">228</span>        "[--range=[startKey],[endKey][;[startKey],[endKey]...]] [&lt;column1&gt; &lt;column2&gt;...]");<a name="line.228"></a>
+<span class="sourceLineNo">229</span>    System.err.println("For performance consider the following options:\n"<a name="line.229"></a>
+<span class="sourceLineNo">230</span>        + "-Dhbase.client.scanner.caching=100\n"<a name="line.230"></a>
+<span class="sourceLineNo">231</span>        + "-Dmapreduce.map.speculative=false");<a name="line.231"></a>
+<span class="sourceLineNo">232</span>  }<a name="line.232"></a>
+<span class="sourceLineNo">233</span><a name="line.233"></a>
+<span class="sourceLineNo">234</span>  @Override<a name="line.234"></a>
+<span class="sourceLineNo">235</span>  public int run(String[] args) throws Exception {<a name="line.235"></a>
+<span class="sourceLineNo">236</span>    if (args.length &lt; 1) {<a name="line.236"></a>
+<span class="sourceLineNo">237</span>      printUsage("Wrong number of parameters: " + args.length);<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      return -1;<a name="line.238"></a>
+<span class="sourceLineNo">239</span>    }<a name="line.239"></a>
+<span class="sourceLineNo">240</span>    Job job = createSubmittableJob(getConf(), args);<a name="line.240"></a>
+<span class="sourceLineNo">241</span>    if (job == null) {<a name="line.241"></a>
+<span class="sourceLineNo">242</span>      return -1;<a name="line.242"></a>
+<span class="sourceLineNo">243</span>    }<a name="line.243"></a>
+<span class="sourceLineNo">244</span>    boolean success = job.waitForCompletion(true);<a name="line.244"></a>
+<span class="sourceLineNo">245</span>    final long expectedCount = getConf().getLong(EXPECTED_COUNT_KEY, -1);<a name="line.245"></a>
+<span class="sourceLineNo">246</span>    if (success &amp;&amp; expectedCount != -1) {<a name="line.246"></a>
+<span class="sourceLineNo">247</span>      final Counter counter = job.getCounters().findCounter(RowCounterMapper.Counters.ROWS);<a name="line.247"></a>
+<span class="sourceLineNo">248</span>      success = expectedCount == counter.getValue();<a name="line.248"></a>
+<span class="sourceLineNo">249</span>      if (!success) {<a name="line.249"></a>
+<span class="sourceLineNo">250</span>        LOG.error("Failing job because count of '" + counter.getValue() +<a name="line.250"></a>
+<span class="sourceLineNo">251</span>            "' does not match expected count of '" + expectedCount + "'");<a name="line.251"></a>
+<span class="sourceLineNo">252</span>      }<a name="line.252"></a>
+<span class="sourceLineNo">253</span>    }<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    return (success ? 0 : 1);<a name="line.254"></a>
+<span class="sourceLineNo">255</span>  }<a name="line.255"></a>
+<span class="sourceLineNo">256</span><a name="line.256"></a>
+<span class="sourceLineNo">257</span>  /**<a name="line.257"></a>
+<span class="sourceLineNo">258</span>   * Main entry point.<a name="line.258"></a>
+<span class="sourceLineNo">259</span>   * @param args The command line parameters.<a name="line.259"></a>
+<span class="sourceLineNo">260</span>   * @throws Exception When running the job fails.<a name="line.260"></a>
+<span class="sourceLineNo">261</span>   */<a name="line.261"></a>
+<span class="sourceLineNo">262</span>  public static void main(String[] args) throws Exception {<a name="line.262"></a>
+<span class="sourceLineNo">263</span>    int errCode = ToolRunner.run(HBaseConfiguration.create(), new RowCounter(), args);<a name="line.263"></a>
+<span class="sourceLineNo">264</span>    System.exit(errCode);<a name="line.264"></a>
+<span class="sourceLineNo">265</span>  }<a name="line.265"></a>
+<span class="sourceLineNo">266</span><a name="line.266"></a>
+<span class="sourceLineNo">267</span>}<a name="line.267"></a>
 
 
 


Mime
View raw message