embulk-filter-row 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +6 -0
  4. data/README.md +1 -1
  5. data/build.gradle +3 -3
  6. data/example/and.yml +5 -6
  7. data/example/example.yml +37 -0
  8. data/example/or.yml +2 -1
  9. data/lib/embulk/filter/row.rb +1 -1
  10. data/src/main/java/org/embulk/filter/row/AbstractColumnVisitor.java +62 -0
  11. data/src/main/java/org/embulk/filter/row/ColumnVisitorAndImpl.java +211 -0
  12. data/src/main/java/org/embulk/filter/row/ColumnVisitorOrImpl.java +211 -0
  13. data/src/main/java/org/embulk/filter/row/RowFilterPlugin.java +106 -0
  14. data/src/main/java/org/embulk/filter/row/{BooleanCondition.java → condition/BooleanCondition.java} +1 -1
  15. data/src/main/java/org/embulk/filter/row/condition/Condition.java +5 -0
  16. data/src/main/java/org/embulk/filter/row/{ConditionConfig.java → condition/ConditionConfig.java} +1 -1
  17. data/src/main/java/org/embulk/filter/row/{ConditionFactory.java → condition/ConditionFactory.java} +1 -1
  18. data/src/main/java/org/embulk/filter/row/{DoubleCondition.java → condition/DoubleCondition.java} +1 -1
  19. data/src/main/java/org/embulk/filter/row/{LongCondition.java → condition/LongCondition.java} +1 -1
  20. data/src/main/java/org/embulk/filter/row/{StringCondition.java → condition/StringCondition.java} +1 -1
  21. data/src/main/java/org/embulk/filter/row/{TimestampCondition.java → condition/TimestampCondition.java} +2 -1
  22. data/src/test/java/org/embulk/filter/row/{TestBooleanCondition.java → condition/TestBooleanCondition.java} +1 -1
  23. data/src/test/java/org/embulk/filter/row/{TestConditionFactory.java → condition/TestConditionFactory.java} +1 -1
  24. data/src/test/java/org/embulk/filter/row/{TestDoubleCondition.java → condition/TestDoubleCondition.java} +1 -1
  25. data/src/test/java/org/embulk/filter/row/{TestLongCondition.java → condition/TestLongCondition.java} +1 -1
  26. data/src/test/java/org/embulk/filter/row/{TestStringCondition.java → condition/TestStringCondition.java} +1 -1
  27. data/src/test/java/org/embulk/filter/row/{TestTimestampCondition.java → condition/TestTimestampCondition.java} +1 -1
  28. metadata +22 -19
  29. data/src/main/java/org/embulk/filter/RowFilterPlugin.java +0 -464
  30. data/src/main/java/org/embulk/filter/row/Condition.java +0 -5
  31. data/src/test/java/org/embulk/filter/TestRowFilterPlugin.java +0 -5
