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.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 
 public class TaskOutputOperator
         implements Operator
 {
     public static class TaskOutputFactory
             implements OutputFactory
     {
         private final SharedBuffer sharedBuffer;
 
         public TaskOutputFactory(SharedBuffer sharedBuffer)
         {
             this. = checkNotNull(sharedBuffer"sharedBuffer is null");
         }
 
         @Override
         public OperatorFactory createOutputOperator(int operatorIdList<TypesourceType)
         {
             return new TaskOutputOperatorFactory(operatorId);
         }
     }
 
     public static class TaskOutputOperatorFactory
             implements OperatorFactory
     {
         private final int operatorId;
         private final SharedBuffer sharedBuffer;
 
         public TaskOutputOperatorFactory(int operatorIdSharedBuffer sharedBuffer)
         {
             this. = operatorId;
             this. = checkNotNull(sharedBuffer"sharedBuffer is null");
         }
 
         @Override
         public List<TypegetTypes()
         {
             return ImmutableList.of();
         }
 
         @Override
         public Operator createOperator(DriverContext driverContext)
         {
             OperatorContext operatorContext = driverContext.addOperatorContext(TaskOutputOperator.class.getSimpleName());
             return new TaskOutputOperator(operatorContext);
         }
 
         @Override
         public void close()
         {
         }
     }
 
     private final OperatorContext operatorContext;
     private final SharedBuffer sharedBuffer;
     private ListenableFuture<?> blocked = ;
     private boolean finished;
 
     public TaskOutputOperator(OperatorContext operatorContextSharedBuffer sharedBuffer)
     {
         this. = checkNotNull(operatorContext"operatorContext is null");
         this. = checkNotNull(sharedBuffer"sharedBuffer is null");
     }
 
     @Override
     {
         return ;
     }
 
     @Override
     public List<TypegetTypes()
     {
         return ImmutableList.of();
     }
    @Override
    public void finish()
    {
         = true;
    }
    @Override
    public boolean isFinished()
    {
        if ( !=  && .isDone()) {
             = ;
        }
        return  &&  == ;
    }
    @Override
    public ListenableFuture<?> isBlocked()
    {
        if ( !=  && .isDone()) {
             = ;
        }
        return ;
    }
    @Override
    public boolean needsInput()
    {
        if ( !=  && .isDone()) {
             = ;
        }
        return ! &&  == ;
    }
    @Override
    public void addInput(Page page)
    {
        checkNotNull(page"page is null");
        checkState( == "output is already blocked");
        ListenableFuture<?> future = .enqueue(page);
        if (!future.isDone()) {
            this. = future;
        }
    }
    @Override
    public Page getOutput()
    {
        return null;
    }
New to GrepCode? Check out our FAQ X