Package com.facebook.presto.block

Examples of com.facebook.presto.block.BlockBuilder.build()


        @Override
        public final Block evaluateIntermediate()
        {
            BlockBuilder out = new BlockBuilder(intermediateTupleInfo);
            evaluateIntermediate(out);
            return out.build();
        }

        @Override
        public final Block evaluateFinal()
        {
View Full Code Here


        @Override
        public final Block evaluateFinal()
        {
            BlockBuilder out = new BlockBuilder(finalTupleInfo);
            evaluateFinal(out);
            return out.build();
        }

        protected void evaluateIntermediate(BlockBuilder out)
        {
            evaluateFinal(out);
View Full Code Here

            }
            else {
                blockBuilder.append((double) i);
            }
        }
        return blockBuilder.build();
    }

    @Override
    public Double getExpectedValue(int start, int length)
    {
View Full Code Here

                }
                else {
                    throw new AssertionError("Can only handle longs and doubles");
                }
            }
            Page page = new Page(builder.build());
            page = OperatorAssertion.appendSampleWeight(ImmutableList.of(page), 2).get(0);
            Accumulator accumulator = getFunction().createAggregation(Optional.<Integer>absent(), Optional.of(page.getChannelCount() - 1), getConfidence(), 0);

            accumulator.addInput(page);
            Block result = accumulator.evaluateFinal();
View Full Code Here

            }
            Block[] sourceBlocks = page.getBlocks();
            Block[] outputBlocks = new Block[sourceBlocks.length + 1]; // +1 for the single boolean output channel

            System.arraycopy(sourceBlocks, 0, outputBlocks, 0, sourceBlocks.length);
            outputBlocks[sourceBlocks.length] = blockBuilder.build();

            maskedPages[i] = new Page(outputBlocks);
        }

        return maskedPages;
View Full Code Here

            partialAggregation.addInput(createGroupByIdBlock(0, page.getPositionCount()), page);
        }

        BlockBuilder partialOut = new BlockBuilder(partialAggregation.getIntermediateTupleInfo());
        partialAggregation.evaluateIntermediate(0, partialOut);
        UncompressedBlock partialBlock = partialOut.build();

        GroupedAccumulator finalAggregation = function.createGroupedIntermediateAggregation(confidence);
        // Add an empty block to test the handling of empty intermediates
        GroupedAccumulator emptyAggregation = function.createGroupedAggregation(Optional.<Integer>absent(), Optional.<Integer>absent(), confidence, args);
        BlockBuilder emptyOut = new BlockBuilder(emptyAggregation.getIntermediateTupleInfo());
View Full Code Here

        GroupedAccumulator finalAggregation = function.createGroupedIntermediateAggregation(confidence);
        // Add an empty block to test the handling of empty intermediates
        GroupedAccumulator emptyAggregation = function.createGroupedAggregation(Optional.<Integer>absent(), Optional.<Integer>absent(), confidence, args);
        BlockBuilder emptyOut = new BlockBuilder(emptyAggregation.getIntermediateTupleInfo());
        emptyAggregation.evaluateIntermediate(0, emptyOut);
        UncompressedBlock emptyBlock = emptyOut.build();
        finalAggregation.addIntermediate(createGroupByIdBlock(0, emptyBlock.getPositionCount()), emptyBlock);

        finalAggregation.addIntermediate(createGroupByIdBlock(0, partialBlock.getPositionCount()), partialBlock);

        return getGroupValue(finalAggregation, 0);
View Full Code Here

        BlockBuilder blockBuilder = new BlockBuilder(TupleInfo.SINGLE_LONG);
        for (int i = 0; i < positions; i++) {
            blockBuilder.append(groupId);
        }
        return new GroupByIdBlock(groupId, blockBuilder.build());
    }

    private static int[] createArgs(AggregationFunction function)
    {
        int[] args = new int[function.getParameterTypes().size()];
View Full Code Here

    private static Object getGroupValue(GroupedAccumulator groupedAggregation, int groupId)
    {
        BlockBuilder out = new BlockBuilder(groupedAggregation.getFinalTupleInfo());
        groupedAggregation.evaluateFinal(groupId, out);
        return BlockAssertions.getOnlyValue(out.build());
    }
}
View Full Code Here

                Slice slice = sliceOutput.slice();
                out.append(slice);
            }

            return out.build();
        }

        @Override
        public final Block evaluateFinal()
        {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.