Package com.foundationdb.qp.loadableplan

Examples of com.foundationdb.qp.loadableplan.DirectObjectCursor


        return true;
    }

    @Override
    public DirectObjectCursor openCursor(PostgresQueryContext context, QueryBindings bindings) {
        DirectObjectCursor cursor = plan.cursor(context, bindings);
        cursor.open();
        return cursor;
    }
View Full Code Here


    @Override
    public int execute(PostgresQueryContext context, QueryBindings bindings, int maxrows) throws IOException {
        PostgresServerSession server = context.getServer();
        PostgresMessenger messenger = server.getMessenger();
        int nrows = 0;
        DirectObjectCursor cursor = null;
        PostgresOutputter<List<?>> outputter = null;
        PostgresDirectObjectCopier copier = null;
        bindings = PostgresLoadablePlan.setParameters(bindings, invocation);
        ServerCallContextStack stack = ServerCallContextStack.get();
        boolean suspended = false, success = false;
        stack.push(context, invocation);
        try {
            context.initStore(schema);
            cursor = context.startCursor(this, bindings);
            switch (outputMode) {
            case TABLE:
                outputter = new PostgresDirectObjectOutputter(context, this);
                break;
            case COPY:
            case COPY_WITH_NEWLINE:
                outputter = copier = new PostgresDirectObjectCopier(context, this, (outputMode == DirectObjectPlan.OutputMode.COPY_WITH_NEWLINE));
                copier.respond();
                break;
            }
            if (cursor != null) {
                List<?> row;
                while ((row = cursor.next()) != null) {
                    if (row.isEmpty()) {
                        messenger.flush();
                    }
                    else {
                        outputter.output(row);
View Full Code Here

        if (multiple)
            queryBindings.setValue(2, new Value(MNumeric.INT.instance(false), 10));
        if (commitFreq > 0)
            queryBindings.setValue(3, new Value(MNumeric.INT.instance(false), commitFreq));

        DirectObjectCursor cursor = plan.cursor(queryContext, queryBindings);
       
        StringBuilder actual = new StringBuilder();

        cursor.open();
        while(true) {
            List<?> columns = cursor.next();
            if (columns == null) {
                break;
            }
            else if (!columns.isEmpty()) {
                assertTrue(columns.size() == 1);
                if (actual.length() > 0)
                    actual.append("\n");
                actual.append(columns.get(0));
            }
        }
        cursor.close();

        assertEquals(expectedSQL, actual.toString());
    }
View Full Code Here

        Schema schema = new Schema(ais());
        StoreAdapter adapter = newStoreAdapter(schema);
        QueryContext queryContext = queryContext(adapter);
        QueryBindings queryBindings = queryContext.createBindings();

        DirectObjectCursor cursor = plan.cursor(queryContext, queryBindings);
        queryBindings.setValue(0, new Value(MString.varcharFor("stat"), "stat"));
        queryBindings.setValue(1, new Value(MString.varcharFor("count=3"), "count=3"));
        queryBindings.setValue(2, new Value(MString.varcharFor("delay=2"), "delay=2"));
        queryBindings.setValue(3, new Value(MString.varcharFor("-a"), "-a"));
       
        int populatedResults = 0;
        int emptyResults = 0;
       
        cursor.open();
        while(true) {
            List<? extends Object> columns = cursor.next();
            if (columns == null) {
                break;
            }
            if (columns.isEmpty()) {
                emptyResults++;
            } else {
                assertEquals(1, columns.size());
                assertTrue(columns.get(0) instanceof String);
                populatedResults++;
            }
        }
        cursor.close();
        assertEquals(3, populatedResults);
        assertTrue(emptyResults > 0 && emptyResults < 60);
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.qp.loadableplan.DirectObjectCursor

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.