FrankChen021 commented on code in PR #19947:
URL: https://github.com/apache/druid/pull/19947#discussion_r3749649087


##########
processing/src/main/java/org/apache/druid/segment/vector/ReverseVectorColumnSelectorFactory.java:
##########
@@ -0,0 +1,421 @@
+/*
+ * 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.vector;
+
+import org.apache.druid.query.dimension.DimensionSpec;
+import org.apache.druid.segment.DimensionDictionarySelector;
+import org.apache.druid.segment.IdLookup;
+import org.apache.druid.segment.column.ColumnCapabilities;
+import org.apache.druid.segment.data.IndexedInts;
+
+import javax.annotation.Nullable;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Wraps a {@link VectorColumnSelectorFactory} whose underlying offset 
iterates batches in descending order (see
+ * {@link DescendingNoFilterVectorOffset} and {@link 
DescendingBitmapVectorOffset}). The underlying offset generates
+ * batches in descending order (from the end of the segment to the start), but 
each batch is internally in ascending
+ * order. This class reverses each batch internally, to provide an overall 
descending order.
+ *
+ * <p>Reversing is done here (on already-decoded vectors) so that low-level 
column readers only ever need to return
+ * batches in internally-ascending order. This allows them to be simpler, as 
they do not need to have handling for
+ * both ascending and descending order.
+ */
+public class ReverseVectorColumnSelectorFactory implements 
VectorColumnSelectorFactory

Review Comment:
   [P2] Reverse factory bypasses virtual-column group-by handling
   
   The wrapper inherits the generic makeGroupByVectorColumnSelector 
implementation instead of preserving the underlying factory's virtual-column 
specialization. A descending vectorized group-by using an 
ExpressionVirtualColumn can therefore reach the generic ARRAY processor and 
fail with UnsupportedOperationException instead of using the supported deferred 
expression selector. Add a reverse-aware group-by override and regression 
coverage.



-- 
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]

Reply via email to