Package com.facebook.presto.operator

Examples of com.facebook.presto.operator.PageBuilder


            sampleWeightField = columnTypes.size() - 1;
        }
        else {
            sampleWeightField = -1;
        }
        pageBuilder = new PageBuilder(toTypes(columnTypes));
    }
View Full Code Here


    public void testSum()
            throws Exception
    {
        int sum = 1_000;
        List<TupleInfo> tupleInfos = ImmutableList.of(TupleInfo.SINGLE_LONG, TupleInfo.SINGLE_LONG);
        PageBuilder builder = new PageBuilder(tupleInfos);
        Random rand = new Random(0);
        for (int i = 0; i < sum; i++) {
            if (rand.nextDouble() < 0.5) {
                builder.getBlockBuilder(0).append(1);
                builder.getBlockBuilder(1).append(2);
            }
        }

        AggregationFunction function = new DeterministicBootstrappedAggregation(LONG_SUM);

        assertApproximateAggregation(function, 1, 0.99, (double) sum, builder.build());
    }
View Full Code Here

        int successes = 0;
        Random rand = new Random(0);
        for (int i = 0; i < trials; i++) {
            int sum = 1_000;
            List<TupleInfo> tupleInfos = ImmutableList.of(TupleInfo.SINGLE_LONG, TupleInfo.SINGLE_LONG);
            PageBuilder builder = new PageBuilder(tupleInfos);
            for (int j = 0; j < sum; j++) {
                if (rand.nextDouble() < 0.5) {
                    builder.getBlockBuilder(0).append(1);
                    builder.getBlockBuilder(1).append(2);
                }
            }

            AggregationFunction function = new DeterministicBootstrappedAggregation(LONG_SUM);

            successes += approximateAggregationWithinErrorBound(function, 1, 0.5, (double) sum, builder.build()) ? 1 : 0;
        }

        // Since we used a confidence of 0.5, successes should have a binomial distribution B(n=20, p=0.5)
        assertTrue(binomial.inverseCumulativeProbability(0.01) < successes && successes < binomial.inverseCumulativeProbability(0.99));
    }
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(new TupleInfo(type.getRawType()));

                channel++;
            }

            PageBuilder pageBuilder = new PageBuilder(outputTypes);
            for (List<Expression> row : node.getRows()) {
                for (int i = 0; i < row.size(); i++) {
                    // evaluate the literal value
                    Object result = ExpressionInterpreter.expressionInterpreter(row.get(i), metadata, context.getSession()).evaluate(new TupleReadable[0]);
                    pageBuilder.getBlockBuilder(i).appendObject(result);
                }
            }

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

            sampleWeightField = columnTypes.size() - 1;
        }
        else {
            sampleWeightField = -1;
        }
        pageBuilder = new PageBuilder(tupleInfos);
    }
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

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

            pageBuilder = new PageBuilder(tupleInfos);
        }
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.