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 SetBuilderOperator
         implements Operator
 {
     public static class SetSupplier
     {
         private final Type type;
         private final SettableFuture<ChannelSetchannelSetFuture = SettableFuture.create();
 
         public SetSupplier(Type type)
         {
             this. = checkNotNull(type"type is null");
         }
 
         public Type getType()
         {
             return ;
         }
 
         public ListenableFuture<ChannelSetgetChannelSet()
         {
             return ;
         }
 
         void setChannelSet(ChannelSet channelSet)
         {
             boolean wasSet = .set(checkNotNull(channelSet"channelSet is null"));
             checkState(wasSet"ChannelSet already set");
         }
     }
 
     public static class SetBuilderOperatorFactory
             implements OperatorFactory
     {
         private final int operatorId;
         private final Optional<IntegerhashChannel;
         private final SetSupplier setProvider;
         private final int setChannel;
         private final int expectedPositions;
         private boolean closed;
 
         public SetBuilderOperatorFactory(
                 int operatorId,
                 List<Typetypes,
                 int setChannel,
                 Optional<IntegerhashChannel,
                 int expectedPositions)
         {
             this. = operatorId;
             Preconditions.checkArgument(setChannel >= 0, "setChannel is negative");
             this. = new SetSupplier(checkNotNull(types"types is null").get(setChannel));
             this. = setChannel;
             this. = checkNotNull(hashChannel"hashChannel is null");
             this. = expectedPositions;
         }
 
         public SetSupplier getSetProvider()
         {
             return ;
         }
 
         @Override
         public List<TypegetTypes()
         {
             return ImmutableList.of();
         }
 
        @Override
        public Operator createOperator(DriverContext driverContext)
        {
            checkState(!"Factory is already closed");
            OperatorContext operatorContext = driverContext.addOperatorContext(SetBuilderOperator.class.getSimpleName());
            return new SetBuilderOperator(operatorContext);
        }
        @Override
        public void close()
        {
             = true;
        }
    }
    private final OperatorContext operatorContext;
    private final SetSupplier setSupplier;
    private final int setChannel;
    private final Optional<IntegerhashChannel;
    private final ChannelSetBuilder channelSetBuilder;
    private boolean finished;
    public SetBuilderOperator(
            OperatorContext operatorContext,
            SetSupplier setSupplier,
            int setChannel,
            Optional<IntegerhashChannel,
            int expectedPositions)
    {
        this. = checkNotNull(operatorContext"operatorContext is null");
        this. = checkNotNull(setSupplier"setProvider is null");
        this. = setChannel;
        this. = checkNotNull(hashChannel"hashChannel is null");
        // Set builder is has a single channel which goes in channel 0, if hash is present, add a hachBlock to channel 1
        Optional<IntegerchannelSetHashChannel = hashChannel.isPresent() ? Optional.of(1) : Optional.empty();
        this. = new ChannelSetBuilder(
                setSupplier.getType(),
                channelSetHashChannel,
                expectedPositions,
                checkNotNull(operatorContext"operatorContext is null"));
    }
    @Override
    {
        return ;
    }
    @Override
    public List<TypegetTypes()
    {
        return ImmutableList.of();
    }
    @Override
    public void finish()
    {
        if () {
            return;
        }
        ChannelSet channelSet = .build();
        .setChannelSet(channelSet);
        .recordGeneratedOutput(channelSet.getEstimatedSizeInBytes(), channelSet.size());
         = true;
    }
    @Override
    public boolean isFinished()
    {
        return ;
    }
    @Override
    public boolean needsInput()
    {
        return !;
    }
    @Override
    public void addInput(Page page)
    {
        checkNotNull(page"page is null");
        checkState(!isFinished(), "Operator is already finished");
        Block sourceBlock = page.getBlock();
        Page sourcePage = .isPresent() ? new Page(sourceBlockpage.getBlock(.get())) : new Page(sourceBlock);
        .addPage(sourcePage);
    }
    @Override
    public Page getOutput()
    {
        return null;
    }
New to GrepCode? Check out our FAQ X