Package com.facebook.presto.spi.block

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


        if (encoding == null) {
            blockBuilder = block.getType().createBlockBuilder(new BlockBuilderStatus());
            encoding = blockBuilder.getEncoding();
        }
        BlockCursor cursor = block.cursor();
        while (cursor.advanceNextPosition()) {
            cursor.appendTo(blockBuilder);
            if (blockBuilder.isFull()) {
                writeBlock();
            }
        }
View Full Code Here


        if (encoding == null) {
            encoding = new SnappyBlockEncoding(block.getType(), block.getEncoding());
            blockBuilder = block.getType().createBlockBuilder(new BlockBuilderStatus());
        }
        BlockCursor cursor = block.cursor();
        while (cursor.advanceNextPosition()) {
            cursor.appendTo(blockBuilder);
            if (blockBuilder.isFull()) {
                flushBlock();
            }
        }
        return this;
View Full Code Here

        if (type == null) {
            type = block.getType();
            dictionaryBuilder = new DictionaryBuilder(type);
        }

        BlockCursor cursor = block.cursor();
        BlockBuilder idBlockBuilder = BIGINT.createBlockBuilder(new BlockBuilderStatus());
        while (cursor.advanceNextPosition()) {
            int key = dictionaryBuilder.putIfAbsent(cursor);
            idBlockBuilder.appendLong(key);
        }
        idWriter.append(idBlockBuilder.build());
View Full Code Here

    {
        checkNotNull(page, "page is null");
        checkState(state == State.RUNNING, "Operator is %s", state);

        BlockCursor[] cursors;
        BlockCursor sampleWeightCursor = null;
        if (sampleWeightChannel.isPresent()) {
            cursors = new BlockCursor[page.getChannelCount() - 1];
            sampleWeightCursor = page.getBlock(sampleWeightChannel.get()).cursor();
        }
        else {
            cursors = new BlockCursor[recordTypes.size()];
        }

        for (int outputChannel = 0; outputChannel < cursors.length; outputChannel++) {
            cursors[outputChannel] = page.getBlock(inputChannels.get(outputChannel)).cursor();
        }

        int rows = 0;
        for (int position = 0; position < page.getPositionCount(); position++) {
            long sampleWeight = 1;
            if (sampleWeightCursor != null) {
                checkArgument(sampleWeightCursor.advanceNextPosition());
                sampleWeight = sampleWeightCursor.getLong();
            }
            rows += sampleWeight;
            recordSink.beginRecord(sampleWeight);
            for (int i = 0; i < cursors.length; i++) {
                checkArgument(cursors[i].advanceNextPosition());
View Full Code Here

        int blockIndex = decodeSliceIndex(pageAddress);
        int blockPosition = decodePosition(pageAddress);

        for (int i = 0; i < channels.length; i++) {
            int channel = channels[i];
            BlockCursor cursor = cursors[i];

            RandomAccessBlock block = this.channels[channel].get(blockIndex);

            if (!block.equalTo(blockPosition, cursor)) {
                return false;
View Full Code Here

            if (dictionaryBuilder == null) {
                dictionaryBuilder = new DictionaryBuilder(block.getType());
            }

            BlockCursor cursor = block.cursor();
            while (cursor.advanceNextPosition()) {
                // update run length stats
                RandomAccessBlock randomAccessBlock = cursor.getSingleValueBlock();
                if (lastValue == null) {
                    lastValue = randomAccessBlock;
                }
                else if (!randomAccessBlock.equalTo(0, lastValue, 0)) {
                    runsCount++;
View Full Code Here

        // determine maximum shared length
        int length = Integer.MAX_VALUE;
        for (int i = 0; i < iterators.size(); i++) {
            Iterator<? extends Block> iterator = iterators.get(i);

            BlockCursor cursor = cursors.get(i);
            if (cursor.getRemainingPositions() <= 0) {
                // load next block
                cursor = iterator.next().cursor();
                cursors.set(i, cursor);
            }
            length = Math.min(length, cursor.getRemainingPositions());
        }

        // build page
        Block[] blocks = new Block[iterators.size()];
        for (int i = 0; i < cursors.size(); i++) {
View Full Code Here

    public void addInput(Page page)
    {
        checkNotNull(page, "page is null");
        checkState(state == State.RUNNING, "Operator is %s", state);

        BlockCursor rowCountCursor = page.getBlock(0).cursor();
        BlockCursor fragmentCursor = page.getBlock(1).cursor();
        for (int i = 0; i < page.getPositionCount(); i++) {
            checkArgument(rowCountCursor.advanceNextPosition());
            checkArgument(fragmentCursor.advanceNextPosition());
            rowCount += rowCountCursor.getLong();
            fragmentBuilder.add(fragmentCursor.getSlice().toStringUtf8());
        }
    }
View Full Code Here

        // create the block builder for the new boolean column
        // we know the exact size required for the block
        BlockBuilder blockBuilder = BOOLEAN.createFixedSizeBlockBuilder(page.getPositionCount());

        Block probeJoinBlock = page.getBlock(probeJoinChannel);
        BlockCursor probeJoinCursor = probeJoinBlock.cursor();

        // update hashing strategy to use probe cursor
        channelSet.setCurrentValue(probeJoinCursor);

        for (int position = 0; position < page.getPositionCount(); position++) {
            checkState(probeJoinCursor.advanceNextPosition());
            if (probeJoinCursor.isNull()) {
                blockBuilder.appendNull();
            }
            else {
                boolean contains = channelSet.containsCurrentValue();
                if (!contains && channelSet.containsNull()) {
View Full Code Here

        }
    }

    private void addInputWithSampling(Page page, int sampleWeightChannel)
    {
        BlockCursor cursor = page.getBlock(sampleWeightChannel).cursor();
        BlockBuilder builder = BIGINT.createBlockBuilder(new BlockBuilderStatus());

        int rowsToCopy = 0;
        // Build the sample weight block, and count how many rows of data to copy
        while (remainingLimit > 0 && cursor.advanceNextPosition()) {
            rowsToCopy++;
            long sampleWeight = cursor.getLong();
            if (sampleWeight <= remainingLimit) {
                builder.appendLong(sampleWeight);
            }
            else {
                builder.appendLong(remainingLimit);
View Full Code Here

TOP

Related Classes of com.facebook.presto.spi.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.