yihua commented on a change in pull request #3778:
URL: https://github.com/apache/hudi/pull/3778#discussion_r734808026



##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/inmemory/HoodieInMemoryHashIndex.java
##########
@@ -7,72 +7,77 @@
  * "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
+ *   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.
+ * 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.hudi.index;
+package org.apache.hudi.index.inmemory;
 
 import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.common.data.HoodieData;
 import org.apache.hudi.common.engine.HoodieEngineContext;
 import org.apache.hudi.common.model.HoodieKey;
 import org.apache.hudi.common.model.HoodieRecord;
 import org.apache.hudi.common.model.HoodieRecordLocation;
 import org.apache.hudi.common.model.HoodieRecordPayload;
 import org.apache.hudi.common.util.Option;
 import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
 import org.apache.hudi.table.HoodieTable;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import java.util.stream.Collectors;
 
 /**
  * Hoodie Index implementation backed by an in-memory Hash map.
  * <p>
  * ONLY USE FOR LOCAL TESTING
  */
-@SuppressWarnings("checkstyle:LineLength")
-public class JavaInMemoryHashIndex<T extends HoodieRecordPayload> extends 
JavaHoodieIndex<T> {
+public class HoodieInMemoryHashIndex<T extends HoodieRecordPayload<T>> extends 
HoodieIndex<T> {
 
   private static ConcurrentMap<HoodieKey, HoodieRecordLocation> 
recordLocationMap;
 
-  public JavaInMemoryHashIndex(HoodieWriteConfig config) {
+  public HoodieInMemoryHashIndex(HoodieWriteConfig config) {
     super(config);
-    synchronized (JavaInMemoryHashIndex.class) {
+    synchronized (HoodieInMemoryHashIndex.class) {
       if (recordLocationMap == null) {
         recordLocationMap = new ConcurrentHashMap<>();
       }
     }
   }
 
   @Override
-  public List<HoodieRecord<T>> tagLocation(List<HoodieRecord<T>> records, 
HoodieEngineContext context,
-                                           HoodieTable<T, 
List<HoodieRecord<T>>, List<HoodieKey>, List<WriteStatus>> hoodieTable) {
-    List<HoodieRecord<T>> taggedRecords = new ArrayList<>();
-    records.stream().forEach(record -> {
-      if (recordLocationMap.containsKey(record.getKey())) {
-        record.unseal();
-        record.setCurrentLocation(recordLocationMap.get(record.getKey()));
-        record.seal();
+  public HoodieData<HoodieRecord<T>> tagLocation(
+      HoodieData<HoodieRecord<T>> records, HoodieEngineContext context,
+      HoodieTable hoodieTable) {
+    return records.mapPartitions(hoodieRecordIterator -> {

Review comment:
       The change here is only regarding the transformations.  For Java List, 
`mapPartitions()` simply falls back to `forEachRemaining()` which is the same 
as `forEach()`.




-- 
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...@hudi.apache.org

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


Reply via email to