Package com.facebook.presto.spi

Examples of com.facebook.presto.spi.Page


                // write position to output block
                hashStrategy.appendTo(leftBlockIndex, leftBlockPosition, pageBuilder, 0);
            }

            // verify output block matches
            Page page = pageBuilder.build();
            assertPageEquals(types, page, new Page(
                    extraChannel.get(leftBlockIndex),
                    varcharChannel.get(leftBlockIndex),
                    longChannel.get(leftBlockIndex),
                    doubleChannel.get(leftBlockIndex),
                    booleanChannel.get(leftBlockIndex)));
View Full Code Here


            else {
                throw new IllegalStateException("Unsupported type " + type);
            }
        }

        return new Page(blocks);
    }
View Full Code Here

        }

        assertEquals(requestLocation.getSequenceId(), token, "token");

        // wait for a single page to arrive
        Page page = null;
        try {
            page = pages.poll(10, TimeUnit.MILLISECONDS);
        }
        catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }

        // if no page, return NO CONTENT
        if (page == null) {
            return new TestingResponse(HttpStatus.NO_CONTENT, ImmutableListMultimap.of(
                    PRESTO_PAGE_TOKEN, String.valueOf(token),
                    PRESTO_PAGE_NEXT_TOKEN, String.valueOf(token)
            ), new byte[0]);
        }

        // add pages up to the size limit
        List<Page> responsePages = new ArrayList<>();
        responsePages.add(page);
        long responseSize = page.getSizeInBytes();
        while (responseSize < maxSize.toBytes()) {
            page = pages.poll();
            if (page == null) {
                break;
            }
            responsePages.add(page);
            responseSize += page.getSizeInBytes();
        }

        // update sequence id
        long nextToken = token + responsePages.size();
        tokenByLocation.put(location, nextToken);
View Full Code Here

    @Test
    public void testHappyPath()
            throws Exception
    {
        Page expectedPage = new Page(100);

        DataSize expectedMaxSize = new DataSize(11, Unit.MEGABYTE);
        MockExchangeRequestProcessor processor = new MockExchangeRequestProcessor(expectedMaxSize);

        CyclicBarrier requestComplete = new CyclicBarrier(2);
View Full Code Here

            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.setNoMorePages();
        }
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

            @Override
            public Page apply(Page page)
            {
                Block[] blocks = new Block[page.getChannelCount() - 1];
                System.arraycopy(page.getBlocks(), 0, blocks, 0, page.getChannelCount() - 1);
                return new Page(blocks);
            }
        }).list();
    }
View Full Code Here

        // first read will be null due to buffering
        assertNull(operator.getOutput());

        // read first page
        Page page = null;
        for (int i = 0; i < 100; i++) {
            page = operator.getOutput();
            if (page != null) {
                break;
            }
View Full Code Here

                    BIGINT.writeLong(builder, sampleWeight);
                }
                Block[] blocks = new Block[page.getChannelCount() + 1];
                System.arraycopy(page.getBlocks(), 0, blocks, 0, page.getChannelCount());
                blocks[blocks.length - 1] = builder.build();
                return new Page(blocks);
            }
        }).list();
    }
View Full Code Here

    public static List<Page> toPages(Operator operator, Iterator<Page> input)
    {
        ImmutableList.Builder<Page> outputPages = ImmutableList.builder();

        while (input.hasNext()) {
            Page inputPage = input.next();

            // read output until input is needed or operator is finished
            int nullPages = 0;
            while (!operator.needsInput() && !operator.isFinished()) {
                Page outputPage = operator.getOutput();
                if (outputPage == null) {
                    // break infinite loop due to null pages
                    assertTrue(nullPages < 1_000_000, "Too many null pages; infinite loop?");
                    nullPages++;
                }
                else {
                    outputPages.add(outputPage);
                    nullPages = 0;
                }
            }

            if (operator.isFinished()) {
                break;
            }

            assertEquals(operator.needsInput(), true);
            operator.addInput(inputPage);

            Page outputPage = operator.getOutput();
            if (outputPage != null) {
                outputPages.add(outputPage);
            }
        }
View Full Code Here

TOP

Related Classes of com.facebook.presto.spi.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.