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.index;
 
 
 
 import java.util.List;
 
 import static com.facebook.presto.util.Types.checkType;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 
 public class IndexSourceOperator
         implements SourceOperator
 {
     public static class IndexSourceOperatorFactory
             implements SourceOperatorFactory
     {
         private final int operatorId;
         private final PlanNodeId sourceId;
         private final ConnectorIndex index;
         private final List<Typetypes;
         private final Function<RecordSetRecordSetprobeKeyNormalizer;
         private boolean closed;
 
         public IndexSourceOperatorFactory(
                 int operatorId,
                 PlanNodeId sourceId,
                 ConnectorIndex index,
                 List<Typetypes,
                 Function<RecordSetRecordSetprobeKeyNormalizer)
         {
             this. = operatorId;
             this. = checkNotNull(sourceId"sourceId is null");
             this. = checkNotNull(index"index is null");
             this. = checkNotNull(types"types is null");
             this. = checkNotNull(probeKeyNormalizer"probeKeyNormalizer 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(IndexSourceOperator.class.getSimpleName());
             return new IndexSourceOperator(
                     operatorContext,
                     ,
                     ,
                     ,
                     );
         }
 
         @Override
         public void close()
         {
              = true;
         }
     }
    private final OperatorContext operatorContext;
    private final PlanNodeId planNodeId;
    private final ConnectorIndex index;
    private final List<Typetypes;
    private final Function<RecordSetRecordSetprobeKeyNormalizer;
    @GuardedBy("this")
    private Operator source;
    public IndexSourceOperator(
            OperatorContext operatorContext,
            PlanNodeId planNodeId,
            ConnectorIndex index,
            List<Typetypes,
            Function<RecordSetRecordSetprobeKeyNormalizer)
    {
        this. = checkNotNull(operatorContext"operatorContext is null");
        this. = checkNotNull(planNodeId"planNodeId is null");
        this. = checkNotNull(index"index is null");
        this. = ImmutableList.copyOf(checkNotNull(types"types is null"));
        this. = checkNotNull(probeKeyNormalizer"probeKeyNormalizer is null");
    }
    @Override
    {
        return ;
    }
    @Override
    public PlanNodeId getSourceId()
    {
        return ;
    }
    @Override
    public synchronized void addSplit(Split split)
    {
        checkNotNull(split"split is null");
        checkType(split.getConnectorSplit(), IndexSplit.class"connectorSplit");
        checkState(getSource() == null"Index source split already set");
        IndexSplit indexSplit = (IndexSplitsplit.getConnectorSplit();
        // Normalize the incoming RecordSet to something that can be consumed by the index
        RecordSet normalizedRecordSet = .apply(indexSplit.getKeyRecordSet());
        RecordSet result = .lookup(normalizedRecordSet);
         = new PageSourceOperator(new RecordPageSource(result), result.getColumnTypes(), );
        .setInfoSupplier(Suppliers.ofInstance(split.getInfo()));
    }
    @Override
    public synchronized void noMoreSplits()
    {
        if ( == null) {
             = new FinishedOperator();
        }
    }
    private synchronized Operator getSource()
    {
        return ;
    }
    @Override
    public List<TypegetTypes()
    {
        return ;
    }
    @Override
    public void finish()
    {
        Operator delegate;
        synchronized (this) {
            delegate = getSource();
            if (delegate == null) {
                 = new FinishedOperator();
                return;
            }
        }
        delegate.finish();
    }
    @Override
    public boolean isFinished()
    {
        Operator delegate = getSource();
        return delegate != null && delegate.isFinished();
    }
    @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()
    {
        Operator delegate = getSource();
        if (delegate == null) {
            return null;
        }
        return delegate.getOutput();
    }
New to GrepCode? Check out our FAQ X