Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.testing;
import static com.google.common.base.Preconditions.checkNotNull;
        implements BlockEncoding
    private static final String NAME = "RLE";
    private final BlockEncoding valueBlockEncoding;
    public RunLengthBlockEncoding(BlockEncoding valueBlockEncoding)
    {
        this. = checkNotNull(valueBlockEncoding"valueBlockEncoding is null");
    }
    @Override
    public String getName()
    {
        return ;
    }
    {
        return ;
    }
    @Override
    public void writeBlock(SliceOutput sliceOutputBlock block)
    {
        RunLengthEncodedBlock rleBlock = (RunLengthEncodedBlockblock;
        // write the run length
        sliceOutput.writeInt(rleBlock.getPositionCount());
        // write the value
        getValueBlockEncoding().writeBlock(sliceOutputrleBlock.getValue());
    }
    @Override
    public RunLengthEncodedBlock readBlock(SliceInput sliceInput)
    {
        // read the run length
        int positionCount = sliceInput.readInt();
        // read the value
        Block value = getValueBlockEncoding().readBlock(sliceInput);
        return new RunLengthEncodedBlock(valuepositionCount);
    }
    private static class RunLengthBlockEncodingFactory
            implements BlockEncodingFactory<RunLengthBlockEncoding>
    {
        @Override
        public String getName()
        {
            return ;
        }
        @Override
        public RunLengthBlockEncoding readEncoding(TypeManager managerBlockEncodingSerde serdeSliceInput input)
        {
            BlockEncoding valueBlockEncoding = serde.readBlockEncoding(input);
            return new RunLengthBlockEncoding(valueBlockEncoding);
        }
        @Override
        public void writeEncoding(BlockEncodingSerde serdeSliceOutput outputRunLengthBlockEncoding blockEncoding)
        {
            serde.writeBlockEncoding(outputblockEncoding.getValueBlockEncoding());
        }
    }
New to GrepCode? Check out our FAQ X