Package com.foundationdb.qp.operator

Examples of com.foundationdb.qp.operator.Cursor


        deleteGenerator = getGenerator (CACHED_DELETE_GENERATOR, context);

        Index pkIndex = context.table.getPrimaryKeyIncludingInternal().getIndex();
        List<List<Object>> pks = PrimaryKeyParser.parsePrimaryKeys(identifiers, pkIndex);
       
        Cursor cursor = null;

        try {
            Operator delete = deleteGenerator.create(tableName);
            cursor = API.cursor(delete, context.queryContext, context.queryBindings);

            for (List<Object> key : pks) {
                for (int i = 0; i < key.size(); i++) {
                    ValueSource value = ValueSources.fromObject(key.get(i), null).value();
                    context.queryBindings.setValue(i, value);
                }
   
                cursor.openTopLevel();
                Row row;
                while ((row = cursor.next()) != null) {
                    // Do Nothing - the act of reading the cursor
                    // does the delete row processing.
                    // TODO: Check that we got 1 row through.
                }
                cursor.closeTopLevel();
            }
        } finally {
            if (cursor != null && !cursor.isClosed())
                cursor.close();

        }
    }
View Full Code Here


                    throw new FKValueMismatchException(join.getMatchingChild(entry.getKey()).getName());
                }
            }
        }
        Operator insert = insertGenerator.create(context.allValues, context.table.getName());
        Cursor cursor = API.cursor(insert, context.queryContext, context.queryBindings);
        JsonRowWriter writer = new JsonRowWriter(new TableRowTracker(context.table, 0));
        WriteCapturePKRow rowWriter = new WriteCapturePKRow();
        writer.writeRows(cursor, appender, context.anyUpdates ? "\n" : "", rowWriter, options);
        context.pkValues = rowWriter.getPKValues();
        context.anyUpdates = true;
View Full Code Here

    @Test
    public void testSingle()
    {
        Operator indexScan = indexScan_Default(itemIidIndexRowType, iidKeyRange(212, true, 212, true), ordering(itemIidIndexRowType), IndexScanSelector.leftJoinAfter(itemIidIndexRowType.index(), itemRowType.table()), lookaheadQuantum());
        Cursor cursor = cursor(indexScan, queryContext, queryBindings);
        String[] expected = new String[]{hkey(2, 21, 212)};
        compareRenderedHKeys(expected, cursor);
    }
View Full Code Here

                                        intRow(cidValueRowType, 4),
                                        intRow(cidValueRowType, 6)),
                    cidValueRowType),
                indexScan_Default(orderCidIndexRowType, cidRange, ordering(orderCidIndexRowType), IndexScanSelector.leftJoinAfter(orderCidIndexRowType.index(), orderRowType.table()), lookaheadQuantum()),
                1, pipelineMap(), 1);
        Cursor cursor = cursor(plan, queryContext, queryBindings);
        String[] expected = new String[]{hkey(2, 21),hkey(2, 22),hkey(2, 23),hkey(2, 24),hkey(2, 25),hkey(2, 26),hkey(2, 27),hkey(2, 28),hkey(2, 29),hkey(4, 41)};
        compareRenderedHKeys(expected, cursor);
    }
View Full Code Here

                map_NestedLoops(
                    indexScan_Default(orderCidIndexRowType, cidRange, ordering(orderCidIndexRowType), IndexScanSelector.leftJoinAfter(orderCidIndexRowType.index(), orderRowType.table()), lookaheadQuantum()),
                    indexScan_Default(itemOidIndexRowType, oidRange, ordering(itemOidIndexRowType), IndexScanSelector.leftJoinAfter(itemOidIndexRowType.index(), itemRowType.table()), lookaheadQuantum()),
                    2, pipelineMap(), 2),
                1, pipelineMap(), 1);
        Cursor cursor = cursor(plan, queryContext, queryBindings);
        String[] expected = new String[]{hkey(2, 21, 211),hkey(2, 21, 212),hkey(2, 22, 221),hkey(2, 22, 222),hkey(2, 24, 241),hkey(2, 25, 251)};
        compareRenderedHKeys(expected, cursor);
    }
View Full Code Here

        this.costEstimate = costEstimate;
    }
   
    @Override
    public ExecuteResults execute(EmbeddedQueryContext context, QueryBindings bindings) {
        Cursor cursor = null;
        try {
            context.initStore(getSchema());
            cursor = API.cursor(resultOperator, context, bindings);
            cursor.openTopLevel();
            ExecuteResults result = new ExecuteResults(cursor);
            cursor = null;
            return result;
        } catch (RuntimeException e) {
            LOG.error("caught error: {}", e.toString());
            cursor = null;
            throw e;
        }      
        finally {
            if (cursor != null) {
                cursor.closeTopLevel();
            }
        }
    }
View Full Code Here

        return false;           // See below.
    }

    @Override
    public Cursor openCursor(PostgresQueryContext context, QueryBindings bindings) {
        Cursor cursor = API.cursor(resultOperator, context, bindings);
        cursor.openTopLevel();
        return cursor;
    }
View Full Code Here

    public int execute(PostgresQueryContext context, QueryBindings bindings, int maxrows) throws IOException {
        PostgresServerSession server = context.getServer();
        PostgresMessenger messenger = server.getMessenger();
        int rowsModified = 0;
        if (resultOperator != null) {
            Cursor cursor = null;
            IOException exceptionDuringExecution = null;
            try {
                preExecute(context, DXLFunction.UNSPECIFIED_DML_WRITE);
                context.initStore(getSchema());
                cursor = openCursor(context, bindings);
                PostgresOutputter<Row> outputter = null;
                if (outputResult) {
                    outputter = getRowOutputter(context);
                    outputter.beforeData();
                }
                Row row;
                while ((row = cursor.next()) != null) {
                    assert getResultRowType() == null || (row.rowType() == getResultRowType()) : row;
                    if (outputResult) {
                        outputter.output(row);
                    }
                    rowsModified++;
View Full Code Here

        Operator plan = indexScan_Default(idxRowType, unbounded(), ordering(A, ASC, B, ASC, C, ASC, ID, ASC));
        long[] idOrdering = longs(1000, 1001, 1002, 1003,
                                  1010, 1011, 1012, 1013,
                                  1020, 1021, 1022, 1023,
                                  1030, 1031, 1032, 1033);
        Cursor cursor = cursor(plan, queryContext, queryBindings);
        cursor.openTopLevel();
        testJump(cursor, idOrdering, 0);
        testJump(cursor, idOrdering, -1);
        cursor.closeTopLevel();
    }
View Full Code Here

        Operator plan = indexScan_Default(idxRowType, unbounded(), ordering(A, ASC, B, ASC, C, ASC, ID, DESC));
        long[] idOrdering = longs(1000, 1001, 1002, 1003,
                                  1010, 1011, 1012, 1013,
                                  1020, 1021, 1022, 1023,
                                  1030, 1031, 1032, 1033);
        Cursor cursor = cursor(plan, queryContext, queryBindings);
        cursor.openTopLevel();
        testJump(cursor, idOrdering, 0);
        testJump(cursor, idOrdering, 1);
        cursor.closeTopLevel();
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.qp.operator.Cursor

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.