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 java.util.Set;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 
 public class DriverFactory
         implements Closeable
 {
     private final boolean inputDriver;
     private final boolean outputDriver;
     private final List<OperatorFactoryoperatorFactories;
     private final Set<PlanNodeIdsourceIds;
     private final int driverInstances;
     private boolean closed;
 
     public DriverFactory(boolean inputDriverboolean outputDriverOperatorFactory firstOperatorFactoryOperatorFactory... otherOperatorFactories)
     {
         this(inputDriver,
                 outputDriver,
                 ImmutableList.<OperatorFactory>builder()
                         .add(checkNotNull(firstOperatorFactory"firstOperatorFactory is null"))
                         .add(checkNotNull(otherOperatorFactories"otherOperatorFactories is null"))
                         .build(),
                 1);
     }
 
     public DriverFactory(boolean inputDriverboolean outputDriverList<OperatorFactoryoperatorFactories)
     {
         this(inputDriveroutputDriveroperatorFactories, 1);
     }
 
     public DriverFactory(boolean inputDriverboolean outputDriverList<OperatorFactoryoperatorFactoriesint driverInstances)
     {
         this. = inputDriver;
         this. = outputDriver;
         this. = ImmutableList.copyOf(checkNotNull(operatorFactories"operatorFactories is null"));
         checkArgument(!operatorFactories.isEmpty(), "There must be at least one operator");
         this. = driverInstances;
 
         ImmutableSet.Builder<PlanNodeIdsourceIds = ImmutableSet.builder();
         for (OperatorFactory operatorFactory : operatorFactories) {
             if (operatorFactory instanceof SourceOperatorFactory) {
                 SourceOperatorFactory sourceOperatorFactory = (SourceOperatorFactoryoperatorFactory;
                 sourceIds.add(sourceOperatorFactory.getSourceId());
             }
         }
         this. = sourceIds.build();
     }
 
     public boolean isInputDriver()
     {
         return ;
     }
 
     public boolean isOutputDriver()
     {
         return ;
     }
 
     public Set<PlanNodeIdgetSourceIds()
     {
         return ;
     }
 
     public synchronized Driver createDriver(DriverContext driverContext)
     {
         checkState(!"DriverFactory is already closed");
         checkNotNull(driverContext"driverContext is null");
         ImmutableList.Builder<Operatoroperators = ImmutableList.builder();
         for (OperatorFactory operatorFactory : ) {
             Operator operator = operatorFactory.createOperator(driverContext);
             operators.add(operator);
         }
         return new Driver(driverContextoperators.build());
     }
 
     @Override
    public synchronized void close()
    {
        if (!) {
             = true;
            for (OperatorFactory operatorFactory : ) {
                operatorFactory.close();
            }
        }
    }
    public int getDriverInstances()
    {
        return ;
    }
New to GrepCode? Check out our FAQ X