org.apache.druid.segment.UnnestColumnValueSelectorCursor Maven / Gradle / Ivy
Show all versions of druid-processing Show documentation
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.druid.segment;
import org.apache.druid.java.util.common.UOE;
import org.apache.druid.query.BaseQuery;
import org.apache.druid.query.dimension.DimensionSpec;
import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector;
import org.apache.druid.segment.column.ColumnCapabilities;
import org.apache.druid.segment.column.ColumnCapabilitiesImpl;
import org.joda.time.DateTime;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* The cursor to help unnest MVDs without dictionary encoding and ARRAY type selectors.
*
* Consider a segment has 2 rows
* ['a', 'b', 'c']
* ['d', 'e']
*
* The baseCursor points to the row ['a', 'b', 'c']
* while the unnestCursor with each call of advance() moves over individual elements.
*
* unnestCursor.advance() -> 'a'
* unnestCursor.advance() -> 'b'
* unnestCursor.advance() -> 'c'
* unnestCursor.advance() -> 'd' (advances base cursor first)
* unnestCursor.advance() -> 'e'
*
*
* The index reference points to the index of each row that the unnest cursor is accessing through currentVal
* The index ranges from 0 to the size of the list in each row which is held in the unnestListForCurrentRow
*
* The needInitialization flag sets up the initial values of unnestListForCurrentRow at the beginning of the segment
*/
public class UnnestColumnValueSelectorCursor implements Cursor
{
private final Cursor baseCursor;
private final ColumnSelectorFactory baseColumnSelectorFactory;
private final ColumnValueSelector columnValueSelector;
private final VirtualColumn unnestColumn;
private final String outputName;
private int index;
private Object currentVal;
private List