clintropolis commented on code in PR #12388: URL: https://github.com/apache/druid/pull/12388#discussion_r847924127
########## processing/src/main/java/org/apache/druid/segment/ColumnSelectorColumnIndexSelector.java: ########## @@ -0,0 +1,123 @@ +/* + * 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.collections.bitmap.BitmapFactory; +import org.apache.druid.query.filter.ColumnIndexSelector; +import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; +import org.apache.druid.segment.column.ColumnIndexCapabilities; +import org.apache.druid.segment.column.ColumnIndexSupplier; +import org.apache.druid.segment.column.NumericColumn; +import org.apache.druid.segment.column.SimpleColumnIndexCapabilities; + +import javax.annotation.Nullable; + +/** + */ +public class ColumnSelectorColumnIndexSelector implements ColumnIndexSelector +{ + private final BitmapFactory bitmapFactory; + private final VirtualColumns virtualColumns; + private final ColumnSelector columnSelector; + + public ColumnSelectorColumnIndexSelector( + final BitmapFactory bitmapFactory, + final VirtualColumns virtualColumns, + final ColumnSelector index + ) + { + this.bitmapFactory = bitmapFactory; + this.virtualColumns = virtualColumns; + this.columnSelector = index; + } + + @Override + public int getNumRows() + { + try (final NumericColumn column = (NumericColumn) columnSelector.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getColumn()) { + return column.length(); + } + } + + @Override + public BitmapFactory getBitmapFactory() + { + return bitmapFactory; + } + + @Nullable + @Override + public <T> ColumnIndexCapabilities getIndexCapabilities( + String column, + Class<T> clazz + ) + { + final ColumnIndexSupplier indexSupplier; + if (isVirtualColumn(column)) { + indexSupplier = virtualColumns.getIndexSupplier(column, columnSelector); + } else { + final ColumnHolder columnHolder = columnSelector.getColumnHolder(column); + if (columnHolder == null || !columnHolder.getCapabilities().isFilterable()) { + // if a column doesn't exist or isn't filterable, return true so that callers can use a value matcher to + // either make an all true or all false bitmap if the matcher matches null + return SimpleColumnIndexCapabilities.getConstant(); Review Comment: this is the current contract of `ColumnIndexSelector`, but if this is reworked to produce a `ColumnIndexSupplier` instead of these split methods then it isn't necessary. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
