From b21bc1e25f1675d82619f397e9e989526483489a Mon Sep 17 00:00:00 2001 From: Nick Dimiduk Date: Sun, 27 Jan 2013 21:14:26 -0800 Subject: [PATCH 1/1] HBASE-7690 Improve printing of HFile metadata Add some special cases to improve readability of 'HFile -m' output. Replace inline String constants with references to public static final variables exported by relevant classes. --- .../hadoop/hbase/io/hfile/HFilePrettyPrinter.java | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java index be0fb17..6a2c9e5 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java @@ -42,6 +42,7 @@ import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.io.hfile.HFile.FileInfo; +import org.apache.hadoop.hbase.regionserver.StoreFile; import org.apache.hadoop.hbase.regionserver.TimeRangeTracker; import org.apache.hadoop.hbase.util.BloomFilter; import org.apache.hadoop.hbase.util.BloomFilterFactory; @@ -322,10 +323,31 @@ public class HFilePrettyPrinter { System.out.println("Fileinfo:"); for (Map.Entry e : fileInfo.entrySet()) { System.out.print(FOUR_SPACES + Bytes.toString(e.getKey()) + " = "); - if (Bytes.compareTo(e.getKey(), Bytes.toBytes("MAX_SEQ_ID_KEY")) == 0) { + if (Bytes.compareTo(e.getKey(), StoreFile.BULKLOAD_TIME_KEY) == 0) { + long ts = Bytes.toLong(e.getValue()); + System.out.println(ts); + } else if (Bytes.compareTo(e.getKey(), StoreFile.DELETE_FAMILY_COUNT) == 0) { + long count = Bytes.toLong(e.getValue()); + System.out.println(count); + } else if (Bytes.compareTo(e.getKey(), StoreFile.EARLIEST_PUT_TS) == 0) { + long ts = Bytes.toLong(e.getValue()); + System.out.println(ts); + } else if (Bytes.compareTo(e.getKey(), StoreFile.EXCLUDE_FROM_MINOR_COMPACTION_KEY) == 0) { + boolean flag = Bytes.toBoolean(e.getValue()); + System.out.println(flag); + } else if (Bytes.compareTo(e.getKey(), HFileWriterV2.KEY_VALUE_VERSION) == 0) { + int version = Bytes.toInt(e.getValue()); + System.out.println(version); + } else if (Bytes.compareTo(e.getKey(), StoreFile.MAJOR_COMPACTION_KEY) == 0) { + boolean flag = Bytes.toBoolean(e.getValue()); + System.out.println(flag); + } else if (Bytes.compareTo(e.getKey(), HFileWriterV2.MAX_MEMSTORE_TS_KEY) == 0) { + long ts = Bytes.toLong(e.getValue()); + System.out.println(ts); + } else if (Bytes.compareTo(e.getKey(), StoreFile.MAX_SEQ_ID_KEY) == 0) { long seqid = Bytes.toLong(e.getValue()); System.out.println(seqid); - } else if (Bytes.compareTo(e.getKey(), Bytes.toBytes("TIMERANGE")) == 0) { + } else if (Bytes.compareTo(e.getKey(), StoreFile.TIMERANGE_KEY) == 0) { TimeRangeTracker timeRangeTracker = new TimeRangeTracker(); Writables.copyWritable(e.getValue(), timeRangeTracker); System.out.println(timeRangeTracker.getMinimumTimestamp() + "...." -- 1.8.1