rdblue commented on a change in pull request #3501:
URL: https://github.com/apache/iceberg/pull/3501#discussion_r766919048



##########
File path: 
flink/v1.13/flink/src/test/java/org/apache/iceberg/flink/source/split/SplitHelpers.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.iceberg.flink.source.split;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
+import org.apache.iceberg.BaseCombinedScanTask;
+import org.apache.iceberg.CombinedScanTask;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.FileScanTask;
+import org.apache.iceberg.MockFileScanTask;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.data.GenericAppenderHelper;
+import org.apache.iceberg.data.RandomGenericData;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.flink.TestFixtures;
+import org.apache.iceberg.flink.source.FlinkSplitPlanner;
+import org.apache.iceberg.flink.source.ScanContext;
+import org.apache.iceberg.hadoop.HadoopCatalog;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.junit.Assert;
+import org.junit.rules.TemporaryFolder;
+
+public class SplitHelpers {
+
+  private static final AtomicLong splitLengthIncrement = new AtomicLong();
+
+  private SplitHelpers() {
+
+  }
+
+  public static List<IcebergSourceSplit> createMockedSplits(int splitCount) {
+    List<IcebergSourceSplit> splits = new ArrayList<>();
+    for (int i = 0; i < splitCount; ++i) {
+      // make sure each task has a different length,
+      // as it is part of the splitId calculation.
+      // This way, we can make sure all generated splits have different 
splitIds
+      FileScanTask fileScanTask = new MockFileScanTask(1024 + 
splitLengthIncrement.incrementAndGet());
+      CombinedScanTask combinedScanTask = new 
BaseCombinedScanTask(fileScanTask);
+      splits.add(IcebergSourceSplit.fromCombinedScanTask(combinedScanTask));
+    }
+    return splits;
+  }
+
+  /**
+   * Unlike {@link SplitHelpers#createMockedSplits(int)} above, this is to 
generate some
+   * realistic IcebergSourceSplit with actual file paths.
+   *
+   * Actual data files are already deleted before return. Caller shouldn't 
attempt to read the
+   * data files. They are intended for serializer or enumerator unit test 
(without actual reading).
+   */
+  public static List<IcebergSourceSplit> createFileSplits(
+      TemporaryFolder temporaryFolder, int fileCount, int filesPerSplit) 
throws Exception {

Review comment:
       Is there a better name that shows that this is creating a table, writing 
data, and then planning a scan?




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