hbase git commit: HBASE-14841 Allow Dictionary to work with BytebufferedCells (Ram)

2016-01-28 Thread ramkrishna
Repository: hbase
Updated Branches:
  refs/heads/master 47506e805 -> 0de221a19


HBASE-14841 Allow Dictionary to work with BytebufferedCells (Ram)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/0de221a1
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0de221a1
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0de221a1

Branch: refs/heads/master
Commit: 0de221a19d799ad515f8f4556cacd05e6b4e74f8
Parents: 47506e8
Author: ramkrishna 
Authored: Fri Jan 29 10:05:26 2016 +0530
Committer: ramkrishna 
Committed: Fri Jan 29 10:06:20 2016 +0530

--
 .../java/org/apache/hadoop/hbase/CellUtil.java  |  19 +++
 .../hadoop/hbase/io/TagCompressionContext.java  |  35 -
 .../io/encoding/BufferedDataBlockEncoder.java   |   6 +-
 .../apache/hadoop/hbase/io/util/Dictionary.java |  13 +-
 .../hadoop/hbase/io/util/LRUDictionary.java | 141 ---
 .../hadoop/hbase/util/ByteBufferUtils.java  |  16 +++
 .../hbase/io/TestTagCompressionContext.java |  78 +-
 7 files changed, 272 insertions(+), 36 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/0de221a1/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
--
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
index 1b38b56..7db1c76 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.KeyValue.Type;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.classification.InterfaceStability;
 import org.apache.hadoop.hbase.io.HeapSize;
+import org.apache.hadoop.hbase.io.TagCompressionContext;
 import org.apache.hadoop.hbase.util.ByteBufferUtils;
 import org.apache.hadoop.hbase.util.ByteRange;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -1629,6 +1630,24 @@ public final class CellUtil {
 return new FirstOnRowDeleteFamilyCell(row, fam);
   }
 
