embulk-filter-icu4j 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f2c54a916cde80da7581afdbbea0e1bbc0175a8
4
- data.tar.gz: bc2b45d7f9fc98642a1e77bdde256847f22383c8
3
+ metadata.gz: 0d8fa0b28ed6c6d8231b04b75fb7e836ddd2aa2e
4
+ data.tar.gz: 62d2df03b4dea26db5531346cb07db60b7f388d5
5
5
  SHA512:
6
- metadata.gz: 6b4bc3099d6a77955bccddbbb805951fcebcaacf1f62bda9b13a35c758ef44d68161ce208c82a639aaa07044bebbf7cb64994826c69aafd944f1ec3ca1854acf
7
- data.tar.gz: 7c10659f1f85f3bd4be6ede17e931fa66d067ae427d80dd172ccc4bf6fdd194f66c902a588100cb6625dfa14fd1d5ebdab4676db0dac0ee11a53db8af22abc94
6
+ metadata.gz: d8d8a07ec890402c0b5b52507ef197c65709e906233a64cc5aebfa8e481f016de34c78332d93066e3f96c685363d8e19282045d1f4a246dc8d67631d51da01c8
7
+ data.tar.gz: 7144d51b395d6e3becb56a0651d8283c8ee534d4a1fa5466c5a91ca30349b357f1be617df6a5802425f46d9200c8f9e1a17559f8a244a0d34c0c6b03fffb9bc6
data/build.gradle CHANGED
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.1.0"
16
+ version = "0.2.0"
17
17
 
18
18
  sourceCompatibility = 1.7
19
19
  targetCompatibility = 1.7
@@ -21,7 +21,7 @@ targetCompatibility = 1.7
21
21
  dependencies {
22
22
  compile "org.embulk:embulk-core:0.7.4"
23
23
  provided "org.embulk:embulk-core:0.7.4"
24
- compile 'icu:icu4j:2.6.1'
24
+ compile 'com.ibm.icu:icu4j:56.1'
25
25
  testCompile "junit:junit:4.+"
26
26
  }
27
27
 
@@ -55,8 +55,14 @@ public class Icu4jFilterPlugin implements FilterPlugin
55
55
 
56
56
  for (String key: task.getKeyNames()) {
57
57
  for (Map<String, String> setting : task.getSettings()) {
58
- Column outputColumn = new Column(i++, key + MoreObjects.firstNonNull(setting.get("suffix"), ""), Types.STRING);
59
- builder.add(outputColumn);
58
+ String keyName = key + MoreObjects.firstNonNull(setting.get("suffix"), "");
59
+ if (task.getKeepInput()) {
60
+ if (setting.get("suffix") != null) {
61
+ builder.add(new Column(i++, keyName, Types.STRING));
62
+ }
63
+ } else {
64
+ builder.add(new Column(i++, keyName, Types.STRING));
65
+ }
60
66
  }
61
67
  }
62
68
  Schema outputSchema = new Schema(builder.build());
@@ -83,62 +89,57 @@ public class Icu4jFilterPlugin implements FilterPlugin
83
89
 
