HBASE-11407 hbase-client should not require Jackson for pure HBase queries be executed (Sergey Beryozkin)
This commit is contained in:
parent
f0a32dff9b
commit
cb9a6d1073
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue