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.operator.scalar;
 
 
 import static com.facebook.presto.type.TypeUtils.readStructuralBlock;
 import static com.facebook.presto.type.TypeUtils.buildStructuralSlice;
 
 public final class ArrayConcatUtils
 {
     private ArrayConcatUtils() {}
 
     public static Slice concat(Type elementTypeSlice leftSlice right)
     {
         Block leftBlock = readStructuralBlock(left);
         Block rightBlock = readStructuralBlock(right);
         BlockBuilder blockBuilder = new VariableWidthBlockBuilder(new BlockBuilderStatus(), leftBlock.getSizeInBytes() + rightBlock.getSizeInBytes());
         for (int i = 0; i < leftBlock.getPositionCount(); i++) {
             elementType.appendTo(leftBlockiblockBuilder);
         }
         for (int i = 0; i < rightBlock.getPositionCount(); i++) {
             elementType.appendTo(rightBlockiblockBuilder);
         }
         return buildStructuralSlice(blockBuilder);
     }
 
     public static Slice appendElement(Type elementTypeSlice inlong value)
     {
         Block block = readStructuralBlock(in);
         BlockBuilder blockBuilder = new VariableWidthBlockBuilder(new BlockBuilderStatus(), block.getSizeInBytes());
         for (int i = 0; i < block.getPositionCount(); i++) {
             elementType.appendTo(blockiblockBuilder);
         }
 
         elementType.writeLong(blockBuildervalue);
 
         return buildStructuralSlice(blockBuilder);
     }
 
     public static Slice appendElement(Type elementTypeSlice inboolean value)
     {
         Block block = readStructuralBlock(in);
         BlockBuilder blockBuilder = new VariableWidthBlockBuilder(new BlockBuilderStatus(), block.getSizeInBytes());
         for (int i = 0; i < block.getPositionCount(); i++) {
             elementType.appendTo(blockiblockBuilder);
         }
 
         elementType.writeBoolean(blockBuildervalue);
 
         return buildStructuralSlice(blockBuilder);
     }
 
     public static Slice appendElement(Type elementTypeSlice indouble value)
     {
         Block block = readStructuralBlock(in);
         BlockBuilder blockBuilder = new VariableWidthBlockBuilder(new BlockBuilderStatus(), block.getSizeInBytes());
         for (int i = 0; i < block.getPositionCount(); i++) {
             elementType.appendTo(blockiblockBuilder);
         }
 
         elementType.writeDouble(blockBuildervalue);
 
         return buildStructuralSlice(blockBuilder);
     }
 
     public static Slice appendElement(Type elementTypeSlice inSlice value)
     {
         Block block = readStructuralBlock(in);
         BlockBuilder blockBuilder = new VariableWidthBlockBuilder(new BlockBuilderStatus(), block.getSizeInBytes());
         for (int i = 0; i < block.getPositionCount(); i++) {
             elementType.appendTo(blockiblockBuilder);
         }
 
         elementType.writeSlice(blockBuildervalue);
 
         return buildStructuralSlice(blockBuilder);
     }
 
     public static Slice prependElement(Type elementTypeSlice valueSlice in)
     {
         Block block = readStructuralBlock(in);
         BlockBuilder blockBuilder = new VariableWidthBlockBuilder(new BlockBuilderStatus(), block.getSizeInBytes());
        elementType.writeSlice(blockBuildervalue);
        for (int i = 0; i < block.getPositionCount(); i++) {
            elementType.appendTo(blockiblockBuilder);
        }
        return buildStructuralSlice(blockBuilder);
    }
    public static Slice prependElement(Type elementTypelong valueSlice in)
    {
        Block block = readStructuralBlock(in);
        BlockBuilder blockBuilder = new VariableWidthBlockBuilder(new BlockBuilderStatus(), block.getSizeInBytes());
        elementType.writeLong(blockBuildervalue);
        for (int i = 0; i < block.getPositionCount(); i++) {
            elementType.appendTo(blockiblockBuilder);
        }
        return buildStructuralSlice(blockBuilder);
    }
    public static Slice prependElement(Type elementTypeboolean valueSlice in)
    {
        Block block = readStructuralBlock(in);
        BlockBuilder blockBuilder = new VariableWidthBlockBuilder(new BlockBuilderStatus(), block.getSizeInBytes());
        elementType.writeBoolean(blockBuildervalue);
        for (int i = 0; i < block.getPositionCount(); i++) {
            elementType.appendTo(blockiblockBuilder);
        }
        return buildStructuralSlice(blockBuilder);
    }
    public static Slice prependElement(Type elementTypedouble valueSlice in)
    {
        Block block = readStructuralBlock(in);
        BlockBuilder blockBuilder = new VariableWidthBlockBuilder(new BlockBuilderStatus(), block.getSizeInBytes());
        elementType.writeDouble(blockBuildervalue);
        for (int i = 0; i < block.getPositionCount(); i++) {
            elementType.appendTo(blockiblockBuilder);
        }
        return buildStructuralSlice(blockBuilder);
    }
New to GrepCode? Check out our FAQ X