Package com.foundationdb.qp.operator

Examples of com.foundationdb.qp.operator.Cursor


                    Collections.singleton(oiType)),
                oiType,
                ordering(cidField, true, oidField, false, iidField, false),
                SortOption.PRESERVE_DUPLICATES,
                8);
        Cursor cursor = cursor(plan, queryContext, queryBindings);
        Row[] expected = new Row[]{
            row(oiType, 12L, 1L, "david", 122L, 12L),
            row(oiType, 12L, 1L, "david", 121L, 12L),
            row(oiType, 11L, 1L, "ori", 112L, 11L),
            row(oiType, 11L, 1L, "ori", 111L, 11L),
View Full Code Here


                    Collections.singleton(oiType)),
                oiType,
                ordering(cidField, false, oidField, true, iidField, true),
                SortOption.PRESERVE_DUPLICATES,
                8);
        Cursor cursor = cursor(plan, queryContext, queryBindings);
        Row[] expected = new Row[]{
            row(oiType, 21L, 2L, "david", 211L, 21L),
            row(oiType, 21L, 2L, "david", 212L, 21L),
            row(oiType, 22L, 2L, "jack", 221L, 22L),
            row(oiType, 22L, 2L, "jack", 222L, 22L),
View Full Code Here

                    Collections.singleton(oiType)),
                oiType,
                ordering(cidField, false, oidField, true, iidField, false),
                SortOption.PRESERVE_DUPLICATES,
                8);
        Cursor cursor = cursor(plan, queryContext, queryBindings);
        Row[] expected = new Row[]{
            row(oiType, 21L, 2L, "david", 212L, 21L),
            row(oiType, 21L, 2L, "david", 211L, 21L),
            row(oiType, 22L, 2L, "jack", 222L, 22L),
            row(oiType, 22L, 2L, "jack", 221L, 22L),
View Full Code Here

                    Collections.singleton(oiType)),
                oiType,
                ordering(cidField, false, oidField, false, iidField, true),
                SortOption.PRESERVE_DUPLICATES,
                8);
        Cursor cursor = cursor(plan, queryContext, queryBindings);
        Row[] expected = new Row[]{
            row(oiType, 22L, 2L, "jack", 221L, 22L),
            row(oiType, 22L, 2L, "jack", 222L, 22L),
            row(oiType, 21L, 2L, "david", 211L, 21L),
            row(oiType, 21L, 2L, "david", 212L, 21L),
View Full Code Here

                    Collections.singleton(oiType)),
                oiType,
                ordering(cidField, false, oidField, false, iidField, false),
                SortOption.PRESERVE_DUPLICATES,
                8);
        Cursor cursor = cursor(plan, queryContext, queryBindings);
        Row[] expected = new Row[]{
            row(oiType, 22L, 2L, "jack", 222L, 22L),
            row(oiType, 22L, 2L, "jack", 221L, 22L),
            row(oiType, 21L, 2L, "david", 212L, 21L),
            row(oiType, 21L, 2L, "david", 211L, 21L),
View Full Code Here

                null,
                true
        );

        QueryContext context = new SimpleQueryContext(newStoreAdapter(schema));
        Cursor cursor = API.cursor(outerIntersect, context, context.createBindings());
        compareRows(
            new Row[] {
                testRow(mdIndex, "x", "one", 3, 30)
            },
            cursor
View Full Code Here

        QueryBindings queryBindings = queryContext.createBindings();
        JsonRowWriter json = new JsonRowWriter(new TableRowTracker(table, depth));
        WriteTableRow rowWriter = new WriteTableRow();
        AkibanAppender appender = AkibanAppender.of(writer);
        boolean transaction = false;
        Cursor cursor = null;
        try {
            if (withTransaction) {
                transactionService.beginTransaction(session);
                transaction = true;
            }
            cursor = API.cursor(plan, queryContext, queryBindings);
            appender.append("[");
            boolean begun = false;

            if (keys == null) {
                begun = json.writeRows(cursor, appender, "\n", rowWriter, options);
            } else {
                for (List<Object> key : keys) {
                    for (int i = 0; i < key.size(); i++) {
                        ValueSource value = ValueSources.fromObject(key.get(i), null).value();
                        queryBindings.setValue(i, value);
                    }
                    if (json.writeRows(cursor, appender, begun ? ",\n" : "\n", rowWriter, options))
                        begun = true;
                }
            }

            appender.append(begun ? "\n]" : "]");
            if (withTransaction) {
                transactionService.commitTransaction(session);
                transaction = false;
            }
        }
        finally {
            if (cursor != null && !cursor.isClosed())
                cursor.closeTopLevel();
            if (transaction)
                transactionService.rollbackTransaction(session);
        }
    }
