embulk-formatter-avro 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/build.gradle +97 -0
- data/config/checkstyle/checkstyle.xml +128 -0
- data/config/checkstyle/default.xml +108 -0
- data/example/config.yml +34 -0
- data/example/sample_01.csv +7 -0
- data/example/schema.avsc +33 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/gradlew +160 -0
- data/gradlew.bat +90 -0
- data/lib/embulk/formatter/avro.rb +3 -0
- data/src/main/java/org/embulk/formatter/avro/AvroFormatterColumnVisitor.java +97 -0
- data/src/main/java/org/embulk/formatter/avro/AvroFormatterPlugin.java +183 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AbstractAvroValueConverter.java +36 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroArrayConverter.java +52 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroBooleanConverter.java +14 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroDoubleConverter.java +29 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroEnumConverter.java +25 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroFixedConverter.java +16 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroFloatConverter.java +29 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroIntConverter.java +29 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroLongConverter.java +29 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroMapConverter.java +52 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroNullConverter.java +40 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroRecordConverter.java +59 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroStringConverter.java +41 -0
- data/src/main/java/org/embulk/formatter/avro/converter/AvroValueConverterFactory.java +52 -0
- data/src/test/java/org/embulk/formatter/avro/TestAvroFormatterPlugin.java +5 -0
- metadata +111 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
package org.embulk.formatter.avro.converter;
|
2
|
+
|
3
|
+
import com.google.common.collect.ImmutableMap;
|
4
|
+
import org.apache.avro.Schema;
|
5
|
+
|
6
|
+
public class AvroValueConverterFactory {
|
7
|
+
static public AbstractAvroValueConverter createConverter(Schema.Field field) {
|
8
|
+
return detectConverter(field.schema());
|
9
|
+
}
|
10
|
+
|
11
|
+
static private AbstractAvroValueConverter detectConverter(Schema schema) {
|
12
|
+
Schema.Type avroType = schema.getType();
|
13
|
+
switch (avroType) {
|
14
|
+
case NULL:
|
15
|
+
return new AvroNullConverter(schema);
|
16
|
+
case BOOLEAN:
|
17
|
+
return new AvroBooleanConverter(schema);
|
18
|
+
case STRING:
|
19
|
+
return new AvroStringConverter(schema);
|
20
|
+
case INT:
|
21
|
+
return new AvroIntConverter(schema);
|
22
|
+
case LONG:
|
23
|
+
return new AvroLongConverter(schema);
|
24
|
+
case FLOAT:
|
25
|
+
return new AvroFloatConverter(schema);
|
26
|
+
case DOUBLE:
|
27
|
+
return new AvroDoubleConverter(schema);
|
28
|
+
case ENUM:
|
29
|
+
return new AvroEnumConverter(schema, schema.getEnumSymbols());
|
30
|
+
case FIXED:
|
31
|
+
return new AvroFixedConverter(schema);
|
32
|
+
case UNION:
|
33
|
+
for (Schema s : schema.getTypes()) {
|
34
|
+
if (s.getType() != Schema.Type.NULL)
|
35
|
+
return detectConverter(s);
|
36
|
+
}
|
37
|
+
return new AvroNullConverter(schema);
|
38
|
+
case ARRAY:
|
39
|
+
return new AvroArrayConverter(schema, detectConverter(schema.getElementType()));
|
40
|
+
case MAP:
|
41
|
+
return new AvroMapConverter(schema, detectConverter(schema.getValueType()));
|
42
|
+
case RECORD:
|
43
|
+
ImmutableMap.Builder<String, AbstractAvroValueConverter> builder = ImmutableMap.builder();
|
44
|
+
for (Schema.Field f : schema.getFields()) {
|
45
|
+
builder.put(f.name(), detectConverter(f.schema()));
|
46
|
+
}
|
47
|
+
return new AvroRecordConverter(schema, builder.build());
|
48
|
+
default:
|
49
|
+
throw new RuntimeException(String.format("%s of %s is unsupported avro type", schema.getType(), schema.getName()));
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-formatter-avro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- joker1007
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ~>
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.0'
|
19
|
+
name: bundler
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '10.0'
|
33
|
+
name: rake
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Formats Avro files for other file output plugins.
|
42
|
+
email:
|
43
|
+
- kakyoin.hierophant@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- build.gradle
|
52
|
+
- config/checkstyle/checkstyle.xml
|
53
|
+
- config/checkstyle/default.xml
|
54
|
+
- example/config.yml
|
55
|
+
- example/sample_01.csv
|
56
|
+
- example/schema.avsc
|
57
|
+
- gradle/wrapper/gradle-wrapper.jar
|
58
|
+
- gradle/wrapper/gradle-wrapper.properties
|
59
|
+
- gradlew
|
60
|
+
- gradlew.bat
|
61
|
+
- lib/embulk/formatter/avro.rb
|
62
|
+
- src/main/java/org/embulk/formatter/avro/AvroFormatterColumnVisitor.java
|
63
|
+
- src/main/java/org/embulk/formatter/avro/AvroFormatterPlugin.java
|
64
|
+
- src/main/java/org/embulk/formatter/avro/converter/AbstractAvroValueConverter.java
|
65
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroArrayConverter.java
|
66
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroBooleanConverter.java
|
67
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroDoubleConverter.java
|
68
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroEnumConverter.java
|
69
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroFixedConverter.java
|
70
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroFloatConverter.java
|
71
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroIntConverter.java
|
72
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroLongConverter.java
|
73
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroMapConverter.java
|
74
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroNullConverter.java
|
75
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroRecordConverter.java
|
76
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroStringConverter.java
|
77
|
+
- src/main/java/org/embulk/formatter/avro/converter/AvroValueConverterFactory.java
|
78
|
+
- src/test/java/org/embulk/formatter/avro/TestAvroFormatterPlugin.java
|
79
|
+
- classpath/xz-1.5.jar
|
80
|
+
- classpath/jackson-mapper-asl-1.9.13.jar
|
81
|
+
- classpath/embulk-formatter-avro-0.1.0.jar
|
82
|
+
- classpath/paranamer-2.7.jar
|
83
|
+
- classpath/avro-1.8.1.jar
|
84
|
+
- classpath/commons-compress-1.8.1.jar
|
85
|
+
- classpath/snappy-java-1.1.1.3.jar
|
86
|
+
- classpath/jackson-core-asl-1.9.13.jar
|
87
|
+
homepage:
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.1.9
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Avro formatter plugin for Embulk
|
111
|
+
test_files: []
|