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 static com.facebook.presto.operator.FilterAndProjectOperator.FilterAndProjectOperatorFactory;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
    private final int filterOperatorId;
    private final int[] tupleFilterChannels;
    private final int[] outputFilterChannels;
    private final List<TypeoutputTypes;
    public DynamicTupleFilterFactory(int filterOperatorIdint[] tupleFilterChannelsint[] outputFilterChannelsList<TypeoutputTypes)
    {
        checkNotNull(tupleFilterChannels"tupleFilterChannels is null");
        checkArgument(tupleFilterChannels.length > 0, "Must have at least one tupleFilterChannel");
        checkNotNull(outputFilterChannels"outputFilterChannels is null");
        checkArgument(outputFilterChannels.length == tupleFilterChannels.length"outputFilterChannels must have same length as tupleFilterChannels");
        checkNotNull(outputTypes"outputTypes is null");
        checkArgument(outputTypes.size() >= outputFilterChannels.length"Must have at least as many output channels as those used for filtering");
        this. = filterOperatorId;
        this. = tupleFilterChannels.clone();
        this. = outputFilterChannels.clone();
        this. = ImmutableList.copyOf(outputTypes);
    }
    public OperatorFactory filterWithTuple(Page tuplePage)
    {
        Page normalizedTuplePage = normalizeTuplePage(tuplePage);
        TupleFilterProcessor processor = new TupleFilterProcessor(normalizedTuplePage);
        return new FilterAndProjectOperatorFactory(processor);
    }
    private Page normalizeTuplePage(Page tuplePage)
    {
        Block[] normalizedBlocks = new Block[.];
        for (int i = 0; i < .i++) {
            normalizedBlocks[i] = tuplePage.getBlock([i]);
        }
        return new Page(normalizedBlocks);
    }
New to GrepCode? Check out our FAQ X