@Override public String[] getColumnNames() /*throws RepositoryException*/{ List<String> names = getColumnNameList(); return names.toArray(new String[names.size()]); // make a defensive copy ... }
@Override public String[] getColumnTypes() { List<String> types = getColumnTypeList(); return types.toArray(new String[types.size()]); // make a defensive copy ... }
@Override public NodeIterator getNodes() throws RepositoryException { if (accessed) { if (restartable) { if (sequence instanceof Restartable) { ((Restartable)sequence).restart(); } else { assert sequence.isEmpty(); } } else if (!sequence.isEmpty()) { throw new RepositoryException(JcrI18n.multipleCallsToGetRowsOrNodesIsNotAllowed.text(queryStatement)); } } if (getSelectorNames().length > 1) { throw new RepositoryException(JcrI18n.multipleSelectorsAppearInQueryUnableToCallMethod.text(queryStatement)); } // Find all of the nodes in the results... accessed = true; int defaultSelectorIndex = computeDefaultSelectorIndex(); return new QueryResultNodeIterator(context, sequence, defaultSelectorIndex); }
/** * {@inheritDoc} * * @see javax.jcr.query.Query#execute() */ @SuppressWarnings( "deprecation" ) @Override public org.modeshape.jcr.api.query.QueryResult execute() throws RepositoryException { context.checkValid(); final long start = System.nanoTime(); // Create an executable query and set it on this object ... CancellableQuery newExecutable = context.createExecutableQuery(query, hints, variables); CancellableQuery executable = executingQuery.getAndSet(newExecutable); if (executable == null) { // We are the first to call 'execute()', so use our newly-created one ... executable = newExecutable; } // otherwise, some other thread called execute, so we can use it and just wait for the results ... final QueryResults result = executable.execute(); // may be cancelled // And reset the reference to null (if not already set to something else) ... executingQuery.compareAndSet(executable, null); checkForProblems(result.getProblems()); context.recordDuration(Math.abs(System.nanoTime() - start), TimeUnit.NANOSECONDS, statement, language); if (Query.XPATH.equals(language)) { return new XPathQueryResult(context, statement, result, hints.restartable, hints.rowsKeptInMemory); } else if (Query.SQL.equals(language)) { return new JcrSqlQueryResult(context, statement, result, hints.restartable, hints.rowsKeptInMemory); } return new JcrQueryResult(context, statement, result, hints.restartable, hints.rowsKeptInMemory); }
System.out.println(" plan -> " + ((JcrQueryResult)result).getPlan()); System.out.println(result); System.out.println(query); System.out.println(" plan -> " + ((JcrQueryResult)result).getPlan()); System.out.println(result); System.out.println(query); System.out.println(" plan -> " + ((JcrQueryResult)result).getPlan()); System.out.println(query); System.out.println(result);
@Override public NodeIterator getNodes() throws RepositoryException { if (accessed) { if (restartable) { if (sequence instanceof Restartable) { ((Restartable)sequence).restart(); } else { assert sequence.isEmpty(); } } else if (!sequence.isEmpty()) { throw new RepositoryException(JcrI18n.multipleCallsToGetRowsOrNodesIsNotAllowed.text(queryStatement)); } } if (getSelectorNames().length > 1) { throw new RepositoryException(JcrI18n.multipleSelectorsAppearInQueryUnableToCallMethod.text(queryStatement)); } // Find all of the nodes in the results... accessed = true; int defaultSelectorIndex = computeDefaultSelectorIndex(); return new QueryResultNodeIterator(context, sequence, defaultSelectorIndex); }
/** * {@inheritDoc} * * @see javax.jcr.query.Query#execute() */ @SuppressWarnings( "deprecation" ) @Override public org.modeshape.jcr.api.query.QueryResult execute() throws RepositoryException { context.checkValid(); final long start = System.nanoTime(); // Create an executable query and set it on this object ... CancellableQuery newExecutable = context.createExecutableQuery(query, hints, variables); CancellableQuery executable = executingQuery.getAndSet(newExecutable); if (executable == null) { // We are the first to call 'execute()', so use our newly-created one ... executable = newExecutable; } // otherwise, some other thread called execute, so we can use it and just wait for the results ... final QueryResults result = executable.execute(); // may be cancelled // And reset the reference to null (if not already set to something else) ... executingQuery.compareAndSet(executable, null); checkForProblems(result.getProblems()); context.recordDuration(Math.abs(System.nanoTime() - start), TimeUnit.NANOSECONDS, statement, language); if (Query.XPATH.equals(language)) { return new XPathQueryResult(context, statement, result, hints.restartable, hints.rowsKeptInMemory); } else if (Query.SQL.equals(language)) { return new JcrSqlQueryResult(context, statement, result, hints.restartable, hints.rowsKeptInMemory); } return new JcrQueryResult(context, statement, result, hints.restartable, hints.rowsKeptInMemory); }
@SuppressWarnings( "deprecation" ) @Override public org.modeshape.jcr.api.query.QueryResult explain() throws RepositoryException { context.checkValid(); // Set to only compute the plan and then create an executable query ... PlanHints hints = this.hints.clone(); hints.planOnly = true; CancellableQuery planOnlyExecutable = context.createExecutableQuery(query, hints, variables); // otherwise, some other thread called execute, so we can use it and just wait for the results ... final QueryResults result = planOnlyExecutable.execute(); // may be cancelled checkForProblems(result.getProblems()); if (Query.XPATH.equals(language)) { return new XPathQueryResult(context, statement, result, false, 0); } else if (Query.SQL.equals(language)) { return new JcrSqlQueryResult(context, statement, result, false, 0); } return new JcrQueryResult(context, statement, result, false, 0); }
@Override public String[] getColumnNames() /*throws RepositoryException*/{ List<String> names = getColumnNameList(); return names.toArray(new String[names.size()]); // make a defensive copy ... }
@Override public String[] getColumnTypes() { List<String> types = getColumnTypeList(); return types.toArray(new String[types.size()]); // make a defensive copy ... }
@SuppressWarnings( "deprecation" ) @Override public org.modeshape.jcr.api.query.QueryResult explain() throws RepositoryException { context.checkValid(); // Set to only compute the plan and then create an executable query ... PlanHints hints = this.hints.clone(); hints.planOnly = true; CancellableQuery planOnlyExecutable = context.createExecutableQuery(query, hints, variables); // otherwise, some other thread called execute, so we can use it and just wait for the results ... final QueryResults result = planOnlyExecutable.execute(); // may be cancelled checkForProblems(result.getProblems()); if (Query.XPATH.equals(language)) { return new XPathQueryResult(context, statement, result, false, 0); } else if (Query.SQL.equals(language)) { return new JcrSqlQueryResult(context, statement, result, false, 0); } return new JcrQueryResult(context, statement, result, false, 0); }