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.split;
 
 
 import java.util.List;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
 public class MappedRecordSet
         implements RecordSet
 {
     private final RecordSet delegate;
     private final int[] delegateFieldIndex;
     private final List<TypecolumnTypes;
 
     public MappedRecordSet(RecordSet delegateList<IntegerdelegateFieldIndex)
     {
         this. = delegate;
         this. = new int[delegateFieldIndex.size()];
         for (int i = 0; i < delegateFieldIndex.size(); i++) {
             this.[i] = delegateFieldIndex.get(i);
         }
 
         List<TypedelegateColumnTypes = delegate.getColumnTypes();
         ImmutableList.Builder<TypecolumnTypes = ImmutableList.builder();
         for (int delegateField : delegateFieldIndex) {
             checkArgument(delegateField >= 0 && delegateField < delegateColumnTypes.size(), "Invalid system field %s"delegateField);
             columnTypes.add(delegateColumnTypes.get(delegateField));
         }
         this. = columnTypes.build();
     }
 
     @Override
     public List<TypegetColumnTypes()
     {
         return ;
     }
 
     @Override
     public RecordCursor cursor()
     {
         return new MappedRecordCursor(.cursor(), );
     }
 
     private static class MappedRecordCursor
             implements RecordCursor
     {
         private final RecordCursor delegate;
         private final int[] delegateFieldIndex;
 
         private MappedRecordCursor(RecordCursor delegateint[] delegateFieldIndex)
         {
             this. = delegate;
             this. = delegateFieldIndex;
         }
 
         @Override
         public long getTotalBytes()
         {
             return .getTotalBytes();
         }
 
         @Override
         public long getCompletedBytes()
         {
             return .getCompletedBytes();
         }
 
         @Override
         public long getReadTimeNanos()
         {
             return .getReadTimeNanos();
         }
 
         @Override
         public Type getType(int field)
         {
             return .getType(toDelegateField(field));
         }
 
         @Override
         public boolean advanceNextPosition()
        {
            return .advanceNextPosition();
        }
        @Override
        public boolean getBoolean(int field)
        {
            return .getBoolean(toDelegateField(field));
        }
        @Override
        public long getLong(int field)
        {
            return .getLong(toDelegateField(field));
        }
        @Override
        public double getDouble(int field)
        {
            return .getDouble(toDelegateField(field));
        }
        @Override
        public Slice getSlice(int field)
        {
            return .getSlice(toDelegateField(field));
        }
        @Override
        public boolean isNull(int field)
        {
            return .isNull(toDelegateField(field));
        }
        @Override
        public void close()
        {
            .close();
        }
        private int toDelegateField(int field)
        {
            checkArgument(field >= 0, "field is negative");
            checkArgument(field < .);
            return [field];
        }
    }
New to GrepCode? Check out our FAQ X