danny0405 commented on a change in pull request #2613:
URL: https://github.com/apache/hudi/pull/2613#discussion_r586099830



##########
File path: 
hudi-flink/src/main/java/org/apache/hudi/source/format/FormatUtils.java
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.hudi.source.format;
+
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.log.HoodieMergedLogRecordScanner;
+import org.apache.hudi.hadoop.config.HoodieRealtimeConfig;
+import org.apache.hudi.operator.FlinkOptions;
+import org.apache.hudi.source.format.mor.MergeOnReadInputSplit;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.generic.GenericRecordBuilder;
+import org.apache.avro.generic.IndexedRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Utilities for format.
+ */
+public class FormatUtils {
+  private FormatUtils() {
+  }
+
+  public static GenericRecord buildAvroRecordBySchema(
+      IndexedRecord record,
+      Schema requiredSchema,
+      int[] requiredPos,
+      GenericRecordBuilder recordBuilder) {
+    List<Schema.Field> requiredFields = requiredSchema.getFields();
+    assert (requiredFields.size() == requiredPos.length);
+    Iterator<Integer> positionIterator = Arrays.stream(requiredPos).iterator();
+    requiredFields.forEach(f -> recordBuilder.set(f, 
record.get(positionIterator.next())));
+    return recordBuilder.build();
+  }
+
+  public static HoodieMergedLogRecordScanner scanLog(
+      MergeOnReadInputSplit split,
+      Schema logSchema,
+      Configuration config) {
+    FileSystem fs = FSUtils.getFs(split.getTablePath(), config);
+    return HoodieMergedLogRecordScanner.newBuilder()

Review comment:
       Yes, we can promote it in the future, i'm not plan to do it in this PR.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to