@@ -0,0 +1,106 @@
1
+ package org.embulk.filter.row;
2
+
3
+ import org.embulk.config.Config;
4
+ import org.embulk.config.ConfigDefault;
5
+ import org.embulk.config.ConfigException;
6
+ import org.embulk.config.ConfigSource;
7
+ import org.embulk.config.Task;
8
+ import org.embulk.config.TaskSource;
9
+
10
+ import org.embulk.filter.row.condition.ConditionConfig;
11
+
12
+ import org.embulk.spi.ColumnVisitor;
13
+ import org.embulk.spi.Exec;
14
+ import org.embulk.spi.FilterPlugin;
15
+ import org.embulk.spi.Page;
16
+ import org.embulk.spi.PageBuilder;
17
+ import org.embulk.spi.PageOutput;
18
+ import org.embulk.spi.PageReader;
19
+ import org.embulk.spi.Schema;
20
+ import org.embulk.spi.time.TimestampParser;
21
+
22
+ import org.slf4j.Logger;
23
+
24
+ import java.util.List;
25
+
26
+ public class RowFilterPlugin implements FilterPlugin
27
+ {
28
+ private static final Logger logger = Exec.getLogger(RowFilterPlugin.class);
29
+
30
+ public RowFilterPlugin() {}
31
+
32
+ public interface PluginTask extends Task, TimestampParser.Task
33
+ {
34
+ @Config("condition")
35
+ @ConfigDefault("\"AND\"")
36
+ public String getCondition();
37
+
38
+ @Config("conditions")
39
+ public List<ConditionConfig> getConditions();
40
+ }
41
+
42
+ @Override
43
+ public void transaction(ConfigSource config, Schema inputSchema,
44
+ FilterPlugin.Control control)
45
+ {
46
+ PluginTask task = config.loadConfig(PluginTask.class);
47
+
48
+ configure(task, inputSchema);
49
+ Schema outputSchema = inputSchema;
50
+
51
+ control.run(task.dump(), outputSchema);
52
+ }
53
+
54
+ void configure(PluginTask task, Schema inputSchema) throws ConfigException
55
+ {
56
+ for (ConditionConfig conditionConfig : task.getConditions()) {
57
+ String columnName = conditionConfig.getColumn();
58
+ inputSchema.lookupColumn(columnName); // throw SchemaConfigException if not found
59
+ }
60
+
61
+ String condition = task.getCondition().toLowerCase();
62
+ if (!condition.equals("or") && !condition.equals("and")) {
63
+ throw new ConfigException("condition must be either of \"or\" or \"and\".");
64
+ }
65
+ }
66
+
67
+ @Override
68
+ public PageOutput open(final TaskSource taskSource, final Schema inputSchema,
69
+ final Schema outputSchema, final PageOutput output)
70
+ {
71
+ final PluginTask task = taskSource.loadTask(PluginTask.class);
72
+ final boolean orCondition = task.getCondition().toLowerCase().equals("or");
73
+
74
+ return new PageOutput() {
75
+ private PageReader pageReader = new PageReader(inputSchema);
76
+ private PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
77
+ private AbstractColumnVisitor visitor = orCondition ?
78
+ new ColumnVisitorOrImpl(task, inputSchema, outputSchema, pageReader, pageBuilder) :
79
+ new ColumnVisitorAndImpl(task, inputSchema, outputSchema, pageReader, pageBuilder);
80
+
81
+ @Override
82
+ public void finish()
83
+ {
84
+ pageBuilder.finish();
85
+ }
86
+
87
+ @Override
88
+ public void close()
89
+ {
90
+ pageBuilder.close();
91
+ }
92
+
93
+ @Override
94
+ public void add(Page page)
95
+ {
96
+ pageReader.setPage(page);
97
+
98
+ while (pageReader.nextRecord()) {
99
+ if (visitor.visitColumns(inputSchema)) {
100
+ pageBuilder.addRecord();
101
+ }
102
+ }
103
+ }
104
+ };
105
+ }
106
+ }
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
  public class BooleanCondition implements Condition
