embulk-filter-null_string 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0fb202cde1e54414f3433e98ed739976bf9a2d7e
4
+ data.tar.gz: 9a8271b90a220fc201e9c48bfc75fcc9dc02e8c6
5
+ SHA512:
6
+ metadata.gz: 5a6fde482127b0f025a1af8dc606b918b118fff783dfaa32453cf7c0b8616ab2beb63f2c84b07e722c04c02f0b38290e5bfc0e6e80c6c4dc6f1ddc59678185a2
7
+ data.tar.gz: ced6372b1fcbdbe7a3c7ddb847926e317391767ff8423876b3fcbe5319dd23c5dc403e252277d07068311d161d932f3154226933bc4054736fc512997c776d98
@@ -0,0 +1,12 @@
1
+ *~
2
+ /pkg/
3
+ /tmp/
4
+ *.gemspec
5
+ .gradle/
6
+ /classpath/
7
+ build/
8
+ .idea
9
+ /.settings/
10
+ /.metadata/
11
+ .classpath
12
+ .project
@@ -0,0 +1,7 @@
1
+ language: java
2
+ jdk:
3
+ - openjdk7
4
+ - oraclejdk7
5
+ - oraclejdk8
6
+ script:
7
+ - ./gradlew test
@@ -0,0 +1,21 @@
1
+
2
+ MIT License
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # Null String filter plugin for Embulk
2
+
3
+ An Embulk filter plugin to convert the matching string to NULL.
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: filter
8
+
9
+ ## Configuration
10
+
11
+ - **columns**: name of convert columns
12
+ - **name**: column name (string, required)
13
+ - **null_string**: value of null_string (string, required)
14
+
15
+ ## Example
16
+
17
+ ```yaml
18
+ - type: null_string
19
+ columns:
20
+ - name: comment
21
+ null_string: ""
22
+ ```
23
+
24
+ ```yaml
25
+ - type: null_string
26
+ columns:
27
+ - name: comment
28
+ null_string: "\\N"
29
+ ```
30
+
31
+ ## Build
32
+
33
+ ```
34
+ $ ./gradlew gem # -t to watch change of files and rebuild continuously
35
+ ```
@@ -0,0 +1,99 @@
1
+ plugins {
2
+ id "com.jfrog.bintray" version "1.1"
3
+ id "com.github.jruby-gradle.base" version "0.1.5"
4
+ id "java"
5
+ id "checkstyle"
6
+ id "findbugs"
7
+ }
8
+ import com.github.jrubygradle.JRubyExec
9
+ repositories {
10
+ mavenCentral()
11
+ jcenter()
12
+ }
13
+ configurations {
14
+ provided
15
+ }
16
+
17
+ version = "0.1.0"
18
+
19
+ sourceCompatibility = 1.7
20
+ targetCompatibility = 1.7
21
+
22
+ dependencies {
23
+ compile "org.embulk:embulk-core:0.8.13"
24
+ provided "org.embulk:embulk-core:0.8.13"
25
+ // compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
26
+ testCompile "junit:junit:4.+"
27
+
28
+ testCompile "org.embulk:embulk-core:0.8.13:tests"
29
+ testCompile "org.embulk:embulk-standards:0.8.13"
30
+
31
+ }
32
+
33
+ task classpath(type: Copy, dependsOn: ["jar"]) {
34
+ doFirst { file("classpath").deleteDir() }
35
+ from (configurations.runtime - configurations.provided + files(jar.archivePath))
36
+ into "classpath"
37
+ }
38
+ clean { delete "classpath" }
39
+
40
+ checkstyle {
41
+ configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
42
+ toolVersion = '6.14.1'
43
+ }
44
+ checkstyleMain {
45
+ configFile = file("${project.rootDir}/config/checkstyle/default.xml")
46
+ ignoreFailures = true
47
+ }
48
+ checkstyleTest {
49
+ configFile = file("${project.rootDir}/config/checkstyle/default.xml")
50
+ ignoreFailures = true
51
+ }
52
+ task checkstyle(type: Checkstyle) {
53
+ classpath = sourceSets.main.output + sourceSets.test.output
54
+ source = sourceSets.main.allJava + sourceSets.test.allJava
55
+ }
56
+
57
+ task gem(type: JRubyExec, dependsOn: ["gemspec", "classpath"]) {
58
+ jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build"
59
+ script "${project.name}.gemspec"
60
+ doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
61
+ }
62
+
63
+ task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
64
+ jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "push"
65
+ script "pkg/${project.name}-${project.version}.gem"
66
+ }
67
+
68
+ task "package"(dependsOn: ["gemspec", "classpath"]) << {
69
+ println "> Build succeeded."
70
+ println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
71
+ }
72
+
73
+ task gemspec {
74
+ ext.gemspecFile = file("${project.name}.gemspec")
75
+ inputs.file "build.gradle"
76
+ outputs.file gemspecFile
77
+ doLast { gemspecFile.write($/
78
+ Gem::Specification.new do |spec|
79
+ spec.name = "${project.name}"
80
+ spec.version = "${project.version}"
81
+ spec.authors = ["Hiroyuki Sato"]
82
+ spec.summary = %[Null String filter plugin for Embulk]
83
+ spec.description = %[An Embulk filter plugin to convert the matching string to NULL.]
84
+ spec.email = ["hiroysato@gmail.com"]
85
+ spec.licenses = ["MIT"]
86
+ spec.homepage = "https://github.com/hiroyuki-sato/embulk-filter-null_string"
87
+
88
+ spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
89
+ spec.test_files = spec.files.grep(%r"^(test|spec)/")
90
+ spec.require_paths = ["lib"]
91
+
92
+ #spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
93
+ spec.add_development_dependency 'bundler', ['~> 1.0']
94
+ spec.add_development_dependency 'rake', ['>= 10.0']
95
+ end
96
+ /$)
97
+ }
98
+ }
99
+ clean { delete "${project.name}.gemspec" }
@@ -0,0 +1,128 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE module PUBLIC
3
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
5
+ <module name="Checker">
6
+ <!-- https://github.com/facebook/presto/blob/master/src/checkstyle/checks.xml -->
7
+ <module name="FileTabCharacter"/>
8
+ <module name="NewlineAtEndOfFile">
9
+ <property name="lineSeparator" value="lf"/>
10
+ </module>
11
+ <module name="RegexpMultiline">
12
+ <property name="format" value="\r"/>
13
+ <property name="message" value="Line contains carriage return"/>
14
+ </module>
15
+ <module name="RegexpMultiline">
16
+ <property name="format" value=" \n"/>
17
+ <property name="message" value="Line has trailing whitespace"/>
18
+ </module>
19
+ <module name="RegexpMultiline">
20
+ <property name="format" value="\{\n\n"/>
21
+ <property name="message" value="Blank line after opening brace"/>
22
+ </module>
23
+ <module name="RegexpMultiline">
24
+ <property name="format" value="\n\n\s*\}"/>
25
+ <property name="message" value="Blank line before closing brace"/>
26
+ </module>
27
+ <module name="RegexpMultiline">
28
+ <property name="format" value="\n\n\n"/>
29
+ <property name="message" value="Multiple consecutive blank lines"/>
30
+ </module>
31
+ <module name="RegexpMultiline">
32
+ <property name="format" value="\n\n\Z"/>
33
+ <property name="message" value="Blank line before end of file"/>
34
+ </module>
35
+ <module name="RegexpMultiline">
36
+ <property name="format" value="Preconditions\.checkNotNull"/>
37
+ <property name="message" value="Use of checkNotNull"/>
38
+ </module>
39
+
40
+ <module name="TreeWalker">
41
+ <module name="EmptyBlock">
42
+ <property name="option" value="text"/>
43
+ <property name="tokens" value="
44
+ LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
45
+ LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
46
+ </module>
47
+ <module name="EmptyStatement"/>
48
+ <module name="EmptyForInitializerPad"/>
49
+ <module name="EmptyForIteratorPad">
50
+ <property name="option" value="space"/>
51
+ </module>
52
+ <module name="MethodParamPad">
53
+ <property name="allowLineBreaks" value="true"/>
54
+ <property name="option" value="nospace"/>
55
+ </module>
56
+ <module name="ParenPad"/>
57
+ <module name="TypecastParenPad"/>
58
+ <module name="NeedBraces"/>
59
+ <module name="LeftCurly">
60
+ <property name="option" value="nl"/>
61
+ <property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
62
+ </module>
63
+ <module name="LeftCurly">
64
+ <property name="option" value="eol"/>
65
+ <property name="tokens" value="
66
+ LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
67
+ LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
68
+ </module>
69
+ <module name="RightCurly">
70
+ <property name="option" value="alone"/>
71
+ </module>
72
+ <module name="GenericWhitespace"/>
73
+ <module name="WhitespaceAfter"/>
74
+ <module name="NoWhitespaceBefore"/>
75
+
76
+ <module name="UpperEll"/>
77
+ <module name="DefaultComesLast"/>
78
+ <module name="ArrayTypeStyle"/>
79
+ <module name="MultipleVariableDeclarations"/>
80
+ <module name="ModifierOrder"/>
81
+ <module name="OneStatementPerLine"/>
82
+ <module name="StringLiteralEquality"/>
83
+ <module name="MutableException"/>
84
+ <module name="EqualsHashCode"/>
85
+ <module name="InnerAssignment"/>
86
+ <module name="InterfaceIsType"/>
87
+ <module name="HideUtilityClassConstructor"/>
88
+
89
+ <module name="MemberName"/>
90
+ <module name="LocalVariableName"/>
91
+ <module name="LocalFinalVariableName"/>
92
+ <module name="TypeName"/>
93
+ <module name="PackageName"/>
94
+ <module name="ParameterName"/>
95
+ <module name="StaticVariableName"/>
96
+ <module name="ClassTypeParameterName">
97
+ <property name="format" value="^[A-Z][0-9]?$"/>
98
+ </module>
99
+ <module name="MethodTypeParameterName">
100
+ <property name="format" value="^[A-Z][0-9]?$"/>
101
+ </module>
102
+
103
+ <module name="AvoidStarImport"/>
104
+ <module name="RedundantImport"/>
105
+ <module name="UnusedImports"/>
106
+ <module name="ImportOrder">
107
+ <property name="groups" value="*,javax,java"/>
108
+ <property name="separated" value="true"/>
109
+ <property name="option" value="bottom"/>
110
+ <property name="sortStaticImportsAlphabetically" value="true"/>
111
+ </module>
112
+
113
+ <module name="WhitespaceAround">
114
+ <property name="allowEmptyConstructors" value="true"/>
115
+ <property name="allowEmptyMethods" value="true"/>
116
+ <property name="ignoreEnhancedForColon" value="false"/>
117
+ <property name="tokens" value="
118
+ ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
119
+ BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
120
+ LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
121
+ LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
122
+ LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
123
+ LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
124
+ PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
125
+ STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
126
+ </module>
127
+ </module>
128
+ </module>
@@ -0,0 +1,108 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE module PUBLIC
3
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
5
+ <!--
6
+ This is a subset of ./checkstyle.xml which allows some loose styles
7
+ -->
8
+ <module name="Checker">
9
+ <module name="FileTabCharacter"/>
10
+ <module name="NewlineAtEndOfFile">
11
+ <property name="lineSeparator" value="lf"/>
12
+ </module>
13
+ <module name="RegexpMultiline">
14
+ <property name="format" value="\r"/>
15
+ <property name="message" value="Line contains carriage return"/>
16
+ </module>
17
+ <module name="RegexpMultiline">
18
+ <property name="format" value=" \n"/>
19
+ <property name="message" value="Line has trailing whitespace"/>
20
+ </module>
21
+ <module name="RegexpMultiline">
22
+ <property name="format" value="\n\n\n"/>
23
+ <property name="message" value="Multiple consecutive blank lines"/>
24
+ </module>
25
+ <module name="RegexpMultiline">
26
+ <property name="format" value="\n\n\Z"/>
27
+ <property name="message" value="Blank line before end of file"/>
28
+ </module>
29
+
30
+ <module name="TreeWalker">
31
+ <module name="EmptyBlock">
32
+ <property name="option" value="text"/>
33
+ <property name="tokens" value="
34
+ LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
35
+ LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
36
+ </module>
37
+ <module name="EmptyStatement"/>
38
+ <module name="EmptyForInitializerPad"/>
39
+ <module name="EmptyForIteratorPad">
40
+ <property name="option" value="space"/>
41
+ </module>
42
+ <module name="MethodParamPad">
43
+ <property name="allowLineBreaks" value="true"/>
44
+ <property name="option" value="nospace"/>
45
+ </module>
46
+ <module name="ParenPad"/>
47
+ <module name="TypecastParenPad"/>
48
+ <module name="NeedBraces"/>
49
+ <module name="LeftCurly">
50
+ <property name="option" value="nl"/>
51
+ <property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
52
+ </module>
53
+ <module name="LeftCurly">
54
+ <property name="option" value="eol"/>
55
+ <property name="tokens" value="
56
+ LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
57
+ LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
58
+ </module>
59
+ <module name="RightCurly">
60
+ <property name="option" value="alone"/>
61
+ </module>
62
+ <module name="GenericWhitespace"/>
63
+ <module name="WhitespaceAfter"/>
64
+ <module name="NoWhitespaceBefore"/>
65
+
66
+ <module name="UpperEll"/>
67
+ <module name="DefaultComesLast"/>
68
+ <module name="ArrayTypeStyle"/>
69
+ <module name="MultipleVariableDeclarations"/>
70
+ <module name="ModifierOrder"/>
71
+ <module name="OneStatementPerLine"/>
72
+ <module name="StringLiteralEquality"/>
73
+ <module name="MutableException"/>
74
+ <module name="EqualsHashCode"/>
75
+ <module name="InnerAssignment"/>
76
+ <module name="InterfaceIsType"/>
77
+ <module name="HideUtilityClassConstructor"/>
78
+
79
+ <module name="MemberName"/>
80
+ <module name="LocalVariableName"/>
81
+ <module name="LocalFinalVariableName"/>
82
+ <module name="TypeName"/>
83
+ <module name="PackageName"/>
84
+ <module name="ParameterName"/>
85
+ <module name="StaticVariableName"/>
86
+ <module name="ClassTypeParameterName">
87
+ <property name="format" value="^[A-Z][0-9]?$"/>
88
+ </module>
89
+ <module name="MethodTypeParameterName">
90
+ <property name="format" value="^[A-Z][0-9]?$"/>
91
+ </module>
92
+
93
+ <module name="WhitespaceAround">
94
+ <property name="allowEmptyConstructors" value="true"/>
95
+ <property name="allowEmptyMethods" value="true"/>
96
+ <property name="ignoreEnhancedForColon" value="false"/>
97
+ <property name="tokens" value="
98
+ ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
99
+ BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
100
+ LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
101
+ LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
102
+ LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
103
+ LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
104
+ PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
105
+ STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
106
+ </module>
107
+ </module>
108
+ </module>
@@ -0,0 +1,6 @@
1
+ #Wed Jan 13 12:41:02 JST 2016
2
+ distributionBase=GRADLE_USER_HOME
3
+ distributionPath=wrapper/dists
4
+ zipStoreBase=GRADLE_USER_HOME
5
+ zipStorePath=wrapper/dists
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
data/gradlew ADDED
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ##############################################################################
4
+ ##
5
+ ## Gradle start up script for UN*X
6
+ ##
7
+ ##############################################################################
8
+
9
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10
+ DEFAULT_JVM_OPTS=""
11
+
12
+ APP_NAME="Gradle"
13
+ APP_BASE_NAME=`basename "$0"`
14
+
15
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
16
+ MAX_FD="maximum"
17
+
18
+ warn ( ) {
19
+ echo "$*"
20
+ }
21
+
22
+ die ( ) {
23
+ echo
24
+ echo "$*"
25
+ echo
26
+ exit 1
27
+ }
28
+
29
+ # OS specific support (must be 'true' or 'false').
30
+ cygwin=false
31
+ msys=false
32
+ darwin=false
33
+ case "`uname`" in
34
+ CYGWIN* )
35
+ cygwin=true
36
+ ;;
37
+ Darwin* )
38
+ darwin=true
39
+ ;;
40
+ MINGW* )
41
+ msys=true
42
+ ;;
43
+ esac
44
+
45
+ # Attempt to set APP_HOME
46
+ # Resolve links: $0 may be a link
47
+ PRG="$0"
48
+ # Need this for relative symlinks.
49
+ while [ -h "$PRG" ] ; do
50
+ ls=`ls -ld "$PRG"`
51
+ link=`expr "$ls" : '.*-> \(.*\)$'`
52
+ if expr "$link" : '/.*' > /dev/null; then
53
+ PRG="$link"
54
+ else
55
+ PRG=`dirname "$PRG"`"/$link"
56
+ fi
57
+ done
58
+ SAVED="`pwd`"
59
+ cd "`dirname \"$PRG\"`/" >/dev/null
60
+ APP_HOME="`pwd -P`"
61
+ cd "$SAVED" >/dev/null
62
+
63
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64
+
65
+ # Determine the Java command to use to start the JVM.
66
+ if [ -n "$JAVA_HOME" ] ; then
67
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68
+ # IBM's JDK on AIX uses strange locations for the executables
69
+ JAVACMD="$JAVA_HOME/jre/sh/java"
70
+ else
71
+ JAVACMD="$JAVA_HOME/bin/java"
72
+ fi
73
+ if [ ! -x "$JAVACMD" ] ; then
74
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75
+
76
+ Please set the JAVA_HOME variable in your environment to match the
77
+ location of your Java installation."
78
+ fi
79
+ else
80
+ JAVACMD="java"
81
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82
+
83
+ Please set the JAVA_HOME variable in your environment to match the
84
+ location of your Java installation."
85
+ fi
86
+
87
+ # Increase the maximum file descriptors if we can.
88
+ if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89
+ MAX_FD_LIMIT=`ulimit -H -n`
90
+ if [ $? -eq 0 ] ; then
91
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92
+ MAX_FD="$MAX_FD_LIMIT"
93
+ fi
94
+ ulimit -n $MAX_FD
95
+ if [ $? -ne 0 ] ; then
96
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
97
+ fi
98
+ else
99
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100
+ fi
101
+ fi
102
+
103
+ # For Darwin, add options to specify how the application appears in the dock
104
+ if $darwin; then
105
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106
+ fi
107
+
108
+ # For Cygwin, switch paths to Windows format before running java
109
+ if $cygwin ; then
110
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112
+ JAVACMD=`cygpath --unix "$JAVACMD"`
113
+
114
+ # We build the pattern for arguments to be converted via cygpath
115
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116
+ SEP=""
117
+ for dir in $ROOTDIRSRAW ; do
118
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
119
+ SEP="|"
120
+ done
121
+ OURCYGPATTERN="(^($ROOTDIRS))"
122
+ # Add a user-defined pattern to the cygpath arguments
123
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125
+ fi
126
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
127
+ i=0
128
+ for arg in "$@" ; do
129
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131
+
132
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134
+ else
135
+ eval `echo args$i`="\"$arg\""
136
+ fi
137
+ i=$((i+1))
138
+ done
139
+ case $i in
140
+ (0) set -- ;;
141
+ (1) set -- "$args0" ;;
142
+ (2) set -- "$args0" "$args1" ;;
143
+ (3) set -- "$args0" "$args1" "$args2" ;;
144
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150
+ esac
151
+ fi
152
+
153
+ # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154
+ function splitJvmOpts() {
155
+ JVM_OPTS=("$@")
156
+ }
157
+ eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158
+ JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159
+
160
+ exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@@ -0,0 +1,90 @@
1
+ @if "%DEBUG%" == "" @echo off
2
+ @rem ##########################################################################
3
+ @rem
4
+ @rem Gradle startup script for Windows
5
+ @rem
6
+ @rem ##########################################################################
7
+
8
+ @rem Set local scope for the variables with windows NT shell
9
+ if "%OS%"=="Windows_NT" setlocal
10
+
11
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12
+ set DEFAULT_JVM_OPTS=
13
+
14
+ set DIRNAME=%~dp0
15
+ if "%DIRNAME%" == "" set DIRNAME=.
16
+ set APP_BASE_NAME=%~n0
17
+ set APP_HOME=%DIRNAME%
18
+
19
+ @rem Find java.exe
20
+ if defined JAVA_HOME goto findJavaFromJavaHome
21
+
22
+ set JAVA_EXE=java.exe
23
+ %JAVA_EXE% -version >NUL 2>&1
24
+ if "%ERRORLEVEL%" == "0" goto init
25
+
26
+ echo.
27
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
+ echo.
29
+ echo Please set the JAVA_HOME variable in your environment to match the
30
+ echo location of your Java installation.
31
+
32
+ goto fail
33
+
34
+ :findJavaFromJavaHome
35
+ set JAVA_HOME=%JAVA_HOME:"=%
36
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
+
38
+ if exist "%JAVA_EXE%" goto init
39
+
40
+ echo.
41
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
+ echo.
43
+ echo Please set the JAVA_HOME variable in your environment to match the
44
+ echo location of your Java installation.
45
+
46
+ goto fail
47
+
48
+ :init
49
+ @rem Get command-line arguments, handling Windowz variants
50
+
51
+ if not "%OS%" == "Windows_NT" goto win9xME_args
52
+ if "%@eval[2+2]" == "4" goto 4NT_args
53
+
54
+ :win9xME_args
55
+ @rem Slurp the command line arguments.
56
+ set CMD_LINE_ARGS=
57
+ set _SKIP=2
58
+
59
+ :win9xME_args_slurp
60
+ if "x%~1" == "x" goto execute
61
+
62
+ set CMD_LINE_ARGS=%*
63
+ goto execute
64
+
65
+ :4NT_args
66
+ @rem Get arguments from the 4NT Shell from JP Software
67
+ set CMD_LINE_ARGS=%$
68
+
69
+ :execute
70
+ @rem Setup the command line
71
+
72
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73
+
74
+ @rem Execute Gradle
75
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76
+
77
+ :end
78
+ @rem End local scope for the variables with windows NT shell
79
+ if "%ERRORLEVEL%"=="0" goto mainEnd
80
+
81
+ :fail
82
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83
+ rem the _cmd.exe /c_ return code!
84
+ if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85
+ exit /b 1
86
+
87
+ :mainEnd
88
+ if "%OS%"=="Windows_NT" endlocal
89
+
90
+ :omega
@@ -0,0 +1,3 @@
1
+ Embulk::JavaPlugin.register_filter(
2
+ "null_string", "org.embulk.filter.null_string.NullStringFilterPlugin",
3
+ File.expand_path('../../../../classpath', __FILE__))
@@ -0,0 +1,98 @@
1
+ package org.embulk.filter.null_string;
2
+
3
+ import org.embulk.config.Config;
4
+ import org.embulk.config.ConfigSource;
5
+ import org.embulk.config.Task;
6
+ import org.embulk.config.TaskSource;
7
+ import org.embulk.spi.Column;
8
+ import org.embulk.spi.Exec;
9
+ import org.embulk.spi.FilterPlugin;
10
+ import org.embulk.spi.Page;
11
+ import org.embulk.spi.PageBuilder;
12
+ import org.embulk.spi.PageOutput;
13
+ import org.embulk.spi.PageReader;
14
+ import org.embulk.spi.Schema;
15
+
16
+ import java.util.List;
17
+
18
+ public class NullStringFilterPlugin
19
+ implements FilterPlugin
20
+ {
21
+ public interface NullColumnConfig
22
+ extends Task
23
+ {
24
+ @Config("name")
25
+ String getName();
26
+
27
+ @Config("null_string")
28
+ String getNullString();
29
+ }
30
+
31
+ public interface PluginTask
32
+ extends Task
33
+ {
34
+ @Config("columns")
35
+ public List<NullColumnConfig> getNullColumnConfig();
36
+ }
37
+
38
+ @Override
39
+ public void transaction(ConfigSource config, Schema inputSchema,
40
+ FilterPlugin.Control control)
41
+ {
42
+ PluginTask task = config.loadConfig(PluginTask.class);
43
+
44
+ Schema outputSchema = inputSchema;
45
+
46
+ for (NullColumnConfig nullConfig : task.getNullColumnConfig()) {
47
+ inputSchema.lookupColumn(nullConfig.getName());
48
+ }
49
+
50
+ control.run(task.dump(), outputSchema);
51
+ }
52
+
53
+ static Schema buildOutputSchema(PluginTask task, Schema inputSchema)
54
+ {
55
+ Schema.Builder builder = Schema.builder();
56
+ for (Column inputColumns : inputSchema.getColumns()) {
57
+ builder.add(inputColumns.getName(), inputColumns.getType());
58
+ }
59
+ return builder.build();
60
+ }
61
+
62
+ @Override
63
+ public PageOutput open(TaskSource taskSource, final Schema inputSchema,
64
+ final Schema outputSchema, final PageOutput output)
65
+ {
66
+ final PluginTask task = taskSource.loadTask(PluginTask.class);
67
+
68
+ return new PageOutput()
69
+ {
70
+ private PageReader pageReader = new PageReader(inputSchema);
71
+ private PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
72
+ private NullStringVisitorImpl visitor = new NullStringVisitorImpl(task, inputSchema, outputSchema, pageReader, pageBuilder);
73
+
74
+ @Override
75
+ public void finish()
76
+ {
77
+ pageBuilder.finish();
78
+ }
79
+
80
+ @Override
81
+ public void close()
82
+ {
83
+ pageBuilder.close();
84
+ }
85
+
86
+ @Override
87
+ public void add(Page page)
88
+ {
89
+ pageReader.setPage(page);
90
+
91
+ while (pageReader.nextRecord()) {
92
+ outputSchema.visitColumns(visitor);
93
+ pageBuilder.addRecord();
94
+ }
95
+ }
96
+ };
97
+ }
98
+ }
@@ -0,0 +1,121 @@
1
+ package org.embulk.filter.null_string;
2
+
3
+ import org.embulk.spi.Column;
4
+ import org.embulk.spi.ColumnVisitor;
5
+ import org.embulk.spi.Exec;
6
+ import org.embulk.spi.PageBuilder;
7
+ import org.embulk.spi.PageReader;
8
+ import org.embulk.spi.Schema;
9
+ import org.slf4j.Logger;
10
+
11
+ import java.util.HashMap;
12
+
13
+ import static java.util.Locale.ENGLISH;
14
+
15
+ public class NullStringVisitorImpl
16
+ implements ColumnVisitor
17
+ {
18
+ private static final Logger logger = Exec.getLogger(NullStringFilterPlugin.class);
19
+ private final NullStringFilterPlugin.PluginTask task;
20
+ private final Schema inputSchema;
21
+ private final Schema outputSchema;
22
+ private final PageReader pageReader;
23
+ private final PageBuilder pageBuilder;
24
+ private final HashMap<String, String> nullStringMap = new HashMap<>();
25
+
26
+ NullStringVisitorImpl(NullStringFilterPlugin.PluginTask task, Schema inputSchema, Schema outputSchema, PageReader pageReader, PageBuilder pageBuilder)
27
+ {
28
+ this.task = task;
29
+ this.inputSchema = inputSchema;
30
+ this.outputSchema = outputSchema;
31
+ this.pageReader = pageReader;
32
+ this.pageBuilder = pageBuilder;
33
+ initializeNullStringMap();
34
+ }
35
+
36
+ private void initializeNullStringMap()
37
+ {
38
+ for (NullStringFilterPlugin.NullColumnConfig nullStringConfig : task.getNullColumnConfig()) {
39
+ logger.debug(String.format(ENGLISH, "set null_string %s = \"%s\"", nullStringConfig.getName(), nullStringConfig.getNullString()));
40
+ nullStringMap.put(nullStringConfig.getName(), nullStringConfig.getNullString());
41
+ }
42
+ }
43
+
44
+ @Override
45
+ public void booleanColumn(Column outputColumn)
46
+ {
47
+ Column inputColumn = inputSchema.lookupColumn(outputColumn.getName());
48
+ pageBuilder.setBoolean(outputColumn, pageReader.getBoolean(inputColumn));
49
+ }
50
+
51
+ @Override
52
+ public void longColumn(Column outputColumn)
53
+ {
54
+ Column inputColumn = inputSchema.lookupColumn(outputColumn.getName());
55
+ if (pageReader.isNull(inputColumn)) {
56
+ pageBuilder.setNull(outputColumn);
57
+ }
58
+ else {
59
+ pageBuilder.setLong(outputColumn, pageReader.getLong(inputColumn));
60
+ }
61
+ }
62
+
63
+ @Override
64
+ public void doubleColumn(Column outputColumn)
65
+ {
66
+ Column inputColumn = inputSchema.lookupColumn(outputColumn.getName());
67
+ if (pageReader.isNull(inputColumn)) {
68
+ pageBuilder.setNull(outputColumn);
69
+ }
70
+ else {
71
+ pageBuilder.setDouble(outputColumn, pageReader.getDouble(inputColumn));
72
+ }
73
+ }
74
+
75
+ @Override
76
+ public void stringColumn(Column outputColumn)
77
+ {
78
+ Column inputColumn = inputSchema.lookupColumn(outputColumn.getName());
79
+ if (pageReader.isNull(inputColumn)) {
80
+ pageBuilder.setNull(outputColumn);
81
+ }
82
+ else {
83
+ String nullString = nullStringMap.get(outputColumn.getName());
84
+ String value = pageReader.getString(inputColumn);
85
+
86
+ logger.debug(String.format(ENGLISH, "value = \"%s\", null_string = \"%s\"", value, nullString));
87
+
88
+ if (nullString != null && nullString.equals(value)) {
89
+ pageBuilder.setNull(outputColumn);
90
+ }
91
+ else {
92
+ pageBuilder.setString(outputColumn, pageReader.getString(inputColumn));
93
+ }
94
+ }
95
+ }
96
+
97
+ @Override
98
+ public void jsonColumn(Column outputColumn)
99
+ {
100
+ Column inputColumn = inputSchema.lookupColumn(outputColumn.getName());
101
+ if (pageReader.isNull(inputColumn)) {
102
+ pageBuilder.setNull(outputColumn);
103
+ }
104
+ else {
105
+ pageBuilder.setJson(outputColumn, pageReader.getJson(inputColumn));
106
+ }
107
+ ;
108
+ }
109
+
110
+ @Override
111
+ public void timestampColumn(Column outputColumn)
112
+ {
113
+ Column inputColumn = inputSchema.lookupColumn(outputColumn.getName());
114
+ if (pageReader.isNull(inputColumn)) {
115
+ pageBuilder.setNull(outputColumn);
116
+ }
117
+ else {
118
+ pageBuilder.setTimestamp(outputColumn, pageReader.getTimestamp(inputColumn));
119
+ }
120
+ }
121
+ }
@@ -0,0 +1,5 @@
1
+ package org.embulk.filter.null_string;
2
+
3
+ public class TestNullStringFilterPlugin
4
+ {
5
+ }
@@ -0,0 +1,271 @@
1
+ package org.embulk.filter.null_string;
2
+
3
+ import org.embulk.EmbulkTestRuntime;
4
+ import org.embulk.config.ConfigLoader;
5
+ import org.embulk.config.ConfigSource;
6
+ import org.embulk.filter.null_string.NullStringFilterPlugin.PluginTask;
7
+ import org.embulk.spi.Exec;
8
+ import org.embulk.spi.Page;
9
+ import org.embulk.spi.PageBuilder;
10
+ import org.embulk.spi.PageReader;
11
+ import org.embulk.spi.PageTestUtils;
12
+ import org.embulk.spi.Schema;
13
+ import org.embulk.spi.TestPageBuilderReader;
14
+ import org.embulk.spi.time.Timestamp;
15
+ import org.embulk.spi.util.Pages;
16
+ import org.junit.Before;
17
+ import org.junit.Rule;
18
+ import org.junit.Test;
19
+ import org.msgpack.value.ValueFactory;
20
+
21
+ import java.util.List;
22
+
23
+ import static org.embulk.spi.type.Types.BOOLEAN;
24
+ import static org.embulk.spi.type.Types.DOUBLE;
25
+ import static org.embulk.spi.type.Types.JSON;
26
+ import static org.embulk.spi.type.Types.LONG;
27
+ import static org.embulk.spi.type.Types.STRING;
28
+ import static org.embulk.spi.type.Types.TIMESTAMP;
29
+ import static org.junit.Assert.assertEquals;
30
+
31
+ public class TestNullStringVisitorImpl
32
+ {
33
+ @Rule
34
+ public EmbulkTestRuntime runtime = new EmbulkTestRuntime();
35
+
36
+ @Before
37
+ public void createResource()
38
+ {
39
+ }
40
+
41
+ private ConfigSource config()
42
+ {
43
+ return runtime.getExec().newConfigSource();
44
+ }
45
+
46
+ private PluginTask taskFromYamlString(String... lines)
47
+ {
48
+ StringBuilder builder = new StringBuilder();
49
+ for (String line : lines) {
50
+ builder.append(line).append("\n");
51
+ }
52
+ String yamlString = builder.toString();
53
+
54
+ ConfigLoader loader = new ConfigLoader(Exec.getModelManager());
55
+ ConfigSource config = loader.fromYamlString(yamlString);
56
+ return config.loadConfig(PluginTask.class);
57
+ }
58
+
59
+ private List<Object[]> filter(PluginTask task, Schema inputSchema, Object... objects)
60
+ {
61
+ TestPageBuilderReader.MockPageOutput output = new TestPageBuilderReader.MockPageOutput();
62
+ Schema outputSchema = NullStringFilterPlugin.buildOutputSchema(task, inputSchema);
63
+ PageBuilder pageBuilder = new PageBuilder(runtime.getBufferAllocator(), outputSchema, output);
64
+ PageReader pageReader = new PageReader(inputSchema);
65
+ NullStringVisitorImpl visitor = new NullStringVisitorImpl(task, inputSchema, outputSchema, pageReader, pageBuilder);
66
+
67
+ List<Page> pages = PageTestUtils.buildPage(runtime.getBufferAllocator(), inputSchema, objects);
68
+ for (Page page : pages) {
69
+ pageReader.setPage(page);
70
+
71
+ while (pageReader.nextRecord()) {
72
+ outputSchema.visitColumns(visitor);
73
+ pageBuilder.addRecord();
74
+ }
75
+ }
76
+ pageBuilder.finish();
77
+ pageBuilder.close();
78
+ return Pages.toObjects(outputSchema, output.pages);
79
+ }
80
+
81
+ @Test
82
+ public void visit_nullString_NoConvert()
83
+ {
84
+ PluginTask task = taskFromYamlString(
85
+ "type: null_string",
86
+ "columns: []");
87
+ Schema inputSchema = Schema.builder()
88
+ .add("timestamp", TIMESTAMP)
89
+ .add("string", STRING)
90
+ .add("boolean", BOOLEAN)
91
+ .add("long", LONG)
92
+ .add("double", DOUBLE)
93
+ .add("json", JSON)
94
+ .build();
95
+ List<Object[]> records = filter(task, inputSchema,
96
+ // row1
97
+ Timestamp.ofEpochSecond(1436745600), "string", new Boolean(true), new Long(0), new Double(0.5), ValueFactory.newString("json"),
98
+ // row2
99
+ Timestamp.ofEpochSecond(1436745600), "string", new Boolean(true), new Long(0), new Double(0.5), ValueFactory.newString("json"));
100
+
101
+ assertEquals(2, records.size());
102
+
103
+ Object[] record;
104
+ {
105
+ record = records.get(0);
106
+ assertEquals(6, record.length);
107
+ assertEquals(Timestamp.ofEpochSecond(1436745600), record[0]);
108
+ assertEquals("string", record[1]);
109
+ assertEquals(new Boolean(true), record[2]);
110
+ assertEquals(new Long(0), record[3]);
111
+ assertEquals(new Double(0.5), record[4]);
112
+ assertEquals(ValueFactory.newString("json"), record[5]);
113
+ }
114
+ }
115
+
116
+ @Test
117
+ public void visit_nullString_BasicConvert()
118
+ {
119
+ PluginTask task = taskFromYamlString(
120
+ "type: null_string",
121
+ "columns:",
122
+ " - name: null_string",
123
+ " null_string: \"\"");
124
+ Schema inputSchema = Schema.builder()
125
+ .add("timestamp", TIMESTAMP)
126
+ .add("string", STRING)
127
+ .add("boolean", BOOLEAN)
128
+ .add("long", LONG)
129
+ .add("double", DOUBLE)
130
+ .add("json", JSON)
131
+ .add("null_string", STRING)
132
+ .build();
133
+ List<Object[]> records = filter(task, inputSchema,
134
+ // row1
135
+ Timestamp.ofEpochSecond(1436745600), "string", new Boolean(true), new Long(0), new Double(0.5), ValueFactory.newString("json"), "",
136
+ // row2
137
+ Timestamp.ofEpochSecond(1436745600), "string", new Boolean(true), new Long(0), new Double(0.5), ValueFactory.newString("json"), "");
138
+
139
+ assertEquals(2, records.size());
140
+
141
+ Object[] record;
142
+ {
143
+ record = records.get(0);
144
+ assertEquals(7, record.length);
145
+ assertEquals(Timestamp.ofEpochSecond(1436745600), record[0]);
146
+ assertEquals("string", record[1]);
147
+ assertEquals(new Boolean(true), record[2]);
148
+ assertEquals(new Long(0), record[3]);
149
+ assertEquals(new Double(0.5), record[4]);
150
+ assertEquals(ValueFactory.newString("json"), record[5]);
151
+ assertEquals(null, record[6]);
152
+ }
153
+ }
154
+
155
+ @Test
156
+ public void visit_nullString_NoMatchConvert()
157
+ {
158
+ PluginTask task = taskFromYamlString(
159
+ "type: null_string",
160
+ "columns:",
161
+ " - name: null_string",
162
+ " null_string: \"\"");
163
+ Schema inputSchema = Schema.builder()
164
+ .add("timestamp", TIMESTAMP)
165
+ .add("string", STRING)
166
+ .add("boolean", BOOLEAN)
167
+ .add("long", LONG)
168
+ .add("double", DOUBLE)
169
+ .add("json", JSON)
170
+ .add("null_string", STRING)
171
+ .build();
172
+ List<Object[]> records = filter(task, inputSchema,
173
+ // row1
174
+ Timestamp.ofEpochSecond(1436745600), "string", new Boolean(true), new Long(0), new Double(0.5), ValueFactory.newString("json"), "test",
175
+ // row2
176
+ Timestamp.ofEpochSecond(1436745600), "string", new Boolean(true), new Long(0), new Double(0.5), ValueFactory.newString("json"), "test");
177
+
178
+ assertEquals(2, records.size());
179
+
180
+ Object[] record;
181
+ {
182
+ record = records.get(0);
183
+ assertEquals(7, record.length);
184
+ assertEquals(Timestamp.ofEpochSecond(1436745600), record[0]);
185
+ assertEquals("string", record[1]);
186
+ assertEquals(new Boolean(true), record[2]);
187
+ assertEquals(new Long(0), record[3]);
188
+ assertEquals(new Double(0.5), record[4]);
189
+ assertEquals(ValueFactory.newString("json"), record[5]);
190
+ assertEquals("test", record[6]);
191
+ }
192
+ }
193
+
194
+ @Test
195
+ public void visit_nullString_StringConvert()
196
+ {
197
+ PluginTask task = taskFromYamlString(
198
+ "type: null_string",
199
+ "columns:",
200
+ " - name: null_string",
201
+ " null_string: \"_NULL_\"");
202
+ Schema inputSchema = Schema.builder()
203
+ .add("timestamp", TIMESTAMP)
204
+ .add("string", STRING)
205
+ .add("boolean", BOOLEAN)
206
+ .add("long", LONG)
207
+ .add("double", DOUBLE)
208
+ .add("json", JSON)
209
+ .add("null_string", STRING)
210
+ .build();
211
+ List<Object[]> records = filter(task, inputSchema,
212
+ // row1
213
+ Timestamp.ofEpochSecond(1436745600), "string", new Boolean(true), new Long(0), new Double(0.5), ValueFactory.newString("json"), "_NULL_",
214
+ // row2
215
+ Timestamp.ofEpochSecond(1436745600), "string", new Boolean(true), new Long(0), new Double(0.5), ValueFactory.newString("json"), "_NULL_");
216
+
217
+ assertEquals(2, records.size());
218
+
219
+ Object[] record;
220
+ {
221
+ record = records.get(0);
222
+ assertEquals(7, record.length);
223
+ assertEquals(Timestamp.ofEpochSecond(1436745600), record[0]);
224
+ assertEquals("string", record[1]);
225
+ assertEquals(new Boolean(true), record[2]);
226
+ assertEquals(new Long(0), record[3]);
227
+ assertEquals(new Double(0.5), record[4]);
228
+ assertEquals(ValueFactory.newString("json"), record[5]);
229
+ assertEquals(null, record[6]);
230
+ }
231
+ }
232
+ @Test
233
+ public void visit_nullString_StringConvert2()
234
+ {
235
+ PluginTask task = taskFromYamlString(
236
+ "type: null_string",
237
+ "columns:",
238
+ " - name: null_string",
239
+ " null_string: \"\\\\N\"");
240
+ Schema inputSchema = Schema.builder()
241
+ .add("timestamp", TIMESTAMP)
242
+ .add("string", STRING)
243
+ .add("boolean", BOOLEAN)
244
+ .add("long", LONG)
245
+ .add("double", DOUBLE)
246
+ .add("json", JSON)
247
+ .add("null_string", STRING)
248
+ .build();
249
+ List<Object[]> records = filter(task, inputSchema,
250
+ // row1
251
+ Timestamp.ofEpochSecond(1436745600), "string", new Boolean(true), new Long(0), new Double(0.5), ValueFactory.newString("json"), "\\N",
252
+ // row2
253
+ Timestamp.ofEpochSecond(1436745600), "string", new Boolean(true), new Long(0), new Double(0.5), ValueFactory.newString("json"), "\\N");
254
+
255
+ assertEquals(2, records.size());
256
+
257
+ Object[] record;
258
+ {
259
+ record = records.get(0);
260
+ assertEquals(7, record.length);
261
+ assertEquals(Timestamp.ofEpochSecond(1436745600), record[0]);
262
+ assertEquals("string", record[1]);
263
+ assertEquals(new Boolean(true), record[2]);
264
+ assertEquals(new Long(0), record[3]);
265
+ assertEquals(new Double(0.5), record[4]);
266
+ assertEquals(ValueFactory.newString("json"), record[5]);
267
+ assertEquals(null, record[6]);
268
+ }
269
+ }
270
+ }
271
+
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: embulk-filter-null_string
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hiroyuki Sato
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-19 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: An Embulk filter plugin to convert the matching string to NULL.
42
+ email:
43
+ - hiroysato@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .travis.yml
50
+ - LICENSE.txt
51
+ - README.md
52
+ - build.gradle
53
+ - config/checkstyle/checkstyle.xml
54
+ - config/checkstyle/default.xml
55
+ - gradle/wrapper/gradle-wrapper.jar
56
+ - gradle/wrapper/gradle-wrapper.properties
57
+ - gradlew
58
+ - gradlew.bat
59
+ - lib/embulk/filter/null_string.rb
60
+ - src/main/java/org/embulk/filter/null_string/NullStringFilterPlugin.java
61
+ - src/main/java/org/embulk/filter/null_string/NullStringVisitorImpl.java
62
+ - src/test/java/org/embulk/filter/null_string/TestNullStringFilterPlugin.java
63
+ - src/test/java/org/embulk/filter/null_string/TestNullStringVisitorImpl.java
64
+ - classpath/embulk-filter-null_string-0.1.0.jar
65
+ homepage: https://github.com/hiroyuki-sato/embulk-filter-null_string
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.1.9
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Null String filter plugin for Embulk
89
+ test_files: []