hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject git commit: HBASE-11407 hbase-client should not require Jackson for pure HBase queries be executed (Sergey Beryozkin)
Date Wed, 25 Jun 2014 23:33:12 GMT
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 <apurtell@apache.org>
Authored: Wed Jun 25 15:53:36 2014 -0700
Committer: Andrew Purtell <apurtell@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);
+  }
+}


Mime
View raw message