You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2014/06/26 01:33:12 UTC

git commit: HBASE-11407 hbase-client should not require Jackson for pure HBase queries be executed (Sergey Beryozkin)

Repository: hbase
Updated Branches:
  refs/heads/0.98 a280f8141 -> 460880f89


HBASE-11407 hbase-client should not require Jackson for pure HBase queries be executed (Sergey Beryozkin)


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

Branch: refs/heads/0.98
Commit: 460880f890676a1282a147dc6e07c29c1fab3a13
Parents: a280f81
Author: Andrew Purtell <ap...@apache.org>
Authored: Wed Jun 25 15:53:36 2014 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Wed Jun 25 15:53:48 2014 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hbase/client/Operation.java   | 12 +++---
 .../apache/hadoop/hbase/util/JsonMapper.java    | 45 ++++++++++++++++++++
 2 files changed, 50 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/460880f8/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Operation.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Operation.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Operation.java
index 05af89a..756b513 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Operation.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Operation.java
@@ -18,13 +18,13 @@
  */
 package org.apache.hadoop.hbase.client;
 
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.codehaus.jackson.map.ObjectMapper;
-
 import java.io.IOException;
 import java.util.Map;
 
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.hbase.util.JsonMapper;
+
 /**
  * Superclass for any type that maps to a potentially application-level query.
  * (e.g. Put, Get, Delete, Scan, Next, etc.)
@@ -37,8 +37,6 @@ public abstract class Operation {
   // TODO Do we need this anymore now we have protobuffed it all?
   private static final int DEFAULT_MAX_COLS = 5;
 
-  private static final ObjectMapper MAPPER = new ObjectMapper();
-
   /**
    * Produces a Map containing a fingerprint which identifies the type and 
    * the static schema components of a query (i.e. column families)
@@ -69,7 +67,7 @@ public abstract class Operation {
    * @return a JSONObject containing this Operation's information, as a string
    */
   public String toJSON(int maxCols) throws IOException {
-    return MAPPER.writeValueAsString(toMap(maxCols));
+    return JsonMapper.writeMapAsString(toMap(maxCols));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/460880f8/hbase-client/src/main/java/org/apache/hadoop/hbase/util/JsonMapper.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/util/JsonMapper.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/util/JsonMapper.java
new file mode 100644
index 0000000..f96b360
--- /dev/null
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/util/JsonMapper.java
@@ -0,0 +1,45 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.util;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.codehaus.jackson.map.ObjectMapper;
+
+/**
+ * Utility class for converting objects to JSON
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
+public final class JsonMapper {
+  private JsonMapper() {
+  }
+
+  private static final ObjectMapper MAPPER = new ObjectMapper();
+
+  public static String writeMapAsString(Map<String, Object> map) throws IOException { 
+    return writeObjectAsString(map);
+  }
+  public static String writeObjectAsString(Object object) throws IOException { 
+    return MAPPER.writeValueAsString(object);
+  }
+}