Package com.foundationdb.qp.operator

Examples of com.foundationdb.qp.operator.Cursor


        IndexBound bound = new IndexBound(boundRow, new SetColumnSelector(0));
        IndexKeyRange keyRange = IndexKeyRange.bounded(idxRowType, bound, true, bound, true);
        Ordering ordering = new Ordering();
        ordering.append(field(idxRowType, 0), true);
        Operator plan = indexScan_Default(idxRowType, keyRange, ordering);
        Cursor cursor = cursor(plan, queryContext, queryBindings);
        long startTime = System.nanoTime();
        for (int r = 0; r < runs; r++) {
            for (int s = 0; s < sequentialAccessesPerRandom; s++) {
                Object key = keys[s];
                if (key instanceof Integer) {
                    valueHolder.putInt64((long) ((Integer) key).intValue());
                } else {
                    valueHolder.putString((String) key, null);
                }
                cursor.openTopLevel();
                Row row = cursor.next();
                assert row != null;
                cursor.closeTopLevel();
            }
        }
        long endTime = System.nanoTime();
        if (label != null) {
            double averageUsec = (endTime - startTime) / (1000.0 * runs * sequentialAccessesPerRandom);
 
View Full Code Here


    }
   
    private KeyReadCursor getKeyCursor (RowType rowType, List<BindableRow> rows) {

        Operator op = valuesScan_Default(rows, rowType);
        Cursor cursor = cursor(op, queryContext, queryBindings);
        API.Ordering ordering = API.ordering();
        ordering.append(new TPreparedField (rowType.typeAt(0), 0), true);
       
        MergeJoinSorter mergeSorter = new MergeJoinSorter(queryContext, queryBindings, cursor,
                rowType, ordering, API.SortOption.PRESERVE_DUPLICATES, Tap.createTimer("Test Tap"));
       
        cursor.open();
        return mergeSorter.readCursor();
    }
View Full Code Here

        Operator scan = groupScan_Default(group);
        TimeOperator timeScan = new TimeOperator(scan);
        Operator select = select_HKeyOrdered(timeScan, tRowType, ExpressionGenerators.literal(Boolean.TRUE));
        long start = System.nanoTime();
        for (int r = 0; r < runs; r++) {
            Cursor cursor = cursor(select, queryContext, queryBindings);
            cursor.openTopLevel();
            while (cursor.next() != null);
        }
        long stop = System.nanoTime();
        long selectNsec = stop - start - timeScan.elapsedNsec();
        if (report) {
            // Report the difference
View Full Code Here

                Operator plan = creator.create(schema);
                StoreAdapter adapter = store().createAdapter(session(), schema);
                QueryContext context = new SimpleQueryContext(adapter, serviceManager());
                QueryBindings bindings = context.createBindings();
                List<Row> rows = new ArrayList<>();
                Cursor cursor = API.cursor(plan, context, bindings);
                cursor.openTopLevel();
                try {
                    Row row;
                    while((row = cursor.next()) != null) {
                        rows.add(row);
                    }
                } finally {
                    cursor.closeTopLevel();
                }
                return rows;
            }
        });
    }
View Full Code Here

    }

    protected List<Row> runPlanInternal(Session session, Schema schema, Operator plan) {
        StoreAdapter adapter = newStoreAdapter(session, schema);
        QueryContext context = queryContext(adapter);
        Cursor cursor = API.cursor(plan, context, context.createBindings());
        cursor.openTopLevel();
        try {
            List<Row> output = new ArrayList<>();
            Row row;
            while((row = cursor.next()) != null) {
                output.add(row);
            }
            return output;
        } finally {
            cursor.closeTopLevel();
        }
    }
View Full Code Here

        final int ITEMS_PER_ORDER = 2;
        populateDB(CUSTOMERS, ORDERS_PER_CUSTOMER, ITEMS_PER_ORDER);
        long start = System.nanoTime();
        Operator plan = groupScan_Default(coi);
        for (int s = 0; s < SCANS; s++) {
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            while (cursor.next() != null) {
            }
            cursor.closeTopLevel();
        }
        long end = System.nanoTime();
        double sec = (end - start) / (1000.0 * 1000 * 1000);
        System.out.println(String.format("scans: %s, db: %s/%s/%s, time: %s",
                                         SCANS, CUSTOMERS, ORDERS_PER_CUSTOMER, ITEMS_PER_ORDER, sec));
View Full Code Here

    {
        API.Ordering ordering = ordering(A, ASC, B, ASC, C, ASC, ID, ASC);
        long[] idOrdering = longs(1010, 1011, 1012, 1013, 1014, 1015);
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, true, 13, true), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, idOrdering, 0);
            testJump(cursor, idOrdering, -1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, true, 13, false), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, first4(idOrdering), 0);
            testJump(cursor, first4(idOrdering), -1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, false, 13, true), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, last4(idOrdering), 0);
            testJump(cursor, last4(idOrdering), -1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, false, 13, false), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, middle2(idOrdering), 0);
            testJump(cursor, middle2(idOrdering), -1);
            cursor.closeTopLevel();
        }
    }
View Full Code Here

    {
        API.Ordering ordering = ordering(A, ASC, B, ASC, C, ASC, ID, DESC);
        long[] idOrdering = longs(1010, 1011, 1012, 1013, 1014, 1015);
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, true, 13, true), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, idOrdering, 0);
            testJump(cursor, idOrdering, 1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, true, 13, false), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, first4(idOrdering), 0);
            testJump(cursor, first4(idOrdering), 1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, false, 13, true), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, last4(idOrdering), 0);
            testJump(cursor, last4(idOrdering), 1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, false, 13, false), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, middle2(idOrdering), 0);
            testJump(cursor, middle2(idOrdering), 1);
            cursor.closeTopLevel();
        }
    }
View Full Code Here

    {
        API.Ordering ordering = ordering(A, ASC, B, ASC, C, DESC, ID, ASC);
        long[] idOrdering = longs(1011, 1010, 1013, 1012, 1015, 1014);
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, true, 13, true), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, idOrdering, 0);
            testJump(cursor, idOrdering, -1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, true, 13, false), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, first4(idOrdering), 0);
            testJump(cursor, first4(idOrdering), -1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, false, 13, true), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, last4(idOrdering), 0);
            testJump(cursor, last4(idOrdering), -1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, false, 13, false), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, middle2(idOrdering), 0);
            testJump(cursor, middle2(idOrdering), -1);
            cursor.closeTopLevel();
        }
    }
View Full Code Here

    {
        API.Ordering ordering = ordering(A, ASC, B, ASC, C, DESC, ID, DESC);
        long[] idOrdering = longs(1011, 1010, 1013, 1012, 1015, 1014);
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, true, 13, true), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, idOrdering, 0);
            testJump(cursor, idOrdering, 1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, true, 13, false), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, first4(idOrdering), 0);
            testJump(cursor, first4(idOrdering), 1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, false, 13, true), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, last4(idOrdering), 0);
            testJump(cursor, last4(idOrdering), 1);
            cursor.closeTopLevel();
        }
        {
            Operator plan = indexScan_Default(idxRowType, bounded(1, 11, false, 13, false), ordering);
            Cursor cursor = cursor(plan, queryContext, queryBindings);
            cursor.openTopLevel();
            testJump(cursor, middle2(idOrdering), 0);
            testJump(cursor, middle2(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.