embulk-parser-jsonl 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +17 -14
- data/bench/gen_dummy.rb +5 -0
- data/bench/typecast.yml +17 -0
- data/bench/without_typecast.yml +17 -0
- data/build.gradle +1 -1
- data/embulk-parser-jsonl.gemspec +1 -1
- data/example/compat.yml +21 -0
- data/example/example.yml +5 -10
- data/example/example_without_typecast.yml +18 -0
- data/example/sample.json +2 -2
- data/src/main/java/org/embulk/parser/jsonl/ColumnCaster.java +97 -0
- data/src/main/java/org/embulk/parser/jsonl/ColumnVisitorImpl.java +164 -0
- data/src/main/java/org/embulk/parser/jsonl/JsonRecordValidateException.java +11 -3
- data/src/main/java/org/embulk/parser/jsonl/JsonlParserPlugin.java +39 -14
- data/src/main/java/org/embulk/parser/jsonl/cast/BooleanCast.java +39 -0
- data/src/main/java/org/embulk/parser/jsonl/cast/DoubleCast.java +41 -0
- data/src/main/java/org/embulk/parser/jsonl/cast/JsonCast.java +40 -0
- data/src/main/java/org/embulk/parser/jsonl/cast/LongCast.java +47 -0
- data/src/main/java/org/embulk/parser/jsonl/cast/StringCast.java +82 -0
- data/src/test/java/org/embulk/parser/jsonl/TestColumnCaster.java +256 -0
- data/src/test/java/org/embulk/parser/jsonl/cast/TestBooleanCast.java +56 -0
- data/src/test/java/org/embulk/parser/jsonl/cast/TestDoubleCast.java +50 -0
- data/src/test/java/org/embulk/parser/jsonl/cast/TestJsonCast.java +80 -0
- data/src/test/java/org/embulk/parser/jsonl/cast/TestLongCast.java +42 -0
- data/src/test/java/org/embulk/parser/jsonl/cast/TestStringCast.java +103 -0
- metadata +21 -7
- data/src/main/java/org/embulk/parser/jsonl/JsonlColumnOption.java +0 -16
- data/src/main/java/org/embulk/parser/jsonl/getter/ColumnGetterFactory.java +0 -24
- data/src/main/java/org/embulk/parser/jsonl/getter/CommonColumnGetter.java +0 -131
- data/src/main/java/org/embulk/parser/jsonl/getter/StringColumnGetter.java +0 -68
@@ -1,68 +0,0 @@
|
|
1
|
-
package org.embulk.parser.jsonl.getter;
|
2
|
-
|
3
|
-
import org.embulk.parser.jsonl.JsonRecordValidateException;
|
4
|
-
import org.embulk.spi.Column;
|
5
|
-
import org.embulk.spi.PageBuilder;
|
6
|
-
import org.embulk.spi.time.TimestampParser;
|
7
|
-
import org.msgpack.core.MessageTypeException;
|
8
|
-
|
9
|
-
public class StringColumnGetter extends CommonColumnGetter {
|
10
|
-
|
11
|
-
public StringColumnGetter(PageBuilder pageBuilder, TimestampParser[] timestampParsers)
|
12
|
-
{
|
13
|
-
super(pageBuilder, timestampParsers);
|
14
|
-
}
|
15
|
-
|
16
|
-
private String getValueAsString()
|
17
|
-
{
|
18
|
-
return value.toString();
|
19
|
-
}
|
20
|
-
|
21
|
-
@Override
|
22
|
-
public void booleanColumn(Column column)
|
23
|
-
{
|
24
|
-
if (isNil(value)) {
|
25
|
-
pageBuilder.setNull(column);
|
26
|
-
}
|
27
|
-
else {
|
28
|
-
try {
|
29
|
-
pageBuilder.setBoolean(column, Boolean.valueOf(getValueAsString()));
|
30
|
-
}
|
31
|
-
catch (MessageTypeException e) {
|
32
|
-
throw new JsonRecordValidateException(e);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
@Override
|
38
|
-
public void longColumn(Column column)
|
39
|
-
{
|
40
|
-
if (isNil(value)) {
|
41
|
-
pageBuilder.setNull(column);
|
42
|
-
}
|
43
|
-
else {
|
44
|
-
try {
|
45
|
-
pageBuilder.setLong(column, Long.valueOf(getValueAsString()));
|
46
|
-
}
|
47
|
-
catch (MessageTypeException | NumberFormatException e) {
|
48
|
-
throw new JsonRecordValidateException(e);
|
49
|
-
}
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
@Override
|
54
|
-
public void doubleColumn(Column column)
|
55
|
-
{
|
56
|
-
if (isNil(value)) {
|
57
|
-
pageBuilder.setNull(column);
|
58
|
-
}
|
59
|
-
else {
|
60
|
-
try {
|
61
|
-
pageBuilder.setDouble(column, Double.valueOf(getValueAsString()));
|
62
|
-
}
|
63
|
-
catch (MessageTypeException | NumberFormatException e) {
|
64
|
-
throw new JsonRecordValidateException(e);
|
65
|
-
}
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|