Repository: beam
Updated Branches:
  refs/heads/master 61790f038 -> 07a49e90b


Rename filePath to filePattern in NumbedShardedFile

This probably would have saved a few hours of debugging by
signposting the intended usage more clearly.


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/797f4f8b
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/797f4f8b
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/797f4f8b

Branch: refs/heads/master
Commit: 797f4f8bc3bf69e630753f0219e220a8a9d80e2d
Parents: db3144b
Author: Kenneth Knowles <[email protected]>
Authored: Tue Apr 4 10:23:54 2017 -0700
Committer: Kenneth Knowles <[email protected]>
Committed: Tue Apr 4 10:23:54 2017 -0700

----------------------------------------------------------------------
 .../beam/sdk/util/NumberedShardedFile.java      | 30 ++++++++++----------
 1 file changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/797f4f8b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/NumberedShardedFile.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/main/java/org/apache/beam/sdk/util/NumberedShardedFile.java
 
b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/NumberedShardedFile.java
index f9f2d6d..740aa46 100644
--- 
a/sdks/java/core/src/main/java/org/apache/beam/sdk/util/NumberedShardedFile.java
+++ 
b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/NumberedShardedFile.java
@@ -64,43 +64,43 @@ public class NumberedShardedFile implements ShardedFile {
   private static final Pattern DEFAULT_SHARD_TEMPLATE =
       Pattern.compile("(?x) \\S* (?<shardnum> \\d+) -of- (?<numshards> \\d+)");
 
-  private final String filePath;
+  private final String filePattern;
   private final Pattern shardTemplate;
 
   /**
    * Constructor that uses default shard template.
    *
-   * @param filePath path or glob of files to include
+   * @param filePattern path or glob of files to include
    */
-  public NumberedShardedFile(String filePath) {
-    this(filePath, DEFAULT_SHARD_TEMPLATE);
+  public NumberedShardedFile(String filePattern) {
+    this(filePattern, DEFAULT_SHARD_TEMPLATE);
   }
 
   /**
    * Constructor.
    *
-   * @param filePath path or glob of files to include
+   * @param filePattern path or glob of files to include
    * @param shardTemplate template of shard name to parse out the total number 
of shards
    *                      which is used in I/O retry to avoid inconsistency of 
filesystem.
    *                      Customized template should assign name "numshards" 
to capturing
    *                      group - total shard number.
    */
-  public NumberedShardedFile(String filePath, Pattern shardTemplate) {
+  public NumberedShardedFile(String filePattern, Pattern shardTemplate) {
     checkArgument(
-        !Strings.isNullOrEmpty(filePath),
-        "Expected valid file path, but received %s", filePath);
+        !Strings.isNullOrEmpty(filePattern),
+        "Expected valid file path, but received %s", filePattern);
     checkNotNull(
         shardTemplate,
         "Expected non-null shard pattern. "
             + "Please call the other constructor to use default pattern: %s",
         DEFAULT_SHARD_TEMPLATE);
 
-    this.filePath = filePath;
+    this.filePattern = filePattern;
     this.shardTemplate = shardTemplate;
   }
 
-  public String getFilePath() {
-    return filePath;
+  public String getFilePattern() {
+    return filePattern;
   }
 
   /**
@@ -112,14 +112,14 @@ public class NumberedShardedFile implements ShardedFile {
   @Override
   public List<String> readFilesWithRetries(Sleeper sleeper, BackOff backOff)
       throws IOException, InterruptedException {
-    IOChannelFactory factory = IOChannelUtils.getFactory(filePath);
+    IOChannelFactory factory = IOChannelUtils.getFactory(filePattern);
     IOException lastException = null;
 
     do {
       try {
         // Match inputPath which may contains glob
-        Collection<String> files = factory.match(filePath);
-        LOG.debug("Found {} file(s) by matching the path: {}", files.size(), 
filePath);
+        Collection<String> files = factory.match(filePattern);
+        LOG.debug("Found {} file(s) by matching the path: {}", files.size(), 
filePattern);
 
         if (files.isEmpty() || !checkTotalNumOfFiles(files)) {
           continue;
@@ -152,7 +152,7 @@ public class NumberedShardedFile implements ShardedFile {
 
   @Override
   public String toString() {
-    return String.format("%s with shard template '%s'", filePath, 
shardTemplate);
+    return String.format("%s with shard template '%s'", filePattern, 
shardTemplate);
   }
 
   /**

Reply via email to