StephanEwen commented on a change in pull request #13401:
URL: https://github.com/apache/flink/pull/13401#discussion_r491929322



##########
File path: 
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/src/FileSourceSplit.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.flink.connector.file.src;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.api.connector.source.SourceSplit;
+import org.apache.flink.core.fs.Path;
+
+import javax.annotation.Nullable;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+import static org.apache.flink.util.Preconditions.checkArgument;
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * A {@link SourceSplit} that represents a file, or a region of a file.
+ */
+@PublicEvolving
+public class FileSourceSplit implements SourceSplit, Serializable {
+
+       private static final long serialVersionUID = 1L;
+
+       private static final String[] NO_HOSTS = new String[0];
+
+       /** The unique ID of the split. Unique within the scope of this source. 
*/
+       private final String id;
+
+       /** The path of the file referenced by this split. */
+       private final Path filePath;
+
+       /** The position of the first byte in the file to process. */
+       private final long offset;
+
+       /** The number of bytes in the file to process. */
+       private final long length;
+
+       /** The number of records to be skipped from the beginning of the split.
+        * This is for file formats that cannot pinpoint every exact record 
position via an offset,
+        * due to read buffers or bulk encoding or compression. */
+       private final long skippedRecordCount;
+
+       /** The names of the hosts storing this range of the file. Empty, if no 
host information is available. */
+       private final String[] hostnames;
+
+       /** The splits are frequently serialized into checkpoints.
+        * Caching the byte representation makes repeated serialization cheap.
+        * This field is used by {@link FileSourceSplitSerializer}. */
+       @Nullable
+       transient byte[] serializedFormCache;

Review comment:
       The current implementation does not exploit this, true. We could change 
it such that it only creates a new `PendingSplitsCheckpoint` instance if there 
was a change.
   
   I added the caching symmetrically to the `FileSourceSplit` because it is 
"hidden" (adds no complexity for the user) and comes for free (no extra work 
done).




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