embulk 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -11
  3. data/build.gradle +22 -2
  4. data/embulk-core/src/main/java/org/embulk/command/Runner.java +7 -0
  5. data/embulk-core/src/main/java/org/embulk/exec/GuessExecutor.java +8 -6
  6. data/embulk-core/src/main/java/org/embulk/exec/LocalExecutor.java +54 -46
  7. data/embulk-core/src/main/java/org/embulk/exec/LoggerProvider.java +20 -3
  8. data/embulk-core/src/main/java/org/embulk/exec/PreviewExecutor.java +41 -10
  9. data/embulk-core/src/main/java/org/embulk/exec/SamplingParserPlugin.java +1 -1
  10. data/embulk-core/src/main/java/org/embulk/exec/SetCurrentThreadName.java +19 -0
  11. data/embulk-core/src/main/java/org/embulk/spi/Exec.java +5 -0
  12. data/embulk-core/src/main/java/org/embulk/spi/ExecSession.java +24 -0
  13. data/embulk-core/src/main/java/org/embulk/spi/FileInputPlugin.java +4 -4
  14. data/embulk-core/src/main/java/org/embulk/spi/FileInputRunner.java +8 -8
  15. data/embulk-core/src/main/java/org/embulk/spi/FileOutputPlugin.java +4 -4
  16. data/embulk-core/src/main/java/org/embulk/spi/FileOutputRunner.java +8 -8
  17. data/embulk-core/src/main/java/org/embulk/spi/InputPlugin.java +4 -4
  18. data/embulk-core/src/main/java/org/embulk/spi/OutputPlugin.java +4 -4
  19. data/embulk-core/src/main/java/org/embulk/spi/time/TimestampFormat.java +1 -1
  20. data/embulk-core/src/main/java/org/embulk/spi/util/FileOutputOutputStream.java +32 -8
  21. data/embulk-core/src/main/java/org/embulk/spi/util/InputStreamFileInput.java +1 -1
  22. data/embulk-core/src/main/java/org/embulk/spi/util/LineEncoder.java +3 -4
  23. data/embulk-core/src/main/java/org/embulk/spi/util/OutputStreamFileOutput.java +88 -0
  24. data/embulk-core/src/test/java/org/embulk/spi/TestFileInputInputStream.java +1 -1
  25. data/embulk-core/src/test/java/org/embulk/spi/TestFileInputRunner.java +5 -5
  26. data/embulk-core/src/test/java/org/embulk/spi/TestFileOutputRunner.java +4 -4
  27. data/embulk-docs/src/release.rst +1 -0
  28. data/embulk-docs/src/release/release-0.4.4.rst +39 -0
  29. data/embulk-standards/src/main/java/org/embulk/standards/GzipFileEncoderPlugin.java +32 -7
  30. data/embulk-standards/src/main/java/org/embulk/standards/LocalFileInputPlugin.java +9 -9
  31. data/embulk-standards/src/main/java/org/embulk/standards/LocalFileOutputPlugin.java +6 -6
  32. data/embulk-standards/src/main/java/org/embulk/standards/NullOutputPlugin.java +5 -5
  33. data/embulk-standards/src/main/java/org/embulk/standards/StdoutOutputPlugin.java +5 -5
  34. data/lib/embulk/command/embulk_run.rb +14 -2
  35. data/lib/embulk/data/new/java/file_input.java.erb +7 -7
  36. data/lib/embulk/data/new/java/file_output.java.erb +5 -5
  37. data/lib/embulk/data/new/java/input.java.erb +6 -6
  38. data/lib/embulk/data/new/java/output.java.erb +5 -5
  39. data/lib/embulk/data_source.rb +3 -3
  40. data/lib/embulk/guess_plugin.rb +5 -5
  41. data/lib/embulk/input_plugin.rb +7 -7
  42. data/lib/embulk/output_plugin.rb +7 -7
  43. data/lib/embulk/version.rb +1 -1
  44. metadata +7 -4
