jon-wei commented on a change in pull request #7588: multi-value string column 
support for expressions
URL: https://github.com/apache/incubator-druid/pull/7588#discussion_r291406362
 
 

 ##########
 File path: 
processing/src/main/java/org/apache/druid/segment/virtual/RowBasedExpressionColumnValueSelector.java
 ##########
 @@ -0,0 +1,108 @@
+/*
+ * 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.virtual;
+
+import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import org.apache.druid.math.expr.Expr;
+import org.apache.druid.math.expr.ExprEval;
+import org.apache.druid.math.expr.Parser;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Expression column value selector that examines a set of 'unknown' type 
input bindings on a row by row basis,
+ * transforming the expression to handle multi-value list typed inputs as they 
are encountered.
+ *
+ * Currently, string dimensions are the only bindings which might appear as a 
{@link String} or a {@link String[]}, so
+ * numbers are eliminated from the set of 'unknown' bindings to check as they 
are encountered.
+ */
+public class RowBasedExpressionColumnValueSelector extends 
ExpressionColumnValueSelector
+{
+  private final List<String> unknownColumns;
+  private final Expr.BindingDetails baseExprBindingDetails;
+  private final Set<String> ignoredColumns;
+  private final Int2ObjectMap<Expr> transformedCache;
+
+  public RowBasedExpressionColumnValueSelector(
+      Expr expression,
+      Expr.BindingDetails baseExprBindingDetails,
+      Expr.ObjectBinding bindings,
+      Set<String> unknownColumnsSet
+  )
+  {
+    super(expression, bindings);
+    this.unknownColumns = new ArrayList<>(unknownColumnsSet);
+    this.baseExprBindingDetails = baseExprBindingDetails;
+    this.ignoredColumns = new HashSet<>();
+    this.transformedCache = new Int2ObjectArrayMap(unknownColumns.size());
+  }
+
+  @Override
+  public ExprEval getObject()
+  {
+    // check to find any arrays for this row
+    List<String> arrayBindings =
+        unknownColumns.stream()
+                      .filter(x -> 
!baseExprBindingDetails.getArrayVariables().contains(x) && isBindingArray(x))
 
 Review comment:
   Can `baseExprBindingDetails.getArrayVariables().contains(x)` change across 
rows? If not, maybe that can be moved out of the per-row logic

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to