View Full Code Here

        final FullTextIndexInfo indexInfo = getIndex(session, index.getIndexName(), index.getIndexedTable().getAIS());
        boolean success = false;
        try {
            StoreAdapter adapter = store.createAdapter(session, indexInfo.getSchema());
            QueryContext queryContext = new SimpleQueryContext(adapter);
            Cursor cursor = null;
            Indexer indexer = indexInfo.getIndexer();
            try(RowIndexer rowIndexer = new RowIndexer(indexInfo, indexer.getWriter(), false)) {
                cursor = API.cursor(indexInfo.fullScan(), queryContext, queryContext.createBindings());
                long count = rowIndexer.indexRows(cursor);
                logger.debug("Populated {} with {} rows", indexInfo.getIndex().getIndexName(), count);
            } finally {
                if(cursor != null && !cursor.isClosed()) {
                    cursor.close();
                }
            }
            transactionService.addCallback(session, CallbackType.COMMIT, new Callback() {
                @Override
                public void run(Session session, long timestamp) {
View Full Code Here

    private void updateIndex(Session session, FullTextIndexInfo indexInfo, Iterable<byte[]> rows) throws IOException {
        StoreAdapter adapter = store.createAdapter(session, indexInfo.getSchema());
        QueryContext queryContext = new SimpleQueryContext(adapter);
        QueryBindings queryBindings = queryContext.createBindings();

        Cursor cursor = null;
        IndexWriter writer = indexInfo.getIndexer().getWriter();
        try(RowIndexer rowIndexer = new RowIndexer(indexInfo, writer, true)) {
            Operator operator = indexInfo.getOperator();
            Iterator<byte[]> it = rows.iterator();
            while(it.hasNext()) {
                byte[] row = it.next();
                Row hkeyRow = toHKeyRow(row, indexInfo.getHKeyRowType(), adapter);
                queryBindings.setRow(0, hkeyRow);
                cursor = API.cursor(operator, queryContext, queryBindings);
                rowIndexer.updateDocument(cursor, row);
                it.remove();
            }
        } finally {
            if(cursor != null && !cursor.isClosed()) {
                cursor.close();
            }
        }
    }
View Full Code Here

    {
        Operator plan = PlanGenerator.generateBranchPlan(table.getAIS(), table);
        StoreAdapter adapter = createAdapter(session, SchemaCache.globalSchema(table.getAIS()));
        QueryContext queryContext = new SimpleQueryContext(adapter);
        QueryBindings queryBindings = queryContext.createBindings();
        Cursor cursor = API.cursor(plan, queryContext, queryBindings);

        List<Column> lookupCols = table.getPrimaryKeyIncludingInternal().getColumns();
        RowDataValueSource pSource = new RowDataValueSource();
        for(int i = 0; i < lookupCols.size(); ++i) {
            Column col = lookupCols.get(i);
            pSource.bind(col.getFieldDef(), rowData);
            queryBindings.setValue(i, pSource);
        }
        try {
            Row row;
            cursor.openTopLevel();
            while((row = cursor.next()) != null) {
                Table aTable = row.rowType().table();
                RowData data = adapter.rowData(aTable.rowDef(), row, new RowDataCreator());
                maintainGroupIndexes(session,
                                     aTable,
                                     aTable.getGroupIndexes(),
                                     data,
                                     null,
                                     StoreGIHandler.forTable(this, session, table),
                                     StoreGIHandler.Action.CASCADE);
            }
        } finally {
            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.