+  /**
+   * Compresses the tags to the given outputstream using the 
TagcompressionContext
+   * @param out the outputstream to which the compression should happen
+   * @param cell the cell which has tags
+   * @param tagCompressionContext the TagCompressionContext
+   * @throws IOException can throw IOException if the compression encounters 
issue
+   */
+  public static void compressTags(DataOutputStream out, Cell cell,
+  TagCompressionContext tagCompressionContext) throws IOException {
+if (cell instanceof ByteBufferedCell) {
+  tagCompressionContext.compressTags(out, ((ByteBufferedCell) 
cell).getTagsByteBuffer(),
+  ((ByteBufferedCell) cell).getTagsPosition(), cell.getTagsLength());
+} else {
+  tagCompressionContext.compressTags(out, cell.getTagsArray(), 
cell.getTagsOffset(),
+  cell.getTagsLength());
+}
+  }
+
   @InterfaceAudience.Private
   /**
* These cells are used in reseeks/seeks to improve the read performance.

http://git-wip-us.apache.org/repos/asf/hbase/blob/0de221a1/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
--
diff --git 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
index 05c4ad1..278dfc4 100644
--- 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
+++ 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
@@ -79,17 +79,24 @@ public class TagCompressionContext {
* Compress tags one by one and writes to the OutputStream.
* @param out Stream to which the compressed tags to be written
* @param in Source buffer where tags are available
+   * @param offset Offset for the tags byte buffer
* @param length Length of all tag bytes
* @throws IOException
*/
-  public void compressTags(OutputStream out, ByteBuffer in, int length) throws 
IOException {
+  public void compressTags(OutputStream out, ByteBuffer in, int offset, int 
length)
+  throws IOException {
 if (in.hasArray()) {
-  compressTags(out, in.array(), in.arrayOffset() + in.position(), length);
-  ByteBufferUtils.skip(in, length);
+  compressTags(out, in.array(), offset, length);
 } else {
-  byte[] tagBuf = new byte[length];
-  in.get(tagBuf);
-  compressTags(out, tagBuf, 0, length);
+  int pos = offset;
+  int endOffset = pos + length;
+  assert pos < endOffset;
+  while (pos < endOffset) {
+int tagLen = ByteBufferUtils.readAsInt(in,

[13/13] hbase git commit: HBASE-14841 Allow Dictionary to work with BytebufferedCells (Ram)

2016-01-29 Thread syuanjiang
HBASE-14841 Allow Dictionary to work with BytebufferedCells (Ram)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/0de221a1
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0de221a1
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0de221a1

Branch: refs/heads/hbase-12439
Commit: 0de221a19d799ad515f8f4556cacd05e6b4e74f8
Parents: 47506e8
Author: ramkrishna 
Authored: Fri Jan 29 10:05:26 2016 +0530
Committer: ramkrishna 
Committed: Fri Jan 29 10:06:20 2016 +0530

--
 .../java/org/apache/hadoop/hbase/CellUtil.java  |  19 +++
 .../hadoop/hbase/io/TagCompressionContext.java  |  35 -
 .../io/encoding/BufferedDataBlockEncoder.java   |   6 +-
 .../apache/hadoop/hbase/io/util/Dictionary.java |  13 +-
 .../hadoop/hbase/io/util/LRUDictionary.java | 141 ---
 .../hadoop/hbase/util/ByteBufferUtils.java  |  16 +++
 .../hbase/io/TestTagCompressionContext.java |  78 +-
 7 files changed, 272 insertions(+), 36 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/0de221a1/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
--
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
index 1b38b56..7db1c76 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.KeyValue.Type;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.classification.InterfaceStability;
 import org.apache.hadoop.hbase.io.HeapSize;
+import org.apache.hadoop.hbase.io.TagCompressionContext;
 import org.apache.hadoop.hbase.util.ByteBufferUtils;
 import org.apache.hadoop.hbase.util.ByteRange;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -1629,6 +1630,24 @@ public final class CellUtil {
 return new FirstOnRowDeleteFamilyCell(row, fam);
   }
 
+  /**
+   * Compresses the tags to the given outputstream using the 
TagcompressionContext
+   * @param out the outputstream to which the compression should happen
+   * @param cell the cell which has tags
+   * @param tagCompressionContext the TagCompressionContext
+   * @throws IOException can throw IOException if the compression encounters 
issue
+   */
+  public static void compressTags(DataOutputStream out, Cell cell,
+  TagCompressionContext tagCompressionContext) throws IOException {
+if (cell instanceof ByteBufferedCell) {
+  tagCompressionContext.compressTags(out, ((ByteBufferedCell) 
cell).getTagsByteBuffer(),
+  ((ByteBufferedCell) cell).getTagsPosition(), cell.getTagsLength());
+} else {
+  tagCompressionContext.compressTags(out, cell.getTagsArray(), 
cell.getTagsOffset(),
+  cell.getTagsLength());
+}
+  }
+
   @InterfaceAudience.Private
   /**
* These cells are used in reseeks/seeks to improve the read performance.

http://git-wip-us.apache.org/repos/asf/hbase/blob/0de221a1/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
--
diff --git 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
index 05c4ad1..278dfc4 100644
--- 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
+++ 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
@@ -79,17 +79,24 @@ public class TagCompressionContext {
* Compress tags one by one and writes to the OutputStream.
* @param out Stream to which the compressed tags to be written
* @param in Source buffer where tags are available
+   * @param offset Offset for the tags byte buffer
* @param length Length of all tag bytes
* @throws IOException
*/
-  public void compressTags(OutputStream out, ByteBuffer in, int length) throws 
IOException {
+  public void compressTags(OutputStream out, ByteBuffer in, int offset, int 
length)
+  throws IOException {
 if (in.hasArray()) {
-  compressTags(out, in.array(), in.arrayOffset() + in.position(), length);
-  ByteBufferUtils.skip(in, length);
+  compressTags(out, in.array(), offset, length);
 } else {
-  byte[] tagBuf = new byte[length];
-  in.get(tagBuf);
-  compressTags(out, tagBuf, 0, length);
+  int pos = offset;
+  int endOffset = pos + length;
+  assert pos < endOffset;
+  while (pos < endOffset) {
+int tagLen = ByteBufferUtils.readAsInt(in, pos, Tag.TAG_LENGTH_SIZE);
+pos += Tag.TAG_LENGTH_SIZE;
+wr