Examples of RowIteratorAdapter


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)) {
                Set<String> leftValues = getLeftValues(leftRow);
                if(leftValues.isEmpty()){
                    leftValues.add(null);
                }
                for (String value : leftValues) {
                    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

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

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

        };
        return new RowIteratorAdapter(rowIterator);
    }
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

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());

        if (leftRows == null || leftRows.isEmpty()) {
            return merger.merge(new RowIteratorAdapter(leftRows),
                    new RowIteratorAdapter(new TreeSet<Row>()), null, rightCo);
        }

        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

        // QueryEngine take care of sorting and applying offset and limit
        // constraints
        boolean externalSort = !NATIVE_SORT;
        RowIterator rows = null;
        try {
            rows = new RowIteratorAdapter(lqf.execute(columnMap, selector,
                    constraint, sort, externalSort, offset, limit));
        } catch (IOException e) {
            throw new RepositoryException("Failed to access the query index", e);
        } finally {
            log.debug(
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

        };
        final PrefetchIterator<RowImpl> prefIt = new  PrefetchIterator<RowImpl>(
                rowIterator,
                PREFETCH_MIN, PREFETCH_TIMEOUT, PREFETCH_MAX,
                result.getSize());
        return new RowIteratorAdapter(prefIt) {
            @Override
            public long getSize() {
                return prefIt.size();
            }
        };
View Full Code Here

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

        };
        final PrefetchIterator<RowImpl> prefIt = new  PrefetchIterator<RowImpl>(
                sessionDelegate.sync(rowIterator),
                PREFETCH_MIN, PREFETCH_TIMEOUT, PREFETCH_MAX,
                result.getSize());
        return new RowIteratorAdapter(prefIt) {
            @Override
            public long getSize() {
                return prefIt.size();
            }
        };
View Full Code Here

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

        };
        final PrefetchIterator<RowImpl> prefIt = new  PrefetchIterator<RowImpl>(
                rowIterator,
                PREFETCH_MIN, PREFETCH_TIMEOUT, PREFETCH_MAX,
                result.getSize());
        return new RowIteratorAdapter(prefIt) {
            @Override
            public long getSize() {
                return prefIt.size();
            }
        };
View Full Code Here

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

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

        };
        return new RowIteratorAdapter(it);
    }
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.