Package com.facebook.presto.operator

Examples of com.facebook.presto.operator.PageBuilder


        // verify channel count
        assertEquals(joinProbe.getChannelCount(), 1);

        BlockCursor probeCursor = page.getBlock(0).cursor();
        PageBuilder pageBuilder = new PageBuilder(ImmutableList.of(VARCHAR));
        for (int position = 0; position < page.getPositionCount(); position++) {
            assertTrue(probeCursor.advanceNextPosition());
            assertTrue(joinProbe.advanceNextPosition());

            joinProbe.appendTo(pageBuilder);

            assertEquals(joinProbe.getCurrentJoinPosition(), lookupSource.getJoinPosition(probeCursor));
        }
        assertFalse(joinProbe.advanceNextPosition());
        assertBlockEquals(pageBuilder.build().getBlock(0), page.getBlock(0));
    }
View Full Code Here


        private boolean finishing;

        public TpchQuery1Operator(OperatorContext operatorContext)
        {
            this.operatorContext = checkNotNull(operatorContext, "operatorContext is null");
            this.pageBuilder = new PageBuilder(TYPES);
        }
View Full Code Here

            return pages;
        }

        List<TupleInfo> tupleInfos = getTupleInfos(pages);

        PageBuilder pageBuilder = new PageBuilder(tupleInfos);

        ImmutableList.Builder<Page> partitionedPages = ImmutableList.builder();
        for (Page page : pages) {
            // open the page
            BlockCursor[] cursors = new BlockCursor[tupleInfos.size()];
            for (int i = 0; i < cursors.length; i++) {
                cursors[i] = page.getBlock(i).cursor();
            }
            // for each position
            for (int position = 0; position < page.getPositionCount(); position++) {
                // advance all cursors
                for (BlockCursor cursor : cursors) {
                    cursor.advanceNextPosition();
                }

                // if hash is not in range skip
                int partitionHashBucket = getPartitionHashBucket(tupleInfos, cursors);
                if (partitionHashBucket != partition) {
                    continue;
                }

                // append row
                for (int channel = 0; channel < cursors.length; channel++) {
                    pageBuilder.getBlockBuilder(channel).append(cursors[channel]);
                }

                // if page is full, flush
                if (pageBuilder.isFull()) {
                    partitionedPages.add(pageBuilder.build());
                    pageBuilder.reset();
                }
            }
        }
        if (!pageBuilder.isEmpty()) {
            partitionedPages.add(pageBuilder.build());
        }

        return partitionedPages.build();
    }
View Full Code Here

                outputTypes.add(type);

                channel++;
            }

            PageBuilder pageBuilder = new PageBuilder(outputTypes);
            for (List<Expression> row : node.getRows()) {
                pageBuilder.declarePosition();
                IdentityHashMap<Expression, Type> expressionTypes = getExpressionTypes(context.getSession(), metadata, ImmutableMap.<Symbol, Type>of(), ImmutableList.copyOf(row));
                for (int i = 0; i < row.size(); i++) {
                    // evaluate the literal value
                    Object result = ExpressionInterpreter.expressionInterpreter(row.get(i), metadata, context.getSession(), expressionTypes).evaluate(new BlockCursor[0]);
                    BlockUtils.appendObject(pageBuilder.getBlockBuilder(i), result);
                }
            }

            OperatorFactory operatorFactory = new ValuesOperatorFactory(context.getNextOperatorId(), ImmutableList.of(pageBuilder.build()));
            return new PhysicalOperation(operatorFactory, outputMappings);
        }
View Full Code Here

            // Create lookup source with new data
            LookupSource lookupSource = pagesIndex.createLookupSource(indexChannels);

            // Build a page containing the keys that produced no output rows, so in future requests can skip these keys
            PageBuilder missingKeysPageBuilder = new PageBuilder(missingKeysIndex.getTypes());
            UnloadedIndexKeyRecordCursor unloadedKeyRecordCursor = unloadedKeysRecordSet.cursor();
            while (unloadedKeyRecordCursor.advanceNextPosition()) {
                BlockCursor[] cursors = unloadedKeyRecordCursor.asBlockCursors();
                if (lookupSource.getJoinPosition(cursors) < 0) {
                    for (int i = 0; i < cursors.length; i++) {
                        cursors[i].appendTo(missingKeysPageBuilder.getBlockBuilder(i));
                    }
                }
            }

            // only update missing keys if we have new missing keys
            if (!missingKeysPageBuilder.isEmpty()) {
                missingKeysIndex.addPage(missingKeysPageBuilder.build());
                missingKeys = missingKeysIndex.createLookupSource(missingKeysChannels);
            }

            return new IndexSnapshot(lookupSource, missingKeys);
        }
