Package javax.jcr.query

Examples of javax.jcr.query.QueryResult


            StringBuilder stmt = new StringBuilder();
            stmt.append("//*[@").append(ISO9075.encode(name));
            stmt.append(" = '").append(data.getId()).append("']");
            Query q = session.getWorkspace().getQueryManager().createQuery(
                    stmt.toString(), Query.XPATH);
            QueryResult result = q.execute();
            ArrayList<Property> l = new ArrayList<Property>();
            for (NodeIterator nit = result.getNodes(); nit.hasNext();) {
                Node n = nit.nextNode();
                l.add(n.getProperty(name));
            }
            if (l.isEmpty()) {
                return PropertyIteratorAdapter.EMPTY;
View Full Code Here


    public QueryResult execute(Column[] columns, Source source,
            Constraint constraint, Ordering[] orderings, long offset, long limit)
            throws RepositoryException {
        long time = System.currentTimeMillis();
        QueryResult qr = execute(columns, source, constraint, orderings,
                offset, limit, 2);
        log.debug("SQL2 QUERY execute took {} ms. native sort is {}.",
                System.currentTimeMillis() - time, NATIVE_SORT);
        return qr;
    }
View Full Code Here

        logQueryAnalysis(csInfo, printIndentation);

        boolean isOuterJoin = JCR_JOIN_TYPE_LEFT_OUTER.equalsIgnoreCase(join
                .getJoinType());
        QueryResult result = execute(merger, csInfo, isOuterJoin,
                printIndentation);

        long sort = System.currentTimeMillis();
        QueryResult sortedResult = sort(result, orderings, evaluator, offset,
                limit);
        log.debug(" {} SQL2 SORT took {} ms.", genString(printIndentation),
                System.currentTimeMillis() - sort);
        return sortedResult;
    }
View Full Code Here

            log.debug("{} SQL2 JOIN execute: there are multiple inner splits.",
                    genString(printIndentation));

            // first branch
            long bTime = System.currentTimeMillis();
            QueryResult branch1 = execute(merger,
                    csInfo.getLeftInnerConstraints(), isOuterJoin,
                    printIndentation + printIndentStep);
            Set<Row> allRows = new TreeSet<Row>(new RowPathComparator(
                    Arrays.asList(merger.getSelectorNames())));
            RowIterator ri1 = branch1.getRows();
            while (ri1.hasNext()) {
                Row r = ri1.nextRow();
                allRows.add(r);
            }
            log.debug("{} SQL2 JOIN executed first branch, took {} ms.",
                    genString(printIndentation), System.currentTimeMillis()
                            - bTime);

            // second branch
            bTime = System.currentTimeMillis();
            QueryResult branch2 = execute(merger,
                    csInfo.getRightInnerConstraints(), isOuterJoin,
                    printIndentation + printIndentStep);
            RowIterator ri2 = branch2.getRows();
            while (ri2.hasNext()) {
                Row r = ri2.nextRow();
                allRows.add(r);
            }
            log.debug("{} SQL2 JOIN executed second branch, took {} ms.",
View Full Code Here

                    comparator, printIndentation + printIndentStep));
            return leftRows;
        }

        Set<Row> leftRows = new TreeSet<Row>(comparator);
        QueryResult leftResult = execute(null, csi.getSource().getLeft(),
                csi.getLeftConstraint(), null, 0, -1, printIndentation);
        for (Row row : JcrUtils.getRows(leftResult)) {
            leftRows.add(row);
        }
        return leftRows;
View Full Code Here

                    csi.getRightConstraint());
            if (ignoreWhereConstraints) {
                rightConstraint = Constraints.or(qomFactory,
                        localRightContraints);
            }
            QueryResult rightResult = execute(null, csi.getSource().getRight(),
                    rightConstraint, null, 0, -1, printIndentation);
            for (Row row : JcrUtils.getRows(rightResult)) {
                rightRows.add(row);
            }
            return rightRows;
        }

        // the 'batch by 500' approach
        Set<Row> rightRows = new TreeSet<Row>(comparator);
        for (int i = 0; i < rightConstraints.size(); i += 500) {
            if (log.isDebugEnabled()) {
                log.debug(genString(printIndentation)
                        + "SQL2 JOIN RIGHT SIDE executing batch # " + i + ".");
            }
            List<Constraint> localRightContraints = rightConstraints.subList(i,
                    Math.min(i + 500, rightConstraints.size()));
            Constraint rightConstraint = Constraints.and(qomFactory,
                    Constraints.or(qomFactory, localRightContraints),
                    csi.getRightConstraint());
            if (ignoreWhereConstraints) {
                rightConstraint = Constraints.or(qomFactory,
                        localRightContraints);
            }

            QueryResult rightResult = execute(null, csi.getSource().getRight(),
                    rightConstraint, null, 0, -1, printIndentation);
            for (Row row : JcrUtils.getRows(rightResult)) {
                rightRows.add(row);
            }
        }
View Full Code Here

                    new Object[] { genString(printIndentation),
                            System.currentTimeMillis() - time, selector,
                            Arrays.toString(columnNames), constraint, offset,
                            limit });
        }
        QueryResult result = new SimpleQueryResult(columnNames, selectorNames,
                rows);
        if (NATIVE_SORT) {
            return result;
        }

        long timeSort = System.currentTimeMillis();
        QueryResult sorted = sort(result, orderings, evaluator, offset, limit);
        log.debug("{}SQL2 SORT took {} ms.", genString(printIndentation),
                System.currentTimeMillis() - timeSort);
        return sorted;
    }
View Full Code Here

        n2.setProperty("value", 1);
        n3.setProperty("value", 2);

        testRootNode.getSession().save();

        QueryResult qr = executeSQL2Query("SELECT * FROM [nt:base] WHERE ISCHILDNODE(["
                + testRoot + "]) ORDER BY [value] desc");
        checkSeq(qr, new Node[] { n1, n3, n2 });
    }
View Full Code Here

        n3.setProperty("value", 2);
        n3.setProperty("text", "a");

        testRootNode.getSession().save();

        QueryResult qr = executeSQL2Query("SELECT * FROM [nt:base] WHERE ISCHILDNODE(["
                + testRoot + "]) ORDER BY [value], [text]");
        checkSeq(qr, new Node[] { n2, n3, n1 });
    }
View Full Code Here

        n3.setProperty("value", 2);
        n3.setProperty("text", "a");

        testRootNode.getSession().save();

        QueryResult qr = executeSQL2Query("SELECT * FROM [nt:base] WHERE ISCHILDNODE(["
                + testRoot + "]) ORDER BY [value] desc, [text] desc");
        checkSeq(qr, new Node[] { n1, n3, n2 });
    }
View Full Code Here

TOP

Related Classes of javax.jcr.query.QueryResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.