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;
 
 
 
 import java.util.List;
 
 import static com.facebook.presto.operator.FinishedPageSource.FINISHED_PAGE_SOURCE;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 
 public class TableScanOperator
         implements SourceOperatorCloseable
 {
     public static class TableScanOperatorFactory
             implements SourceOperatorFactory
     {
         private final int operatorId;
         private final PlanNodeId sourceId;
         private final PageSourceProvider pageSourceProvider;
         private final List<Typetypes;
         private final List<ColumnHandlecolumns;
         private boolean closed;
 
         public TableScanOperatorFactory(
                 int operatorId,
                 PlanNodeId sourceId,
                 PageSourceProvider pageSourceProvider,
                 List<Typetypes,
                 Iterable<ColumnHandlecolumns)
         {
             this. = operatorId;
             this. = checkNotNull(sourceId"sourceId is null");
             this. = checkNotNull(types"types is null");
             this. = checkNotNull(pageSourceProvider"pageSourceManager is null");
             this. = ImmutableList.copyOf(checkNotNull(columns"columns is null"));
         }
 
         @Override
         public PlanNodeId getSourceId()
         {
             return ;
         }
 
         @Override
         public List<TypegetTypes()
         {
             return ;
         }
 
         @Override
         public SourceOperator createOperator(DriverContext driverContext)
         {
             checkState(!"Factory is already closed");
             OperatorContext operatorContext = driverContext.addOperatorContext(TableScanOperator.class.getSimpleName());
             return new TableScanOperator(
                     operatorContext,
                     ,
                     ,
                     ,
                     );
         }
 
         @Override
         public void close()
         {
              = true;
         }
     }
 
     private final OperatorContext operatorContext;
     private final PlanNodeId planNodeId;
    private final PageSourceProvider pageSourceProvider;
    private final List<Typetypes;
    private final List<ColumnHandlecolumns;
    private final SettableFuture<?> blocked;
    @GuardedBy("this")
    private ConnectorPageSource source;
    private long completedBytes;
    private long readTimeNanos;
    public TableScanOperator(
            OperatorContext operatorContext,
            PlanNodeId planNodeId,
            PageSourceProvider pageSourceProvider,
            List<Typetypes,
            Iterable<ColumnHandlecolumns)
    {
        this. = checkNotNull(operatorContext"operatorContext is null");
        this. = checkNotNull(planNodeId"planNodeId is null");
        this. = checkNotNull(types"types is null");
        this. = checkNotNull(pageSourceProvider"pageSourceManager is null");
        this. = ImmutableList.copyOf(checkNotNull(columns"columns is null"));
        this. = SettableFuture.create();
    }
    @Override
    {
        return ;
    }
    @Override
    public PlanNodeId getSourceId()
    {
        return ;
    }
    @Override
    public synchronized void addSplit(Split split)
    {
        checkNotNull(split"split is null");
        checkState(getSource() == null"Table scan split already set");
        Object splitInfo = split.getInfo();
        if (splitInfo != null) {
            .setInfoSupplier(Suppliers.ofInstance(splitInfo));
        }
        .set(null);
    }
    @Override
    public synchronized void noMoreSplits()
    {
        if ( == null) {
             = ;
        }
    }
    private synchronized ConnectorPageSource getSource()
    {
        return ;
    }
    @Override
    public List<TypegetTypes()
    {
        return ;
    }
    @Override
    public synchronized void close()
    {
        finish();
    }
    @Override
    public void finish()
    {
        ConnectorPageSource delegate = getSource();
        if (delegate == null) {
            return;
        }
        try {
            delegate.close();
        }
        catch (IOException e) {
            throw Throwables.propagate(e);
        }
    }
    @Override
    public boolean isFinished()
    {
        ConnectorPageSource delegate = getSource();
        return delegate != null && delegate.isFinished();
    }
    @Override
    public ListenableFuture<?> isBlocked()
    {
        ConnectorPageSource delegate = getSource();
        if (delegate != null) {
            return ;
        }
        return ;
    }
    @Override
    public boolean needsInput()
    {
        return false;
    }
    @Override
    public void addInput(Page page)
    {
        throw new UnsupportedOperationException(getClass().getName() + " can not take input");
    }
    @Override
    public Page getOutput()
    {
        ConnectorPageSource delegate = getSource();
        if (delegate == null) {
            return null;
        }
        Page page = delegate.getNextPage();
        if (page != null) {
            // assure the page is in memory before handing to another operator
            page.assureLoaded();
            // update operator stats
            long endCompletedBytes = delegate.getCompletedBytes();
            long endReadTimeNanos = delegate.getReadTimeNanos();
            .recordGeneratedInput(endCompletedBytes - page.getPositionCount(), endReadTimeNanos - );
             = endCompletedBytes;
             = endReadTimeNanos;
        }
        return page;
    }
New to GrepCode? Check out our FAQ X