You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "gortiz (via GitHub)" <gi...@apache.org> on 2023/03/17 07:28:05 UTC

[GitHub] [pinot] gortiz commented on a diff in pull request #10361: Data visitors

gortiz commented on code in PR #10361:
URL: https://github.com/apache/pinot/pull/10361#discussion_r1139869079


##########
pinot-spi/src/main/java/org/apache/pinot/spi/data/MultiValueVisitor.java:
##########
@@ -0,0 +1,99 @@
+/**
+ * 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.pinot.spi.data;
+
+import java.math.BigDecimal;
+
+
+public interface MultiValueVisitor<R> {
+
+  R visitInt(int[] value);

Review Comment:
   Yep, usually is better to return something in visitors. Otherwise _visitors that return_ should store some state that the caller has to consult later with a getter method. That means that the visitor must be stateful and the code will be uglier. Instead, if you let visitor to return, it will be easier to use from caller perspective and you can always use Void when not needed.
   
   In fact, in a previous life when I heavily use visitors, I usually introduce a second generic `A` (from Argument) that was used to pass contextual information to the visitor. Visit methods were defined as `R visit(SomeClass value, A argument)`. By doing that visitor instances are almost always stateless. I didn't do that here because it is not a well common pattern and didn't want to make it too complex.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org