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.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 import static java.util.Objects.requireNonNull;
 
         implements Operator
 {
     public static class InMemoryExchangeSourceOperatorFactory
             implements OperatorFactory
     {
         private final int operatorId;
         private final InMemoryExchange inMemoryExchange;
         private final boolean broadcast;
         private int bufferIndex;
         private boolean closed;
 
         public static InMemoryExchangeSourceOperatorFactory createRandomDistribution(int operatorIdInMemoryExchange inMemoryExchange)
         {
             requireNonNull(inMemoryExchange"inMemoryExchange is null");
             checkArgument(inMemoryExchange.getBufferCount() == 1, "exchange must have only one buffer");
             return new InMemoryExchangeSourceOperatorFactory(operatorIdinMemoryExchangefalse);
         }
 
         public static InMemoryExchangeSourceOperatorFactory createBroadcastDistribution(int operatorIdInMemoryExchange inMemoryExchange)
         {
             requireNonNull(inMemoryExchange"inMemoryExchange is null");
             checkArgument(inMemoryExchange.getBufferCount() > 1, "exchange must have more than one buffer");
             return new InMemoryExchangeSourceOperatorFactory(operatorIdinMemoryExchangetrue);
         }
 
         private InMemoryExchangeSourceOperatorFactory(int operatorIdInMemoryExchange inMemoryExchangeboolean broadcast)
         {
             this. = operatorId;
             this. = requireNonNull(inMemoryExchange"inMemoryExchange is null");
             checkArgument( < inMemoryExchange.getBufferCount());
             this. = broadcast;
         }
 
         @Override
         public List<TypegetTypes()
         {
             return .getTypes();
         }
 
         @Override
         public Operator createOperator(DriverContext driverContext)
         {
             checkState(!"Factory is already closed");
             checkState( < .getBufferCount(), "All operators already created");
             OperatorContext operatorContext = driverContext.addOperatorContext(InMemoryExchangeSourceOperator.class.getSimpleName());
             Operator operator = new InMemoryExchangeSourceOperator(operatorContext);
             if () {
                 ++;
             }
             return operator;
         }
 
         @Override
         public void close()
         {
              = true;
         }
     }
 
     private final OperatorContext operatorContext;
     private final InMemoryExchange exchange;
     private final int bufferIndex;
 
     public InMemoryExchangeSourceOperator(OperatorContext operatorContextInMemoryExchange exchangeint bufferIndex)
     {
         this. = checkNotNull(operatorContext"operatorContext is null");
         this. = checkNotNull(exchange"exchange is null");
         checkArgument(bufferIndex < exchange.getBufferCount());
         this. = bufferIndex;
     }
 
     @Override
    {
        return ;
    }
    @Override
    public List<TypegetTypes()
    {
        return .getTypes();
    }
    @Override
    public void finish()
    {
        .finish();
    }
    @Override
    public boolean isFinished()
    {
        return .isFinished();
    }
    @Override
    public ListenableFuture<?> isBlocked()
    {
        ListenableFuture<?> blocked = .waitForReading();
        if (blocked.isDone()) {
            return ;
        }
        return blocked;
    }
    @Override
    public boolean needsInput()
    {
        return false;
    }
    @Override
    public void addInput(Page page)
    {
        throw new UnsupportedOperationException();
    }
    @Override
    public Page getOutput()
    {
        Page page = .removePage();
        if (page != null) {
        }
        return page;
    }
    @Override
    public void close()
            throws Exception
    {
        finish();
    }
New to GrepCode? Check out our FAQ X