Package com.facebook.presto.block

Examples of com.facebook.presto.block.BlockCursor


        }

        @Override
        protected void processIntermediate(Block block)
        {
            BlockCursor intermediates = block.cursor();

            for (int position = 0; position < block.getPositionCount(); position++) {
                checkState(intermediates.advanceNextPosition());
                count += intermediates.getLong();
            }
        }
View Full Code Here


        @Override
        protected void processInput(GroupByIdBlock groupIdsBlock, Block valuesBlock, Optional<Block> maskBlock)
        {
            maxValues.ensureCapacity(groupIdsBlock.getGroupCount());

            BlockCursor values = valuesBlock.cursor();

            for (int position = 0; position < groupIdsBlock.getPositionCount(); position++) {
                checkState(values.advanceNextPosition());

                // skip null values
                if (!values.isNull()) {
                    long groupId = groupIdsBlock.getGroupId(position);

                    Slice value = values.getSlice();
                    Slice currentValue = maxValues.get(groupId);
                    if (currentValue == null || value.compareTo(currentValue) > 0) {
                        maxValues.set(groupId, value);

                        // update size
                        if (currentValue != null) {
                            sizeOfValues -= currentValue.length();
                        }
                        sizeOfValues += value.length();
                    }
                }
            }
            checkState(!values.advanceNextPosition());
        }
View Full Code Here

        }

        @Override
        protected void processInput(Block block, Optional<Block> maskBlock)
        {
            BlockCursor values = block.cursor();

            for (int position = 0; position < block.getPositionCount(); position++) {
                checkState(values.advanceNextPosition());
                if (!values.isNull()) {
                    max = max(max, values.getSlice());
                }
            }
        }
View Full Code Here

                    long groupId = groupIdsBlock.getGroupId(position);
                    counts.increment(groupId);
                }
            }
            else {
                BlockCursor cursor = page.getBlock(maskChannel.get()).cursor();
                for (int position = 0; position < groupIdsBlock.getPositionCount(); position++) {
                    long groupId = groupIdsBlock.getGroupId(position);
                    cursor.advanceNextPosition();
                    if (cursor.getBoolean()) {
                        counts.increment(groupId);
                    }
                }
            }
        }
View Full Code Here

        @Override
        public void addIntermediate(GroupByIdBlock groupIdsBlock, Block block)
        {
            counts.ensureCapacity(groupIdsBlock.getGroupCount());

            BlockCursor intermediates = block.cursor();

            for (int position = 0; position < groupIdsBlock.getPositionCount(); position++) {
                checkState(intermediates.advanceNextPosition());

                long groupId = groupIdsBlock.getGroupId(position);
                counts.add(groupId, intermediates.getLong());
            }
        }
View Full Code Here

        {
            if (!maskChannel.isPresent()) {
                count += page.getPositionCount();
            }
            else {
                BlockCursor masks = page.getBlock(maskChannel.get()).cursor();
                while (masks.advanceNextPosition()) {
                    if (masks.getBoolean()) {
                        count++;
                    }
                }
            }
        }
View Full Code Here

        }

        @Override
        public void addIntermediate(Block block)
        {
            BlockCursor intermediates = block.cursor();

            for (int position = 0; position < block.getPositionCount(); position++) {
                checkState(intermediates.advanceNextPosition());
                count += intermediates.getLong();
            }
        }
View Full Code Here

        @Override
        protected void processInput(GroupByIdBlock groupIdsBlock, Block valuesBlock, Optional<Block> maskBlock)
        {
            minValues.ensureCapacity(groupIdsBlock.getGroupCount());

            BlockCursor values = valuesBlock.cursor();

            for (int position = 0; position < groupIdsBlock.getPositionCount(); position++) {
                checkState(values.advanceNextPosition());

                // skip null values
                if (!values.isNull()) {
                    long groupId = groupIdsBlock.getGroupId(position);

                    Slice value = values.getSlice();
                    Slice currentValue = minValues.get(groupId);
                    if (currentValue == null || value.compareTo(currentValue) < 0) {
                        minValues.set(groupId, value);

                        // update size
                        if (currentValue != null) {
                            sizeOfValues -= currentValue.length();
                        }
                        sizeOfValues += value.length();
                    }
                }
            }
            checkState(!values.advanceNextPosition());
        }
View Full Code Here

        }

        @Override
        protected void processInput(Block block, Optional<Block> maskBlock)
        {
            BlockCursor values = block.cursor();

            for (int position = 0; position < block.getPositionCount(); position++) {
                checkState(values.advanceNextPosition());
                if (!values.isNull()) {
                    min = min(min, values.getSlice());
                }
            }
        }
View Full Code Here

        {
            checkArgument(percentileChannel != -1, "Raw input is not allowed for a final aggregation");

            digests.ensureCapacity(groupIdsBlock.getGroupCount());

            BlockCursor values = page.getBlock(valueChannel).cursor();
            BlockCursor weights = page.getBlock(weightChannel).cursor();
            BlockCursor percentiles = page.getBlock(percentileChannel).cursor();
            BlockCursor masks = null;
            if (maskChannel.isPresent()) {
                masks = page.getBlock(maskChannel.get()).cursor();
            }

            for (int position = 0; position < groupIdsBlock.getPositionCount(); position++) {
                checkState(values.advanceNextPosition());
                checkState(weights.advanceNextPosition());
                checkState(percentiles.advanceNextPosition());
                checkState(masks == null || masks.advanceNextPosition());

                long groupId = groupIdsBlock.getGroupId(position);

                // skip null values
                if (!values.isNull() && !weights.isNull() && (masks == null || masks.getBoolean())) {
                    DigestAndPercentile currentValue = digests.get(groupId);
                    if (currentValue == null) {
                        currentValue = new DigestAndPercentile(new QuantileDigest(0.01));
                        digests.set(groupId, currentValue);
                        sizeOfValues += currentValue.getDigest().estimatedInMemorySizeInBytes();
View Full Code Here

TOP

Related Classes of com.facebook.presto.block.BlockCursor

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.