hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [17/17] hbase git commit: HBASE-14557 MapReduce WALPlayer issue with NoTagsKeyValue.
Date Fri, 30 Oct 2015 16:54:16 GMT
HBASE-14557 MapReduce WALPlayer issue with NoTagsKeyValue.


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

Branch: refs/heads/hbase-12439
Commit: b0ad82191cc216c65751b68cbc11280fd5d5cd47
Parents: 23fa181
Author: anoopsjohn <anoopsamjohn@gmail.com>
Authored: Fri Oct 30 21:18:09 2015 +0530
Committer: anoopsjohn <anoopsamjohn@gmail.com>
Committed: Fri Oct 30 21:18:09 2015 +0530

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/KeyValueUtil.java   | 20 +++++++++++++++++---
 .../hadoop/hbase/io/hfile/HFileBlockIndex.java  |  4 +---
 .../hbase/mob/mapreduce/MemStoreWrapper.java    |  8 ++++----
 .../hbase/mob/mapreduce/SweepReducer.java       | 10 ++++------
 4 files changed, 26 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/b0ad8219/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
----------------------------------------------------------------------
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 98e2205..c9da738 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
@@ -437,14 +437,28 @@ public class KeyValueUtil {
   /*************** misc **********************************/
   /**
    * @param cell
-   * @return <code>cell</code> if it is an instance of {@link KeyValue} else
we will return a
-   * new {@link KeyValue} instance made from <code>cell</code>
+   * @return <code>cell</code> if it is an object of class {@link KeyValue} else
we will return a
+   *         new {@link KeyValue} instance made from <code>cell</code> Note:
Even if the cell is an
+   *         object of any of the subclass of {@link KeyValue}, we will create a new
+   *         {@link KeyValue} object wrapping same buffer. This API is used only with MR
based tools
+   *         which expect the type to be exactly KeyValue. That is the reason for doing this
way.
    * @deprecated without any replacement.
    */
   @Deprecated
   public static KeyValue ensureKeyValue(final Cell cell) {
     if (cell == null) return null;
-    return cell instanceof KeyValue? (KeyValue)cell: copyToNewKeyValue(cell);
+    if (cell instanceof KeyValue) {
+      if (cell.getClass().getName().equals(KeyValue.class.getName())) {
+        return (KeyValue) cell;
+      }
+      // Cell is an Object of any of the sub classes of KeyValue. Make a new KeyValue wrapping
the
+      // same byte[]
+      KeyValue kv = (KeyValue) cell;
+      KeyValue newKv = new KeyValue(kv.bytes, kv.offset, kv.length);
+      newKv.setSequenceId(kv.getSequenceId());
+      return newKv;
+    }
+    return copyToNewKeyValue(cell);
   }
 
   @Deprecated

http://git-wip-us.apache.org/repos/asf/hbase/blob/b0ad8219/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java
index 75f1f82..1bdba3b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java
@@ -40,7 +40,6 @@ import org.apache.hadoop.hbase.CellUtil;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.KeyValue.KeyOnlyKeyValue;
-import org.apache.hadoop.hbase.KeyValueUtil;
 import org.apache.hadoop.hbase.ByteBufferedKeyOnlyKeyValue;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.io.HeapSize;
@@ -350,9 +349,8 @@ public class HFileBlockIndex {
           if (index == -1) {
             // This has to be changed
             // For now change this to key value
-            KeyValue kv = KeyValueUtil.ensureKeyValue(key);
             throw new IOException("The key "
-                + Bytes.toStringBinary(kv.getKey(), kv.getKeyOffset(), kv.getKeyLength())
+                + CellUtil.getCellKeyAsString(key)
                 + " is before the" + " first key of the non-root index block " + block);
           }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/b0ad8219/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/mapreduce/MemStoreWrapper.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/mapreduce/MemStoreWrapper.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/mapreduce/MemStoreWrapper.java
index fdda1de..08e6753 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/mapreduce/MemStoreWrapper.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/mapreduce/MemStoreWrapper.java
@@ -172,12 +172,12 @@ public class MemStoreWrapper {
   }
 
   /**
-   * Adds a KeyValue into the memstore.
-   * @param kv The KeyValue to be added.
+   * Adds a Cell into the memstore.
+   * @param cell The Cell to be added.
    * @throws IOException
    */
-  public void addToMemstore(KeyValue kv) throws IOException {
-    memstore.add(kv);
+  public void addToMemstore(Cell cell) throws IOException {
+    memstore.add(cell);
     // flush the memstore if it's full.
     flushMemStoreIfNecessary();
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/b0ad8219/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/mapreduce/SweepReducer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/mapreduce/SweepReducer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/mapreduce/SweepReducer.java
index 03a05cc..d39267b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/mapreduce/SweepReducer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/mapreduce/SweepReducer.java
@@ -331,13 +331,13 @@ public class SweepReducer extends Reducer<Text, KeyValue, Writable,
Writable> {
       }
       // write the hfile name
       writer.append(mobFileName.getFileName(), MobConstants.EMPTY_STRING);
-      Set<KeyValue> kvs = new HashSet<KeyValue>();
+      Set<Cell> kvs = new HashSet<Cell>();
       for (KeyValue kv : values) {
         if (kv.getValueLength() > Bytes.SIZEOF_INT) {
           mobFileStat.addValidSize(Bytes.toInt(kv.getValueArray(), kv.getValueOffset(),
               Bytes.SIZEOF_INT));
         }
-        kvs.add(kv.createKeyOnly(false));
+        kvs.add(kv);
       }
       // If the mob file is a invalid one or a small one, merge it into new/bigger ones.
       if (mobFileStat.needClean() || (mergeSmall && mobFileStat.needMerge())) {
@@ -351,11 +351,9 @@ public class SweepReducer extends Reducer<Text, KeyValue, Writable,
Writable> {
           scanner.seek(KeyValueUtil.createFirstOnRow(HConstants.EMPTY_BYTE_ARRAY));
           Cell cell;
           while (null != (cell = scanner.next())) {
-            KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
-            KeyValue keyOnly = kv.createKeyOnly(false);
-            if (kvs.contains(keyOnly)) {
+            if (kvs.contains(cell)) {
               // write the KeyValue existing in HBase to the memstore.
-              memstore.addToMemstore(kv);
+              memstore.addToMemstore(cell);
               memstoreUpdated = true;
             }
           }


Mime
View raw message