use of org.codehaus.jackson.map.JsonMappingException in project hive by apache.
the class Vertex method extractOpTree.
/**
* @throws JSONException
* @throws JsonParseException
* @throws JsonMappingException
* @throws IOException
* @throws Exception
* We assume that there is a single top-level Map Operator Tree or a
* Reduce Operator Tree in a vertex
*/
public void extractOpTree() throws JSONException, JsonParseException, JsonMappingException, IOException, Exception {
if (vertexObject.length() != 0) {
for (String key : JSONObject.getNames(vertexObject)) {
if (key.equals("Map Operator Tree:")) {
extractOp(vertexObject.getJSONArray(key).getJSONObject(0));
} else if (key.equals("Reduce Operator Tree:") || key.equals("Processor Tree:")) {
extractOp(vertexObject.getJSONObject(key));
} else if (key.equals("Join:")) {
// this is the case when we have a map-side SMB join
// one input of the join is treated as a dummy vertex
JSONArray array = vertexObject.getJSONArray(key);
for (int index = 0; index < array.length(); index++) {
JSONObject mpOpTree = array.getJSONObject(index);
Vertex v = new Vertex(null, mpOpTree, parser);
v.extractOpTree();
v.dummy = true;
mergeJoinDummyVertexs.add(v);
}
} else if (key.equals("Merge File Operator")) {
JSONObject opTree = vertexObject.getJSONObject(key);
if (opTree.has("Map Operator Tree:")) {
extractOp(opTree.getJSONArray("Map Operator Tree:").getJSONObject(0));
} else {
throw new Exception("Merge File Operator does not have a Map Operator Tree");
}
} else if (key.equals("Execution mode:")) {
executionMode = " " + vertexObject.getString(key);
} else if (key.equals("tagToInput:")) {
JSONObject tagToInput = vertexObject.getJSONObject(key);
for (String tag : JSONObject.getNames(tagToInput)) {
this.tagToInput.put(tag, (String) tagToInput.get(tag));
}
} else if (key.equals("tag:")) {
this.tag = vertexObject.getString(key);
} else {
throw new Exception("Unsupported operator tree in vertex " + this.name);
}
}
}
}
use of org.codehaus.jackson.map.JsonMappingException in project hive by apache.
the class Vertex method extractOp.
/**
* @param operator
* @param parent
* @return
* @throws JSONException
* @throws JsonParseException
* @throws JsonMappingException
* @throws IOException
* @throws Exception
* assumption: each operator only has one parent but may have many
* children
*/
Op extractOp(JSONObject operator) throws JSONException, JsonParseException, JsonMappingException, IOException, Exception {
String[] names = JSONObject.getNames(operator);
if (names.length != 1) {
throw new Exception("Expect only one operator in " + operator.toString());
} else {
String opName = names[0];
JSONObject attrObj = (JSONObject) operator.get(opName);
Map<String, String> attrs = new TreeMap<>();
List<Op> children = new ArrayList<>();
String id = null;
String outputVertexName = null;
for (String attrName : JSONObject.getNames(attrObj)) {
if (attrName.equals("children")) {
Object childrenObj = attrObj.get(attrName);
if (childrenObj instanceof JSONObject) {
if (((JSONObject) childrenObj).length() != 0) {
children.add(extractOp((JSONObject) childrenObj));
}
} else if (childrenObj instanceof JSONArray) {
if (((JSONArray) childrenObj).length() != 0) {
JSONArray array = ((JSONArray) childrenObj);
for (int index = 0; index < array.length(); index++) {
children.add(extractOp(array.getJSONObject(index)));
}
}
} else {
throw new Exception("Unsupported operator " + this.name + "'s children operator is neither a jsonobject nor a jsonarray");
}
} else {
if (attrName.equals("OperatorId:")) {
id = attrObj.get(attrName).toString();
} else if (attrName.equals("outputname:")) {
outputVertexName = attrObj.get(attrName).toString();
} else {
if (!attrObj.get(attrName).toString().isEmpty()) {
attrs.put(attrName, attrObj.get(attrName).toString());
}
}
}
}
Op op = new Op(opName, id, outputVertexName, children, attrs, operator, this, parser);
if (!children.isEmpty()) {
for (Op child : children) {
child.parent = op;
}
} else {
this.rootOps.add(op);
}
return op;
}
}
use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.
the class NewsDao method getMore.
public NewsMoreResponse getMore(String more_url) {
NewsMoreResponse response;
try {
String result = RequestCacheUtil.getRequestContent(mActivity, more_url + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, true);
response = mObjectMapper.readValue(result, new TypeReference<NewsMoreResponse>() {
});
return response;
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.
the class NewsDao method mapperJson.
public NewsResponseEntity mapperJson(boolean useCache) {
// TODO Auto-generated method stub
NewsJson newsJson;
try {
String result = RequestCacheUtil.getRequestContent(mActivity, Urls.NEWS_LIST + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
newsJson = mObjectMapper.readValue(result, new TypeReference<NewsJson>() {
});
if (newsJson == null) {
return null;
}
this._newsResponse = newsJson.getResponse();
return _newsResponse;
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.
the class SearchDao method mapperJson.
/**
* 这里的逻辑判断得优化 目前仅为实现功能编写的代码 不妥
*
* @return
*/
public List<Object> mapperJson() {
categorys.clear();
tabs.clear();
hasChild = false;
try {
if (mTag.equals("news")) {
NewsSearchJson newsSearchJson = mObjectMapper.readValue(HttpUtils.getByHttpClient(mActivity, Urls.BASE_SEARCH_URL + "t=" + mTag + "&w=" + keyWord + Utility.getScreenParams(mActivity)), new TypeReference<NewsSearchJson>() {
});
categorys.add(newsSearchJson.getResponse());
cate_name = newsSearchJson.getResponse().getName();
if (newsSearchJson.getResponse().getItems() != null) {
hasChild = true;
}
} else if (mTag.equals("wiki")) {
WikiSearchJson wikiSearchJson = mObjectMapper.readValue(HttpUtils.getByHttpClient(mActivity, Urls.BASE_SEARCH_URL + "t=" + mTag + "&w=" + keyWord), new TypeReference<WikiSearchJson>() {
});
categorys.add(wikiSearchJson.getResponse());
cate_name = wikiSearchJson.getResponse().getName();
if (wikiSearchJson.getResponse().getItems() != null) {
hasChild = true;
}
} else if (mTag.equals("blog")) {
BlogSearchJson blogSearchJson = mObjectMapper.readValue(HttpUtils.getByHttpClient(mActivity, Urls.BASE_SEARCH_URL + "t=" + mTag + "&w=" + keyWord), new TypeReference<BlogSearchJson>() {
});
categorys.add(blogSearchJson.getResponse());
cate_name = blogSearchJson.getResponse().getName();
if (blogSearchJson.getResponse().getItems() != null) {
hasChild = true;
}
}
return categorys;
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations