Package com.facebook.presto.operator

Examples of com.facebook.presto.operator.Page


    private long estimateCountVectorized(List<Object> values, int field)
    {
        Aggregator aggregator = createAggregator(aggregation(getAggregationFunction(), new Input(0, field)), AggregationNode.Step.SINGLE);

        if (!values.isEmpty()) {
            aggregator.addValue(new Page(createBlock(values, field + 1)));
        }

        return (long) BlockAssertions.toValues(aggregator.getResult()).get(0).get(0);
    }
View Full Code Here


        return selectSingleValue(operator);
    }

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

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

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

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

        return executeFilter(operator);
    }

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

        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(0));
            value = true;
        }
        else {
View Full Code Here

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

        // 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

    private static final Duration MAX_WAIT = new Duration(1, TimeUnit.SECONDS);
    private static final DataSize PAGE_SIZE = createPage(42).getDataSize();

    private static Page createPage(int i)
    {
        return new Page(BlockAssertions.createLongsBlock(i));
    }
View Full Code Here

    private void assertBufferResultEquals(BufferResult actual, BufferResult expected)
    {
        assertEquals(actual.getElements().size(), expected.getElements().size());
        assertEquals(actual.getStartingSequenceId(), expected.getStartingSequenceId());
        for (int i = 0; i < actual.getElements().size(); i++) {
            Page actualPage = actual.getElements().get(i);
            Page expectedPage = expected.getElements().get(i);
            assertEquals(actualPage.getChannelCount(), expectedPage.getChannelCount());
            for (int channel = 0; channel < actualPage.getChannelCount(); channel++) {
                assertBlockEquals(actualPage.getBlock(channel), expectedPage.getBlock(channel));
            }
        }
        assertEquals(actual.isBufferClosed(), expected.isBufferClosed());
    }
View Full Code Here

    private void testVectorMultiplePositions(Block block, Object expectedValue, int field)
    {
        Aggregator function = createAggregator(aggregation(getFunction(), new Input(0, field)), Step.SINGLE);

        function.addValue(new Page(createCompositeTupleBlock(block, field)));
        assertEquals(getActualValue(function), expectedValue);
    }
View Full Code Here

        assertEquals(getResult(function.getFinalTupleInfo(), aggregator1), expected);

        // verify addValue(BlockCursor...)
        Aggregator aggregator2 = createAggregator(definition, Step.FINAL);
        for (Page input : inputs) {
            Page partial = computePartial(function, input);

            BlockCursor[] cursors = new BlockCursor[partial.getBlocks().length];
            for (int i = 0; i < cursors.length; i++) {
                cursors[i] = partial.getBlock(i).cursor();
            }

            while (BlockAssertions.advanceAllCursorsToNextPosition(cursors)) {
                aggregator2.addValue(cursors);
            }
View Full Code Here

        else {
            valuesBlock = createDoublesBlock(values);
            percentilesBlock = new RunLengthEncodedBlock(createTuple(percentile), values.length);
        }

        return new Page(valuesBlock, percentilesBlock);
    }
View Full Code Here

        else {
            valuesBlock = createLongsBlock(values);
            percentilesBlock = new RunLengthEncodedBlock(createTuple(percentile), values.length);
        }

        return new Page(valuesBlock, percentilesBlock);
    }
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.