.../src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java | 12 ++++++++---- .../org/apache/hadoop/hbase/io/encoding/NoneEncoder.java | 12 ++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java index 7b9bcb1..a35df62 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java @@ -617,19 +617,20 @@ public class KeyValueUtil { cell.getValueLength(), cell.getTagsLength(), withTags); } - public static void oswrite(final Cell cell, final OutputStream out, final boolean withTags) + public static int oswrite(final Cell cell, final OutputStream out, final boolean withTags) throws IOException { if (cell instanceof ExtendedCell) { - ((ExtendedCell)cell).write(out, withTags); + return ((ExtendedCell)cell).write(out, withTags); } else { short rlen = cell.getRowLength(); byte flen = cell.getFamilyLength(); int qlen = cell.getQualifierLength(); int vlen = cell.getValueLength(); int tlen = cell.getTagsLength(); - + int size = 0; // write key length - ByteBufferUtils.putInt(out, keyLength(rlen, flen, qlen)); + int klen = keyLength(rlen, flen, qlen); + ByteBufferUtils.putInt(out, klen); // write value length ByteBufferUtils.putInt(out, vlen); // Write rowkey - 2 bytes rk length followed by rowkey bytes @@ -646,6 +647,7 @@ public class KeyValueUtil { out.write(cell.getTypeByte()); // write value out.write(cell.getValueArray(), cell.getValueOffset(), vlen); + size = klen + vlen + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE; // write tags if we have to if (withTags && tlen > 0) { // 2 bytes tags length followed by tags bytes @@ -655,7 +657,9 @@ public class KeyValueUtil { out.write((byte) (0xff & (tlen >> 8))); out.write((byte) (0xff & tlen)); out.write(cell.getTagsArray(), cell.getTagsOffset(), tlen); + size += tlen + KeyValue.TAGS_LENGTH_SIZE; } + return size; } } } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/NoneEncoder.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/NoneEncoder.java index 4b8d203..c428fec 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/NoneEncoder.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/NoneEncoder.java @@ -41,14 +41,10 @@ public class NoneEncoder { } public int write(Cell cell) throws IOException { - int klength = KeyValueUtil.keyLength(cell); - int vlength = cell.getValueLength(); - - out.writeInt(klength); - out.writeInt(vlength); - CellUtil.writeFlatKey(cell, out); - CellUtil.writeValue(out, cell, vlength); - int size = klength + vlength + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE; + // We write tags seperately because though there is no tag in KV + // if the hfilecontext says include tags we need the tags length to be + // written + int size = KeyValueUtil.oswrite(cell, out, false); // Write the additional tag into the stream if (encodingCtx.getHFileContext().isIncludesTags()) { int tagsLength = cell.getTagsLength();