4
4
  {
@@ -0,0 +1,5 @@
1
+ package org.embulk.filter.row.condition;
2
+
3
+ public interface Condition
4
+ {
5
+ }
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
  import com.google.common.base.Optional;
4
4
  import org.embulk.config.Config;
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
  import com.google.common.base.Throwables;
4
4
 
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
  public class DoubleCondition implements Condition
4
4
  {
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
 
4
4
  public class LongCondition implements Condition
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
  public class StringCondition implements Condition
4
4
  {
@@ -1,4 +1,5 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
+
2
3
  import org.embulk.spi.time.Timestamp;
3
4
 
4
5
  public class TimestampCondition implements Condition
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
  import org.junit.Test;
4
4
 
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
  import com.google.common.base.Optional;
4
4
 
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
  import org.junit.Test;
4
4
 
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
  import org.junit.Test;
4
4
 
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
  import org.junit.Test;
4
4
 
@@ -1,4 +1,4 @@
1
- package org.embulk.filter.row;
1
+ package org.embulk.filter.row.condition;
2
2
 
3
3
  import org.embulk.spi.time.Timestamp;
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-filter-row
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-27 00:00:00.000000000 Z
11
+ date: 2016-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,6 +54,7 @@ files:
54
54
  - config/checkstyle/checkstyle.xml
55
55
  - example/and.yml
56
56
  - example/example.csv
57
+ - example/example.yml
57
58
  - example/or.yml
58
59
  - gradle/wrapper/gradle-wrapper.jar
59
60
  - gradle/wrapper/gradle-wrapper.properties
@@ -61,23 +62,25 @@ files:
61
62
  - gradlew.bat
62
63
  - lib/embulk/filter/row.rb
63
64
  - settings.gradle
64
- - src/main/java/org/embulk/filter/RowFilterPlugin.java
65
- - src/main/java/org/embulk/filter/row/BooleanCondition.java
66
- - src/main/java/org/embulk/filter/row/Condition.java
67
- - src/main/java/org/embulk/filter/row/ConditionConfig.java
68
- - src/main/java/org/embulk/filter/row/ConditionFactory.java
69
- - src/main/java/org/embulk/filter/row/DoubleCondition.java
70
- - src/main/java/org/embulk/filter/row/LongCondition.java
71
- - src/main/java/org/embulk/filter/row/StringCondition.java
72
- - src/main/java/org/embulk/filter/row/TimestampCondition.java
73
- - src/test/java/org/embulk/filter/TestRowFilterPlugin.java
74
- - src/test/java/org/embulk/filter/row/TestBooleanCondition.java
75
- - src/test/java/org/embulk/filter/row/TestConditionFactory.java
76
- - src/test/java/org/embulk/filter/row/TestDoubleCondition.java
77
- - src/test/java/org/embulk/filter/row/TestLongCondition.java
78
- - src/test/java/org/embulk/filter/row/TestStringCondition.java
79
- - src/test/java/org/embulk/filter/row/TestTimestampCondition.java
80
- - classpath/embulk-filter-row-0.2.1.jar
65
+ - src/main/java/org/embulk/filter/row/AbstractColumnVisitor.java
66
+ - src/main/java/org/embulk/filter/row/ColumnVisitorAndImpl.java
67
+ - src/main/java/org/embulk/filter/row/ColumnVisitorOrImpl.java
68
+ - src/main/java/org/embulk/filter/row/RowFilterPlugin.java
69
+ - src/main/java/org/embulk/filter/row/condition/BooleanCondition.java
70
+ - src/main/java/org/embulk/filter/row/condition/Condition.java
71
+ - src/main/java/org/embulk/filter/row/condition/ConditionConfig.java
72
+ - src/main/java/org/embulk/filter/row/condition/ConditionFactory.java
73
+ - src/main/java/org/embulk/filter/row/condition/DoubleCondition.java
74
+ - src/main/java/org/embulk/filter/row/condition/LongCondition.java
75
+ - src/main/java/org/embulk/filter/row/condition/StringCondition.java
76
+ - src/main/java/org/embulk/filter/row/condition/TimestampCondition.java
77
+ - src/test/java/org/embulk/filter/row/condition/TestBooleanCondition.java
78
+ - src/test/java/org/embulk/filter/row/condition/TestConditionFactory.java
79
+ - src/test/java/org/embulk/filter/row/condition/TestDoubleCondition.java
80
+ - src/test/java/org/embulk/filter/row/condition/TestLongCondition.java
81
+ - src/test/java/org/embulk/filter/row/condition/TestStringCondition.java
82
+ - src/test/java/org/embulk/filter/row/condition/TestTimestampCondition.java
83
+ - classpath/embulk-filter-row-0.2.2.jar
81
84
  homepage: https://github.com/sonots/embulk-filter-row
82
85
  licenses:
83
86
  - MIT
@@ -1,464 +0,0 @@
1
- package org.embulk.filter;
2
-
3
- import org.embulk.config.Config;
4
- import org.embulk.config.ConfigDefault;
5
- import org.embulk.config.ConfigException;
6
- import org.embulk.config.ConfigSource;
7
- import org.embulk.config.Task;
8
- import org.embulk.config.TaskSource;
9
-
10
- import org.embulk.filter.row.BooleanCondition;
11
- import org.embulk.filter.row.Condition;
12
- import org.embulk.filter.row.ConditionConfig;
13
- import org.embulk.filter.row.ConditionFactory;
14
- import org.embulk.filter.row.DoubleCondition;
15
- import org.embulk.filter.row.LongCondition;
16
- import org.embulk.filter.row.StringCondition;
17
- import org.embulk.filter.row.TimestampCondition;
18
-
19
- import org.embulk.spi.Column;
20
- import org.embulk.spi.ColumnVisitor;
21
- import org.embulk.spi.Exec;
22
- import org.embulk.spi.FilterPlugin;
23
- import org.embulk.spi.Page;
24
- import org.embulk.spi.PageBuilder;
25
- import org.embulk.spi.PageOutput;
26
- import org.embulk.spi.PageReader;
27
- import org.embulk.spi.Schema;
28
- import org.embulk.spi.time.Timestamp;
29
- import org.embulk.spi.time.TimestampParser;
30
-
31
- import org.slf4j.Logger;
32
-
33
- import java.util.ArrayList;
34
- import java.util.HashMap;
35
- import java.util.List;
36
-
37
- public class RowFilterPlugin implements FilterPlugin
38
- {
39
- private static final Logger logger = Exec.getLogger(RowFilterPlugin.class);
40
-
41
- public RowFilterPlugin()
42
- {
43
- }
44
-
45
- public interface PluginTask extends Task, TimestampParser.Task
46
- {
47
- @Config("condition")
48
- @ConfigDefault("\"AND\"")
49
- public String getCondition();
50
-
51
- @Config("conditions")
52
- public List<ConditionConfig> getConditions();
53
- }
54
-
55
- @Override
56
- public void transaction(ConfigSource config, Schema inputSchema,
57
- FilterPlugin.Control control)
58
- {
59
- PluginTask task = config.loadConfig(PluginTask.class);
60
-
61
- for (ConditionConfig conditionConfig : task.getConditions()) {
62
- String columnName = conditionConfig.getColumn();
63
- inputSchema.lookupColumn(columnName); // throw SchemaConfigException if not found
64
- }
65
-
66
- String condition = task.getCondition().toLowerCase();
67
- if (!condition.equals("or") && !condition.equals("and")) {
68
- throw new ConfigException("condition must be either of \"or\" or \"and\".");
69
- }
70
-
71
- Schema outputSchema = inputSchema;
72
- control.run(task.dump(), outputSchema);
73
- }
74
-
75
- @Override
76
- public PageOutput open(final TaskSource taskSource, final Schema inputSchema,
77
- final Schema outputSchema, final PageOutput output)
78
- {
79
- PluginTask task = taskSource.loadTask(PluginTask.class);
80
-
81
- final boolean orCondition = task.getCondition().toLowerCase().equals("or");
82
-
83
- final HashMap<String, List<Condition>> conditionMap = new HashMap<String, List<Condition>>();
84
- for (Column column : outputSchema.getColumns()) {
85
- String columnName = column.getName();
86
- conditionMap.put(columnName, new ArrayList<Condition>());
87
- }
88
-
89
- for (ConditionConfig conditionConfig : task.getConditions()) {
90
- String columnName = conditionConfig.getColumn();
91
- for (Column column : outputSchema.getColumns()) {
92
- if (columnName.equals(column.getName())) {
93
- ConditionFactory factory = new ConditionFactory(task.getJRuby(), column, conditionConfig);
94
- Condition condition = factory.createCondition();
95
- conditionMap.get(columnName).add(condition);
96
- break;
97
- }
98
- }
99
- }
100
-
101
- return new PageOutput() {
102
- private PageReader pageReader = new PageReader(inputSchema);
103
- private PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
104
- private boolean shouldAddRecord;
105
- private ColumnVisitor visitor = orCondition ? new ColumnVisitorOrImpl(pageBuilder) : new ColumnVisitorAndImpl(pageBuilder);
106
-
107
- @Override
108
- public void finish()
109
- {
110
- pageBuilder.finish();
111
- }
112
-
113
- @Override
114
- public void close()
115
- {
116
- pageBuilder.close();
117
- }
118
-
119
- @Override
120
- public void add(Page page)
121
- {
122
- pageReader.setPage(page);
123
-
124
- while (pageReader.nextRecord()) {
125
- shouldAddRecord = orCondition ? false : true;
126
- inputSchema.visitColumns(visitor);
127
- if (shouldAddRecord) {
128
- pageBuilder.addRecord();
129
- }
130
- }
131
- }
132
-
133
- class ColumnVisitorOrImpl implements ColumnVisitor
134
- {
135
- private final PageBuilder pageBuilder;
136
-
137
- ColumnVisitorOrImpl(PageBuilder pageBuilder)
138
- {
139
- this.pageBuilder = pageBuilder;
140
- }
141
-
142
- @Override
143
- public void booleanColumn(Column column)
144
- {
145
- if (pageReader.isNull(column)) {
146
- pageBuilder.setNull(column);
147
- }
148
- else {
149
- pageBuilder.setBoolean(column, pageReader.getBoolean(column));
150
- }
151
- if (shouldAddRecord) {
152
- return;
153
- }
154
- List<Condition> conditionList = conditionMap.get(column.getName());
155
- for (Condition tempCondition : conditionList) {
156
- BooleanCondition condition = (BooleanCondition) tempCondition;
157
- if (pageReader.isNull(column)) {
158
- if (condition.compare(null)) {
159
- shouldAddRecord = true;
160
- break;
161
- }
162
- }
163
- else {
164
- boolean subject = pageReader.getBoolean(column);
165
- if (condition.compare(subject)) {
166
- shouldAddRecord = true;
167
- break;
168
- }
169
- }
170
- }
171
- }
172
-
173
- @Override
174
- public void longColumn(Column column)
175
- {
176
- if (pageReader.isNull(column)) {
177
- pageBuilder.setNull(column);
178
- }
179
- else {
180
- pageBuilder.setLong(column, pageReader.getLong(column));
181
- }
182
- if (shouldAddRecord) {
183
- return;
184
- }
185
- List<Condition> conditionList = conditionMap.get(column.getName());
186
- for (Condition tempCondition : conditionList) {
187
- LongCondition condition = (LongCondition) tempCondition;
188
- if (pageReader.isNull(column)) {
189
- if (condition.compare(null)) {
190
- shouldAddRecord = true;
191
- break;
192
- }
193
- }
194
- else {
195
- long subject = pageReader.getLong(column);
196
- if (condition.compare(subject)) {
197
- shouldAddRecord = true;
198
- break;
199
- }
200
- }
201
- }
202
- }
203
-
204
- @Override
205
- public void doubleColumn(Column column)
206
- {
207
- if (pageReader.isNull(column)) {
208
- pageBuilder.setNull(column);
209
- }
210
- else {
211
- pageBuilder.setDouble(column, pageReader.getDouble(column));
212
- }
213
- if (shouldAddRecord) {
214
- return;
215
- }
216
- List<Condition> conditionList = conditionMap.get(column.getName());
217
- for (Condition tempCondition : conditionList) {
218
- DoubleCondition condition = (DoubleCondition) tempCondition;
219
- if (pageReader.isNull(column)) {
220
- if (condition.compare(null)) {
221
- shouldAddRecord = true;
222
- break;
223
- }
224
- }
225
- else {
226
- double subject = pageReader.getDouble(column);
227
- if (condition.compare(subject)) {
228
- shouldAddRecord = true;
229
- break;
230
- }
231
- }
232
- }
233
- }
234
-
235
- @Override
236
- public void stringColumn(Column column)
237
- {
238
- if (pageReader.isNull(column)) {
239
- pageBuilder.setNull(column);
240
- }
241
- else {
242
- pageBuilder.setString(column, pageReader.getString(column));
243
- }
244
- if (shouldAddRecord) {
245
- return;
246
- }
247
- List<Condition> conditionList = conditionMap.get(column.getName());
248
- for (Condition tempCondition : conditionList) {
249
- StringCondition condition = (StringCondition) tempCondition;
250
- if (pageReader.isNull(column)) {
251
- if (condition.compare(null)) {
252
- shouldAddRecord = true;
253
- break;
254
- }
255
- }
256
- else {
257
- String subject = pageReader.getString(column);
258
- if (condition.compare(subject)) {
259
- shouldAddRecord = true;
260
- break;
261
- }
262
- }
263
- }
264
- }
265
-
266
- @Override
267
- public void timestampColumn(Column column)
268
- {
269
- if (pageReader.isNull(column)) {
270
- pageBuilder.setNull(column);
271
- }
272
- else {
273
- pageBuilder.setTimestamp(column, pageReader.getTimestamp(column));
274
- }
275
- if (shouldAddRecord) {
276
- return;
277
- }
278
- List<Condition> conditionList = conditionMap.get(column.getName());
279
- for (Condition tempCondition : conditionList) {
280
- TimestampCondition condition = (TimestampCondition) tempCondition;
281
- if (pageReader.isNull(column)) {
282
- if (condition.compare(null)) {
283
- shouldAddRecord = true;
284
- break;
285
- }
286
- }
287
- else {
288
- Timestamp subject = pageReader.getTimestamp(column);
289
- if (condition.compare(subject)) {
290
- shouldAddRecord = true;
291
- break;
292
- }
293
- }
294
- }
295
- }
296
- }
297
-
298
- class ColumnVisitorAndImpl implements ColumnVisitor
299
- {
300
- private final PageBuilder pageBuilder;
301
-
302
- ColumnVisitorAndImpl(PageBuilder pageBuilder)
303
- {
304
- this.pageBuilder = pageBuilder;
305
- }
306
-
307
- @Override
308
- public void booleanColumn(Column column)
309
- {
310
- if (!shouldAddRecord) {
311
- return;
312
- }
313
- List<Condition> conditionList = conditionMap.get(column.getName());
314
- for (Condition tempCondition : conditionList) {
315
- BooleanCondition condition = (BooleanCondition) tempCondition;
316
- if (pageReader.isNull(column)) {
317
- if (!condition.compare(null)) {
318
- shouldAddRecord = false;
319
- break;
320
- }
321
- }
322
- else {
323
- boolean subject = pageReader.getBoolean(column);
324
- if (!condition.compare(subject)) {
325
- shouldAddRecord = false;
326
- break;
327
- }
328
- }
329
- }
330
- if (pageReader.isNull(column)) {
331
- pageBuilder.setNull(column);
332
- }
333
- else {
334
- pageBuilder.setBoolean(column, pageReader.getBoolean(column));
335
- }
336
- }
337
-
338
- @Override
339
- public void longColumn(Column column)
340
- {
341
- if (!shouldAddRecord) {
342
- return;
343
- }
344
- List<Condition> conditionList = conditionMap.get(column.getName());
345
- for (Condition tempCondition : conditionList) {
346
- LongCondition condition = (LongCondition) tempCondition;
347
- if (pageReader.isNull(column)) {
348
- if (!condition.compare(null)) {
349
- shouldAddRecord = false;
350
- break;
351
- }
352
- }
353
- else {
354
- long subject = pageReader.getLong(column);
355
- if (!condition.compare(subject)) {
356
- shouldAddRecord = false;
357
- break;
358
- }
359
- }
360
- }
361
- if (pageReader.isNull(column)) {
362
- pageBuilder.setNull(column);
363
- }
364
- else {
365
- pageBuilder.setLong(column, pageReader.getLong(column));
366
- }
367
- }
368
-
369
- @Override
370
- public void doubleColumn(Column column)
371
- {
372
- if (!shouldAddRecord) {
373
- return;
374
- }
375
- List<Condition> conditionList = conditionMap.get(column.getName());
376
- for (Condition tempCondition : conditionList) {
377
- DoubleCondition condition = (DoubleCondition) tempCondition;
378
- if (pageReader.isNull(column)) {
379
- if (!condition.compare(null)) {
380
- shouldAddRecord = false;
381
- break;
382
- }
383
- }
384
- else {
385
- double subject = pageReader.getDouble(column);
386
- if (!condition.compare(subject)) {
387
- shouldAddRecord = false;
388
- break;
389
- }
390
- }
391
- }
392
- if (pageReader.isNull(column)) {
393
- pageBuilder.setNull(column);
394
- }
395
- else {
396
- pageBuilder.setDouble(column, pageReader.getDouble(column));
397
- }
398
- }
399
-
400
- @Override
401
- public void stringColumn(Column column)
402
- {
403
- if (!shouldAddRecord) {
404
- return;
405
- }
406
- List<Condition> conditionList = conditionMap.get(column.getName());
407
- for (Condition tempCondition : conditionList) {
408
- StringCondition condition = (StringCondition) tempCondition;
409
- if (pageReader.isNull(column)) {
410
- if (!condition.compare(null)) {
411
- shouldAddRecord = false;
412
- break;
413
- }
414
- }
415
- else {
416
- String subject = pageReader.getString(column);
417
- if (!condition.compare(subject)) {
418
- shouldAddRecord = false;
419
- break;
420
- }
421
- }
422
- }
423
- if (pageReader.isNull(column)) {
424
- pageBuilder.setNull(column);
425
- }
426
- else {
427
- pageBuilder.setString(column, pageReader.getString(column));
428
- }
429
- }
430
-
431
- @Override
432
- public void timestampColumn(Column column)
433
- {
434
- if (!shouldAddRecord) {
435
- return;
436
- }
437
- List<Condition> conditionList = conditionMap.get(column.getName());
438
- for (Condition tempCondition : conditionList) {
439
- TimestampCondition condition = (TimestampCondition) tempCondition;
440
- if (pageReader.isNull(column)) {
441
- if (!condition.compare(null)) {
442
- shouldAddRecord = false;
443
- break;
444
- }
445
- }
446
- else {
447
- Timestamp subject = pageReader.getTimestamp(column);
448
- if (!condition.compare(subject)) {
449
- shouldAddRecord = false;
450
- break;
451
- }
452
- }
453
- }
454
- if (pageReader.isNull(column)) {
455
- pageBuilder.setNull(column);
456
- }
457
- else {
458
- pageBuilder.setTimestamp(column, pageReader.getTimestamp(column));
459
- }
460
- }
461
- }
462
- };
463
- }
464
- }