View Full Code Here

            return pages;
        }

        List<Type> types = getTypes(pages);

        PageBuilder pageBuilder = new PageBuilder(types);

        ImmutableList.Builder<Page> partitionedPages = ImmutableList.builder();
        for (Page page : pages) {
            // open the page
            BlockCursor[] cursors = new BlockCursor[types.size()];
            for (int i = 0; i < cursors.length; i++) {
                cursors[i] = page.getBlock(i).cursor();
            }
            // for each position
            for (int position = 0; position < page.getPositionCount(); position++) {
                // advance all cursors
                for (BlockCursor cursor : cursors) {
                    cursor.advanceNextPosition();
                }

                // if hash is not in range skip
                int partitionHashBucket = getPartitionHashBucket(cursors);
                if (partitionHashBucket != partition) {
                    continue;
                }

                // append row
                for (int channel = 0; channel < cursors.length; channel++) {
                    cursors[channel].appendTo(pageBuilder.getBlockBuilder(channel));
                }

                // if page is full, flush
                if (pageBuilder.isFull()) {
                    partitionedPages.add(pageBuilder.build());
                    pageBuilder.reset();
                }
            }
        }
        if (!pageBuilder.isEmpty()) {
            partitionedPages.add(pageBuilder.build());
        }

        return partitionedPages.build();
    }
View Full Code Here

            columns = new ArrayList<>();
            for (int i = 0; i < types.size(); i++) {
                columns.add(new ArrayList<Block>());
            }

            pageBuilder = new PageBuilder(types);
        }
View Full Code Here

                outputTypes.add(type);

                channel++;
            }

            PageBuilder pageBuilder = new PageBuilder(outputTypes);
            for (List<Expression> row : node.getRows()) {
                pageBuilder.declarePosition();
                IdentityHashMap<Expression, Type> expressionTypes = getExpressionTypes(
                        context.getSession(),
                        metadata,
                        sqlParser,
                        ImmutableMap.<Symbol, Type>of(),
                        ImmutableList.copyOf(row));
                for (int i = 0; i < row.size(); i++) {
                    // evaluate the literal value
                    Object result = ExpressionInterpreter.expressionInterpreter(row.get(i), metadata, context.getSession(), expressionTypes).evaluate(new BlockCursor[0]);
                    BlockUtils.appendObject(pageBuilder.getBlockBuilder(i), result);
                }
            }

            OperatorFactory operatorFactory = new ValuesOperatorFactory(context.getNextOperatorId(), ImmutableList.of(pageBuilder.build()));
            return new PhysicalOperation(operatorFactory, outputMappings);
        }
View Full Code Here

        private boolean finishing;

        public TpchQuery1Operator(OperatorContext operatorContext)
        {
            this.operatorContext = checkNotNull(operatorContext, "operatorContext is null");
            this.pageBuilder = new PageBuilder(TUPLE_INFOS);
        }
View Full Code Here

                outputTypes.add(type);

                channel++;
            }

            PageBuilder pageBuilder = new PageBuilder(outputTypes);
            for (List<Expression> row : node.getRows()) {
                pageBuilder.declarePosition();
                IdentityHashMap<Expression, Type> expressionTypes = getExpressionTypes(
                        context.getSession(),
                        metadata,
                        sqlParser,
                        ImmutableMap.<Symbol, Type>of(),
                        ImmutableList.copyOf(row));
                for (int i = 0; i < row.size(); i++) {
                    // evaluate the literal value
                    Object result = ExpressionInterpreter.expressionInterpreter(row.get(i), metadata, context.getSession(), expressionTypes).evaluate(0);
                    BlockUtils.appendObject(outputTypes.get(i), pageBuilder.getBlockBuilder(i), result);
                }
            }

            OperatorFactory operatorFactory = new ValuesOperatorFactory(context.getNextOperatorId(), outputTypes, ImmutableList.of(pageBuilder.build()));
            return new PhysicalOperation(operatorFactory, outputMappings);
        }
View Full Code Here

TOP

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

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.