embulk-output-td 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/build.gradle +9 -8
- data/embulk-output-td.gemspec +1 -1
- data/src/main/java/org/embulk/output/td/MsgpackGZFileBuilder.java +11 -12
- data/src/main/java/org/embulk/output/td/RecordWriter.java +4 -7
- data/src/main/java/org/embulk/output/td/TdOutputPlugin.java +89 -84
- data/src/main/java/org/embulk/output/td/writer/FieldWriterSet.java +9 -0
- data/src/main/java/org/embulk/output/td/writer/JsonFieldWriter.java +23 -0
- data/src/test/java/org/embulk/output/td/TestRecordWriter.java +37 -38
- data/src/test/java/org/embulk/output/td/TestTdOutputPlugin.java +53 -49
- metadata +9 -30
- data/src/main/java/com/treasuredata/api/TdApiClient.java +0 -506
- data/src/main/java/com/treasuredata/api/TdApiClientConfig.java +0 -79
- data/src/main/java/com/treasuredata/api/TdApiConflictException.java +0 -10
- data/src/main/java/com/treasuredata/api/TdApiConstants.java +0 -10
- data/src/main/java/com/treasuredata/api/TdApiException.java +0 -20
- data/src/main/java/com/treasuredata/api/TdApiExecutionException.java +0 -10
- data/src/main/java/com/treasuredata/api/TdApiExecutionInterruptedException.java +0 -16
- data/src/main/java/com/treasuredata/api/TdApiExecutionTimeoutException.java +0 -18
- data/src/main/java/com/treasuredata/api/TdApiNotFoundException.java +0 -10
- data/src/main/java/com/treasuredata/api/TdApiResponseException.java +0 -32
- data/src/main/java/com/treasuredata/api/model/TDArrayColumnType.java +0 -80
- data/src/main/java/com/treasuredata/api/model/TDBulkImportSession.java +0 -157
- data/src/main/java/com/treasuredata/api/model/TDColumn.java +0 -129
- data/src/main/java/com/treasuredata/api/model/TDColumnType.java +0 -23
- data/src/main/java/com/treasuredata/api/model/TDColumnTypeDeserializer.java +0 -128
- data/src/main/java/com/treasuredata/api/model/TDDatabase.java +0 -49
- data/src/main/java/com/treasuredata/api/model/TDDatabaseList.java +0 -24
- data/src/main/java/com/treasuredata/api/model/TDMapColumnType.java +0 -88
- data/src/main/java/com/treasuredata/api/model/TDPrimitiveColumnType.java +0 -61
- data/src/main/java/com/treasuredata/api/model/TDTable.java +0 -64
- data/src/main/java/com/treasuredata/api/model/TDTableList.java +0 -33
- data/src/main/java/com/treasuredata/api/model/TDTablePermission.java +0 -50
- data/src/main/java/com/treasuredata/api/model/TDTableSchema.java +0 -44
- data/src/main/java/com/treasuredata/api/model/TDTableType.java +0 -37
- data/src/test/java/com/treasuredata/api/TestTdApiClient.java +0 -79
@@ -1,129 +0,0 @@
|
|
1
|
-
package com.treasuredata.api.model;
|
2
|
-
|
3
|
-
import com.fasterxml.jackson.annotation.JsonCreator;
|
4
|
-
import com.fasterxml.jackson.annotation.JsonValue;
|
5
|
-
import com.fasterxml.jackson.databind.RuntimeJsonMappingException;
|
6
|
-
import com.google.common.base.Objects;
|
7
|
-
import com.google.common.base.Strings;
|
8
|
-
import com.google.common.collect.Lists;
|
9
|
-
import org.json.simple.JSONArray;
|
10
|
-
import org.json.simple.parser.JSONParser;
|
11
|
-
import org.json.simple.parser.ParseException;
|
12
|
-
|
13
|
-
import java.util.ArrayList;
|
14
|
-
import java.util.List;
|
15
|
-
|
16
|
-
public class TDColumn
|
17
|
-
{
|
18
|
-
private String name;
|
19
|
-
private TDColumnType type;
|
20
|
-
private byte[] key;
|
21
|
-
|
22
|
-
public TDColumn(String name, TDColumnType type, byte[] key)
|
23
|
-
{
|
24
|
-
this.name = name;
|
25
|
-
this.type = type;
|
26
|
-
this.key = key;
|
27
|
-
}
|
28
|
-
|
29
|
-
public String getName()
|
30
|
-
{
|
31
|
-
return name;
|
32
|
-
}
|
33
|
-
|
34
|
-
public TDColumnType getType()
|
35
|
-
{
|
36
|
-
return type;
|
37
|
-
}
|
38
|
-
|
39
|
-
public byte[] getKey()
|
40
|
-
{
|
41
|
-
return key;
|
42
|
-
}
|
43
|
-
|
44
|
-
private static JSONArray castToArray(Object obj)
|
45
|
-
{
|
46
|
-
if (obj instanceof JSONArray) {
|
47
|
-
return (JSONArray) obj;
|
48
|
-
}
|
49
|
-
else {
|
50
|
-
throw new RuntimeJsonMappingException("Not an json array: " + obj);
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
public static List<TDColumn> parseTuple(String jsonStr)
|
55
|
-
{
|
56
|
-
if (Strings.isNullOrEmpty(jsonStr)) {
|
57
|
-
return new ArrayList<>(0);
|
58
|
-
}
|
59
|
-
|
60
|
-
// unescape json quotation
|
61
|
-
try {
|
62
|
-
String unescaped = jsonStr.replaceAll("\\\"", "\"");
|
63
|
-
JSONArray arr = castToArray(new JSONParser().parse(unescaped));
|
64
|
-
List<TDColumn> columnList = new ArrayList<>(arr.size());
|
65
|
-
for (Object e : arr) {
|
66
|
-
JSONArray columnNameAndType = castToArray(e);
|
67
|
-
String[] s = new String[columnNameAndType.size()];
|
68
|
-
for (int i = 0; i < columnNameAndType.size(); ++i) {
|
69
|
-
s[i] = columnNameAndType.get(i).toString();
|
70
|
-
}
|
71
|
-
columnList.add(parseTuple(s));
|
72
|
-
}
|
73
|
-
return columnList;
|
74
|
-
}
|
75
|
-
catch (ParseException e) {
|
76
|
-
return new ArrayList<>(0);
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
@JsonCreator
|
81
|
-
public static TDColumn parseTuple(String[] tuple)
|
82
|
-
{
|
83
|
-
// TODO encode key in some ways
|
84
|
-
if (tuple != null && tuple.length == 2) {
|
85
|
-
return new TDColumn(
|
86
|
-
tuple[0],
|
87
|
-
TDColumnTypeDeserializer.parseColumnType(tuple[1]),
|
88
|
-
tuple[0].getBytes());
|
89
|
-
|
90
|
-
}
|
91
|
-
else if (tuple != null && tuple.length == 3) {
|
92
|
-
return new TDColumn(
|
93
|
-
tuple[0],
|
94
|
-
TDColumnTypeDeserializer.parseColumnType(tuple[1]),
|
95
|
-
tuple[2].getBytes());
|
96
|
-
|
97
|
-
}
|
98
|
-
else {
|
99
|
-
throw new RuntimeJsonMappingException("Unexpected string tuple to deserialize TDColumn");
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
@JsonValue
|
104
|
-
public String[] getTuple()
|
105
|
-
{
|
106
|
-
return new String[] { name, type.toString(), new String(key) };
|
107
|
-
}
|
108
|
-
|
109
|
-
@Override
|
110
|
-
public boolean equals(Object obj)
|
111
|
-
{
|
112
|
-
if (this == obj) {
|
113
|
-
return true;
|
114
|
-
}
|
115
|
-
if (obj == null || getClass() != obj.getClass()) {
|
116
|
-
return false;
|
117
|
-
}
|
118
|
-
TDColumn other = (TDColumn) obj;
|
119
|
-
return Objects.equal(this.name, other.name) &&
|
120
|
-
Objects.equal(type, other.type) &&
|
121
|
-
Objects.equal(key, other.key);
|
122
|
-
}
|
123
|
-
|
124
|
-
@Override
|
125
|
-
public int hashCode()
|
126
|
-
{
|
127
|
-
return Objects.hashCode(name, type, key);
|
128
|
-
}
|
129
|
-
}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
package com.treasuredata.api.model;
|
2
|
-
|
3
|
-
import com.fasterxml.jackson.annotation.JsonValue;
|
4
|
-
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
5
|
-
|
6
|
-
@JsonDeserialize(using = TDColumnTypeDeserializer.class)
|
7
|
-
public interface TDColumnType
|
8
|
-
{
|
9
|
-
public boolean isPrimitive();
|
10
|
-
|
11
|
-
public boolean isArrayType();
|
12
|
-
|
13
|
-
public boolean isMapType();
|
14
|
-
|
15
|
-
public TDPrimitiveColumnType asPrimitiveType();
|
16
|
-
|
17
|
-
public TDArrayColumnType asArrayType();
|
18
|
-
|
19
|
-
public TDMapColumnType asMapType();
|
20
|
-
|
21
|
-
@JsonValue
|
22
|
-
public String toString();
|
23
|
-
}
|
@@ -1,128 +0,0 @@
|
|
1
|
-
package com.treasuredata.api.model;
|
2
|
-
|
3
|
-
import com.fasterxml.jackson.core.JsonParser;
|
4
|
-
import com.fasterxml.jackson.core.JsonProcessingException;
|
5
|
-
import com.fasterxml.jackson.core.JsonToken;
|
6
|
-
import com.fasterxml.jackson.databind.DeserializationContext;
|
7
|
-
import com.fasterxml.jackson.databind.JsonDeserializer;
|
8
|
-
import com.fasterxml.jackson.databind.RuntimeJsonMappingException;
|
9
|
-
|
10
|
-
import java.io.IOException;
|
11
|
-
|
12
|
-
public class TDColumnTypeDeserializer
|
13
|
-
extends JsonDeserializer<TDColumnType>
|
14
|
-
{
|
15
|
-
@Override
|
16
|
-
public TDColumnType deserialize(JsonParser jp, DeserializationContext ctxt)
|
17
|
-
throws IOException, JsonProcessingException
|
18
|
-
{
|
19
|
-
if (jp.nextToken() != JsonToken.VALUE_STRING) {
|
20
|
-
//throw new JsonMappingException("Unexpected JSON element to deserialize TDColumnType");
|
21
|
-
throw new RuntimeJsonMappingException("Unexpected JSON element to deserialize TDColumnType");
|
22
|
-
}
|
23
|
-
String str = jp.getText();
|
24
|
-
return parseColumnType(str);
|
25
|
-
}
|
26
|
-
|
27
|
-
public static TDColumnType parseColumnType(String str)
|
28
|
-
{
|
29
|
-
Parser p = new Parser(str);
|
30
|
-
TDColumnType type = parseColumnTypeRecursive(p);
|
31
|
-
if (!p.eof()) {
|
32
|
-
throw new IllegalArgumentException("Cannot parse type: EOF expected: " + str);
|
33
|
-
}
|
34
|
-
return type;
|
35
|
-
}
|
36
|
-
|
37
|
-
private static TDColumnType parseColumnTypeRecursive(Parser p)
|
38
|
-
{
|
39
|
-
if (p.scan("string")) {
|
40
|
-
return TDPrimitiveColumnType.STRING;
|
41
|
-
|
42
|
-
}
|
43
|
-
else if (p.scan("int")) {
|
44
|
-
return TDPrimitiveColumnType.INT;
|
45
|
-
|
46
|
-
}
|
47
|
-
else if (p.scan("long")) {
|
48
|
-
return TDPrimitiveColumnType.LONG;
|
49
|
-
|
50
|
-
}
|
51
|
-
else if (p.scan("double")) {
|
52
|
-
return TDPrimitiveColumnType.DOUBLE;
|
53
|
-
|
54
|
-
}
|
55
|
-
else if (p.scan("float")) {
|
56
|
-
return TDPrimitiveColumnType.FLOAT;
|
57
|
-
|
58
|
-
}
|
59
|
-
else if (p.scan("array")) {
|
60
|
-
if (!p.scan("<")) {
|
61
|
-
throw new IllegalArgumentException("Cannot parse type: expected '<' for array type: " + p.getString());
|
62
|
-
}
|
63
|
-
TDColumnType elementType = parseColumnTypeRecursive(p);
|
64
|
-
if (!p.scan(">")) {
|
65
|
-
throw new IllegalArgumentException("Cannot parse type: expected '>' for array type: " + p.getString());
|
66
|
-
}
|
67
|
-
return new TDArrayColumnType(elementType);
|
68
|
-
|
69
|
-
}
|
70
|
-
else if (p.scan("map")) {
|
71
|
-
if (!p.scan("<")) {
|
72
|
-
throw new IllegalArgumentException("Cannot parse type: expected '<' for map type: " + p.getString());
|
73
|
-
}
|
74
|
-
TDColumnType keyType = parseColumnTypeRecursive(p);
|
75
|
-
if (!p.scan(",")) {
|
76
|
-
throw new IllegalArgumentException("Cannot parse type: expected ',' for map type: " + p.getString());
|
77
|
-
}
|
78
|
-
TDColumnType valueType = parseColumnTypeRecursive(p);
|
79
|
-
if (!p.scan(">")) {
|
80
|
-
throw new IllegalArgumentException("Cannot parse type: expected '>' for map type: " + p.getString());
|
81
|
-
}
|
82
|
-
return new TDMapColumnType(keyType, valueType);
|
83
|
-
|
84
|
-
}
|
85
|
-
else {
|
86
|
-
throw new IllegalArgumentException("Cannot parse type: " + p.getString());
|
87
|
-
}
|
88
|
-
}
|
89
|
-
|
90
|
-
private static class Parser
|
91
|
-
{
|
92
|
-
private final String string;
|
93
|
-
private int offset;
|
94
|
-
|
95
|
-
public Parser(String string)
|
96
|
-
{
|
97
|
-
this.string = string;
|
98
|
-
}
|
99
|
-
|
100
|
-
public String getString()
|
101
|
-
{
|
102
|
-
return string;
|
103
|
-
}
|
104
|
-
|
105
|
-
public boolean scan(String s)
|
106
|
-
{
|
107
|
-
skipSpaces();
|
108
|
-
if (string.startsWith(s, offset)) {
|
109
|
-
offset += s.length();
|
110
|
-
return true;
|
111
|
-
}
|
112
|
-
return false;
|
113
|
-
}
|
114
|
-
|
115
|
-
public boolean eof()
|
116
|
-
{
|
117
|
-
skipSpaces();
|
118
|
-
return string.length() <= offset;
|
119
|
-
}
|
120
|
-
|
121
|
-
private void skipSpaces()
|
122
|
-
{
|
123
|
-
while (string.startsWith(" ", offset)) {
|
124
|
-
offset++;
|
125
|
-
}
|
126
|
-
}
|
127
|
-
}
|
128
|
-
}
|
@@ -1,49 +0,0 @@
|
|
1
|
-
package com.treasuredata.api.model;
|
2
|
-
|
3
|
-
import com.fasterxml.jackson.annotation.JsonCreator;
|
4
|
-
import com.fasterxml.jackson.annotation.JsonProperty;
|
5
|
-
import com.google.common.base.Objects;
|
6
|
-
|
7
|
-
public class TDDatabase
|
8
|
-
{
|
9
|
-
private String name;
|
10
|
-
// "permission" field is also available but not necessary yet
|
11
|
-
|
12
|
-
@JsonCreator
|
13
|
-
public TDDatabase(
|
14
|
-
@JsonProperty("name") String name)
|
15
|
-
{
|
16
|
-
this.name = name;
|
17
|
-
}
|
18
|
-
|
19
|
-
@JsonProperty
|
20
|
-
public String getName()
|
21
|
-
{
|
22
|
-
return name;
|
23
|
-
}
|
24
|
-
|
25
|
-
public boolean isWritable()
|
26
|
-
{
|
27
|
-
// TODO not implemented yet
|
28
|
-
return true;
|
29
|
-
}
|
30
|
-
|
31
|
-
@Override
|
32
|
-
public boolean equals(Object obj)
|
33
|
-
{
|
34
|
-
if (this == obj) {
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
if (obj == null || getClass() != obj.getClass()) {
|
38
|
-
return false;
|
39
|
-
}
|
40
|
-
TDDatabase other = (TDDatabase) obj;
|
41
|
-
return Objects.equal(this.name, other.name);
|
42
|
-
}
|
43
|
-
|
44
|
-
@Override
|
45
|
-
public int hashCode()
|
46
|
-
{
|
47
|
-
return Objects.hashCode(name);
|
48
|
-
}
|
49
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
package com.treasuredata.api.model;
|
2
|
-
|
3
|
-
import com.fasterxml.jackson.annotation.JsonCreator;
|
4
|
-
import com.fasterxml.jackson.annotation.JsonProperty;
|
5
|
-
|
6
|
-
import java.util.List;
|
7
|
-
|
8
|
-
public class TDDatabaseList
|
9
|
-
{
|
10
|
-
private List<TDDatabase> databases;
|
11
|
-
|
12
|
-
@JsonCreator
|
13
|
-
public TDDatabaseList(
|
14
|
-
@JsonProperty("databases") List<TDDatabase> databases)
|
15
|
-
{
|
16
|
-
this.databases = databases;
|
17
|
-
}
|
18
|
-
|
19
|
-
@JsonProperty
|
20
|
-
public List<TDDatabase> getDatabases()
|
21
|
-
{
|
22
|
-
return databases;
|
23
|
-
}
|
24
|
-
}
|
@@ -1,88 +0,0 @@
|
|
1
|
-
package com.treasuredata.api.model;
|
2
|
-
|
3
|
-
import com.google.common.base.Objects;
|
4
|
-
|
5
|
-
public class TDMapColumnType
|
6
|
-
implements TDColumnType
|
7
|
-
{
|
8
|
-
private TDColumnType keyType;
|
9
|
-
private TDColumnType valueType;
|
10
|
-
|
11
|
-
public TDMapColumnType(TDColumnType keyType, TDColumnType valueType)
|
12
|
-
{
|
13
|
-
this.keyType = keyType;
|
14
|
-
this.valueType = valueType;
|
15
|
-
}
|
16
|
-
|
17
|
-
public TDColumnType getKeyType()
|
18
|
-
{
|
19
|
-
return keyType;
|
20
|
-
}
|
21
|
-
|
22
|
-
public TDColumnType getValueType()
|
23
|
-
{
|
24
|
-
return valueType;
|
25
|
-
}
|
26
|
-
|
27
|
-
@Override
|
28
|
-
public String toString()
|
29
|
-
{
|
30
|
-
return "map<" + keyType + "," + valueType + ">";
|
31
|
-
}
|
32
|
-
|
33
|
-
@Override
|
34
|
-
public boolean isPrimitive()
|
35
|
-
{
|
36
|
-
return false;
|
37
|
-
}
|
38
|
-
|
39
|
-
@Override
|
40
|
-
public boolean isArrayType()
|
41
|
-
{
|
42
|
-
return false;
|
43
|
-
}
|
44
|
-
|
45
|
-
@Override
|
46
|
-
public boolean isMapType()
|
47
|
-
{
|
48
|
-
return true;
|
49
|
-
}
|
50
|
-
|
51
|
-
@Override
|
52
|
-
public TDPrimitiveColumnType asPrimitiveType()
|
53
|
-
{
|
54
|
-
return null;
|
55
|
-
}
|
56
|
-
|
57
|
-
@Override
|
58
|
-
public TDArrayColumnType asArrayType()
|
59
|
-
{
|
60
|
-
return null;
|
61
|
-
}
|
62
|
-
|
63
|
-
@Override
|
64
|
-
public TDMapColumnType asMapType()
|
65
|
-
{
|
66
|
-
return this;
|
67
|
-
}
|
68
|
-
|
69
|
-
@Override
|
70
|
-
public boolean equals(Object obj)
|
71
|
-
{
|
72
|
-
if (this == obj) {
|
73
|
-
return true;
|
74
|
-
}
|
75
|
-
if (obj == null || getClass() != obj.getClass()) {
|
76
|
-
return false;
|
77
|
-
}
|
78
|
-
TDMapColumnType other = (TDMapColumnType) obj;
|
79
|
-
return Objects.equal(this.keyType, other.keyType) &&
|
80
|
-
Objects.equal(this.valueType, other.valueType);
|
81
|
-
}
|
82
|
-
|
83
|
-
@Override
|
84
|
-
public int hashCode()
|
85
|
-
{
|
86
|
-
return Objects.hashCode(keyType, valueType);
|
87
|
-
}
|
88
|
-
}
|