Examples of RowIteratorAdapter


Examples of org.apache.jackrabbit.commons.iterator.RowIteratorAdapter

            public void remove() {
                it.remove();
            }

        };
        return new RowIteratorAdapter(it);
    }
View Full Code Here

Examples of org.apache.jackrabbit.commons.iterator.RowIteratorAdapter

            final List<Row> rowsList = lqf.execute(columnMap, selector, constraint);
            // Added by jahia
            QueryResult result;
            if (rowsList.size() > 0 && rowsList.get(0) instanceof FacetRow) {
                FacetRow facets = (FacetRow) rowsList.remove(0);
                RowIterator rows = new RowIteratorAdapter(rowsList);
                result = new FacetedQueryResult(columnNames, selectorNames, rows, facets);
                QueryResult r = sort(result, orderings, offset, limit);
                if (r != result) {
                    result = new FacetedQueryResult(columnNames, selectorNames, r.getRows(), facets);
                }
            } else {
                RowIterator rows = new RowIteratorAdapter(rowsList);
                result = new JahiaSimpleQueryResult(columnNames, selectorNames, rows);
                QueryResult r = sort(result, orderings, offset, limit);
                if (r != result) {
                    result = new JahiaSimpleQueryResult(columnNames, selectorNames, r.getRows());
                }
View Full Code Here

Examples of org.apache.jackrabbit.commons.iterator.RowIteratorAdapter

                    execute(null, right, rightConstraint, null, 0, -1);
                for (Row row : JcrUtils.getRows(rigthResult)) {
                    list.add(row);
                }
            }
            rightRows = new RowIteratorAdapter(list);
        }

        QueryResult result =
            merger.merge(new RowIteratorAdapter(leftRows), rightRows);
        return sort(result, orderings, offset, limit);
    }
View Full Code Here

Examples of org.apache.jackrabbit.commons.iterator.RowIteratorAdapter

                RowIterator subIterator = queryResult.getRows();
                while (subIterator.hasNext()) {
                    rows.add(subIterator.nextRow());
                }
            }
            resultRowIterator = new RowIteratorAdapter(rows);
        }
        return resultRowIterator;
    }
View Full Code Here

Examples of org.apache.jackrabbit.commons.iterator.RowIteratorAdapter

        return result.getColumnNames();
    }

    public RowIterator getRows() throws RepositoryException {
        final RowIterator rowIterator = result.getRows();
        return new RowIteratorAdapter(new RangeIteratorAdapter(rowIterator, rowIterator.getSize())) {
            @Override
            public Row next() {
                return new RowDecorator((Row) super.next());
            }
        };
View Full Code Here

Examples of org.apache.jackrabbit.commons.iterator.RowIteratorAdapter

            public void remove() {
                throw new UnsupportedOperationException();
            }

        };
        return new RowIteratorAdapter(it);
    }
View Full Code Here

Examples of org.apache.jackrabbit.commons.iterator.RowIteratorAdapter

            }
            log.debug("{} SQL2 JOIN executed second branch, took {} ms.",
                    genString(printIndentation), System.currentTimeMillis()
                            - bTime);
            return new SimpleQueryResult(merger.getColumnNames(),
                    merger.getSelectorNames(), new RowIteratorAdapter(allRows));
        }
       
        Set<Row> leftRows = buildLeftRowsJoin(csInfo, leftCo, printIndentation
                + printIndentStep);
        if (log.isDebugEnabled()) {
            timeJoinLeftSide = System.currentTimeMillis() - timeJoinLeftSide;
            log.debug(genString(printIndentation) + "SQL2 JOIN LEFT SIDE took "
                    + timeJoinLeftSide + " ms. fetched " + leftRows.size()
                    + " rows.");
        }

        // The join constraint information is split into:
        // - rightConstraints selects just the 'ON' constraints
        // - csInfo has the 'WHERE' constraints
        //
        // So, in the case of an OUTER JOIN we'll run 2 queries, one with
        // 'ON'
        // and one with 'ON' + 'WHERE' conditions
        // this way, at merge time in case of an outer join we can tell if
        // it's a 'null' row, or a bad row -> one that must not be returned.
        // This way at the end we'll have:
        // - rightRowsSet containing the 'ON' dataset
        // - excludingOuterJoinRowsSet: the 'ON' + 'WHERE' condition
        // dataset, or
        // NULL if there is no 'WHERE' condition

        long timeJoinRightSide = System.currentTimeMillis();
        List<Constraint> rightConstraints = merger
                .getRightJoinConstraints(leftRows);
        Comparator<Row> rightCo = new RowPathComparator(
                merger.getRightSelectors());

        Set<Row> rightRows = buildRightRowsJoin(csInfo, rightConstraints,
                isOuterJoin, rightCo, printIndentation + printIndentStep);

        // this has to be initialized as null
        Set<Row> excludingOuterJoinRowsSet = null;
        if (isOuterJoin && csInfo.getRightConstraint() != null) {
            excludingOuterJoinRowsSet = buildRightRowsJoin(csInfo,
                    rightConstraints, false, rightCo, printIndentation
                            + printIndentStep);
        }

        if (log.isDebugEnabled()) {
            timeJoinRightSide = System.currentTimeMillis() - timeJoinRightSide;
            log.debug(genString(printIndentation)
                    + "SQL2 JOIN RIGHT SIDE took " + timeJoinRightSide
                    + " ms. fetched " + rightRows.size() + " rows.");
        }
        // merge left with right datasets
        return merger.merge(new RowIteratorAdapter(leftRows),
                new RowIteratorAdapter(rightRows), excludingOuterJoinRowsSet,
                rightCo);

    }
