Skip to content

Commit 2b741d6

Browse files
authored
Merge pull request #27 from civitaspo/notPartitoningIfFilesAreCompressed
[WIP] Not partitoning if files are compressed
2 parents d975288 + 0853e05 commit 2b741d6

11 files changed

+602
-560
lines changed

src/main/java/org/embulk/input/hdfs/ConfigurationBuilder.java

Lines changed: 0 additions & 82 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.embulk.input.hdfs;
2+
3+
import org.apache.hadoop.conf.Configuration;
4+
import org.embulk.config.Config;
5+
import org.embulk.config.ConfigDefault;
6+
import org.embulk.config.ConfigException;
7+
import org.embulk.spi.Exec;
8+
import org.slf4j.Logger;
9+
10+
import java.io.File;
11+
import java.net.MalformedURLException;
12+
import java.util.List;
13+
import java.util.Map;
14+
15+
public class ConfigurationFactory
16+
{
17+
public static final Logger logger = Exec.getLogger(ConfigurationFactory.class);
18+
19+
interface Task
20+
{
21+
@Config("config_files")
22+
@ConfigDefault("[]")
23+
List<String> getConfigFiles();
24+
25+
@Config("config")
26+
@ConfigDefault("{}")
27+
Map<String, String> getConfig();
28+
}
29+
30+
private ConfigurationFactory()
31+
{
32+
}
33+
34+
public static Configuration create(Task task)
35+
{
36+
Configuration c = new Configuration();
37+
for (String f : task.getConfigFiles()) {
38+
try {
39+
logger.debug("embulk-input-hdfs: load a config file: {}", f);
40+
c.addResource(new File(f).toURI().toURL());
41+
}
42+
catch (MalformedURLException e) {
43+
throw new ConfigException(e);
44+
}
45+
}
46+
47+
for (Map.Entry<String, String> entry : task.getConfig().entrySet()) {
48+
logger.debug("embulk-input-hdfs: load a config: {}:{}", entry.getKey(), entry.getValue());
49+
c.set(entry.getKey(), entry.getValue());
50+
}
51+
52+
// For logging
53+
for (Map.Entry<String, String> entry : c) {
54+
logger.trace("embulk-input-hdfs: {}: {}", entry.getKey(), entry.getValue());
55+
}
56+
logger.trace("embulk-input-hdfs: Resource Files: {}", c);
57+
58+
return c;
59+
}
60+
}

0 commit comments

Comments
 (0)