Skip to content

Commit c4d8247

Browse files
committed
Merge pull request #14 from civitaspo/v0.1.8
Change the class of numPartitions: int to long
2 parents bbd56b9 + d77f82c commit c4d8247

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Diff for: src/main/java/org/embulk/input/hdfs/HdfsFileInputPlugin.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public interface PluginTask extends Task
5858

5959
@Config("num_partitions") // this parameter is the approximate value.
6060
@ConfigDefault("-1") // Default: Runtime.getRuntime().availableProcessors()
61-
public int getApproximateNumPartitions();
61+
public long getApproximateNumPartitions();
6262

6363
public List<HdfsPartialFile> getFiles();
6464
public void setFiles(List<HdfsPartialFile> hdfsFiles);
@@ -246,25 +246,25 @@ public Path apply(@Nullable String input)
246246
}
247247
});
248248

249-
int totalFileLength = 0;
249+
long totalFileLength = 0;
250250
for (Path path : pathList) {
251251
totalFileLength += fs.getFileStatus(path).getLen();
252252
}
253253

254254
// TODO: optimum allocation of resources
255-
int approximateNumPartitions =
255+
long approximateNumPartitions =
256256
(task.getApproximateNumPartitions() <= 0) ? Runtime.getRuntime().availableProcessors() : task.getApproximateNumPartitions();
257-
int partitionSizeByOneTask = totalFileLength / approximateNumPartitions;
257+
long partitionSizeByOneTask = totalFileLength / approximateNumPartitions;
258258

259259
List<HdfsPartialFile> hdfsPartialFiles = new ArrayList<>();
260260
for (Path path : pathList) {
261-
int fileLength = (int) fs.getFileStatus(path).getLen(); // declare `fileLength` here because this is used below.
261+
long fileLength = fs.getFileStatus(path).getLen(); // declare `fileLength` here because this is used below.
262262
if (fileLength <= 0) {
263263
logger.info("embulk-input-hdfs: Skip the 0 byte target file: {}", path);
264264
continue;
265265
}
266266

267-
int numPartitions;
267+
long numPartitions;
268268
if (path.toString().endsWith(".gz") || path.toString().endsWith(".bz2") || path.toString().endsWith(".lzo")) {
269269
numPartitions = 1;
270270
}

Diff for: src/main/java/org/embulk/input/hdfs/HdfsFilePartitioner.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public class HdfsFilePartitioner
1414
{
1515
private FileSystem fs;
1616
private Path path;
17-
private int numPartitions;
17+
private long numPartitions;
1818

19-
public HdfsFilePartitioner(FileSystem fs, Path path, int numPartitions)
19+
public HdfsFilePartitioner(FileSystem fs, Path path, long numPartitions)
2020
{
2121
this.fs = fs;
2222
this.path = path;

0 commit comments

Comments
 (0)