84
90
  return new PageOutput() {
85
91
  private PageReader reader = new PageReader(inputSchema);
92
+ private PageBuilder builder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
86
93
 
87
94
  @Override
88
95
  public void finish() {
89
- output.finish();
96
+ builder.finish();
90
97
  }
91
98
 
92
99
  @Override
93
100
  public void close() {
94
- output.close();
101
+ builder.close();
95
102
  }
96
103
 
97
104
  @Override
98
105
  public void add(Page page) {
99
106
  reader.setPage(page);
100
-
101
- try (final PageBuilder builder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output)) {
102
- while (reader.nextRecord()) {
103
- setValue(builder);
104
- builder.addRecord();
105
- }
106
- builder.finish();
107
- }
108
- }
109
-
110
- /**
111
- * @param builder
112
- */
113
- private void setValue(PageBuilder builder) {
114
- if (task.getKeepInput()) {
115
- for (Column inputColumn: inputSchema.getColumns()) {
116
- if (reader.isNull(inputColumn)) {
117
- builder.setNull(inputColumn);
118
- continue;
119
- }
120
- if (Types.STRING.equals(inputColumn.getType())) {
121
- builder.setString(inputColumn, reader.getString(inputColumn));
122
- } else if (Types.BOOLEAN.equals(inputColumn.getType())) {
123
- builder.setBoolean(inputColumn, reader.getBoolean(inputColumn));
124
- } else if (Types.DOUBLE.equals(inputColumn.getType())) {
125
- builder.setDouble(inputColumn, reader.getDouble(inputColumn));
126
- } else if (Types.LONG.equals(inputColumn.getType())) {
127
- builder.setLong(inputColumn, reader.getLong(inputColumn));
128
- } else if (Types.TIMESTAMP.equals(inputColumn.getType())) {
129
- builder.setTimestamp(inputColumn, reader.getTimestamp(inputColumn));
107
+ while (reader.nextRecord()) {
108
+ if (task.getKeepInput()) {
109
+ for (Column inputColumn: inputSchema.getColumns()) {
110
+ if (reader.isNull(inputColumn)) {
111
+ builder.setNull(inputColumn);
112
+ continue;
113
+ }
114
+ if (Types.STRING.equals(inputColumn.getType())) {
115
+ builder.setString(inputColumn, reader.getString(inputColumn));
116
+ } else if (Types.BOOLEAN.equals(inputColumn.getType())) {
117
+ builder.setBoolean(inputColumn, reader.getBoolean(inputColumn));
118
+ } else if (Types.DOUBLE.equals(inputColumn.getType())) {
119
+ builder.setDouble(inputColumn, reader.getDouble(inputColumn));
120
+ } else if (Types.LONG.equals(inputColumn.getType())) {
121
+ builder.setLong(inputColumn, reader.getLong(inputColumn));
122
+ } else if (Types.TIMESTAMP.equals(inputColumn.getType())) {
123
+ builder.setTimestamp(inputColumn, reader.getTimestamp(inputColumn));
124
+ }
130
125
  }
131
126
  }
132
- }
133
127
 
134
- List<Map<String, String>> settings = task.getSettings();
135
- for (Column column : keyNameColumns) {
136
- for (int i = 0; i < settings.size(); i++) {
137
- Map<String, String> setting = settings.get(i);
138
- String suffix = setting.get("suffix");
139
- Column outputColumn = outputSchema.lookupColumn(column.getName() + MoreObjects.firstNonNull(suffix, ""));
140
- builder.setString(outputColumn, convert(column, suffix, setting.get("case"), transliterators.get(i)));
128
+ List<Map<String, String>> settings = task.getSettings();
129
+ for (Column column : keyNameColumns) {
130
+ for (int i = 0; i < settings.size(); i++) {
131
+ Map<String, String> setting = settings.get(i);
132
+ String suffix = setting.get("suffix");
133
+ Column outputColumn = outputSchema.lookupColumn(column.getName() + MoreObjects.firstNonNull(suffix, ""));
134
+ String convert = convert(column, suffix, setting.get("case"), transliterators.get(i));
135
+ if (convert == null) {
136
+ builder.setNull(outputColumn);
137
+ } else {
138
+ builder.setString(outputColumn, convert);
139
+ }
140
+ }
141
141
  }
142
+ builder.addRecord();
142
143
  }
143
144
  }
144
145
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-filter-icu4j
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - toyama0919
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-01 00:00:00.000000000 Z
11
+ date: 2015-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -57,7 +57,8 @@ files:
57
57
  - lib/embulk/filter/icu4j.rb
58
58
  - src/main/java/org/embulk/filter/icu4j/Icu4jFilterPlugin.java
59
59
  - src/test/java/org/embulk/filter/icu4j/TestIcu4jFilterPlugin.java
60
- - classpath/embulk-filter-icu4j-0.1.0.jar
60
+ - classpath/embulk-filter-icu4j-0.2.0.jar
61
+ - classpath/icu4j-56.1.jar
61
62
  homepage: https://github.com/toyama0919/embulk-filter-icu4j
62
63
  licenses:
63
64
  - MIT