Package com.foundationdb.qp.row

Examples of com.foundationdb.qp.row.Row


                }
                checkQueryCancelation();
                while (pending.isEmpty() && (lookupState != LookupState.EXHAUSTED)) {
                    advance();
                }
                Row row = pending.poll();
                if (LOG_EXECUTION) {
                    LOG.debug("GroupLookup: yield {}", row);
                }
                return row;
            } finally {
View Full Code Here


            }
        }

        private void advanceInput()
        {
            Row currentRow = input.next();
            if (currentRow != null) {
                if (currentRow.rowType() == inputRowType) {
                    findAncestors(currentRow);
                    lookupState = LookupState.ANCESTOR;
                }
                if (keepInput) {
                    pending.add(currentRow);
View Full Code Here

        private Row readAncestorRow(HKey hKey)
        {
            try {
                lookupCursor.rebind(hKey, false);
                lookupCursor.open();
                Row retrievedRow = lookupCursor.next();
                if (retrievedRow != null) {
                    // Retrieved row might not actually be what we were looking for -- not all ancestors are present,
                    // (there are orphan rows).
                    retrievedRow = hKey.equals(retrievedRow.hKey()) ? retrievedRow : null;
                }
                return retrievedRow;
            } finally {
                lookupCursor.close();
            }
View Full Code Here

            }
        }

        private void advanceBranch()
        {
            Row currentLookupRow = lookupCursor.next();
            lookupRow = null;
            if (currentLookupRow == null) {
                lookupState = LookupState.BETWEEN;
                lookupCursor.close();
            } else if (branchOutputRowTypes.contains(currentLookupRow.rowType())) {
                lookupRow = currentLookupRow;
            }
            if (lookupRow != null) {
                pending.add(lookupRow);
            }
View Full Code Here

            try {
                if (CURSOR_LIFECYCLE_ENABLED) {
                    CursorLifecycle.checkIdleOrActive(this);
                }
                checkQueryCancelation();
                Row outputRow = null;
                while (isActive() && outputRow == null) {
                    // Get some more input rows, crossing bindings boundaries as
                    // necessary, and open cursors for them.
                    pipeline:
                    while (!bindingsExhausted && inputs[nextIndex].inputRow == null) {
                        if (nextBindings == null) {
                            if (newBindings) {
                                nextBindings = currentBindings;
                                newBindings = false;
                            }
                            while ((nextBindings == null) ||
                                   (nextBindings.getDepth() != currentBindings.getDepth())) {
                                nextBindings = input.nextBindings();
                                if (nextBindings == null) {
                                    bindingsExhausted = true;
                                    break pipeline;
                                }
                                pendingBindings.add(nextBindings);
                            }
                            input.open();
                        }
                        Row row = input.next();
                        if (row == null) {
                            // This is correct, close the input to allow
                            // nextBindings() to process correctly.
                            input.close();
                            nextBindings = null;
                        }
                        else {
                            InputState inputState = inputs[nextIndex];
                            inputState.inputRow = row;
                            if (LOG_EXECUTION) {
                                LOG.debug("GroupLookup: new input {}", row);
                            }
                            inputState.queryBindings = nextBindings;
                            for (int i = 0; i < ncursors; i++) {
                                if (i == keepInputCursorIndex) continue;
                                boolean deep = false;
                                if (i == branchCursorIndex) {
                                    row.hKey().copyTo(inputState.lookupHKeys[i]);
                                    if (branchRootOrdinal != -1) {
                                        inputState.lookupHKeys[i].extendWithOrdinal(branchRootOrdinal);
                                    }
                                    deep = true;
                                }
                                else {
                                    inputState.lookupHKeys[i] = row.ancestorHKey(ancestors.get(i));
                                }
                                inputState.cursors[i].rebind(inputState.lookupHKeys[i], deep);
                                inputState.cursors[i].open();
                            }
                            nextIndex = (nextIndex + 1) % quantum;
View Full Code Here

                switch (sortingState) {
                case FILLING:
                    {
                        // If duplicates are preserved, the label is different for each row. Otherwise, it stays at 0.
                        int label = 0;
                        Row row;
                        while ((row = input.next()) != null) {
                            assert row.rowType() == sortType : row;
                            Holder holder;
                            holder = new Holder(label, row, tEvaluations);
                            if (preserveDuplicates) {
                                label++;
                            }
                            if (sorted.size() < limit) {
                                // Still room: add it in.
                                holder.freeze();
                                boolean added = sorted.add(holder);
                                assert !preserveDuplicates || added;
                            }
                            else {
                                // Current greatest element.
                                Holder last = sorted.last();
                                if (last.compareTo(holder) > 0) {
                                    // New row is less, so keep it
                                    // instead unless it's already in
                                    // there (in suppress dups case).
                                    boolean added = sorted.add(holder);
                                    if (added) {
                                        sorted.remove(last);
                                        last.empty();
                                        holder.freeze();
                                    }
                                    else {
                                        assert !preserveDuplicates;
                                    }
                                }
                                else {
                                    // Will not be using new row.
                                    holder.empty();
                                }
                            }
                        }
                        iterator = sorted.iterator();
                        sortingState = State.EMPTYING;
                    }
                    /* falls through */
                case EMPTYING:
                    Row output;
                    if (iterator.hasNext()) {
                        Holder holder = iterator.next();
                        output = holder.empty();
                    }
                    else {
View Full Code Here

                values[i] = toObject(evaluation.resultValue());
            }
        }

        public Row empty() {
            Row result = row;
            row = null;
            return result;
        }
View Full Code Here

            if (TAP_NEXT_ENABLED) {
                TAP_NEXT.in();
            }
            try {
                checkQueryCancelation();
                Row row;
                while ((row = input.next()) != null) {
                    assert row.rowType() == distinctType : row;
                    if (isDistinctP(row)) break;
                }
                if (row == null) {
                    setIdle();
                }
View Full Code Here

            }
            try {
                if (CURSOR_LIFECYCLE_ENABLED) {
                    CursorLifecycle.checkIdleOrActive(this);
                }
                Row next = null;
                while (isActive() && next == null) {
                    assert !(leftRow == null && rightRow == null);
                    long c = compareRows();
                    if (c < 0) {
                        if (keepUnmatchedLeft) {
View Full Code Here

        // For use by this class

        private void nextLeftRow()
        {
            Row row = leftInput.next();
            leftRow = row;
            if (LOG_EXECUTION) {
                LOG.debug("intersect_Ordered: left {}", row);
            }
        }
View Full Code Here

TOP

Related Classes of com.foundationdb.qp.row.Row

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.