Search in sources :

Example 51 with JsonArray

use of javax.json.JsonArray in project drill by apache.

the class ProfileParser method getOpInfo.

/**
   * We often run test queries single threaded to make analysis of the profile
   * easier. For a single-threaded (single slice) query, get a map from
   * operator ID to operator information as preparation for additional
   * analysis.
   *
   * @return
   */
public Map<Integer, OperatorProfile> getOpInfo() {
    Map<Integer, String> ops = getOperators();
    Map<Integer, OperatorProfile> info = new HashMap<>();
    JsonArray frags = getFragmentProfile();
    JsonObject fragProfile = frags.getJsonObject(0).getJsonArray("minorFragmentProfile").getJsonObject(0);
    JsonArray opList = fragProfile.getJsonArray("operatorProfile");
    for (JsonObject opProfile : opList.getValuesAs(JsonObject.class)) {
        parseOpProfile(ops, info, opProfile);
    }
    return info;
}
Also used : JsonArray(javax.json.JsonArray) HashMap(java.util.HashMap) JsonObject(javax.json.JsonObject)

Example 52 with JsonArray

use of javax.json.JsonArray in project scylla-jmx by scylladb.

the class APIClient method getMapStringIntegerValue.

public Map<String, Integer> getMapStringIntegerValue(String string, MultivaluedMap<String, String> queryParams) {
    Map<String, Integer> res = new HashMap<String, Integer>();
    JsonReader reader = getReader(string, queryParams);
    JsonArray arr = reader.readArray();
    JsonObject obj = null;
    for (int i = 0; i < arr.size(); i++) {
        obj = arr.getJsonObject(i);
        res.put(obj.getString("key"), obj.getInt("value"));
    }
    return res;
}
Also used : JsonArray(javax.json.JsonArray) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) JsonReader(javax.json.JsonReader) JsonObject(javax.json.JsonObject) JsonString(javax.json.JsonString)

Example 53 with JsonArray

use of javax.json.JsonArray in project scylla-jmx by scylladb.

the class APIClient method getSetStringValue.

public Set<String> getSetStringValue(String string, MultivaluedMap<String, String> queryParams) {
    JsonReader reader = getReader(string, queryParams);
    JsonArray arr = reader.readArray();
    Set<String> res = new HashSet<String>();
    for (int i = 0; i < arr.size(); i++) {
        res.add(arr.getString(i));
    }
    reader.close();
    return res;
}
Also used : JsonArray(javax.json.JsonArray) JsonReader(javax.json.JsonReader) JsonString(javax.json.JsonString) HashSet(java.util.HashSet)

Example 54 with JsonArray

use of javax.json.JsonArray in project scylla-jmx by scylladb.

the class APIClient method getReverseMapStrValue.

public Map<String, String> getReverseMapStrValue(String string, MultivaluedMap<String, String> queryParams) {
    if (string.equals("")) {
        return null;
    }
    JsonReader reader = getReader(string, queryParams);
    JsonArray arr = reader.readArray();
    Map<String, String> map = new HashMap<String, String>();
    for (int i = 0; i < arr.size(); i++) {
        JsonObject obj = arr.getJsonObject(i);
        if (obj.containsKey("key") && obj.containsKey("value")) {
            map.put(obj.getString("value"), obj.getString("key"));
        }
    }
    reader.close();
    return map;
}
Also used : JsonArray(javax.json.JsonArray) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) JsonReader(javax.json.JsonReader) JsonObject(javax.json.JsonObject) JsonString(javax.json.JsonString)

Example 55 with JsonArray

use of javax.json.JsonArray in project scylla-jmx by scylladb.

the class APIClient method getEstimatedHistogramAsLongArrValue.

public long[] getEstimatedHistogramAsLongArrValue(String string, MultivaluedMap<String, String> queryParams) {
    JsonObject obj = getJsonObj(string, queryParams);
    JsonArray arr = obj.getJsonArray("buckets");
    if (arr == null) {
        return new long[0];
    }
    long[] res = new long[arr.size()];
    for (int i = 0; i < arr.size(); i++) {
        res[i] = arr.getJsonNumber(i).longValue();
    }
    return res;
}
Also used : JsonArray(javax.json.JsonArray) JsonObject(javax.json.JsonObject)

Aggregations

JsonArray (javax.json.JsonArray)128 JsonObject (javax.json.JsonObject)97 Test (org.junit.Test)42 ArrayList (java.util.ArrayList)32 JsonReader (javax.json.JsonReader)31 HashMap (java.util.HashMap)29 JsonString (javax.json.JsonString)28 HashSet (java.util.HashSet)21 NameValuePair (org.apache.commons.httpclient.NameValuePair)20 Credentials (org.apache.commons.httpclient.Credentials)19 UsernamePasswordCredentials (org.apache.commons.httpclient.UsernamePasswordCredentials)19 StringReader (java.io.StringReader)18 HttpTest (org.apache.sling.commons.testing.integration.HttpTest)17 LinkedHashMap (java.util.LinkedHashMap)14 JsonValue (javax.json.JsonValue)11 Map (java.util.Map)10 JsonException (javax.json.JsonException)9 Response (javax.ws.rs.core.Response)9 IOException (java.io.IOException)7 JerseyTest (org.glassfish.jersey.test.JerseyTest)7