View Full Code Here

Examples of org.apache.jackrabbit.commons.iterator.RowIteratorAdapter

                selectorMap);
        String[] columnNames = columnMap.keySet().toArray(
                new String[columnMap.size()]);

        try {
            RowIterator rows = new RowIteratorAdapter(lqf.execute(columnMap,
                    selector, constraint));
            QueryResult result = new SimpleQueryResult(columnNames,
                    selectorNames, rows);
            return sort(result, orderings, evaluator, offset, limit);
        } catch (IOException e) {
View Full Code Here

Examples of org.apache.jackrabbit.commons.iterator.RowIteratorAdapter

                int size = rows.size();
                rows = rows.subList(0, (int) Math.min(limit, size));
            }

            return new SimpleQueryResult(result.getColumnNames(),
                    result.getSelectorNames(), new RowIteratorAdapter(rows));
        } else {
            return result;
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.commons.iterator.RowIteratorAdapter

                            rows.add(mergeRow(leftRow, rightRow));
                        }
                    }
                }
            }
            return asQueryResult(new RowIteratorAdapter(rows));
        }

        if (JCR_JOIN_TYPE_LEFT_OUTER.equals(type)) {
            // there are no RIGHT dataset values
            if (map.isEmpty()) {
                // if there are no WHERE conditions, just return everything
                // else return an empty set
                if (excludingOuterJoinRowsSet == null) {
                    return asQueryResult(new RowIteratorAdapter(leftRows) {
                        @Override
                        public Object next() {
                            return mergeRow((Row) super.next(), null);
                        }
                    });
                }
                return asQueryResult(new RowIteratorAdapter(
                        Collections.emptySet()));
            }

            List<Row> rows = new ArrayList<Row>();
            for (Row leftRow : new RowIterable(leftRows)) {
                for (String value : getLeftValues(leftRow)) {
                    List<Row> matchingRows = map.get(value);
                    if (matchingRows != null) {
                        for (Row rightRow : matchingRows) {
                            // I have possible WHERE clauses on the join that I
                            // need to look at for each rightRow
                            if (excludingOuterJoinRowsSet == null) {
                                rows.add(mergeRow(leftRow, rightRow));
                            } else {
                                boolean isIncluded = false;
                                // apparently
                                // 'excludingOuterJoinRowsSet.contains' fails to
                                // match rows

                                // TODO can 'rightRow.getNode()' break because
                                // of joins that are bigger than 2 way?
                                // how does this perform for 3 way joins ?
                                for (Row r : excludingOuterJoinRowsSet) {
                                    if(rowComparator.compare(rightRow, r) == 0){
                                        isIncluded = true;
                                        break;
                                    }
                                }
                                if (isIncluded) {
                                    rows.add(mergeRow(leftRow, rightRow));
                                }
                            }
                        }
                    } else {
                        // No matches in an outer join -> add a null row, if
                        // there are no 'WHERE' conditions
                        if (excludingOuterJoinRowsSet == null) {
                            rows.add(mergeRow(leftRow, null));
                        }
                    }
                }
            }
            return asQueryResult(new RowIteratorAdapter(rows));
        }
        return asQueryResult(new RowIteratorAdapter(Collections.emptySet()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.