gianm commented on code in PR #12745: URL: https://github.com/apache/druid/pull/12745#discussion_r917024629
########## processing/src/main/java/org/apache/druid/frame/field/StringFieldReader.java: ########## @@ -0,0 +1,276 @@ +/* + * 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.frame.field; + +import com.google.common.base.Predicate; +import com.google.common.primitives.Ints; +import org.apache.datasketches.memory.Memory; +import org.apache.druid.frame.read.FrameReaderUtils; +import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.query.extraction.ExtractionFn; +import org.apache.druid.query.filter.ValueMatcher; +import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import org.apache.druid.segment.ColumnValueSelector; +import org.apache.druid.segment.DimensionSelector; +import org.apache.druid.segment.DimensionSelectorUtils; +import org.apache.druid.segment.IdLookup; +import org.apache.druid.segment.column.ColumnType; +import org.apache.druid.segment.data.IndexedInts; +import org.apache.druid.segment.data.RangeIndexedInts; + +import javax.annotation.Nullable; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Reads fields written by {@link StringFieldWriter} or {@link StringArrayFieldWriter}. + */ +public class StringFieldReader implements FieldReader +{ + private final boolean asArray; + + StringFieldReader(final boolean asArray) + { + this.asArray = asArray; + } + + @Override + public ColumnValueSelector<?> makeColumnValueSelector(Memory memory, ReadableFieldPointer fieldPointer) + { + return new Selector(memory, fieldPointer, null, asArray); + } + + @Override + public DimensionSelector makeDimensionSelector( + Memory memory, + ReadableFieldPointer fieldPointer, + @Nullable ExtractionFn extractionFn + ) + { + if (asArray) { + throw new ISE("Cannot call makeDimensionSelector on field of type [%s]", ColumnType.STRING_ARRAY); + } + + return new Selector(memory, fieldPointer, extractionFn, false); + } + + @Override + public boolean isComparable() + { + return true; + } + + private static class Selector implements DimensionSelector Review Comment: The Selectors are core Druid things used by the query engines and various other stuff. The main two nonvectorized ones are ColumnValueSelector and DimensionSelector. Their javadocs have some notes about what they are and how they are used. So, this is provided so we have a way to plug frame data into all the other Druid stuff that works with selectors. -- 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]
