Package com.facebook.presto.spi.block

Examples of com.facebook.presto.spi.block.Block


        return encoding;
    }

    private void writeBlock()
    {
        Block block = blockBuilder.build();
        encoding.writeBlock(sliceOutput, block);
        blockBuilder = block.getType().createBlockBuilder(new BlockBuilderStatus());
    }
View Full Code Here


                dictionaryBuilder = new ChannelSetBuilder(block.getType(), MAX_UNIQUE_COUNT, null);
            }

            for (int position = 0; position < block.getPositionCount(); position++) {
                // update run length stats
                Block value = block.getSingleValueBlock(position);
                if (lastValue == null) {
                    lastValue = value;
                }
                else if (!value.equalTo(0, lastValue, 0)) {
                    runsCount++;
                    lastValue = value;
                }

                // update dictionary stats
View Full Code Here

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

            digests.ensureCapacity(groupIdsBlock.getGroupCount());

            Block values = page.getBlock(valueChannel);
            Block percentiles = page.getBlock(percentileChannel);
            Block masks = null;
            if (maskChannel.isPresent()) {
                masks = page.getBlock(maskChannel.get());
            }

            for (int position = 0; position < groupIdsBlock.getPositionCount(); position++) {
                long groupId = groupIdsBlock.getGroupId(position);

                // skip null values
                if (!values.isNull(position) && (masks == null || masks.getBoolean(position))) {
                    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

        @Override
        public void addInput(Page page)
        {
            checkArgument(valueChannel != -1, "Raw input is not allowed for a final aggregation");

            Block values = page.getBlock(valueChannel);
            Block percentiles = page.getBlock(percentileChannel);
            Block masks = null;
            if (maskChannel.isPresent()) {
                masks = page.getBlock(maskChannel.get());
            }

            for (int position = 0; position < page.getPositionCount(); position++) {
                if (!values.isNull(position) && (masks == null || masks.getBoolean(position))) {
                    addValue(digest, position, values, parameterType);
                    if (!percentiles.isNull(position)) {
                        percentile = percentiles.getDouble(position);
                    }
                }
View Full Code Here

        }

        @Override
        public void addInput(Page page)
        {
            Block masks = null;
            if (maskChannel.isPresent()) {
                masks = page.getBlock(maskChannel.get());
            }
            Block sampleWeights = page.getBlock(sampleWeightChannel);

            for (int position = 0; position < page.getPositionCount(); position++) {
                long weight = ApproximateUtils.computeSampleWeight(masks, sampleWeights, position);
                count += weight;
                if (weight > 0) {
View Full Code Here

        @Override
        public void addInput(GroupByIdBlock groupIdsBlock, Page page)
        {
            counts.ensureCapacity(groupIdsBlock.getGroupCount());
            Block masks = maskChannel.isPresent() ? page.getBlock(maskChannel.get()) : null;

            for (int position = 0; position < groupIdsBlock.getPositionCount(); position++) {
                long groupId = groupIdsBlock.getGroupId(position);
                if (masks == null || masks.getBoolean(position)) {
                    counts.increment(groupId);
                }
            }
        }
View Full Code Here

        {
            if (!maskChannel.isPresent()) {
                count += page.getPositionCount();
            }
            else {
                Block masks = page.getBlock(maskChannel.get());
                for (int position = 0; position < page.getPositionCount(); position++) {
                    if (masks == null || masks.getBoolean(position)) {
                        count++;
                    }
                }
            }
        }
View Full Code Here

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

            digests.ensureCapacity(groupIdsBlock.getGroupCount());

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

            for (int position = 0; position < groupIdsBlock.getPositionCount(); position++) {
                long groupId = groupIdsBlock.getGroupId(position);

                // skip null values
                if (!values.isNull(position) && !weights.isNull(position) && (masks == null || masks.getBoolean(position))) {
                    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

        @Override
        public void addInput(Page page)
        {
            checkArgument(valueChannel != -1, "Raw input is not allowed for a final aggregation");

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

            for (int position = 0; position < page.getPositionCount(); position++) {
                if (!values.isNull(position) && !weights.isNull(position) && (masks == null || masks.getBoolean(position))) {
                    addValue(digest, position, values, weights.getLong(position), parameterType);

                    // use last non-null percentile
                    if (!percentiles.isNull(position)) {
                        percentile = percentiles.getDouble(position);
View Full Code Here

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

            groupedState.ensureCapacity(groupIdsBlock.getGroupCount());

            Block values = page.getBlock(valueChannel);
            Block masks = maskChannel.transform(page.blockGetter()).orNull();
            Block sampleWeights = sampleWeightChannel.transform(page.blockGetter()).orNull();

            for (int position = 0; position < groupIdsBlock.getPositionCount(); position++) {
                long sampleWeight = ApproximateUtils.computeSampleWeight(masks, sampleWeights, position);

                if (!values.isNull(position) && sampleWeight > 0) {
View Full Code Here

TOP

Related Classes of com.facebook.presto.spi.block.Block

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.