/** * @inheritDoc */ public RowIterator getRows() throws RepositoryException { return result.getRows(); }
public long size() { QueryResult result = resultModel.getObject().getQueryResult(); if (result != null) { try { return (int) result.getRows().getSize(); } catch (RepositoryException e) { log.error("Error parsing query results", e); } } return 0; }
public Object call(Query query) throws RepositoryException { RowIterator rows = query.execute().getRows(); assertTrue("empty result", rows.hasNext()); Row r = rows.nextRow(); assertEquals("unexpected value", TEST_VALUE, r.getValue(columnName1).getString()); assertEquals("unexpected value", TEST_VALUE, r.getValue(columnName2).getString()); return null; } });
public Object call(Query query) throws RepositoryException { RowIterator rows = query.execute().getRows(); while (rows.hasNext()) { double score = rows.nextRow().getScore("s"); if (!Double.isNaN(score)) { assertTrue("wrong full text search score", Double.MIN_VALUE < score); } } return null; } });
private Node iterate(Query query) throws RepositoryException { QueryResult r = query.execute(); RowIterator it = r.getRows(); Node last = null; while (it.hasNext()) { last = it.nextRow().getNode(); LOG.debug(last.getPath()); } return last; }
protected void search(QueryManager qm, ExecutionContext context) throws RepositoryException { Query q = getQuery(qm, context); QueryResult r = q.execute(); RowIterator it = r.getRows(); for (int rows = 0; it.hasNext() && rows < MAX_RESULTS; rows++) { Node node = it.nextRow().getNode(); LOG.debug(node.getPath()); } }
@Override public boolean isTraversal(ResourceResolver resourceResolver, String language, String statement) throws RepositoryException { final QueryManager queryManager = resourceResolver.adaptTo(Session.class).getWorkspace().getQueryManager(); final Query query = queryManager.createQuery("explain " + statement, language); final QueryResult queryResult = query.execute(); final RowIterator rows = queryResult.getRows(); final Row firstRow = rows.nextRow(); final String plan = firstRow.getValue("plan").getString(); return StringUtils.contains(plan, " /* traverse "); }
@Override protected void search(QueryManager qm, ExecutionContext context) throws RepositoryException { searchCommon(qm, context); Query q = getQuery(qm, context); QueryResult r = q.execute(); RowIterator it = r.getRows(); for (int rows = 0; it.hasNext() && rows < LIMIT; rows++) { Node node = it.nextRow().getNode(); LOG.debug(node.getPath()); } }
@Override protected void search(QueryManager qm, ExecutionContext context) throws RepositoryException { searchCommon(qm, context); Query q = getQuery(qm, context); QueryResult r = q.execute(); RowIterator it = r.getRows(); for (int rows = 0; it.hasNext() && rows < LIMIT; rows++) { Node node = it.nextRow().getNode(); LOG.debug(node.getPath()); } }
static String getResult(QueryResult result, String propertyName) throws RepositoryException { StringBuilder buff = new StringBuilder(); RowIterator it = result.getRows(); while (it.hasNext()) { if (buff.length() > 0) { buff.append(", "); } buff.append(it.nextRow().getValue(propertyName).getString()); } return buff.toString(); }
static String getResult(QueryResult result, String propertyName) throws RepositoryException { StringBuilder buff = new StringBuilder(); RowIterator it = result.getRows(); while (it.hasNext()) { if (buff.length() > 0) { buff.append(", "); } buff.append(it.nextRow().getValue(propertyName).getString()); } return buff.toString(); }
static List<String> getResult(QueryResult result, String propertyName) throws RepositoryException { List<String> results = Lists.newArrayList(); RowIterator it = result.getRows(); while (it.hasNext()) { Row row = it.nextRow(); results.add(row.getValue(propertyName).getString()); } return results; }
static List<String> getResult(QueryResult result, String propertyName) throws RepositoryException { List<String> results = Lists.newArrayList(); RowIterator it = result.getRows(); while (it.hasNext()) { Row row = it.nextRow(); results.add(row.getValue(propertyName).getString()); } return results; }
static List<String> getResult(QueryResult result, String propertyName) throws RepositoryException { List<String> results = Lists.newArrayList(); RowIterator it = result.getRows(); while (it.hasNext()) { Row row = it.nextRow(); results.add(row.getValue(propertyName).getString()); } return results; }
public void testScoreWithoutFulltext() throws Exception { System.out.println(Query.JCR_SQL2); QueryResult r = executeSQL2Query("select [jcr:path] from [nt:base] order by [jcr:score]"); RowIterator it = r.getRows(); while (it.hasNext()) { it.nextRow(); } }
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; }
private static String getQueryPlan(RepositoryFixture fixture, String query) throws RepositoryException, IOException { Session session = fixture.getAdminSession(); QueryManager qm = session.getWorkspace().getQueryManager(); Query explain = qm.createQuery("explain "+query, Query.JCR_SQL2); QueryResult explainResult = explain.execute(); Row explainRow = explainResult.getRows().nextRow(); String explanation = explainRow.getValue("plan").getString(); session.logout(); return explanation; }
private Set<String> getSuggestions(String query) throws Exception { QueryManager queryManager = session.getWorkspace().getQueryManager(); QueryResult result = queryManager.createQuery(query, Query.JCR_SQL2).execute(); RowIterator rows = result.getRows(); Set<String> suggestions = newHashSet(); while (rows.hasNext()) { suggestions.add(rows.nextRow().getValue("suggestion").getString()); } return suggestions; }
@Ignore("OAK-3992") @Test public void ambiguousSubtreeIndexWithDescendantConstraint() throws Exception { String query = createSuggestQuery(NT_OAK_UNSTRUCTURED, "te", "/content2"); String explainQuery = "EXPLAIN " + createSuggestQuery(NT_OAK_UNSTRUCTURED, "te", "/content2"); QueryManager queryManager = session.getWorkspace().getQueryManager(); QueryResult result = queryManager.createQuery(explainQuery, Query.JCR_SQL2).execute(); RowIterator rows = result.getRows(); String explanation = rows.nextRow().toString(); assertTrue("Subtree index should get picked", explanation.contains("lucene:sugg-idx(/content2/oak:index/sugg-idx)")); validateSuggestions(query, newHashSet("test4")); }
public void testPositionEmptyResult() throws RepositoryException { QueryManager qm = superuser.getWorkspace().getQueryManager(); String stmt = testPath + "/*[@" + propertyName1 + " > 1000]"; QueryResult result = qm.createQuery(stmt, Query.XPATH).execute(); assertEquals("Wrong position", 0, result.getNodes().getPosition()); assertEquals("Wrong position", 0, result.getRows().getPosition()); stmt += " order by jcr:score()"; result = qm.createQuery(stmt, Query.XPATH).execute(); assertEquals("Wrong position", 0, result.getNodes().getPosition()); assertEquals("Wrong position", 0, result.getRows().getPosition()); } }