hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [05/13] hbase-site git commit: Published site at .
Date Sun, 08 Oct 2017 15:13:00 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/177c08e4/devapidocs/src-html/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.html b/devapidocs/src-html/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.html
index 19939f2..fc44569 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.html
@@ -67,738 +67,752 @@
 <span class="sourceLineNo">059</span>import org.apache.hadoop.hbase.HBaseInterfaceAudience;<a name="line.59"></a>
 <span class="sourceLineNo">060</span>import org.apache.hadoop.hbase.HConstants;<a name="line.60"></a>
 <span class="sourceLineNo">061</span>import org.apache.hadoop.hbase.HRegionInfo;<a name="line.61"></a>
-<span class="sourceLineNo">062</span>import org.apache.hadoop.hbase.KeyValueUtil;<a name="line.62"></a>
-<span class="sourceLineNo">063</span>import org.apache.hadoop.hbase.TableName;<a name="line.63"></a>
-<span class="sourceLineNo">064</span>import org.apache.hadoop.hbase.Tag;<a name="line.64"></a>
-<span class="sourceLineNo">065</span>import org.apache.hadoop.hbase.TagUtil;<a name="line.65"></a>
-<span class="sourceLineNo">066</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.66"></a>
-<span class="sourceLineNo">067</span>import org.apache.yetus.audience.InterfaceStability;<a name="line.67"></a>
-<span class="sourceLineNo">068</span>import org.apache.hadoop.hbase.io.FSDataInputStreamWrapper;<a name="line.68"></a>
-<span class="sourceLineNo">069</span>import org.apache.hadoop.hbase.io.hfile.HFile.FileInfo;<a name="line.69"></a>
-<span class="sourceLineNo">070</span>import org.apache.hadoop.hbase.mob.MobUtils;<a name="line.70"></a>
-<span class="sourceLineNo">071</span>import org.apache.hadoop.hbase.regionserver.TimeRangeTracker;<a name="line.71"></a>
-<span class="sourceLineNo">072</span>import org.apache.hadoop.hbase.util.BloomFilter;<a name="line.72"></a>
-<span class="sourceLineNo">073</span>import org.apache.hadoop.hbase.util.BloomFilterFactory;<a name="line.73"></a>
-<span class="sourceLineNo">074</span>import org.apache.hadoop.hbase.util.BloomFilterUtil;<a name="line.74"></a>
-<span class="sourceLineNo">075</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.75"></a>
-<span class="sourceLineNo">076</span>import org.apache.hadoop.hbase.util.FSUtils;<a name="line.76"></a>
-<span class="sourceLineNo">077</span>import org.apache.hadoop.hbase.util.HFileArchiveUtil;<a name="line.77"></a>
-<span class="sourceLineNo">078</span>import org.apache.hadoop.util.Tool;<a name="line.78"></a>
-<span class="sourceLineNo">079</span>import org.apache.hadoop.util.ToolRunner;<a name="line.79"></a>
-<span class="sourceLineNo">080</span><a name="line.80"></a>
-<span class="sourceLineNo">081</span>import com.codahale.metrics.ConsoleReporter;<a name="line.81"></a>
-<span class="sourceLineNo">082</span>import com.codahale.metrics.Counter;<a name="line.82"></a>
-<span class="sourceLineNo">083</span>import com.codahale.metrics.Gauge;<a name="line.83"></a>
-<span class="sourceLineNo">084</span>import com.codahale.metrics.Histogram;<a name="line.84"></a>
-<span class="sourceLineNo">085</span>import com.codahale.metrics.Meter;<a name="line.85"></a>
-<span class="sourceLineNo">086</span>import com.codahale.metrics.MetricFilter;<a name="line.86"></a>
-<span class="sourceLineNo">087</span>import com.codahale.metrics.MetricRegistry;<a name="line.87"></a>
-<span class="sourceLineNo">088</span>import com.codahale.metrics.ScheduledReporter;<a name="line.88"></a>
-<span class="sourceLineNo">089</span>import com.codahale.metrics.Snapshot;<a name="line.89"></a>
-<span class="sourceLineNo">090</span>import com.codahale.metrics.Timer;<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> * Implements pretty-printing functionality for {@link HFile}s.<a name="line.93"></a>
-<span class="sourceLineNo">094</span> */<a name="line.94"></a>
-<span class="sourceLineNo">095</span>@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)<a name="line.95"></a>
-<span class="sourceLineNo">096</span>@InterfaceStability.Evolving<a name="line.96"></a>
-<span class="sourceLineNo">097</span>public class HFilePrettyPrinter extends Configured implements Tool {<a name="line.97"></a>
-<span class="sourceLineNo">098</span><a name="line.98"></a>
-<span class="sourceLineNo">099</span>  private static final Log LOG = LogFactory.getLog(HFilePrettyPrinter.class);<a name="line.99"></a>
+<span class="sourceLineNo">062</span>import org.apache.hadoop.hbase.KeyValue;<a name="line.62"></a>
+<span class="sourceLineNo">063</span>import org.apache.hadoop.hbase.KeyValueUtil;<a name="line.63"></a>
+<span class="sourceLineNo">064</span>import org.apache.hadoop.hbase.TableName;<a name="line.64"></a>
+<span class="sourceLineNo">065</span>import org.apache.hadoop.hbase.Tag;<a name="line.65"></a>
+<span class="sourceLineNo">066</span>import org.apache.hadoop.hbase.TagUtil;<a name="line.66"></a>
+<span class="sourceLineNo">067</span>import org.apache.hadoop.hbase.regionserver.HStoreFile;<a name="line.67"></a>
+<span class="sourceLineNo">068</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.68"></a>
+<span class="sourceLineNo">069</span>import org.apache.yetus.audience.InterfaceStability;<a name="line.69"></a>
+<span class="sourceLineNo">070</span>import org.apache.hadoop.hbase.io.FSDataInputStreamWrapper;<a name="line.70"></a>
+<span class="sourceLineNo">071</span>import org.apache.hadoop.hbase.io.hfile.HFile.FileInfo;<a name="line.71"></a>
+<span class="sourceLineNo">072</span>import org.apache.hadoop.hbase.mob.MobUtils;<a name="line.72"></a>
+<span class="sourceLineNo">073</span>import org.apache.hadoop.hbase.regionserver.TimeRangeTracker;<a name="line.73"></a>
+<span class="sourceLineNo">074</span>import org.apache.hadoop.hbase.util.BloomFilter;<a name="line.74"></a>
+<span class="sourceLineNo">075</span>import org.apache.hadoop.hbase.util.BloomFilterFactory;<a name="line.75"></a>
+<span class="sourceLineNo">076</span>import org.apache.hadoop.hbase.util.BloomFilterUtil;<a name="line.76"></a>
+<span class="sourceLineNo">077</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.77"></a>
+<span class="sourceLineNo">078</span>import org.apache.hadoop.hbase.util.FSUtils;<a name="line.78"></a>
+<span class="sourceLineNo">079</span>import org.apache.hadoop.hbase.util.HFileArchiveUtil;<a name="line.79"></a>
+<span class="sourceLineNo">080</span>import org.apache.hadoop.util.Tool;<a name="line.80"></a>
+<span class="sourceLineNo">081</span>import org.apache.hadoop.util.ToolRunner;<a name="line.81"></a>
+<span class="sourceLineNo">082</span><a name="line.82"></a>
+<span class="sourceLineNo">083</span>import com.codahale.metrics.ConsoleReporter;<a name="line.83"></a>
+<span class="sourceLineNo">084</span>import com.codahale.metrics.Counter;<a name="line.84"></a>
+<span class="sourceLineNo">085</span>import com.codahale.metrics.Gauge;<a name="line.85"></a>
+<span class="sourceLineNo">086</span>import com.codahale.metrics.Histogram;<a name="line.86"></a>
+<span class="sourceLineNo">087</span>import com.codahale.metrics.Meter;<a name="line.87"></a>
+<span class="sourceLineNo">088</span>import com.codahale.metrics.MetricFilter;<a name="line.88"></a>
+<span class="sourceLineNo">089</span>import com.codahale.metrics.MetricRegistry;<a name="line.89"></a>
+<span class="sourceLineNo">090</span>import com.codahale.metrics.ScheduledReporter;<a name="line.90"></a>
+<span class="sourceLineNo">091</span>import com.codahale.metrics.Snapshot;<a name="line.91"></a>
+<span class="sourceLineNo">092</span>import com.codahale.metrics.Timer;<a name="line.92"></a>
+<span class="sourceLineNo">093</span><a name="line.93"></a>
+<span class="sourceLineNo">094</span>/**<a name="line.94"></a>
+<span class="sourceLineNo">095</span> * Implements pretty-printing functionality for {@link HFile}s.<a name="line.95"></a>
+<span class="sourceLineNo">096</span> */<a name="line.96"></a>
+<span class="sourceLineNo">097</span>@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)<a name="line.97"></a>
+<span class="sourceLineNo">098</span>@InterfaceStability.Evolving<a name="line.98"></a>
+<span class="sourceLineNo">099</span>public class HFilePrettyPrinter extends Configured implements Tool {<a name="line.99"></a>
 <span class="sourceLineNo">100</span><a name="line.100"></a>
-<span class="sourceLineNo">101</span>  private Options options = new Options();<a name="line.101"></a>
+<span class="sourceLineNo">101</span>  private static final Log LOG = LogFactory.getLog(HFilePrettyPrinter.class);<a name="line.101"></a>
 <span class="sourceLineNo">102</span><a name="line.102"></a>
-<span class="sourceLineNo">103</span>  private boolean verbose;<a name="line.103"></a>
-<span class="sourceLineNo">104</span>  private boolean printValue;<a name="line.104"></a>
-<span class="sourceLineNo">105</span>  private boolean printKey;<a name="line.105"></a>
-<span class="sourceLineNo">106</span>  private boolean shouldPrintMeta;<a name="line.106"></a>
-<span class="sourceLineNo">107</span>  private boolean printBlockIndex;<a name="line.107"></a>
-<span class="sourceLineNo">108</span>  private boolean printBlockHeaders;<a name="line.108"></a>
-<span class="sourceLineNo">109</span>  private boolean printStats;<a name="line.109"></a>
-<span class="sourceLineNo">110</span>  private boolean checkRow;<a name="line.110"></a>
-<span class="sourceLineNo">111</span>  private boolean checkFamily;<a name="line.111"></a>
-<span class="sourceLineNo">112</span>  private boolean isSeekToRow = false;<a name="line.112"></a>
-<span class="sourceLineNo">113</span>  private boolean checkMobIntegrity = false;<a name="line.113"></a>
-<span class="sourceLineNo">114</span>  private Map&lt;String, List&lt;Path&gt;&gt; mobFileLocations;<a name="line.114"></a>
-<span class="sourceLineNo">115</span>  private static final int FOUND_MOB_FILES_CACHE_CAPACITY = 50;<a name="line.115"></a>
-<span class="sourceLineNo">116</span>  private static final int MISSING_MOB_FILES_CACHE_CAPACITY = 20;<a name="line.116"></a>
-<span class="sourceLineNo">117</span>  private PrintStream out = System.out;<a name="line.117"></a>
-<span class="sourceLineNo">118</span>  private PrintStream err = System.err;<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>   * The row which the user wants to specify and print all the KeyValues for.<a name="line.121"></a>
-<span class="sourceLineNo">122</span>   */<a name="line.122"></a>
-<span class="sourceLineNo">123</span>  private byte[] row = null;<a name="line.123"></a>
-<span class="sourceLineNo">124</span><a name="line.124"></a>
-<span class="sourceLineNo">125</span>  private List&lt;Path&gt; files = new ArrayList&lt;&gt;();<a name="line.125"></a>
-<span class="sourceLineNo">126</span>  private int count;<a name="line.126"></a>
-<span class="sourceLineNo">127</span><a name="line.127"></a>
-<span class="sourceLineNo">128</span>  private static final String FOUR_SPACES = "    ";<a name="line.128"></a>
+<span class="sourceLineNo">103</span>  private Options options = new Options();<a name="line.103"></a>
+<span class="sourceLineNo">104</span><a name="line.104"></a>
+<span class="sourceLineNo">105</span>  private boolean verbose;<a name="line.105"></a>
+<span class="sourceLineNo">106</span>  private boolean printValue;<a name="line.106"></a>
+<span class="sourceLineNo">107</span>  private boolean printKey;<a name="line.107"></a>
+<span class="sourceLineNo">108</span>  private boolean shouldPrintMeta;<a name="line.108"></a>
+<span class="sourceLineNo">109</span>  private boolean printBlockIndex;<a name="line.109"></a>
+<span class="sourceLineNo">110</span>  private boolean printBlockHeaders;<a name="line.110"></a>
+<span class="sourceLineNo">111</span>  private boolean printStats;<a name="line.111"></a>
+<span class="sourceLineNo">112</span>  private boolean checkRow;<a name="line.112"></a>
+<span class="sourceLineNo">113</span>  private boolean checkFamily;<a name="line.113"></a>
+<span class="sourceLineNo">114</span>  private boolean isSeekToRow = false;<a name="line.114"></a>
+<span class="sourceLineNo">115</span>  private boolean checkMobIntegrity = false;<a name="line.115"></a>
+<span class="sourceLineNo">116</span>  private Map&lt;String, List&lt;Path&gt;&gt; mobFileLocations;<a name="line.116"></a>
+<span class="sourceLineNo">117</span>  private static final int FOUND_MOB_FILES_CACHE_CAPACITY = 50;<a name="line.117"></a>
+<span class="sourceLineNo">118</span>  private static final int MISSING_MOB_FILES_CACHE_CAPACITY = 20;<a name="line.118"></a>
+<span class="sourceLineNo">119</span>  private PrintStream out = System.out;<a name="line.119"></a>
+<span class="sourceLineNo">120</span>  private PrintStream err = System.err;<a name="line.120"></a>
+<span class="sourceLineNo">121</span><a name="line.121"></a>
+<span class="sourceLineNo">122</span>  /**<a name="line.122"></a>
+<span class="sourceLineNo">123</span>   * The row which the user wants to specify and print all the KeyValues for.<a name="line.123"></a>
+<span class="sourceLineNo">124</span>   */<a name="line.124"></a>
+<span class="sourceLineNo">125</span>  private byte[] row = null;<a name="line.125"></a>
+<span class="sourceLineNo">126</span><a name="line.126"></a>
+<span class="sourceLineNo">127</span>  private List&lt;Path&gt; files = new ArrayList&lt;&gt;();<a name="line.127"></a>
+<span class="sourceLineNo">128</span>  private int count;<a name="line.128"></a>
 <span class="sourceLineNo">129</span><a name="line.129"></a>
-<span class="sourceLineNo">130</span>  public HFilePrettyPrinter() {<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    super();<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    init();<a name="line.132"></a>
-<span class="sourceLineNo">133</span>  }<a name="line.133"></a>
-<span class="sourceLineNo">134</span><a name="line.134"></a>
-<span class="sourceLineNo">135</span>  public HFilePrettyPrinter(Configuration conf) {<a name="line.135"></a>
-<span class="sourceLineNo">136</span>    super(conf);<a name="line.136"></a>
-<span class="sourceLineNo">137</span>    init();<a name="line.137"></a>
-<span class="sourceLineNo">138</span>  }<a name="line.138"></a>
-<span class="sourceLineNo">139</span><a name="line.139"></a>
-<span class="sourceLineNo">140</span>  private void init() {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>    options.addOption("v", "verbose", false,<a name="line.141"></a>
-<span class="sourceLineNo">142</span>        "Verbose output; emits file and meta data delimiters");<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    options.addOption("p", "printkv", false, "Print key/value pairs");<a name="line.143"></a>
-<span class="sourceLineNo">144</span>    options.addOption("e", "printkey", false, "Print keys");<a name="line.144"></a>
-<span class="sourceLineNo">145</span>    options.addOption("m", "printmeta", false, "Print meta data of file");<a name="line.145"></a>
-<span class="sourceLineNo">146</span>    options.addOption("b", "printblocks", false, "Print block index meta data");<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    options.addOption("h", "printblockheaders", false, "Print block headers for each block.");<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    options.addOption("k", "checkrow", false,<a name="line.148"></a>
-<span class="sourceLineNo">149</span>        "Enable row order check; looks for out-of-order keys");<a name="line.149"></a>
-<span class="sourceLineNo">150</span>    options.addOption("a", "checkfamily", false, "Enable family check");<a name="line.150"></a>
-<span class="sourceLineNo">151</span>    options.addOption("w", "seekToRow", true,<a name="line.151"></a>
-<span class="sourceLineNo">152</span>      "Seek to this row and print all the kvs for this row only");<a name="line.152"></a>
-<span class="sourceLineNo">153</span>    options.addOption("s", "stats", false, "Print statistics");<a name="line.153"></a>
-<span class="sourceLineNo">154</span>    options.addOption("i", "checkMobIntegrity", false,<a name="line.154"></a>
-<span class="sourceLineNo">155</span>      "Print all cells whose mob files are missing");<a name="line.155"></a>
-<span class="sourceLineNo">156</span><a name="line.156"></a>
-<span class="sourceLineNo">157</span>    OptionGroup files = new OptionGroup();<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    files.addOption(new Option("f", "file", true,<a name="line.158"></a>
-<span class="sourceLineNo">159</span>      "File to scan. Pass full-path; e.g. hdfs://a:9000/hbase/hbase:meta/12/34"));<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    files.addOption(new Option("r", "region", true,<a name="line.160"></a>
-<span class="sourceLineNo">161</span>      "Region to scan. Pass region name; e.g. 'hbase:meta,,1'"));<a name="line.161"></a>
-<span class="sourceLineNo">162</span>    options.addOptionGroup(files);<a name="line.162"></a>
-<span class="sourceLineNo">163</span>  }<a name="line.163"></a>
-<span class="sourceLineNo">164</span><a name="line.164"></a>
-<span class="sourceLineNo">165</span>  public void setPrintStreams(PrintStream out, PrintStream err) {<a name="line.165"></a>
-<span class="sourceLineNo">166</span>    this.out = out;<a name="line.166"></a>
-<span class="sourceLineNo">167</span>    this.err = err;<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>  public boolean parseOptions(String args[]) throws ParseException,<a name="line.170"></a>
-<span class="sourceLineNo">171</span>      IOException {<a name="line.171"></a>
-<span class="sourceLineNo">172</span>    if (args.length == 0) {<a name="line.172"></a>
-<span class="sourceLineNo">173</span>      HelpFormatter formatter = new HelpFormatter();<a name="line.173"></a>
-<span class="sourceLineNo">174</span>      formatter.printHelp("HFile", options, true);<a name="line.174"></a>
-<span class="sourceLineNo">175</span>      return false;<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    }<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    CommandLineParser parser = new PosixParser();<a name="line.177"></a>
-<span class="sourceLineNo">178</span>    CommandLine cmd = parser.parse(options, args);<a name="line.178"></a>
-<span class="sourceLineNo">179</span><a name="line.179"></a>
-<span class="sourceLineNo">180</span>    verbose = cmd.hasOption("v");<a name="line.180"></a>
-<span class="sourceLineNo">181</span>    printValue = cmd.hasOption("p");<a name="line.181"></a>
-<span class="sourceLineNo">182</span>    printKey = cmd.hasOption("e") || printValue;<a name="line.182"></a>
-<span class="sourceLineNo">183</span>    shouldPrintMeta = cmd.hasOption("m");<a name="line.183"></a>
-<span class="sourceLineNo">184</span>    printBlockIndex = cmd.hasOption("b");<a name="line.184"></a>
-<span class="sourceLineNo">185</span>    printBlockHeaders = cmd.hasOption("h");<a name="line.185"></a>
-<span class="sourceLineNo">186</span>    printStats = cmd.hasOption("s");<a name="line.186"></a>
-<span class="sourceLineNo">187</span>    checkRow = cmd.hasOption("k");<a name="line.187"></a>
-<span class="sourceLineNo">188</span>    checkFamily = cmd.hasOption("a");<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    checkMobIntegrity = cmd.hasOption("i");<a name="line.189"></a>
-<span class="sourceLineNo">190</span><a name="line.190"></a>
-<span class="sourceLineNo">191</span>    if (cmd.hasOption("f")) {<a name="line.191"></a>
-<span class="sourceLineNo">192</span>      files.add(new Path(cmd.getOptionValue("f")));<a name="line.192"></a>
-<span class="sourceLineNo">193</span>    }<a name="line.193"></a>
-<span class="sourceLineNo">194</span><a name="line.194"></a>
-<span class="sourceLineNo">195</span>    if (cmd.hasOption("w")) {<a name="line.195"></a>
-<span class="sourceLineNo">196</span>      String key = cmd.getOptionValue("w");<a name="line.196"></a>
-<span class="sourceLineNo">197</span>      if (key != null &amp;&amp; key.length() != 0) {<a name="line.197"></a>
-<span class="sourceLineNo">198</span>        row = Bytes.toBytesBinary(key);<a name="line.198"></a>
-<span class="sourceLineNo">199</span>        isSeekToRow = true;<a name="line.199"></a>
-<span class="sourceLineNo">200</span>      } else {<a name="line.200"></a>
-<span class="sourceLineNo">201</span>        err.println("Invalid row is specified.");<a name="line.201"></a>
-<span class="sourceLineNo">202</span>        System.exit(-1);<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      }<a name="line.203"></a>
-<span class="sourceLineNo">204</span>    }<a name="line.204"></a>
-<span class="sourceLineNo">205</span><a name="line.205"></a>
-<span class="sourceLineNo">206</span>    if (cmd.hasOption("r")) {<a name="line.206"></a>
-<span class="sourceLineNo">207</span>      String regionName = cmd.getOptionValue("r");<a name="line.207"></a>
-<span class="sourceLineNo">208</span>      byte[] rn = Bytes.toBytes(regionName);<a name="line.208"></a>
-<span class="sourceLineNo">209</span>      byte[][] hri = HRegionInfo.parseRegionName(rn);<a name="line.209"></a>
-<span class="sourceLineNo">210</span>      Path rootDir = FSUtils.getRootDir(getConf());<a name="line.210"></a>
-<span class="sourceLineNo">211</span>      Path tableDir = FSUtils.getTableDir(rootDir, TableName.valueOf(hri[0]));<a name="line.211"></a>
-<span class="sourceLineNo">212</span>      String enc = HRegionInfo.encodeRegionName(rn);<a name="line.212"></a>
-<span class="sourceLineNo">213</span>      Path regionDir = new Path(tableDir, enc);<a name="line.213"></a>
-<span class="sourceLineNo">214</span>      if (verbose)<a name="line.214"></a>
-<span class="sourceLineNo">215</span>        out.println("region dir -&gt; " + regionDir);<a name="line.215"></a>
-<span class="sourceLineNo">216</span>      List&lt;Path&gt; regionFiles = HFile.getStoreFiles(FileSystem.get(getConf()),<a name="line.216"></a>
-<span class="sourceLineNo">217</span>          regionDir);<a name="line.217"></a>
-<span class="sourceLineNo">218</span>      if (verbose)<a name="line.218"></a>
-<span class="sourceLineNo">219</span>        out.println("Number of region files found -&gt; "<a name="line.219"></a>
-<span class="sourceLineNo">220</span>            + regionFiles.size());<a name="line.220"></a>
-<span class="sourceLineNo">221</span>      if (verbose) {<a name="line.221"></a>
-<span class="sourceLineNo">222</span>        int i = 1;<a name="line.222"></a>
-<span class="sourceLineNo">223</span>        for (Path p : regionFiles) {<a name="line.223"></a>
-<span class="sourceLineNo">224</span>          if (verbose)<a name="line.224"></a>
-<span class="sourceLineNo">225</span>            out.println("Found file[" + i++ + "] -&gt; " + p);<a name="line.225"></a>
-<span class="sourceLineNo">226</span>        }<a name="line.226"></a>
-<span class="sourceLineNo">227</span>      }<a name="line.227"></a>
-<span class="sourceLineNo">228</span>      files.addAll(regionFiles);<a name="line.228"></a>
-<span class="sourceLineNo">229</span>    }<a name="line.229"></a>
-<span class="sourceLineNo">230</span><a name="line.230"></a>
-<span class="sourceLineNo">231</span>    if(checkMobIntegrity) {<a name="line.231"></a>
-<span class="sourceLineNo">232</span>      if (verbose) {<a name="line.232"></a>
-<span class="sourceLineNo">233</span>        System.out.println("checkMobIntegrity is enabled");<a name="line.233"></a>
-<span class="sourceLineNo">234</span>      }<a name="line.234"></a>
-<span class="sourceLineNo">235</span>      mobFileLocations = new HashMap&lt;&gt;();<a name="line.235"></a>
-<span class="sourceLineNo">236</span>    }<a name="line.236"></a>
-<span class="sourceLineNo">237</span><a name="line.237"></a>
-<span class="sourceLineNo">238</span>    cmd.getArgList().forEach((file) -&gt; files.add(new Path(file)));<a name="line.238"></a>
+<span class="sourceLineNo">130</span>  private static final String FOUR_SPACES = "    ";<a name="line.130"></a>
+<span class="sourceLineNo">131</span><a name="line.131"></a>
+<span class="sourceLineNo">132</span>  public HFilePrettyPrinter() {<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    super();<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    init();<a name="line.134"></a>
+<span class="sourceLineNo">135</span>  }<a name="line.135"></a>
+<span class="sourceLineNo">136</span><a name="line.136"></a>
+<span class="sourceLineNo">137</span>  public HFilePrettyPrinter(Configuration conf) {<a name="line.137"></a>
+<span class="sourceLineNo">138</span>    super(conf);<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    init();<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 void init() {<a name="line.142"></a>
+<span class="sourceLineNo">143</span>    options.addOption("v", "verbose", false,<a name="line.143"></a>
+<span class="sourceLineNo">144</span>        "Verbose output; emits file and meta data delimiters");<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    options.addOption("p", "printkv", false, "Print key/value pairs");<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    options.addOption("e", "printkey", false, "Print keys");<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    options.addOption("m", "printmeta", false, "Print meta data of file");<a name="line.147"></a>
+<span class="sourceLineNo">148</span>    options.addOption("b", "printblocks", false, "Print block index meta data");<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    options.addOption("h", "printblockheaders", false, "Print block headers for each block.");<a name="line.149"></a>
+<span class="sourceLineNo">150</span>    options.addOption("k", "checkrow", false,<a name="line.150"></a>
+<span class="sourceLineNo">151</span>        "Enable row order check; looks for out-of-order keys");<a name="line.151"></a>
+<span class="sourceLineNo">152</span>    options.addOption("a", "checkfamily", false, "Enable family check");<a name="line.152"></a>
+<span class="sourceLineNo">153</span>    options.addOption("w", "seekToRow", true,<a name="line.153"></a>
+<span class="sourceLineNo">154</span>      "Seek to this row and print all the kvs for this row only");<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    options.addOption("s", "stats", false, "Print statistics");<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    options.addOption("i", "checkMobIntegrity", false,<a name="line.156"></a>
+<span class="sourceLineNo">157</span>      "Print all cells whose mob files are missing");<a name="line.157"></a>
+<span class="sourceLineNo">158</span><a name="line.158"></a>
+<span class="sourceLineNo">159</span>    OptionGroup files = new OptionGroup();<a name="line.159"></a>
+<span class="sourceLineNo">160</span>    files.addOption(new Option("f", "file", true,<a name="line.160"></a>
+<span class="sourceLineNo">161</span>      "File to scan. Pass full-path; e.g. hdfs://a:9000/hbase/hbase:meta/12/34"));<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    files.addOption(new Option("r", "region", true,<a name="line.162"></a>
+<span class="sourceLineNo">163</span>      "Region to scan. Pass region name; e.g. 'hbase:meta,,1'"));<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    options.addOptionGroup(files);<a name="line.164"></a>
+<span class="sourceLineNo">165</span>  }<a name="line.165"></a>
+<span class="sourceLineNo">166</span><a name="line.166"></a>
+<span class="sourceLineNo">167</span>  public void setPrintStreams(PrintStream out, PrintStream err) {<a name="line.167"></a>
+<span class="sourceLineNo">168</span>    this.out = out;<a name="line.168"></a>
+<span class="sourceLineNo">169</span>    this.err = err;<a name="line.169"></a>
+<span class="sourceLineNo">170</span>  }<a name="line.170"></a>
+<span class="sourceLineNo">171</span><a name="line.171"></a>
+<span class="sourceLineNo">172</span>  public boolean parseOptions(String args[]) throws ParseException,<a name="line.172"></a>
+<span class="sourceLineNo">173</span>      IOException {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    if (args.length == 0) {<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      HelpFormatter formatter = new HelpFormatter();<a name="line.175"></a>
+<span class="sourceLineNo">176</span>      formatter.printHelp("HFile", options, true);<a name="line.176"></a>
+<span class="sourceLineNo">177</span>      return false;<a name="line.177"></a>
+<span class="sourceLineNo">178</span>    }<a name="line.178"></a>
+<span class="sourceLineNo">179</span>    CommandLineParser parser = new PosixParser();<a name="line.179"></a>
+<span class="sourceLineNo">180</span>    CommandLine cmd = parser.parse(options, args);<a name="line.180"></a>
+<span class="sourceLineNo">181</span><a name="line.181"></a>
+<span class="sourceLineNo">182</span>    verbose = cmd.hasOption("v");<a name="line.182"></a>
+<span class="sourceLineNo">183</span>    printValue = cmd.hasOption("p");<a name="line.183"></a>
+<span class="sourceLineNo">184</span>    printKey = cmd.hasOption("e") || printValue;<a name="line.184"></a>
+<span class="sourceLineNo">185</span>    shouldPrintMeta = cmd.hasOption("m");<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    printBlockIndex = cmd.hasOption("b");<a name="line.186"></a>
+<span class="sourceLineNo">187</span>    printBlockHeaders = cmd.hasOption("h");<a name="line.187"></a>
+<span class="sourceLineNo">188</span>    printStats = cmd.hasOption("s");<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    checkRow = cmd.hasOption("k");<a name="line.189"></a>
+<span class="sourceLineNo">190</span>    checkFamily = cmd.hasOption("a");<a name="line.190"></a>
+<span class="sourceLineNo">191</span>    checkMobIntegrity = cmd.hasOption("i");<a name="line.191"></a>
+<span class="sourceLineNo">192</span><a name="line.192"></a>
+<span class="sourceLineNo">193</span>    if (cmd.hasOption("f")) {<a name="line.193"></a>
+<span class="sourceLineNo">194</span>      files.add(new Path(cmd.getOptionValue("f")));<a name="line.194"></a>
+<span class="sourceLineNo">195</span>    }<a name="line.195"></a>
+<span class="sourceLineNo">196</span><a name="line.196"></a>
+<span class="sourceLineNo">197</span>    if (cmd.hasOption("w")) {<a name="line.197"></a>
+<span class="sourceLineNo">198</span>      String key = cmd.getOptionValue("w");<a name="line.198"></a>
+<span class="sourceLineNo">199</span>      if (key != null &amp;&amp; key.length() != 0) {<a name="line.199"></a>
+<span class="sourceLineNo">200</span>        row = Bytes.toBytesBinary(key);<a name="line.200"></a>
+<span class="sourceLineNo">201</span>        isSeekToRow = true;<a name="line.201"></a>
+<span class="sourceLineNo">202</span>      } else {<a name="line.202"></a>
+<span class="sourceLineNo">203</span>        err.println("Invalid row is specified.");<a name="line.203"></a>
+<span class="sourceLineNo">204</span>        System.exit(-1);<a name="line.204"></a>
+<span class="sourceLineNo">205</span>      }<a name="line.205"></a>
+<span class="sourceLineNo">206</span>    }<a name="line.206"></a>
+<span class="sourceLineNo">207</span><a name="line.207"></a>
+<span class="sourceLineNo">208</span>    if (cmd.hasOption("r")) {<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      String regionName = cmd.getOptionValue("r");<a name="line.209"></a>
+<span class="sourceLineNo">210</span>      byte[] rn = Bytes.toBytes(regionName);<a name="line.210"></a>
+<span class="sourceLineNo">211</span>      byte[][] hri = HRegionInfo.parseRegionName(rn);<a name="line.211"></a>
+<span class="sourceLineNo">212</span>      Path rootDir = FSUtils.getRootDir(getConf());<a name="line.212"></a>
+<span class="sourceLineNo">213</span>      Path tableDir = FSUtils.getTableDir(rootDir, TableName.valueOf(hri[0]));<a name="line.213"></a>
+<span class="sourceLineNo">214</span>      String enc = HRegionInfo.encodeRegionName(rn);<a name="line.214"></a>
+<span class="sourceLineNo">215</span>      Path regionDir = new Path(tableDir, enc);<a name="line.215"></a>
+<span class="sourceLineNo">216</span>      if (verbose)<a name="line.216"></a>
+<span class="sourceLineNo">217</span>        out.println("region dir -&gt; " + regionDir);<a name="line.217"></a>
+<span class="sourceLineNo">218</span>      List&lt;Path&gt; regionFiles = HFile.getStoreFiles(FileSystem.get(getConf()),<a name="line.218"></a>
+<span class="sourceLineNo">219</span>          regionDir);<a name="line.219"></a>
+<span class="sourceLineNo">220</span>      if (verbose)<a name="line.220"></a>
+<span class="sourceLineNo">221</span>        out.println("Number of region files found -&gt; "<a name="line.221"></a>
+<span class="sourceLineNo">222</span>            + regionFiles.size());<a name="line.222"></a>
+<span class="sourceLineNo">223</span>      if (verbose) {<a name="line.223"></a>
+<span class="sourceLineNo">224</span>        int i = 1;<a name="line.224"></a>
+<span class="sourceLineNo">225</span>        for (Path p : regionFiles) {<a name="line.225"></a>
+<span class="sourceLineNo">226</span>          if (verbose)<a name="line.226"></a>
+<span class="sourceLineNo">227</span>            out.println("Found file[" + i++ + "] -&gt; " + p);<a name="line.227"></a>
+<span class="sourceLineNo">228</span>        }<a name="line.228"></a>
+<span class="sourceLineNo">229</span>      }<a name="line.229"></a>
+<span class="sourceLineNo">230</span>      files.addAll(regionFiles);<a name="line.230"></a>
+<span class="sourceLineNo">231</span>    }<a name="line.231"></a>
+<span class="sourceLineNo">232</span><a name="line.232"></a>
+<span class="sourceLineNo">233</span>    if(checkMobIntegrity) {<a name="line.233"></a>
+<span class="sourceLineNo">234</span>      if (verbose) {<a name="line.234"></a>
+<span class="sourceLineNo">235</span>        System.out.println("checkMobIntegrity is enabled");<a name="line.235"></a>
+<span class="sourceLineNo">236</span>      }<a name="line.236"></a>
+<span class="sourceLineNo">237</span>      mobFileLocations = new HashMap&lt;&gt;();<a name="line.237"></a>
+<span class="sourceLineNo">238</span>    }<a name="line.238"></a>
 <span class="sourceLineNo">239</span><a name="line.239"></a>
-<span class="sourceLineNo">240</span>    return true;<a name="line.240"></a>
-<span class="sourceLineNo">241</span>  }<a name="line.241"></a>
-<span class="sourceLineNo">242</span><a name="line.242"></a>
-<span class="sourceLineNo">243</span>  /**<a name="line.243"></a>
-<span class="sourceLineNo">244</span>   * Runs the command-line pretty-printer, and returns the desired command<a name="line.244"></a>
-<span class="sourceLineNo">245</span>   * exit code (zero for success, non-zero for failure).<a name="line.245"></a>
-<span class="sourceLineNo">246</span>   */<a name="line.246"></a>
-<span class="sourceLineNo">247</span>  @Override<a name="line.247"></a>
-<span class="sourceLineNo">248</span>  public int run(String[] args) {<a name="line.248"></a>
-<span class="sourceLineNo">249</span>    if (getConf() == null) {<a name="line.249"></a>
-<span class="sourceLineNo">250</span>      throw new RuntimeException("A Configuration instance must be provided.");<a name="line.250"></a>
-<span class="sourceLineNo">251</span>    }<a name="line.251"></a>
-<span class="sourceLineNo">252</span>    try {<a name="line.252"></a>
-<span class="sourceLineNo">253</span>      FSUtils.setFsDefault(getConf(), FSUtils.getRootDir(getConf()));<a name="line.253"></a>
-<span class="sourceLineNo">254</span>      if (!parseOptions(args))<a name="line.254"></a>
-<span class="sourceLineNo">255</span>        return 1;<a name="line.255"></a>
-<span class="sourceLineNo">256</span>    } catch (IOException ex) {<a name="line.256"></a>
-<span class="sourceLineNo">257</span>      LOG.error("Error parsing command-line options", ex);<a name="line.257"></a>
-<span class="sourceLineNo">258</span>      return 1;<a name="line.258"></a>
-<span class="sourceLineNo">259</span>    } catch (ParseException ex) {<a name="line.259"></a>
-<span class="sourceLineNo">260</span>      LOG.error("Error parsing command-line options", ex);<a name="line.260"></a>
-<span class="sourceLineNo">261</span>      return 1;<a name="line.261"></a>
-<span class="sourceLineNo">262</span>    }<a name="line.262"></a>
-<span class="sourceLineNo">263</span><a name="line.263"></a>
-<span class="sourceLineNo">264</span>    // iterate over all files found<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    for (Path fileName : files) {<a name="line.265"></a>
-<span class="sourceLineNo">266</span>      try {<a name="line.266"></a>
-<span class="sourceLineNo">267</span>        int exitCode = processFile(fileName);<a name="line.267"></a>
-<span class="sourceLineNo">268</span>        if (exitCode != 0) {<a name="line.268"></a>
-<span class="sourceLineNo">269</span>          return exitCode;<a name="line.269"></a>
-<span class="sourceLineNo">270</span>        }<a name="line.270"></a>
-<span class="sourceLineNo">271</span>      } catch (IOException ex) {<a name="line.271"></a>
-<span class="sourceLineNo">272</span>        LOG.error("Error reading " + fileName, ex);<a name="line.272"></a>
-<span class="sourceLineNo">273</span>        return -2;<a name="line.273"></a>
-<span class="sourceLineNo">274</span>      }<a name="line.274"></a>
-<span class="sourceLineNo">275</span>    }<a name="line.275"></a>
-<span class="sourceLineNo">276</span><a name="line.276"></a>
-<span class="sourceLineNo">277</span>    if (verbose || printKey) {<a name="line.277"></a>
-<span class="sourceLineNo">278</span>      out.println("Scanned kv count -&gt; " + count);<a name="line.278"></a>
-<span class="sourceLineNo">279</span>    }<a name="line.279"></a>
-<span class="sourceLineNo">280</span><a name="line.280"></a>
-<span class="sourceLineNo">281</span>    return 0;<a name="line.281"></a>
-<span class="sourceLineNo">282</span>  }<a name="line.282"></a>
-<span class="sourceLineNo">283</span><a name="line.283"></a>
-<span class="sourceLineNo">284</span>  public int processFile(Path file) throws IOException {<a name="line.284"></a>
-<span class="sourceLineNo">285</span>    if (verbose)<a name="line.285"></a>
-<span class="sourceLineNo">286</span>      out.println("Scanning -&gt; " + file);<a name="line.286"></a>
-<span class="sourceLineNo">287</span><a name="line.287"></a>
-<span class="sourceLineNo">288</span>    Path rootPath = FSUtils.getRootDir(getConf());<a name="line.288"></a>
-<span class="sourceLineNo">289</span>    String rootString = rootPath + rootPath.SEPARATOR;<a name="line.289"></a>
-<span class="sourceLineNo">290</span>    if (!file.toString().startsWith(rootString)) {<a name="line.290"></a>
-<span class="sourceLineNo">291</span>      // First we see if fully-qualified URI matches the root dir. It might<a name="line.291"></a>
-<span class="sourceLineNo">292</span>      // also be an absolute path in the same filesystem, so we prepend the FS<a name="line.292"></a>
-<span class="sourceLineNo">293</span>      // of the root dir and see if that fully-qualified URI matches.<a name="line.293"></a>
-<span class="sourceLineNo">294</span>      FileSystem rootFS = rootPath.getFileSystem(getConf());<a name="line.294"></a>
-<span class="sourceLineNo">295</span>      String qualifiedFile = rootFS.getUri().toString() + file.toString();<a name="line.295"></a>
-<span class="sourceLineNo">296</span>      if (!qualifiedFile.startsWith(rootString)) {<a name="line.296"></a>
-<span class="sourceLineNo">297</span>        err.println("ERROR, file (" + file +<a name="line.297"></a>
-<span class="sourceLineNo">298</span>            ") is not in HBase's root directory (" + rootString + ")");<a name="line.298"></a>
-<span class="sourceLineNo">299</span>        return -2;<a name="line.299"></a>
-<span class="sourceLineNo">300</span>      }<a name="line.300"></a>
-<span class="sourceLineNo">301</span>    }<a name="line.301"></a>
-<span class="sourceLineNo">302</span><a name="line.302"></a>
-<span class="sourceLineNo">303</span>    FileSystem fs = file.getFileSystem(getConf());<a name="line.303"></a>
-<span class="sourceLineNo">304</span>    if (!fs.exists(file)) {<a name="line.304"></a>
-<span class="sourceLineNo">305</span>      err.println("ERROR, file doesnt exist: " + file);<a name="line.305"></a>
-<span class="sourceLineNo">306</span>      return -2;<a name="line.306"></a>
-<span class="sourceLineNo">307</span>    }<a name="line.307"></a>
-<span class="sourceLineNo">308</span><a name="line.308"></a>
-<span class="sourceLineNo">309</span>    HFile.Reader reader = HFile.createReader(fs, file, new CacheConfig(getConf()), true, getConf());<a name="line.309"></a>
+<span class="sourceLineNo">240</span>    cmd.getArgList().forEach((file) -&gt; files.add(new Path(file)));<a name="line.240"></a>
+<span class="sourceLineNo">241</span><a name="line.241"></a>
+<span class="sourceLineNo">242</span>    return true;<a name="line.242"></a>
+<span class="sourceLineNo">243</span>  }<a name="line.243"></a>
+<span class="sourceLineNo">244</span><a name="line.244"></a>
+<span class="sourceLineNo">245</span>  /**<a name="line.245"></a>
+<span class="sourceLineNo">246</span>   * Runs the command-line pretty-printer, and returns the desired command<a name="line.246"></a>
+<span class="sourceLineNo">247</span>   * exit code (zero for success, non-zero for failure).<a name="line.247"></a>
+<span class="sourceLineNo">248</span>   */<a name="line.248"></a>
+<span class="sourceLineNo">249</span>  @Override<a name="line.249"></a>
+<span class="sourceLineNo">250</span>  public int run(String[] args) {<a name="line.250"></a>
+<span class="sourceLineNo">251</span>    if (getConf() == null) {<a name="line.251"></a>
+<span class="sourceLineNo">252</span>      throw new RuntimeException("A Configuration instance must be provided.");<a name="line.252"></a>
+<span class="sourceLineNo">253</span>    }<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    try {<a name="line.254"></a>
+<span class="sourceLineNo">255</span>      FSUtils.setFsDefault(getConf(), FSUtils.getRootDir(getConf()));<a name="line.255"></a>
+<span class="sourceLineNo">256</span>      if (!parseOptions(args))<a name="line.256"></a>
+<span class="sourceLineNo">257</span>        return 1;<a name="line.257"></a>
+<span class="sourceLineNo">258</span>    } catch (IOException ex) {<a name="line.258"></a>
+<span class="sourceLineNo">259</span>      LOG.error("Error parsing command-line options", ex);<a name="line.259"></a>
+<span class="sourceLineNo">260</span>      return 1;<a name="line.260"></a>
+<span class="sourceLineNo">261</span>    } catch (ParseException ex) {<a name="line.261"></a>
+<span class="sourceLineNo">262</span>      LOG.error("Error parsing command-line options", ex);<a name="line.262"></a>
+<span class="sourceLineNo">263</span>      return 1;<a name="line.263"></a>
+<span class="sourceLineNo">264</span>    }<a name="line.264"></a>
+<span class="sourceLineNo">265</span><a name="line.265"></a>
+<span class="sourceLineNo">266</span>    // iterate over all files found<a name="line.266"></a>
+<span class="sourceLineNo">267</span>    for (Path fileName : files) {<a name="line.267"></a>
+<span class="sourceLineNo">268</span>      try {<a name="line.268"></a>
+<span class="sourceLineNo">269</span>        int exitCode = processFile(fileName);<a name="line.269"></a>
+<span class="sourceLineNo">270</span>        if (exitCode != 0) {<a name="line.270"></a>
+<span class="sourceLineNo">271</span>          return exitCode;<a name="line.271"></a>
+<span class="sourceLineNo">272</span>        }<a name="line.272"></a>
+<span class="sourceLineNo">273</span>      } catch (IOException ex) {<a name="line.273"></a>
+<span class="sourceLineNo">274</span>        LOG.error("Error reading " + fileName, ex);<a name="line.274"></a>
+<span class="sourceLineNo">275</span>        return -2;<a name="line.275"></a>
+<span class="sourceLineNo">276</span>      }<a name="line.276"></a>
+<span class="sourceLineNo">277</span>    }<a name="line.277"></a>
+<span class="sourceLineNo">278</span><a name="line.278"></a>
+<span class="sourceLineNo">279</span>    if (verbose || printKey) {<a name="line.279"></a>
+<span class="sourceLineNo">280</span>      out.println("Scanned kv count -&gt; " + count);<a name="line.280"></a>
+<span class="sourceLineNo">281</span>    }<a name="line.281"></a>
+<span class="sourceLineNo">282</span><a name="line.282"></a>
+<span class="sourceLineNo">283</span>    return 0;<a name="line.283"></a>
+<span class="sourceLineNo">284</span>  }<a name="line.284"></a>
+<span class="sourceLineNo">285</span><a name="line.285"></a>
+<span class="sourceLineNo">286</span>  public int processFile(Path file) throws IOException {<a name="line.286"></a>
+<span class="sourceLineNo">287</span>    if (verbose)<a name="line.287"></a>
+<span class="sourceLineNo">288</span>      out.println("Scanning -&gt; " + file);<a name="line.288"></a>
+<span class="sourceLineNo">289</span><a name="line.289"></a>
+<span class="sourceLineNo">290</span>    Path rootPath = FSUtils.getRootDir(getConf());<a name="line.290"></a>
+<span class="sourceLineNo">291</span>    String rootString = rootPath + rootPath.SEPARATOR;<a name="line.291"></a>
+<span class="sourceLineNo">292</span>    if (!file.toString().startsWith(rootString)) {<a name="line.292"></a>
+<span class="sourceLineNo">293</span>      // First we see if fully-qualified URI matches the root dir. It might<a name="line.293"></a>
+<span class="sourceLineNo">294</span>      // also be an absolute path in the same filesystem, so we prepend the FS<a name="line.294"></a>
+<span class="sourceLineNo">295</span>      // of the root dir and see if that fully-qualified URI matches.<a name="line.295"></a>
+<span class="sourceLineNo">296</span>      FileSystem rootFS = rootPath.getFileSystem(getConf());<a name="line.296"></a>
+<span class="sourceLineNo">297</span>      String qualifiedFile = rootFS.getUri().toString() + file.toString();<a name="line.297"></a>
+<span class="sourceLineNo">298</span>      if (!qualifiedFile.startsWith(rootString)) {<a name="line.298"></a>
+<span class="sourceLineNo">299</span>        err.println("ERROR, file (" + file +<a name="line.299"></a>
+<span class="sourceLineNo">300</span>            ") is not in HBase's root directory (" + rootString + ")");<a name="line.300"></a>
+<span class="sourceLineNo">301</span>        return -2;<a name="line.301"></a>
+<span class="sourceLineNo">302</span>      }<a name="line.302"></a>
+<span class="sourceLineNo">303</span>    }<a name="line.303"></a>
+<span class="sourceLineNo">304</span><a name="line.304"></a>
+<span class="sourceLineNo">305</span>    FileSystem fs = file.getFileSystem(getConf());<a name="line.305"></a>
+<span class="sourceLineNo">306</span>    if (!fs.exists(file)) {<a name="line.306"></a>
+<span class="sourceLineNo">307</span>      err.println("ERROR, file doesnt exist: " + file);<a name="line.307"></a>
+<span class="sourceLineNo">308</span>      return -2;<a name="line.308"></a>
+<span class="sourceLineNo">309</span>    }<a name="line.309"></a>
 <span class="sourceLineNo">310</span><a name="line.310"></a>
-<span class="sourceLineNo">311</span>    Map&lt;byte[], byte[]&gt; fileInfo = reader.loadFileInfo();<a name="line.311"></a>
+<span class="sourceLineNo">311</span>    HFile.Reader reader = HFile.createReader(fs, file, new CacheConfig(getConf()), true, getConf());<a name="line.311"></a>
 <span class="sourceLineNo">312</span><a name="line.312"></a>
-<span class="sourceLineNo">313</span>    KeyValueStatsCollector fileStats = null;<a name="line.313"></a>
+<span class="sourceLineNo">313</span>    Map&lt;byte[], byte[]&gt; fileInfo = reader.loadFileInfo();<a name="line.313"></a>
 <span class="sourceLineNo">314</span><a name="line.314"></a>
-<span class="sourceLineNo">315</span>    if (verbose || printKey || checkRow || checkFamily || printStats || checkMobIntegrity) {<a name="line.315"></a>
-<span class="sourceLineNo">316</span>      // scan over file and read key/value's and check if requested<a name="line.316"></a>
-<span class="sourceLineNo">317</span>      HFileScanner scanner = reader.getScanner(false, false, false);<a name="line.317"></a>
-<span class="sourceLineNo">318</span>      fileStats = new KeyValueStatsCollector();<a name="line.318"></a>
-<span class="sourceLineNo">319</span>      boolean shouldScanKeysValues = false;<a name="line.319"></a>
-<span class="sourceLineNo">320</span>      if (this.isSeekToRow) {<a name="line.320"></a>
-<span class="sourceLineNo">321</span>        // seek to the first kv on this row<a name="line.321"></a>
-<span class="sourceLineNo">322</span>        shouldScanKeysValues =<a name="line.322"></a>
-<span class="sourceLineNo">323</span>          (scanner.seekTo(CellUtil.createFirstOnRow(this.row)) != -1);<a name="line.323"></a>
-<span class="sourceLineNo">324</span>      } else {<a name="line.324"></a>
-<span class="sourceLineNo">325</span>        shouldScanKeysValues = scanner.seekTo();<a name="line.325"></a>
-<span class="sourceLineNo">326</span>      }<a name="line.326"></a>
-<span class="sourceLineNo">327</span>      if (shouldScanKeysValues)<a name="line.327"></a>
-<span class="sourceLineNo">328</span>        scanKeysValues(file, fileStats, scanner, row);<a name="line.328"></a>
-<span class="sourceLineNo">329</span>    }<a name="line.329"></a>
-<span class="sourceLineNo">330</span><a name="line.330"></a>
-<span class="sourceLineNo">331</span>    // print meta data<a name="line.331"></a>
-<span class="sourceLineNo">332</span>    if (shouldPrintMeta) {<a name="line.332"></a>
-<span class="sourceLineNo">333</span>      printMeta(reader, fileInfo);<a name="line.333"></a>
-<span class="sourceLineNo">334</span>    }<a name="line.334"></a>
-<span class="sourceLineNo">335</span><a name="line.335"></a>
-<span class="sourceLineNo">336</span>    if (printBlockIndex) {<a name="line.336"></a>
-<span class="sourceLineNo">337</span>      out.println("Block Index:");<a name="line.337"></a>
-<span class="sourceLineNo">338</span>      out.println(reader.getDataBlockIndexReader());<a name="line.338"></a>
-<span class="sourceLineNo">339</span>    }<a name="line.339"></a>
-<span class="sourceLineNo">340</span><a name="line.340"></a>
-<span class="sourceLineNo">341</span>    if (printBlockHeaders) {<a name="line.341"></a>
-<span class="sourceLineNo">342</span>      out.println("Block Headers:");<a name="line.342"></a>
-<span class="sourceLineNo">343</span>      /*<a name="line.343"></a>
-<span class="sourceLineNo">344</span>       * TODO: this same/similar block iteration logic is used in HFileBlock#blockRange and<a name="line.344"></a>
-<span class="sourceLineNo">345</span>       * TestLazyDataBlockDecompression. Refactor?<a name="line.345"></a>
-<span class="sourceLineNo">346</span>       */<a name="line.346"></a>
-<span class="sourceLineNo">347</span>      FSDataInputStreamWrapper fsdis = new FSDataInputStreamWrapper(fs, file);<a name="line.347"></a>
-<span class="sourceLineNo">348</span>      long fileSize = fs.getFileStatus(file).getLen();<a name="line.348"></a>
-<span class="sourceLineNo">349</span>      FixedFileTrailer trailer =<a name="line.349"></a>
-<span class="sourceLineNo">350</span>        FixedFileTrailer.readFromStream(fsdis.getStream(false), fileSize);<a name="line.350"></a>
-<span class="sourceLineNo">351</span>      long offset = trailer.getFirstDataBlockOffset(),<a name="line.351"></a>
-<span class="sourceLineNo">352</span>        max = trailer.getLastDataBlockOffset();<a name="line.352"></a>
-<span class="sourceLineNo">353</span>      HFileBlock block;<a name="line.353"></a>
-<span class="sourceLineNo">354</span>      while (offset &lt;= max) {<a name="line.354"></a>
-<span class="sourceLineNo">355</span>        block = reader.readBlock(offset, -1, /* cacheBlock */ false, /* pread */ false,<a name="line.355"></a>
-<span class="sourceLineNo">356</span>          /* isCompaction */ false, /* updateCacheMetrics */ false, null, null);<a name="line.356"></a>
-<span class="sourceLineNo">357</span>        offset += block.getOnDiskSizeWithHeader();<a name="line.357"></a>
-<span class="sourceLineNo">358</span>        out.println(block);<a name="line.358"></a>
-<span class="sourceLineNo">359</span>      }<a name="line.359"></a>
-<span class="sourceLineNo">360</span>    }<a name="line.360"></a>
-<span class="sourceLineNo">361</span><a name="line.361"></a>
-<span class="sourceLineNo">362</span>    if (printStats) {<a name="line.362"></a>
-<span class="sourceLineNo">363</span>      fileStats.finish();<a name="line.363"></a>
-<span class="sourceLineNo">364</span>      out.println("Stats:\n" + fileStats);<a name="line.364"></a>
-<span class="sourceLineNo">365</span>    }<a name="line.365"></a>
-<span class="sourceLineNo">366</span><a name="line.366"></a>
-<span class="sourceLineNo">367</span>    reader.close();<a name="line.367"></a>
-<span class="sourceLineNo">368</span>    return 0;<a name="line.368"></a>
-<span class="sourceLineNo">369</span>  }<a name="line.369"></a>
-<span class="sourceLineNo">370</span><a name="line.370"></a>
-<span class="sourceLineNo">371</span>  private void scanKeysValues(Path file, KeyValueStatsCollector fileStats,<a name="line.371"></a>
-<span class="sourceLineNo">372</span>      HFileScanner scanner,  byte[] row) throws IOException {<a name="line.372"></a>
-<span class="sourceLineNo">373</span>    Cell pCell = null;<a name="line.373"></a>
-<span class="sourceLineNo">374</span>    FileSystem fs = FileSystem.get(getConf());<a name="line.374"></a>
-<span class="sourceLineNo">375</span>    Set&lt;String&gt; foundMobFiles = new LinkedHashSet&lt;&gt;(FOUND_MOB_FILES_CACHE_CAPACITY);<a name="line.375"></a>
-<span class="sourceLineNo">376</span>    Set&lt;String&gt; missingMobFiles = new LinkedHashSet&lt;&gt;(MISSING_MOB_FILES_CACHE_CAPACITY);<a name="line.376"></a>
-<span class="sourceLineNo">377</span>    do {<a name="line.377"></a>
-<span class="sourceLineNo">378</span>      Cell cell = scanner.getCell();<a name="line.378"></a>
-<span class="sourceLineNo">379</span>      if (row != null &amp;&amp; row.length != 0) {<a name="line.379"></a>
-<span class="sourceLineNo">380</span>        int result = CellComparator.COMPARATOR.compareRows(cell, row, 0, row.length);<a name="line.380"></a>
-<span class="sourceLineNo">381</span>        if (result &gt; 0) {<a name="line.381"></a>
-<span class="sourceLineNo">382</span>          break;<a name="line.382"></a>
-<span class="sourceLineNo">383</span>        } else if (result &lt; 0) {<a name="line.383"></a>
-<span class="sourceLineNo">384</span>          continue;<a name="line.384"></a>
-<span class="sourceLineNo">385</span>        }<a name="line.385"></a>
-<span class="sourceLineNo">386</span>      }<a name="line.386"></a>
-<span class="sourceLineNo">387</span>      // collect stats<a name="line.387"></a>
-<span class="sourceLineNo">388</span>      if (printStats) {<a name="line.388"></a>
-<span class="sourceLineNo">389</span>        fileStats.collect(cell);<a name="line.389"></a>
-<span class="sourceLineNo">390</span>      }<a name="line.390"></a>
-<span class="sourceLineNo">391</span>      // dump key value<a name="line.391"></a>
-<span class="sourceLineNo">392</span>      if (printKey) {<a name="line.392"></a>
-<span class="sourceLineNo">393</span>        out.print("K: " + cell);<a name="line.393"></a>
-<span class="sourceLineNo">394</span>        if (printValue) {<a name="line.394"></a>
-<span class="sourceLineNo">395</span>          out.print(" V: "<a name="line.395"></a>
-<span class="sourceLineNo">396</span>              + Bytes.toStringBinary(cell.getValueArray(), cell.getValueOffset(),<a name="line.396"></a>
-<span class="sourceLineNo">397</span>                  cell.getValueLength()));<a name="line.397"></a>
-<span class="sourceLineNo">398</span>          int i = 0;<a name="line.398"></a>
-<span class="sourceLineNo">399</span>          List&lt;Tag&gt; tags = TagUtil.asList(cell.getTagsArray(), cell.getTagsOffset(),<a name="line.399"></a>
-<span class="sourceLineNo">400</span>              cell.getTagsLength());<a name="line.400"></a>
-<span class="sourceLineNo">401</span>          for (Tag tag : tags) {<a name="line.401"></a>
-<span class="sourceLineNo">402</span>            out.print(String.format(" T[%d]: %s", i++, tag.toString()));<a name="line.402"></a>
-<span class="sourceLineNo">403</span>          }<a name="line.403"></a>
-<span class="sourceLineNo">404</span>        }<a name="line.404"></a>
-<span class="sourceLineNo">405</span>        out.println();<a name="line.405"></a>
-<span class="sourceLineNo">406</span>      }<a name="line.406"></a>
-<span class="sourceLineNo">407</span>      // check if rows are in order<a name="line.407"></a>
-<span class="sourceLineNo">408</span>      if (checkRow &amp;&amp; pCell != null) {<a name="line.408"></a>
-<span class="sourceLineNo">409</span>        if (CellComparator.COMPARATOR.compareRows(pCell, cell) &gt; 0) {<a name="line.409"></a>
-<span class="sourceLineNo">410</span>          err.println("WARNING, previous row is greater then"<a name="line.410"></a>
-<span class="sourceLineNo">411</span>              + " current row\n\tfilename -&gt; " + file + "\n\tprevious -&gt; "<a name="line.411"></a>
-<span class="sourceLineNo">412</span>              + CellUtil.getCellKeyAsString(pCell) + "\n\tcurrent  -&gt; "<a name="line.412"></a>
-<span class="sourceLineNo">413</span>              + CellUtil.getCellKeyAsString(cell));<a name="line.413"></a>
-<span class="sourceLineNo">414</span>        }<a name="line.414"></a>
-<span class="sourceLineNo">415</span>      }<a name="line.415"></a>
-<span class="sourceLineNo">416</span>      // check if families are consistent<a name="line.416"></a>
-<span class="sourceLineNo">417</span>      if (checkFamily) {<a name="line.417"></a>
-<span class="sourceLineNo">418</span>        String fam = Bytes.toString(cell.getFamilyArray(), cell.getFamilyOffset(),<a name="line.418"></a>
-<span class="sourceLineNo">419</span>            cell.getFamilyLength());<a name="line.419"></a>
-<span class="sourceLineNo">420</span>        if (!file.toString().contains(fam)) {<a name="line.420"></a>
-<span class="sourceLineNo">421</span>          err.println("WARNING, filename does not match kv family,"<a name="line.421"></a>
-<span class="sourceLineNo">422</span>              + "\n\tfilename -&gt; " + file + "\n\tkeyvalue -&gt; "<a name="line.422"></a>
-<span class="sourceLineNo">423</span>              + CellUtil.getCellKeyAsString(cell));<a name="line.423"></a>
-<span class="sourceLineNo">424</span>        }<a name="line.424"></a>
-<span class="sourceLineNo">425</span>        if (pCell != null &amp;&amp; CellComparator.compareFamilies(pCell, cell) != 0) {<a name="line.425"></a>
-<span class="sourceLineNo">426</span>          err.println("WARNING, previous kv has different family"<a name="line.426"></a>
-<span class="sourceLineNo">427</span>              + " compared to current key\n\tfilename -&gt; " + file<a name="line.427"></a>
-<span class="sourceLineNo">428</span>              + "\n\tprevious -&gt; " + CellUtil.getCellKeyAsString(pCell)<a name="line.428"></a>
-<span class="sourceLineNo">429</span>              + "\n\tcurrent  -&gt; " + CellUtil.getCellKeyAsString(cell));<a name="line.429"></a>
-<span class="sourceLineNo">430</span>        }<a name="line.430"></a>
-<span class="sourceLineNo">431</span>      }<a name="line.431"></a>
-<span class="sourceLineNo">432</span>      // check if mob files are missing.<a name="line.432"></a>
-<span class="sourceLineNo">433</span>      if (checkMobIntegrity &amp;&amp; MobUtils.isMobReferenceCell(cell)) {<a name="line.433"></a>
-<span class="sourceLineNo">434</span>        Tag tnTag = MobUtils.getTableNameTag(cell);<a name="line.434"></a>
-<span class="sourceLineNo">435</span>        if (tnTag == null) {<a name="line.435"></a>
-<span class="sourceLineNo">436</span>          System.err.println("ERROR, wrong tag format in mob reference cell "<a name="line.436"></a>
-<span class="sourceLineNo">437</span>            + CellUtil.getCellKeyAsString(cell));<a name="line.437"></a>
-<span class="sourceLineNo">438</span>        } else if (!MobUtils.hasValidMobRefCellValue(cell)) {<a name="line.438"></a>
-<span class="sourceLineNo">439</span>          System.err.println("ERROR, wrong value format in mob reference cell "<a name="line.439"></a>
-<span class="sourceLineNo">440</span>            + CellUtil.getCellKeyAsString(cell));<a name="line.440"></a>
-<span class="sourceLineNo">441</span>        } else {<a name="line.441"></a>
-<span class="sourceLineNo">442</span>          TableName tn = TableName.valueOf(TagUtil.cloneValue(tnTag));<a name="line.442"></a>
-<span class="sourceLineNo">443</span>          String mobFileName = MobUtils.getMobFileName(cell);<a name="line.443"></a>
-<span class="sourceLineNo">444</span>          boolean exist = mobFileExists(fs, tn, mobFileName,<a name="line.444"></a>
-<span class="sourceLineNo">445</span>            Bytes.toString(CellUtil.cloneFamily(cell)), foundMobFiles, missingMobFiles);<a name="line.445"></a>
-<span class="sourceLineNo">446</span>          if (!exist) {<a name="line.446"></a>
-<span class="sourceLineNo">447</span>            // report error<a name="line.447"></a>
-<span class="sourceLineNo">448</span>            System.err.println("ERROR, the mob file [" + mobFileName<a name="line.448"></a>
-<span class="sourceLineNo">449</span>              + "] is missing referenced by cell " + CellUtil.getCellKeyAsString(cell));<a name="line.449"></a>
-<span class="sourceLineNo">450</span>          }<a name="line.450"></a>
-<span class="sourceLineNo">451</span>        }<a name="line.451"></a>
-<span class="sourceLineNo">452</span>      }<a name="line.452"></a>
-<span class="sourceLineNo">453</span>      pCell = cell;<a name="line.453"></a>
-<span class="sourceLineNo">454</span>      ++count;<a name="line.454"></a>
-<span class="sourceLineNo">455</span>    } while (scanner.next());<a name="line.455"></a>
-<span class="sourceLineNo">456</span>  }<a name="line.456"></a>
-<span class="sourceLineNo">457</span><a name="line.457"></a>
-<span class="sourceLineNo">458</span>  /**<a name="line.458"></a>
-<span class="sourceLineNo">459</span>   * Checks whether the referenced mob file exists.<a name="line.459"></a>
-<span class="sourceLineNo">460</span>   */<a name="line.460"></a>
-<span class="sourceLineNo">461</span>  private boolean mobFileExists(FileSystem fs, TableName tn, String mobFileName, String family,<a name="line.461"></a>
-<span class="sourceLineNo">462</span>    Set&lt;String&gt; foundMobFiles, Set&lt;String&gt; missingMobFiles) throws IOException {<a name="line.462"></a>
-<span class="sourceLineNo">463</span>    if (foundMobFiles.contains(mobFileName)) {<a name="line.463"></a>
-<span class="sourceLineNo">464</span>      return true;<a name="line.464"></a>
-<span class="sourceLineNo">465</span>    }<a name="line.465"></a>
-<span class="sourceLineNo">466</span>    if (missingMobFiles.contains(mobFileName)) {<a name="line.466"></a>
-<span class="sourceLineNo">467</span>      return false;<a name="line.467"></a>
-<span class="sourceLineNo">468</span>    }<a name="line.468"></a>
-<span class="sourceLineNo">469</span>    String tableName = tn.getNameAsString();<a name="line.469"></a>
-<span class="sourceLineNo">470</span>    List&lt;Path&gt; locations = mobFileLocations.get(tableName);<a name="line.470"></a>
-<span class="sourceLineNo">471</span>    if (locations == null) {<a name="line.471"></a>
-<span class="sourceLineNo">472</span>      locations = new ArrayList&lt;&gt;(2);<a name="line.472"></a>
-<span class="sourceLineNo">473</span>      locations.add(MobUtils.getMobFamilyPath(getConf(), tn, family));<a name="line.473"></a>
-<span class="sourceLineNo">474</span>      locations.add(HFileArchiveUtil.getStoreArchivePath(getConf(), tn,<a name="line.474"></a>
-<span class="sourceLineNo">475</span>        MobUtils.getMobRegionInfo(tn).getEncodedName(), family));<a name="line.475"></a>
-<span class="sourceLineNo">476</span>      mobFileLocations.put(tn.getNameAsString(), locations);<a name="line.476"></a>
-<span class="sourceLineNo">477</span>    }<a name="line.477"></a>
-<span class="sourceLineNo">478</span>    boolean exist = false;<a name="line.478"></a>
-<span class="sourceLineNo">479</span>    for (Path location : locations) {<a name="line.479"></a>
-<span class="sourceLineNo">480</span>      Path mobFilePath = new Path(location, mobFileName);<a name="line.480"></a>
-<span class="sourceLineNo">481</span>      if (fs.exists(mobFilePath)) {<a name="line.481"></a>
-<span class="sourceLineNo">482</span>        exist = true;<a name="line.482"></a>
-<span class="sourceLineNo">483</span>        break;<a name="line.483"></a>
-<span class="sourceLineNo">484</span>      }<a name="line.484"></a>
-<span class="sourceLineNo">485</span>    }<a name="line.485"></a>
-<span class="sourceLineNo">486</span>    if (exist) {<a name="line.486"></a>
-<span class="sourceLineNo">487</span>      evictMobFilesIfNecessary(foundMobFiles, FOUND_MOB_FILES_CACHE_CAPACITY);<a name="line.487"></a>
-<span class="sourceLineNo">488</span>      foundMobFiles.add(mobFileName);<a name="line.488"></a>
-<span class="sourceLineNo">489</span>    } else {<a name="line.489"></a>
-<span class="sourceLineNo">490</span>      evictMobFilesIfNecessary(missingMobFiles, MISSING_MOB_FILES_CACHE_CAPACITY);<a name="line.490"></a>
-<span class="sourceLineNo">491</span>      missingMobFiles.add(mobFileName);<a name="line.491"></a>
-<span class="sourceLineNo">492</span>    }<a name="line.492"></a>
-<span class="sourceLineNo">493</span>    return exist;<a name="line.493"></a>
-<span class="sourceLineNo">494</span>  }<a name="line.494"></a>
-<span class="sourceLineNo">495</span><a name="line.495"></a>
-<span class="sourceLineNo">496</span>  /**<a name="line.496"></a>
-<span class="sourceLineNo">497</span>   * Evicts the cached mob files if the set is larger than the limit.<a name="line.497"></a>
-<span class="sourceLineNo">498</span>   */<a name="line.498"></a>
-<span class="sourceLineNo">499</span>  private void evictMobFilesIfNecessary(Set&lt;String&gt; mobFileNames, int limit) {<a name="line.499"></a>
-<span class="sourceLineNo">500</span>    if (mobFileNames.size() &lt; limit) {<a name="line.500"></a>
-<span class="sourceLineNo">501</span>      return;<a name="line.501"></a>
-<span class="sourceLineNo">502</span>    }<a name="line.502"></a>
-<span class="sourceLineNo">503</span>    int index = 0;<a name="line.503"></a>
-<span class="sourceLineNo">504</span>    int evict = limit / 2;<a name="line.504"></a>
-<span class="sourceLineNo">505</span>    Iterator&lt;String&gt; fileNamesItr = mobFileNames.iterator();<a name="line.505"></a>
-<span class="sourceLineNo">506</span>    while (index &lt; evict &amp;&amp; fileNamesItr.hasNext()) {<a name="line.506"></a>
-<span class="sourceLineNo">507</span>      fileNamesItr.next();<a name="line.507"></a>
-<span class="sourceLineNo">508</span>      fileNamesItr.remove();<a name="line.508"></a>
-<span class="sourceLineNo">509</span>      index++;<a name="line.509"></a>
-<span class="sourceLineNo">510</span>    }<a name="line.510"></a>
-<span class="sourceLineNo">511</span>  }<a name="line.511"></a>
-<span class="sourceLineNo">512</span><a name="line.512"></a>
-<span class="sourceLineNo">513</span>  /**<a name="line.513"></a>
-<span class="sourceLineNo">514</span>   * Format a string of the form "k1=v1, k2=v2, ..." into separate lines<a name="line.514"></a>
-<span class="sourceLineNo">515</span>   * with a four-space indentation.<a name="line.515"></a>
-<span class="sourceLineNo">516</span>   */<a name="line.516"></a>
-<span class="sourceLineNo">517</span>  private static String asSeparateLines(String keyValueStr) {<a name="line.517"></a>
-<span class="sourceLineNo">518</span>    return keyValueStr.replaceAll(", ([a-zA-Z]+=)",<a name="line.518"></a>
-<span class="sourceLineNo">519</span>                                  ",\n" + FOUR_SPACES + "$1");<a name="line.519"></a>
-<span class="sourceLineNo">520</span>  }<a name="line.520"></a>
-<span class="sourceLineNo">521</span><a name="line.521"></a>
-<span class="sourceLineNo">522</span>  private void printMeta(HFile.Reader reader, Map&lt;byte[], byte[]&gt; fileInfo)<a name="line.522"></a>
-<span class="sourceLineNo">523</span>      throws IOException {<a name="line.523"></a>
-<span class="sourceLineNo">524</span>    out.println("Block index size as per heapsize: "<a name="line.524"></a>
-<span class="sourceLineNo">525</span>        + reader.indexSize());<a name="line.525"></a>
-<span class="sourceLineNo">526</span>    out.println(asSeparateLines(reader.toString()));<a name="line.526"></a>
-<span class="sourceLineNo">527</span>    out.println("Trailer:\n    "<a name="line.527"></a>
-<span class="sourceLineNo">528</span>        + asSeparateLines(reader.getTrailer().toString()));<a name="line.528"></a>
-<span class="sourceLineNo">529</span>    out.println("Fileinfo:");<a name="line.529"></a>
-<span class="sourceLineNo">530</span>    for (Map.Entry&lt;byte[], byte[]&gt; e : fileInfo.entrySet()) {<a name="line.530"></a>
-<span class="sourceLineNo">531</span>      out.print(FOUR_SPACES + Bytes.toString(e.getKey()) + " = ");<a name="line.531"></a>
-<span class="sourceLineNo">532</span>      if (Bytes.compareTo(e.getKey(), Bytes.toBytes("MAX_SEQ_ID_KEY")) == 0) {<a name="line.532"></a>
-<span class="sourceLineNo">533</span>        long seqid = Bytes.toLong(e.getValue());<a name="line.533"></a>
-<span class="sourceLineNo">534</span>        out.println(seqid);<a name="line.534"></a>
-<span class="sourceLineNo">535</span>      } else if (Bytes.compareTo(e.getKey(), Bytes.toBytes("TIMERANGE")) == 0) {<a name="line.535"></a>
-<span class="sourceLineNo">536</span>        TimeRangeTracker timeRangeTracker = TimeRangeTracker.getTimeRangeTracker(e.getValue());<a name="line.536"></a>
-<span class="sourceLineNo">537</span>        out.println(timeRangeTracker.getMin() + "...." + timeRangeTracker.getMax());<a name="line.537"></a>
-<span class="sourceLineNo">538</span>      } else if (Bytes.compareTo(e.getKey(), FileInfo.AVG_KEY_LEN) == 0<a name="line.538"></a>
-<span class="sourceLineNo">539</span>          || Bytes.compareTo(e.getKey(), FileInfo.AVG_VALUE_LEN) == 0) {<a name="line.539"></a>
-<span class="sourceLineNo">540</span>        out.println(Bytes.toInt(e.getValue()));<a name="line.540"></a>
-<span class="sourceLineNo">541</span>      } else {<a name="line.541"></a>
-<span class="sourceLineNo">542</span>        out.println(Bytes.toStringBinary(e.getValue()));<a name="line.542"></a>
-<span class="sourceLineNo">543</span>      }<a name="line.543"></a>
-<span class="sourceLineNo">544</span>    }<a name="line.544"></a>
-<span class="sourceLineNo">545</span><a name="line.545"></a>
-<span class="sourceLineNo">546</span>    try {<a name="line.546"></a>
-<span class="sourceLineNo">547</span>      out.println("Mid-key: " + reader.midKey().map(CellUtil::getCellKeyAsString));<a name="line.547"></a>
-<span class="sourceLineNo">548</span>    } catch (Exception e) {<a name="line.548"></a>
-<span class="sourceLineNo">549</span>      out.println ("Unable to retrieve the midkey");<a name="line.549"></a>
-<span class="sourceLineNo">550</span>    }<a name="line.550"></a>
-<span class="sourceLineNo">551</span><a name="line.551"></a>
-<span class="sourceLineNo">552</span>    // Printing general bloom information<a name="line.552"></a>
-<span class="sourceLineNo">553</span>    DataInput bloomMeta = reader.getGeneralBloomFilterMetadata();<a name="line.553"></a>
-<span class="sourceLineNo">554</span>    BloomFilter bloomFilter = null;<a name="line.554"></a>
-<span class="sourceLineNo">555</span>    if (bloomMeta != null)<a name="line.555"></a>
-<span class="sourceLineNo">556</span>      bloomFilter = BloomFilterFactory.createFromMeta(bloomMeta, reader);<a name="line.556"></a>
-<span class="sourceLineNo">557</span><a name="line.557"></a>
-<span class="sourceLineNo">558</span>    out.println("Bloom filter:");<a name="line.558"></a>
-<span class="sourceLineNo">559</span>    if (bloomFilter != null) {<a name="line.559"></a>
-<span class="sourceLineNo">560</span>      out.println(FOUR_SPACES + bloomFilter.toString().replaceAll(<a name="line.560"></a>
-<span class="sourceLineNo">561</span>          BloomFilterUtil.STATS_RECORD_SEP, "\n" + FOUR_SPACES));<a name="line.561"></a>
-<span class="sourceLineNo">562</span>    } else {<a name="line.562"></a>
-<span class="sourceLineNo">563</span>      out.println(FOUR_SPACES + "Not present");<a name="line.563"></a>
+<span class="sourceLineNo">315</span>    KeyValueStatsCollector fileStats = null;<a name="line.315"></a>
+<span class="sourceLineNo">316</span><a name="line.316"></a>
+<span class="sourceLineNo">317</span>    if (verbose || printKey || checkRow || checkFamily || printStats || checkMobIntegrity) {<a name="line.317"></a>
+<span class="sourceLineNo">318</span>      // scan over file and read key/value's and check if requested<a name="line.318"></a>
+<span class="sourceLineNo">319</span>      HFileScanner scanner = reader.getScanner(false, false, false);<a name="line.319"></a>
+<span class="sourceLineNo">320</span>      fileStats = new KeyValueStatsCollector();<a name="line.320"></a>
+<span class="sourceLineNo">321</span>      boolean shouldScanKeysValues = false;<a name="line.321"></a>
+<span class="sourceLineNo">322</span>      if (this.isSeekToRow) {<a name="line.322"></a>
+<span class="sourceLineNo">323</span>        // seek to the first kv on this row<a name="line.323"></a>
+<span class="sourceLineNo">324</span>        shouldScanKeysValues =<a name="line.324"></a>
+<span class="sourceLineNo">325</span>          (scanner.seekTo(CellUtil.createFirstOnRow(this.row)) != -1);<a name="line.325"></a>
+<span class="sourceLineNo">326</span>      } else {<a name="line.326"></a>
+<span class="sourceLineNo">327</span>        shouldScanKeysValues = scanner.seekTo();<a name="line.327"></a>
+<span class="sourceLineNo">328</span>      }<a name="line.328"></a>
+<span class="sourceLineNo">329</span>      if (shouldScanKeysValues)<a name="line.329"></a>
+<span class="sourceLineNo">330</span>        scanKeysValues(file, fileStats, scanner, row);<a name="line.330"></a>
+<span class="sourceLineNo">331</span>    }<a name="line.331"></a>
+<span class="sourceLineNo">332</span><a name="line.332"></a>
+<span class="sourceLineNo">333</span>    // print meta data<a name="line.333"></a>
+<span class="sourceLineNo">334</span>    if (shouldPrintMeta) {<a name="line.334"></a>
+<span class="sourceLineNo">335</span>      printMeta(reader, fileInfo);<a name="line.335"></a>
+<span class="sourceLineNo">336</span>    }<a name="line.336"></a>
+<span class="sourceLineNo">337</span><a name="line.337"></a>
+<span class="sourceLineNo">338</span>    if (printBlockIndex) {<a name="line.338"></a>
+<span class="sourceLineNo">339</span>      out.println("Block Index:");<a name="line.339"></a>
+<span class="sourceLineNo">340</span>      out.println(reader.getDataBlockIndexReader());<a name="line.340"></a>
+<span class="sourceLineNo">341</span>    }<a name="line.341"></a>
+<span class="sourceLineNo">342</span><a name="line.342"></a>
+<span class="sourceLineNo">343</span>    if (printBlockHeaders) {<a name="line.343"></a>
+<span class="sourceLineNo">344</span>      out.println("Block Headers:");<a name="line.344"></a>
+<span class="sourceLineNo">345</span>      /*<a name="line.345"></a>
+<span class="sourceLineNo">346</span>       * TODO: this same/similar block iteration logic is used in HFileBlock#blockRange and<a name="line.346"></a>
+<span class="sourceLineNo">347</span>       * TestLazyDataBlockDecompression. Refactor?<a name="line.347"></a>
+<span class="sourceLineNo">348</span>       */<a name="line.348"></a>
+<span class="sourceLineNo">349</span>      FSDataInputStreamWrapper fsdis = new FSDataInputStreamWrapper(fs, file);<a name="line.349"></a>
+<span class="sourceLineNo">350</span>      long fileSize = fs.getFileStatus(file).getLen();<a name="line.350"></a>
+<span class="sourceLineNo">351</span>      FixedFileTrailer trailer =<a name="line.351"></a>
+<span class="sourceLineNo">352</span>        FixedFileTrailer.readFromStream(fsdis.getStream(false), fileSize);<a name="line.352"></a>
+<span class="sourceLineNo">353</span>      long offset = trailer.getFirstDataBlockOffset(),<a name="line.353"></a>
+<span class="sourceLineNo">354</span>        max = trailer.getLastDataBlockOffset();<a name="line.354"></a>
+<span class="sourceLineNo">355</span>      HFileBlock block;<a name="line.355"></a>
+<span class="sourceLineNo">356</span>      while (offset &lt;= max) {<a name="line.356"></a>
+<span class="sourceLineNo">357</span>        block = reader.readBlock(offset, -1, /* cacheBlock */ false, /* pread */ false,<a name="line.357"></a>
+<span class="sourceLineNo">358</span>          /* isCompaction */ false, /* updateCacheMetrics */ false, null, null);<a name="line.358"></a>
+<span class="sourceLineNo">359</span>        offset += block.getOnDiskSizeWithHeader();<a name="line.359"></a>
+<span class="sourceLineNo">360</span>        out.println(block);<a name="line.360"></a>
+<span class="sourceLineNo">361</span>      }<a name="line.361"></a>
+<span class="sourceLineNo">362</span>    }<a name="line.362"></a>
+<span class="sourceLineNo">363</span><a name="line.363"></a>
+<span class="sourceLineNo">364</span>    if (printStats) {<a name="line.364"></a>
+<span class="sourceLineNo">365</span>      fileStats.finish();<a name="line.365"></a>
+<span class="sourceLineNo">366</span>      out.println("Stats:\n" + fileStats);<a name="line.366"></a>
+<span class="sourceLineNo">367</span>    }<a name="line.367"></a>
+<span class="sourceLineNo">368</span><a name="line.368"></a>
+<span class="sourceLineNo">369</span>    reader.close();<a name="line.369"></a>
+<span class="sourceLineNo">370</span>    return 0;<a name="line.370"></a>
+<span class="sourceLineNo">371</span>  }<a name="line.371"></a>
+<span class="sourceLineNo">372</span><a name="line.372"></a>
+<span class="sourceLineNo">373</span>  private void scanKeysValues(Path file, KeyValueStatsCollector fileStats,<a name="line.373"></a>
+<span class="sourceLineNo">374</span>      HFileScanner scanner,  byte[] row) throws IOException {<a name="line.374"></a>
+<span class="sourceLineNo">375</span>    Cell pCell = null;<a name="line.375"></a>
+<span class="sourceLineNo">376</span>    FileSystem fs = FileSystem.get(getConf());<a name="line.376"></a>
+<span class="sourceLineNo">377</span>    Set&lt;String&gt; foundMobFiles = new LinkedHashSet&lt;&gt;(FOUND_MOB_FILES_CACHE_CAPACITY);<a name="line.377"></a>
+<span class="sourceLineNo">378</span>    Set&lt;String&gt; missingMobFiles = new LinkedHashSet&lt;&gt;(MISSING_MOB_FILES_CACHE_CAPACITY);<a name="line.378"></a>
+<span class="sourceLineNo">379</span>    do {<a name="line.379"></a>
+<span class="sourceLineNo">380</span>      Cell cell = scanner.getCell();<a name="line.380"></a>
+<span class="sourceLineNo">381</span>      if (row != null &amp;&amp; row.length != 0) {<a name="line.381"></a>
+<span class="sourceLineNo">382</span>        int result = CellComparator.COMPARATOR.compareRows(cell, row, 0, row.length);<a name="line.382"></a>
+<span class="sourceLineNo">383</span>        if (result &gt; 0) {<a name="line.383"></a>
+<span class="sourceLineNo">384</span>          break;<a name="line.384"></a>
+<span class="sourceLineNo">385</span>        } else if (result &lt; 0) {<a name="line.385"></a>
+<span class="sourceLineNo">386</span>          continue;<a name="line.386"></a>
+<span class="sourceLineNo">387</span>        }<a name="line.387"></a>
+<span class="sourceLineNo">388</span>      }<a name="line.388"></a>
+<span class="sourceLineNo">389</span>      // collect stats<a name="line.389"></a>
+<span class="sourceLineNo">390</span>      if (printStats) {<a name="line.390"></a>
+<span class="sourceLineNo">391</span>        fileStats.collect(cell);<a name="line.391"></a>
+<span class="sourceLineNo">392</span>      }<a name="line.392"></a>
+<span class="sourceLineNo">393</span>      // dump key value<a name="line.393"></a>
+<span class="sourceLineNo">394</span>      if (printKey) {<a name="line.394"></a>
+<span class="sourceLineNo">395</span>        out.print("K: " + cell);<a name="line.395"></a>
+<span class="sourceLineNo">396</span>        if (printValue) {<a name="line.396"></a>
+<span class="sourceLineNo">397</span>          out.print(" V: "<a name="line.397"></a>
+<span class="sourceLineNo">398</span>              + Bytes.toStringBinary(cell.getValueArray(), cell.getValueOffset(),<a name="line.398"></a>
+<span class="sourceLineNo">399</span>                  cell.getValueLength()));<a name="line.399"></a>
+<span class="sourceLineNo">400</span>          int i = 0;<a name="line.400"></a>
+<span class="sourceLineNo">401</span>          List&lt;Tag&gt; tags = TagUtil.asList(cell.getTagsArray(), cell.getTagsOffset(),<a name="line.401"></a>
+<span class="sourceLineNo">402</span>              cell.getTagsLength());<a name="line.402"></a>
+<span class="sourceLineNo">403</span>          for (Tag tag : tags) {<a name="line.403"></a>
+<span class="sourceLineNo">404</span>            out.print(String.format(" T[%d]: %s", i++, tag.toString()));<a name="line.404"></a>
+<span class="sourceLineNo">405</span>          }<a name="line.405"></a>
+<span class="sourceLineNo">406</span>        }<a name="line.406"></a>
+<span class="sourceLineNo">407</span>        out.println();<a name="line.407"></a>
+<span class="sourceLineNo">408</span>      }<a name="line.408"></a>
+<span class="sourceLineNo">409</span>      // check if rows are in order<a name="line.409"></a>
+<span class="sourceLineNo">410</span>      if (checkRow &amp;&amp; pCell != null) {<a name="line.410"></a>
+<span class="sourceLineNo">411</span>        if (CellComparator.COMPARATOR.compareRows(pCell, cell) &gt; 0) {<a name="line.411"></a>
+<span class="sourceLineNo">412</span>          err.println("WARNING, previous row is greater then"<a name="line.412"></a>
+<span class="sourceLineNo">413</span>              + " current row\n\tfilename -&gt; " + file + "\n\tprevious -&gt; "<a name="line.413"></a>
+<span class="sourceLineNo">414</span>              + CellUtil.getCellKeyAsString(pCell) + "\n\tcurrent  -&gt; "<a name="line.414"></a>
+<span class="sourceLineNo">415</span>              + CellUtil.getCellKeyAsString(cell));<a name="line.415"></a>
+<span class="sourceLineNo">416</span>        }<a name="line.416"></a>
+<span class="sourceLineNo">417</span>      }<a name="line.417"></a>
+<span class="sourceLineNo">418</span>      // check if families are consistent<a name="line.418"></a>
+<span class="sourceLineNo">419</span>      if (checkFamily) {<a name="line.419"></a>
+<span class="sourceLineNo">420</span>        String fam = Bytes.toString(cell.getFamilyArray(), cell.getFamilyOffset(),<a name="line.420"></a>
+<span class="sourceLineNo">421</span>            cell.getFamilyLength());<a name="line.421"></a>
+<span class="sourceLineNo">422</span>        if (!file.toString().contains(fam)) {<a name="line.422"></a>
+<span class="sourceLineNo">423</span>          err.println("WARNING, filename does not match kv family,"<a name="line.423"></a>
+<span class="sourceLineNo">424</span>              + "\n\tfilename -&gt; " + file + "\n\tkeyvalue -&gt; "<a name="line.424"></a>
+<span class="sourceLineNo">425</span>              + CellUtil.getCellKeyAsString(cell));<a name="line.425"></a>
+<span class="sourceLineNo">426</span>        }<a name="line.426"></a>
+<span class="sourceLineNo">427</span>        if (pCell != null &amp;&amp; CellComparator.compareFamilies(pCell, cell) != 0) {<a name="line.427"></a>
+<span class="sourceLineNo">428</span>          err.println("WARNING, previous kv has different family"<a name="line.428"></a>
+<span class="sourceLineNo">429</span>              + " compared to current key\n\tfilename -&gt; " + file<a name="line.429"></a>
+<span class="sourceLineNo">430</span>              + "\n\tprevious -&gt; " + CellUtil.getCellKeyAsString(pCell)<a name="line.430"></a>
+<span class="sourceLineNo">431</span>              + "\n\tcurrent  -&gt; " + CellUtil.getCellKeyAsString(cell));<a name="line.431"></a>
+<span class="sourceLineNo">432</span>        }<a name="line.432"></a>
+<span class="sourceLineNo">433</span>      }<a name="line.433"></a>
+<span class="sourceLineNo">434</span>      // check if mob files are missing.<a name="line.434"></a>
+<span class="sourceLineNo">435</span>      if (checkMobIntegrity &amp;&amp; MobUtils.isMobReferenceCell(cell)) {<a name="line.435"></a>
+<span class="sourceLineNo">436</span>        Tag tnTag = MobUtils.getTableNameTag(cell);<a name="line.436"></a>
+<span class="sourceLineNo">437</span>        if (tnTag == null) {<a name="line.437"></a>
+<span class="sourceLineNo">438</span>          System.err.println("ERROR, wrong tag format in mob reference cell "<a name="line.438"></a>
+<span class="sourceLineNo">439</span>            + CellUtil.getCellKeyAsString(cell));<a name="line.439"></a>
+<span class="sourceLineNo">440</span>        } else if (!MobUtils.hasValidMobRefCellValue(cell)) {<a name="line.440"></a>
+<span class="sourceLineNo">441</span>          System.err.println("ERROR, wrong value format in mob reference cell "<a name="line.441"></a>
+<span class="sourceLineNo">442</span>            + CellUtil.getCellKeyAsString(cell));<a name="line.442"></a>
+<span class="sourceLineNo">443</span>        } else {<a name="line.443"></a>
+<span class="sourceLineNo">444</span>          TableName tn = TableName.valueOf(TagUtil.cloneValue(tnTag));<a name="line.444"></a>
+<span class="sourceLineNo">445</span>          String mobFileName = MobUtils.getMobFileName(cell);<a name="line.445"></a>
+<span class="sourceLineNo">446</span>          boolean exist = mobFileExists(fs, tn, mobFileName,<a name="line.446"></a>
+<span class="sourceLineNo">447</span>            Bytes.toString(CellUtil.cloneFamily(cell)), foundMobFiles, missingMobFiles);<a name="line.447"></a>
+<span class="sourceLineNo">448</span>          if (!exist) {<a name="line.448"></a>
+<span class="sourceLineNo">449</span>            // report error<a name="line.449"></a>
+<span class="sourceLineNo">450</span>            System.err.println("ERROR, the mob file [" + mobFileName<a name="line.450"></a>
+<span class="sourceLineNo">451</span>              + "] is missing referenced by cell " + CellUtil.getCellKeyAsString(cell));<a name="line.451"></a>
+<span class="sourceLineNo">452</span>          }<a name="line.452"></a>
+<span class="sourceLineNo">453</span>        }<a name="line.453"></a>
+<span class="sourceLineNo">454</span>      }<a name="line.454"></a>
+<span class="sourceLineNo">455</span>      pCell = cell;<a name="line.455"></a>
+<span class="sourceLineNo">456</span>      ++count;<a name="line.456"></a>
+<span class="sourceLineNo">457</span>    } while (scanner.next());<a name="line.457"></a>
+<span class="sourceLineNo">458</span>  }<a name="line.458"></a>
+<span class="sourceLineNo">459</span><a name="line.459"></a>
+<span class="sourceLineNo">460</span>  /**<a name="line.460"></a>
+<span class="sourceLineNo">461</span>   * Checks whether the referenced mob file exists.<a name="line.461"></a>
+<span class="sourceLineNo">462</span>   */<a name="line.462"></a>
+<span class="sourceLineNo">463</span>  private boolean mobFileExists(FileSystem fs, TableName tn, String mobFileName, String family,<a name="line.463"></a>
+<span class="sourceLineNo">464</span>    Set&lt;String&gt; foundMobFiles, Set&lt;String&gt; missingMobFiles) throws IOException {<a name="line.464"></a>
+<span class="sourceLineNo">465</span>    if (foundMobFiles.contains(mobFileName)) {<a name="line.465"></a>
+<span class="sourceLineNo">466</span>      return true;<a name="line.466"></a>
+<span class="sourceLineNo">467</span>    }<a name="line.467"></a>
+<span class="sourceLineNo">468</span>    if (missingMobFiles.contains(mobFileName)) {<a name="line.468"></a>
+<span class="sourceLineNo">469</span>      return false;<a name="line.469"></a>
+<span class="sourceLineNo">470</span>    }<a name="line.470"></a>
+<span class="sourceLineNo">471</span>    String tableName = tn.getNameAsString();<a name="line.471"></a>
+<span class="sourceLineNo">472</span>    List&lt;Path&gt; locations = mobFileL

<TRUNCATED>

Mime
View raw message