Index: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV3.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV3.java (revision 1532178) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV3.java (working copy) @@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.fs.HFileSystem; import org.apache.hadoop.hbase.io.FSDataInputStreamWrapper; import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding; +import org.apache.hadoop.hbase.io.hfile.HFile.FileInfo; import org.apache.hadoop.hbase.util.ByteBufferUtils; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.io.WritableUtils; @@ -59,7 +60,11 @@ final long size, final CacheConfig cacheConf, DataBlockEncoding preferredEncodingInCache, final HFileSystem hfs) throws IOException { super(path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs); - + byte[] tmp = fileInfo.get(FileInfo.MAX_TAGS_LEN); + // max tag length is not present in the HFile means tags were not at all written to file. + if (tmp != null) { + hfileContext.setIncludesTags(true); + } } @Override @@ -68,7 +73,6 @@ .withIncludesMvcc(this.includesMemstoreTS) .withHBaseCheckSum(true) .withCompressionAlgo(this.compressAlgo) - .withIncludesTags(true) .build(); return hfileContext; } Index: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterV2.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterV2.java (revision 1532178) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterV2.java (working copy) @@ -93,6 +93,7 @@ public Writer createWriter(FileSystem fs, Path path, FSDataOutputStream ostream, KVComparator comparator, HFileContext context) throws IOException { + context.setIncludesTags(false);// HFile V2 does not deal with tags at all! return new HFileWriterV2(conf, cacheConf, fs, path, ostream, comparator, context); } @@ -113,7 +114,7 @@ if (fsBlockWriter != null) throw new IllegalStateException("finishInit called twice"); - fsBlockWriter = createBlockWriter(); + fsBlockWriter = new HFileBlock.Writer(blockEncoder, hFileContext); // Data block index writer boolean cacheIndexesOnWrite = cacheConf.shouldCacheIndexesOnWrite(); @@ -129,11 +130,6 @@ if (LOG.isTraceEnabled()) LOG.trace("Initialized with " + cacheConf); } - protected HFileBlock.Writer createBlockWriter() { - // HFile filesystem-level (non-caching) block writer - hFileContext.setIncludesTags(false); - return new HFileBlock.Writer(blockEncoder, hFileContext); - } /** * At a block boundary, write all the inline blocks and opens new block. * Index: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterV3.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterV3.java (revision 1532178) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterV3.java (working copy) @@ -39,7 +39,6 @@ @InterfaceAudience.Private public class HFileWriterV3 extends HFileWriterV2 { - // TODO : Use this to track maxtaglength private int maxTagsLength = 0; static class WriterFactoryV3 extends HFile.WriterFactory { @@ -183,13 +182,6 @@ } @Override - protected HFileBlock.Writer createBlockWriter() { - // HFile filesystem-level (non-caching) block writer - hFileContext.setIncludesTags(true); - return new HFileBlock.Writer(blockEncoder, hFileContext); - } - - @Override protected int getMajorVersion() { return 3; }