Search in sources :

Example 11 with JsonObject

use of org.apache.jackrabbit.oak.commons.json.JsonObject in project jackrabbit-oak by apache.

the class ClusterViewTest method asJsonObject.

private JsonObject asJsonObject(final ClusterView view) {
    final String json = view.asDescriptorValue();
    //        System.out.println(json);
    JsopTokenizer t = new JsopTokenizer(json);
    t.read('{');
    JsonObject o = JsonObject.create(t);
    return o;
}
Also used : JsonObject(org.apache.jackrabbit.oak.commons.json.JsonObject) JsopTokenizer(org.apache.jackrabbit.oak.commons.json.JsopTokenizer)

Example 12 with JsonObject

use of org.apache.jackrabbit.oak.commons.json.JsonObject in project jackrabbit-oak by apache.

the class QueryTest method getCost.

private static double getCost(Session session, String xpath) throws RepositoryException {
    QueryManager qm = session.getWorkspace().getQueryManager();
    QueryResult qr = qm.createQuery("explain measure " + xpath, "xpath").execute();
    Row r = qr.getRows().nextRow();
    String plan = r.getValue("plan").getString();
    String cost = plan.substring(plan.lastIndexOf('{'));
    JsonObject json = parseJson(cost);
    double c = Double.parseDouble(json.getProperties().get("a"));
    return c;
}
Also used : QueryResult(javax.jcr.query.QueryResult) QueryManager(javax.jcr.query.QueryManager) JsonObject(org.apache.jackrabbit.oak.commons.json.JsonObject) Row(javax.jcr.query.Row)

Aggregations

JsonObject (org.apache.jackrabbit.oak.commons.json.JsonObject)12 Test (org.junit.Test)6 JsopTokenizer (org.apache.jackrabbit.oak.commons.json.JsopTokenizer)3 Node (javax.jcr.Node)2 QueryManager (javax.jcr.query.QueryManager)1 QueryResult (javax.jcr.query.QueryResult)1 Row (javax.jcr.query.Row)1 JsopBuilder (org.apache.jackrabbit.oak.commons.json.JsopBuilder)1