Package com.facebook.presto.operator

Examples of com.facebook.presto.operator.Page


            List<String> data = ImmutableList.of("apple", "banana", "cherry", "date");

            // load initial pages
            for (int i = 0; i < initialPages; i++) {
                checkState(sharedBuffer.enqueue(new Page(createStringsBlock(Iterables.concat(Collections.nCopies(i + 1, data))))).isDone(), "Unable to add page to buffer");
            }
            sharedBuffer.finish();
        }
View Full Code Here


        @Override
        public Page getOutput()
        {
            // only return a page if the page buffer isFull or we are finishing and the page buffer has data
            if (pageBuilder.isFull() || (finishing && !pageBuilder.isEmpty())) {
                Page page = pageBuilder.build();
                pageBuilder.reset();
                return page;
            }
            return null;
        }
View Full Code Here

        @Override
        public Page getOutput()
        {
            // only return a page if the page buffer isFull or we are finishing and the page buffer has data
            if (pageBuilder.isFull() || (finishing && !pageBuilder.isEmpty())) {
                Page page = pageBuilder.build();
                pageBuilder.reset();
                return page;
            }
            return null;
        }
View Full Code Here

    }

    private static void importData(AlignmentOperator source, ColumnFileHandle fileHandle)
    {
        while (!source.isFinished()) {
            Page page = source.getOutput();
            if (page != null) {
                fileHandle.append(page);
            }
            checkState(source.isBlocked().isDone(), "Alignment operator is blocked");
        }
View Full Code Here

                .toString();
    }

    private static List<Type> getTypes(List<Page> pages)
    {
        Page firstPage = pages.get(0);
        List<Type> types = new ArrayList<>();
        for (Block block : firstPage.getBlocks()) {
            types.add(block.getType());
        }
        return types;
    }
View Full Code Here

            ImmutableList.Builder<RowIterable> pages = ImmutableList.builder();
            // wait up to max wait for data to arrive; then try to return at least DESIRED_RESULT_BYTES
            int bytes = 0;
            while (bytes < DESIRED_RESULT_BYTES) {
                Page page = exchangeClient.getNextPage(maxWait);
                if (page == null) {
                    break;
                }
                bytes += page.getDataSize().toBytes();
                pages.add(new RowIterable(session, page));

                // only wait on first call
                maxWait = new Duration(0, TimeUnit.MILLISECONDS);
            }
View Full Code Here

        return selectSingleValue(operator);
    }

    public static Object selectSingleValue(Operator operator)
    {
        Page output = getAtMostOnePage(operator, SOURCE_PAGE);

        assertNotNull(output);
        assertEquals(output.getPositionCount(), 1);
        assertEquals(output.getChannelCount(), 1);

        Block block = output.getBlock(0);
        assertEquals(block.getPositionCount(), 1);

        BlockCursor cursor = block.cursor();
        assertTrue(cursor.advanceNextPosition());
        if (cursor.isNull()) {
View Full Code Here

        return executeFilter(operator);
    }

    private static boolean executeFilter(Operator operator)
    {
        Page page = getAtMostOnePage(operator, SOURCE_PAGE);

        boolean value;
        if (page != null) {
            assertEquals(page.getPositionCount(), 1);
            assertEquals(page.getChannelCount(), 1);

            BlockCursor cursor = page.getBlock(0).cursor();
            assertTrue(cursor.advanceNextPosition());
            assertTrue(cursor.getBoolean());
            value = true;
        }
        else {
View Full Code Here

        return value;
    }

    private static boolean executeFilterWithNoInputColumns(Operator operator)
    {
        Page page = getAtMostOnePage(operator, ZERO_CHANNEL_PAGE);

        boolean value;
        if (page != null) {
            assertEquals(page.getPositionCount(), 1);
            assertEquals(page.getChannelCount(), 0);
            value = true;
        }
        else {
            value = false;
        }
View Full Code Here

        if (operator.needsInput()) {
            operator.addInput(sourcePage);
        }

        // try to get the output page
        Page result = operator.getOutput();

        // tell operator to finish
        operator.finish();

        // try to get output until the operator is finished
        while (!operator.isFinished()) {
            // operator should never block
            assertTrue(operator.isBlocked().isDone());

            Page output = operator.getOutput();
            if (output != null) {
                assertNull(result);
                result = output;
            }
        }
View Full Code Here

TOP

Related Classes of com.facebook.presto.operator.Page

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.