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


##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/join/PrimitiveLookupTable.java:
##########
@@ -0,0 +1,104 @@
+/**
+ * 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.query.runtime.operator.join;
+
+import com.google.common.collect.Sets;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import javax.annotation.Nullable;
+
+
+public abstract class PrimitiveLookupTable extends LookupTable {
+
+  private Object _valueForNullKey;
+
+  @Override
+  public void addRow(@Nullable Object key, Object[] row) {
+    if (key == null) {
+      _valueForNullKey = computeNewValue(row, _valueForNullKey);
+      return;
+    }
+    addRowNotNullKey(key, row);
+  }
+
+  @Override
+  public void finish() {
+    if (!_keysUnique) {
+      if (_valueForNullKey != null) {
+        _valueForNullKey = convertArrayToList(_valueForNullKey);
+      }
+      finishNotNullKey();
+    }
+  }
+
+  protected abstract void finishNotNullKey();
+
+  protected abstract void addRowNotNullKey(Object key, Object[] row);
+
+  @Override
+  public boolean containsKey(@Nullable Object key) {
+    if (key == null) {
+      return _valueForNullKey != null;
+    }
+    return containsNotNullKey(key);
+  }
+
+  protected abstract boolean containsNotNullKey(Object key);
+
+  @Nullable
+  @Override
+  public Object lookup(@Nullable Object key) {
+    if (key == null) {
+      return _valueForNullKey;
+    }
+    return lookupNotNullKey(key);
+  }
+
+  protected abstract Object lookupNotNullKey(Object key);
+
+  @SuppressWarnings("rawtypes")
+  @Override
+  public Set<Map.Entry> entrySet() {
+    Set notNullSet = notNullKeyEntrySet();
+    if (_valueForNullKey != null) {
+      HashSet<Map.Entry<Object, Object>> nullEntry = Sets.newHashSet(new 
Map.Entry<Object, Object>() {

Review Comment:
   I've decided to use the Set.of solution



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