Jackie-Jiang commented on a change in pull request #7087: URL: https://github.com/apache/incubator-pinot/pull/7087#discussion_r660140790
########## File path: pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/merger/UnionMerger.java ########## @@ -0,0 +1,47 @@ +/** + * 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.segment.local.upsert.merger; + +import java.util.Set; +import java.util.TreeSet; + + +public class UnionMerger implements PartialUpsertMerger { + UnionMerger() { + } + + /** + * Append the new value from incoming row to the given multi-value field of previous record. + */ + @Override + public Object merge(Object previousValue, Object currentValue) { + return union((Object[]) previousValue, (Object[]) currentValue); + } + + private static Object union(Object[] a, Object[] b) { + Set<Object> union = new TreeSet<>(); + for (int i = 0; i < a.length; i++) { Review comment: (minor) ```suggestion for (int value: a) { ``` ########## File path: pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/merger/AppendMerger.java ########## @@ -0,0 +1,48 @@ +/** + * 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.segment.local.upsert.merger; + + + +public class AppendMerger implements PartialUpsertMerger { + AppendMerger() { + } + + /** + * Append the new value from incoming row to the given multi-value field of previous record. + */ + @Override + public Object merge(Object previousValue, Object currentValue) { + return append((Object[]) previousValue, (Object[]) currentValue); + } + + private static Object append(Object[] a, Object[] b) { + Object[] merged = new Object[a.length + b.length]; + int count = 0; + + for (int i = 0; i < a.length; i++) { Review comment: Use `System.arraycopy()` instead of for loop for better performance ########## File path: pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java ########## @@ -385,6 +387,14 @@ static void validatePartialUpsertStrategies(TableConfig tableConfig, Schema sche Preconditions.checkState(!schema.getDateTimeNames().contains(column), "INCREMENT merger cannot be applied to date time column: %s", column); } + + if (entry.getValue() == UpsertConfig.Strategy.APPEND || entry.getValue() == UpsertConfig.Strategy.UNION) { Review comment: Cache `entry.getValue()` to a local variable -- 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-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org