@@ -25,7 +25,7 @@ public class TestFileInputInputStream
25
25
  private void newOutputStream()
26
26
  {
27
27
  fileOutput = new MockFileOutput();
28
- out = new FileOutputOutputStream(fileOutput, runtime.getBufferAllocator());
28
+ out = new FileOutputOutputStream(fileOutput, runtime.getBufferAllocator(), FileOutputOutputStream.CloseMode.CLOSE);
29
29
  }
30
30
 
31
31
  private void newInputStream()
@@ -53,7 +53,7 @@ public class TestFileInputRunner
53
53
 
54
54
  @Override
55
55
  public ConfigDiff resume(TaskSource taskSource,
56
- int processorCount,
56
+ int taskCount,
57
57
  FileInputPlugin.Control control)
58
58
  {
59
59
  throw new UnsupportedOperationException();
@@ -61,13 +61,13 @@ public class TestFileInputRunner
61
61
 
62
62
  @Override
63
63
  public void cleanup(TaskSource taskSource,
64
- int processorCount,
64
+ int taskCount,
65
65
  List<CommitReport> successCommitReports)
66
66
  {
67
67
  }
68
68
 
69
69
  public TransactionalFileInput open(TaskSource taskSource,
70
- int processorIndex)
70
+ int taskIndex)
71
71
  {
72
72
  return new TransactionalFileInput()
73
73
  {
@@ -127,7 +127,7 @@ public class TestFileInputRunner
127
127
  runner.transaction(config, new InputPlugin.Control()
128
128
  {
129
129
  public List<CommitReport> run(TaskSource inputTaskSource,
130
- Schema schema, int processorCount)
130
+ Schema schema, int taskCount)
131
131
  {
132
132
  List<CommitReport> reports = new ArrayList<>();
133
133
  reports.add(runner.run(inputTaskSource, schema, 0, output));
@@ -181,7 +181,7 @@ public class TestFileInputRunner
181
181
  runner.transaction(config, new InputPlugin.Control()
182
182
  {
183
183
  public List<CommitReport> run(TaskSource inputTaskSource,
184
- Schema schema, int processorCount)
184
+ Schema schema, int taskCount)
185
185
  {
186
186
  List<CommitReport> reports = new ArrayList<>();
187
187
  reports.add(runner.run(inputTaskSource, schema, 0, output));
@@ -33,7 +33,7 @@ public class TestFileOutputRunner
33
33
  Boolean transactionCompleted = null;
34
34
 
35
35
  @Override
36
- public ConfigDiff transaction(ConfigSource config, int processorCount,
36
+ public ConfigDiff transaction(ConfigSource config, int taskCount,
37
37
  FileOutputPlugin.Control control)
38
38
  {
39
39
  PluginTask task = config.loadConfig(PluginTask.class);
@@ -43,7 +43,7 @@ public class TestFileOutputRunner
43
43
 
44
44
  @Override
45
45
  public ConfigDiff resume(TaskSource taskSource,
46
- int processorCount,
46
+ int taskCount,
47
47
  FileOutputPlugin.Control control)
48
48
  {
49
49
  throw new UnsupportedOperationException();
@@ -51,14 +51,14 @@ public class TestFileOutputRunner
51
51
 
52
52
  @Override
53
53
  public void cleanup(TaskSource taskSource,
54
- int processorCount,
54
+ int taskCount,
55
55
  List<CommitReport> successCommitReports)
56
56
  {
57
57
  }
58
58
 
59
59
  @Override
60
60
  public TransactionalFileOutput open(TaskSource taskSource,
61
- final int processorIndex)
61
+ final int taskIndex)
62
62
  {
63
63
  return new TransactionalFileOutput()
64
64
  {
@@ -14,4 +14,5 @@ Release Notes
14
14
  release/release-0.4.1
15
15
  release/release-0.4.2
16
16
  release/release-0.4.3
17
+ release/release-0.4.4
17
18
 
@@ -0,0 +1,39 @@
1
+ Release 0.4.4
2
+ ==================================
3
+
4
+ CLI
5
+ ------------------
6
+
7
+ * Supports ``-l, --log-level LEVEL`` option to specify log level. (@ykubota++)
8
+
9
+ Plugin API Changes
10
+ ------------------
11
+
12
+ * Added ``Exec.isPreview()`` method which returns true if the transaction is running in in preview mode.
13
+ * Added ``util.OutputStreamFileOutput`` class.
14
+ * ``util.FileOutputOutputStream`` requires ``CloseMode`` at the constructor.
15
+ * When ``Embulk::DataSource#prop`` returns a String, Array, or Hash value, it returns a copy of the value.
16
+ * When ``Embulk::DataSource#prop`` returns a Hash value, it returns ``DataSource`` instance.
17
+
18
+ Plugin SPI
19
+ ------------------
20
+
21
+ * Changed local variable name ``processorIndex`` to ``taskIndex``.
22
+ * Changed local variable name ``processorCount`` to ``taskCount``.
23
+
24
+ Built-in plugins
25
+ ------------------
26
+
27
+ * Added ``gzip`` encoder plugin.
28
+
29
+ General Changes
30
+ ------------------
31
+
32
+ * ``preview`` runs filter plugins in addition to input plugins.
33
+ * Fixed a problem of ``guess`` where guess plugins ignore formatter properties (such as ``charset``) guessed by other guess plugins (@hiroyuki-sato++).
34
+ * Log messages include "transaction", "resume", "cleanup", or task index at the header.
35
+ * Timestamp in log messages include time zone.
36
+
37
+ Release Date
38
+ ------------------
39
+ 2015-02-18
@@ -5,12 +5,15 @@ import java.io.IOException;
5
5
  import java.util.zip.GZIPOutputStream;
6
6
  import org.embulk.config.Task;
7
7
  import org.embulk.config.Config;
8
+ import org.embulk.config.ConfigInject;
8
9
  import org.embulk.config.ConfigDefault;
9
10
  import org.embulk.config.TaskSource;
10
11
  import org.embulk.config.ConfigSource;
11
12
  import org.embulk.spi.EncoderPlugin;
12
13
  import org.embulk.spi.FileOutput;
14
+ import org.embulk.spi.BufferAllocator;
13
15
  import org.embulk.spi.util.FileOutputOutputStream;
16
+ import org.embulk.spi.util.OutputStreamFileOutput;
14
17
 
15
18
  public class GzipFileEncoderPlugin
16
19
  implements EncoderPlugin
@@ -18,9 +21,13 @@ public class GzipFileEncoderPlugin
18
21
  public interface PluginTask
19
22
  extends Task
20
23
  {
21
- @Config("level")
22
- @ConfigDefault("6")
23
- public int getLevel();
24
+ // TODO java.util.zip.GZIPOutputStream doesn't support compression level
25
+ //@Config("level")
26
+ //@ConfigDefault("6")
27
+ //public int getLevel();
28
+
29
+ @ConfigInject
30
+ public BufferAllocator getBufferAllocator();
24
31
  }
25
32
 
26
33
  public void transaction(ConfigSource config, EncoderPlugin.Control control)
@@ -30,10 +37,28 @@ public class GzipFileEncoderPlugin
30
37
  }
31
38
 
32
39
  @Override
33
- public FileOutput open(TaskSource taskSource, FileOutput fileOutput)
40
+ public FileOutput open(TaskSource taskSource, final FileOutput fileOutput)
34
41
  {
35
- throw new AssertionError("OutputStreamFileOutput is not implemented yet");
36
- // TODO GZIPOutputStream doesn't support level option?
37
- //return new OutputStreamFileOutput(new GZIPOutputStream(new FileOutputOutputStream(fileOutput)));
42
+ PluginTask task = taskSource.loadTask(PluginTask.class);
43
+
44
+ final FileOutputOutputStream output = new FileOutputOutputStream(fileOutput, task.getBufferAllocator(), FileOutputOutputStream.CloseMode.CLOSE);
45
+
46
+ return new OutputStreamFileOutput(new OutputStreamFileOutput.Provider() {
47
+ public OutputStream openNext() throws IOException
48
+ {
49
+ output.nextFile();
50
+ return new GZIPOutputStream(output);
51
+ }
52
+
53
+ public void finish() throws IOException
54
+ {
55
+ fileOutput.finish();
56
+ }
57
+
58
+ public void close() throws IOException
59
+ {
60
+ fileOutput.close();
61
+ }
62
+ });
38
63
  }
39
64
  }
@@ -64,22 +64,22 @@ public class LocalFileInputPlugin
64
64
  task.setFiles(files);
65
65
 
66
66
  // number of processors is same with number of files
67
- int processorCount = task.getFiles().size();
68
- return resume(task.dump(), processorCount, control);
67
+ int taskCount = task.getFiles().size();
68
+ return resume(task.dump(), taskCount, control);
69
69
  }
70
70
 
71
71
  @Override
72
72
  public ConfigDiff resume(TaskSource taskSource,
73
- int processorCount,
73
+ int taskCount,
74
74
  FileInputPlugin.Control control)
75
75
  {
76
- control.run(taskSource, processorCount);
76
+ control.run(taskSource, taskCount);
77
77
  return Exec.newConfigDiff();
78
78
  }
79
79
 
80
80
  @Override
81
81
  public void cleanup(TaskSource taskSource,
82
- int processorCount,
82
+ int taskCount,
83
83
  List<CommitReport> successCommitReports)
84
84
  { }
85
85
 
@@ -155,10 +155,10 @@ public class LocalFileInputPlugin
155
155
  }
156
156
 
157
157
  @Override
158
- public TransactionalFileInput open(TaskSource taskSource, int processorIndex)
158
+ public TransactionalFileInput open(TaskSource taskSource, int taskIndex)
159
159
  {
160
160
  PluginTask task = taskSource.loadTask(PluginTask.class);
161
- return new LocalFileInput(task, processorIndex);
161
+ return new LocalFileInput(task, taskIndex);
162
162
  }
163
163
 
164
164
  public static class LocalFileInput
@@ -191,9 +191,9 @@ public class LocalFileInputPlugin
191
191
  public void close() { }
192
192
  }
193
193
 
194
- public LocalFileInput(PluginTask task, int processorIndex)
194
+ public LocalFileInput(PluginTask task, int taskIndex)
195
195
  {
196
- super(task.getBufferAllocator(), new SingleFileProvider(new File(task.getFiles().get(processorIndex))));
196
+ super(task.getBufferAllocator(), new SingleFileProvider(new File(task.getFiles().get(taskIndex))));
197
197
  }
198
198
 
199
199
  @Override
@@ -40,7 +40,7 @@ public class LocalFileOutputPlugin
40
40
  private final Logger log = Exec.getLogger(getClass());
41
41
 
42
42
  @Override
43
- public ConfigDiff transaction(ConfigSource config, int processorCount,
43
+ public ConfigDiff transaction(ConfigSource config, int taskCount,
44
44
  FileOutputPlugin.Control control)
45
45
  {
46
46
  PluginTask task = config.loadConfig(PluginTask.class);
@@ -48,12 +48,12 @@ public class LocalFileOutputPlugin
48
48
  // validate sequence_format
49
49
  String.format(task.getSequenceFormat(), 0, 0);
50
50
 
51
- return resume(task.dump(), processorCount, control);
51
+ return resume(task.dump(), taskCount, control);
52
52
  }
53
53
 
54
54
  @Override
55
55
  public ConfigDiff resume(TaskSource taskSource,
56
- int processorCount,
56
+ int taskCount,
57
57
  FileOutputPlugin.Control control)
58
58
  {
59
59
  control.run(taskSource);
@@ -62,12 +62,12 @@ public class LocalFileOutputPlugin
62
62
 
63
63
  @Override
64
64
  public void cleanup(TaskSource taskSource,
65
- int processorCount,
65
+ int taskCount,
66
66
  List<CommitReport> successCommitReports)
67
67
  { }
68
68
 
69
69
  @Override
70
- public TransactionalFileOutput open(TaskSource taskSource, final int processorIndex)
70
+ public TransactionalFileOutput open(TaskSource taskSource, final int taskIndex)
71
71
  {
72
72
  PluginTask task = taskSource.loadTask(PluginTask.class);
73
73
 
@@ -84,7 +84,7 @@ public class LocalFileOutputPlugin
84
84
  public void nextFile()
85
85
  {
86
86
  closeFile();
87
- String path = pathPrefix + String.format(sequenceFormat, processorIndex, fileIndex) + pathSuffix;
87
+ String path = pathPrefix + String.format(sequenceFormat, taskIndex, fileIndex) + pathSuffix;
88
88
  log.info("Writing local file '{}'", path);
89
89
  fileNames.add(path);
90
90
  try {
@@ -16,14 +16,14 @@ public class NullOutputPlugin
16
16
  {
17
17
  @Override
18
18
  public ConfigDiff transaction(ConfigSource config,
19
- Schema schema, int processorCount,
19
+ Schema schema, int taskCount,
20
20
  OutputPlugin.Control control)
21
21
  {
22
- return resume(Exec.newTaskSource(), schema, processorCount, control);
22
+ return resume(Exec.newTaskSource(), schema, taskCount, control);
23
23
  }
24
24
 
25
25
  public ConfigDiff resume(TaskSource taskSource,
26
- Schema schema, int processorCount,
26
+ Schema schema, int taskCount,
27
27
  OutputPlugin.Control control)
28
28
  {
29
29
  control.run(taskSource);
@@ -31,12 +31,12 @@ public class NullOutputPlugin
31
31
  }
32
32
 
33
33
  public void cleanup(TaskSource taskSource,
34
- Schema schema, int processorCount,
34
+ Schema schema, int taskCount,
35
35
  List<CommitReport> successCommitReports)
36
36
  { }
37
37
 
38
38
  @Override
39
- public TransactionalPageOutput open(TaskSource taskSource, Schema schema, int processorIndex)
39
+ public TransactionalPageOutput open(TaskSource taskSource, Schema schema, int taskIndex)
40
40
  {
41
41
  return new TransactionalPageOutput() {
42
42
  public void add(Page page)
@@ -27,16 +27,16 @@ public class StdoutOutputPlugin
27
27
 
28
28
  @Override
29
29
  public ConfigDiff transaction(ConfigSource config,
30
- Schema schema, int processorCount,
30
+ Schema schema, int taskCount,
31
31
  OutputPlugin.Control control)
32
32
  {
33
33
  final PluginTask task = config.loadConfig(PluginTask.class);
34
- return resume(task.dump(), schema, processorCount, control);
34
+ return resume(task.dump(), schema, taskCount, control);
35
35
  }
36
36
 
37
37
  @Override
38
38
  public ConfigDiff resume(TaskSource taskSource,
39
- Schema schema, int processorCount,
39
+ Schema schema, int taskCount,
40
40
  OutputPlugin.Control control)
41
41
  {
42
42
  control.run(taskSource);
@@ -44,13 +44,13 @@ public class StdoutOutputPlugin
44
44
  }
45
45
 
46
46
  public void cleanup(TaskSource taskSource,
47
- Schema schema, int processorCount,
47
+ Schema schema, int taskCount,
48
48
  List<CommitReport> successCommitReports)
49
49
  { }
50
50
 
51
51
  @Override
52
52
  public TransactionalPageOutput open(TaskSource taskSource, final Schema schema,
53
- int processorIndex)
53
+ int taskIndex)
54
54
  {
55
55
  final PluginTask task = taskSource.loadTask(PluginTask.class);
56
56
 
@@ -32,7 +32,7 @@ module Embulk
32
32
  require 'optparse'
33
33
  op = OptionParser.new
34
34
 
35
- puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S %Z")}: Embulk v#{Embulk::VERSION}"
35
+ puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S,%3N %z")}: Embulk v#{Embulk::VERSION}"
36
36
 
37
37
  load_paths = []
38
38
  classpaths = []
@@ -56,6 +56,9 @@ module Embulk
56
56
 
57
57
  when :run
58
58
  op.banner = "Usage: run <config.yml>"
59
+ op.on('-l', '--log-level LEVEL', 'Log level (fatal, error, warn, info, or trace)') do |level|
60
+ options[:logLevel] = level
61
+ end
59
62
  op.on('-I', '--load-path PATH', 'Add ruby script directory path ($LOAD_PATH)') do |load_path|
60
63
  load_paths << load_path
61
64
  end
@@ -71,7 +74,10 @@ module Embulk
71
74
  args = 1..1
72
75
 
73
76
  when :cleanup
74
- op.banner = "Usage: run <config.yml>"
77
+ op.banner = "Usage: cleanup <config.yml>"
78
+ op.on('-l', '--log-level LEVEL', 'Log level (fatal, error, warn, info, or trace)') do |level|
79
+ options[:logLevel] = level
80
+ end
75
81
  op.on('-I', '--load-path PATH', 'Add ruby script directory path ($LOAD_PATH)') do |load_path|
76
82
  load_paths << load_path
77
83
  end
@@ -85,6 +91,9 @@ module Embulk
85
91
 
86
92
  when :preview
87
93
  op.banner = "Usage: preview <config.yml>"
94
+ op.on('-l', '--log-level LEVEL', 'Log level (fatal, error, warn, info, or trace)') do |level|
95
+ options[:logLevel] = level
96
+ end
88
97
  op.on('-I', '--load-path PATH', 'Add ruby script directory path ($LOAD_PATH)') do |load_path|
89
98
  load_paths << load_path
90
99
  end
@@ -95,6 +104,9 @@ module Embulk
95
104
 
96
105
  when :guess
97
106
  op.banner = "Usage: guess <partial-config.yml>"
107
+ op.on('-l', '--log-level LEVEL', 'Log level (fatal, error, warn, info, or trace)') do |level|
108
+ options[:logLevel] = level
109
+ end
98
110
  op.on('-o', '--output PATH', 'Path to a file to write the guessed configuration') do |path|
99
111
  options[:nextConfigOutputPath] = path
100
112
  end
@@ -31,30 +31,30 @@ public class <%= java_class_name %>
31
31
  {
32
32
  PluginTask task = config.loadConfig(PluginTask.class);
33
33
 
34
- // processorCount is usually number of input files
35
- int processorCount = 1; // number of run() method calls
34
+ // taskCount is usually number of input files
35
+ int taskCount = 1; // number of run() method calls
36
36
 
37
- return resume(task.dump(), processorCount, control);
37
+ return resume(task.dump(), taskCount, control);
38
38
  }
39
39
 
40
40
  @Override
41
41
  public ConfigDiff resume(TaskSource taskSource,
42
- int processorCount,
42
+ int taskCount,
43
43
  FileInputPlugin.Control control)
44
44
  {
45
- control.run(taskSource, processorCount);
45
+ control.run(taskSource, taskCount);
46
46
  return Exec.newConfigDiff();
47
47
  }
48
48
 
49
49
  @Override
50
50
  public void cleanup(TaskSource taskSource,
51
- int processorCount,
51
+ int taskCount,
52
52
  List<CommitReport> successCommitReports)
53
53
  {
54
54
  }
55
55
 
56
56
  @Override
57
- public TransactionalFileInput open(TaskSource taskSource, int processorIndex)
57
+ public TransactionalFileInput open(TaskSource taskSource, int taskIndex)
58
58
  {
59
59
  PluginTask task = taskSource.loadTask(PluginTask.class);
60
60