embulk-input-dynamodb 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/master.yml +34 -0
  3. data/.github/workflows/test.yml +30 -0
  4. data/.scalafmt.conf +5 -0
  5. data/CHANGELOG.md +49 -0
  6. data/README.md +204 -54
  7. data/build.gradle +53 -44
  8. data/example/config-deprecated.yml +20 -0
  9. data/example/config-query-as-json.yml +18 -0
  10. data/example/config-query.yml +22 -0
  11. data/example/config-scan.yml +18 -0
  12. data/example/prepare_dynamodb_table.sh +67 -0
  13. data/gradle/wrapper/gradle-wrapper.jar +0 -0
  14. data/gradle/wrapper/gradle-wrapper.properties +1 -2
  15. data/gradlew +67 -48
  16. data/gradlew.bat +20 -10
  17. data/{test/run_dynamodb_local.sh → run_dynamodb_local.sh} +2 -1
  18. data/settings.gradle +1 -0
  19. data/src/main/scala/org/embulk/input/dynamodb/DeprecatedDynamodbInputPlugin.scala +73 -0
  20. data/src/main/scala/org/embulk/input/dynamodb/DynamodbInputPlugin.scala +76 -25
  21. data/src/main/scala/org/embulk/input/dynamodb/PluginTask.scala +132 -32
  22. data/src/main/scala/org/embulk/input/dynamodb/aws/Aws.scala +44 -0
  23. data/src/main/scala/org/embulk/input/dynamodb/aws/AwsClientConfiguration.scala +37 -0
  24. data/src/main/scala/org/embulk/input/dynamodb/aws/AwsCredentials.scala +240 -0
  25. data/src/main/scala/org/embulk/input/dynamodb/aws/AwsDynamodbConfiguration.scala +35 -0
  26. data/src/main/scala/org/embulk/input/dynamodb/aws/AwsEndpointConfiguration.scala +79 -0
  27. data/src/main/scala/org/embulk/input/dynamodb/aws/HttpProxy.scala +61 -0
  28. data/src/main/scala/org/embulk/input/dynamodb/deprecated/AttributeValueHelper.scala +72 -0
  29. data/src/main/scala/org/embulk/input/dynamodb/{Filter.scala → deprecated/Filter.scala} +3 -3
  30. data/src/main/scala/org/embulk/input/dynamodb/{FilterConfig.scala → deprecated/FilterConfig.scala} +13 -13
  31. data/src/main/scala/org/embulk/input/dynamodb/{ope → deprecated/ope}/AbstractOperation.scala +36 -18
  32. data/src/main/scala/org/embulk/input/dynamodb/{ope → deprecated/ope}/QueryOperation.scala +21 -13
  33. data/src/main/scala/org/embulk/input/dynamodb/{ope → deprecated/ope}/ScanOperation.scala +20 -13
  34. data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbAttributeValue.scala +154 -0
  35. data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbAttributeValueEmbulkTypeTransformable.scala +245 -0
  36. data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbAttributeValueType.scala +33 -0
  37. data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemColumnVisitor.scala +50 -0
  38. data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemConsumer.scala +40 -0
  39. data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemIterator.scala +19 -0
  40. data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemReader.scala +64 -0
  41. data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemSchema.scala +135 -0
  42. data/src/main/scala/org/embulk/input/dynamodb/operation/AbstractDynamodbOperation.scala +169 -0
  43. data/src/main/scala/org/embulk/input/dynamodb/operation/DynamodbOperationProxy.scala +59 -0
  44. data/src/main/scala/org/embulk/input/dynamodb/operation/DynamodbQueryOperation.scala +72 -0
  45. data/src/main/scala/org/embulk/input/dynamodb/operation/DynamodbScanOperation.scala +93 -0
  46. data/src/main/scala/org/embulk/input/dynamodb/operation/EmbulkDynamodbOperation.scala +15 -0
  47. data/src/main/scala/org/embulk/input/dynamodb/package.scala +4 -9
  48. data/src/test/scala/org/embulk/input/dynamodb/AttributeValueHelperTest.scala +245 -101
  49. data/src/test/scala/org/embulk/input/dynamodb/AwsCredentialsTest.scala +150 -97
  50. data/src/test/scala/org/embulk/input/dynamodb/DynamodbQueryOperationTest.scala +188 -0
  51. data/src/test/scala/org/embulk/input/dynamodb/DynamodbScanOperationTest.scala +181 -0
  52. data/src/test/scala/org/embulk/input/dynamodb/testutil/EmbulkTestBase.scala +85 -0
  53. metadata +73 -49
  54. data/circle.yml +0 -16
  55. data/config/checkstyle/checkstyle.xml +0 -128
  56. data/config/checkstyle/default.xml +0 -108
  57. data/src/main/scala/org/embulk/input/dynamodb/AttributeValueHelper.scala +0 -41
  58. data/src/main/scala/org/embulk/input/dynamodb/AwsCredentials.scala +0 -63
  59. data/src/main/scala/org/embulk/input/dynamodb/DynamoDBClient.scala +0 -23
  60. data/src/test/resources/yaml/authMethodBasic.yml +0 -21
  61. data/src/test/resources/yaml/authMethodBasic_Error.yml +0 -19
  62. data/src/test/resources/yaml/authMethodEnv.yml +0 -19
  63. data/src/test/resources/yaml/authMethodProfile.yml +0 -20
  64. data/src/test/resources/yaml/dynamodb-local-query.yml +0 -25
  65. data/src/test/resources/yaml/dynamodb-local-scan.yml +0 -23
  66. data/src/test/resources/yaml/notSetAuthMethod.yml +0 -20
  67. data/src/test/scala/org/embulk/input/dynamodb/ope/QueryOperationTest.scala +0 -83
  68. data/src/test/scala/org/embulk/input/dynamodb/ope/ScanOperationTest.scala +0 -83
  69. data/test/create_table.sh +0 -16
  70. data/test/put_items.sh +0 -25
@@ -0,0 +1,20 @@
1
+ in:
2
+ type: dynamodb
3
+ region: us-east-1
4
+ endpoint: http://localhost:8000
5
+ operation: scan
6
+ table: embulk-input-dynamodb_example
7
+ auth_method: basic
8
+ access_key_id: dummy
9
+ secret_access_key: dummy
10
+ columns:
11
+ - {name: primary-key, type: string}
12
+ - {name: sort-key, type: long}
13
+ - {name: doubleValue, type: double}
14
+ - {name: boolValue, type: boolean}
15
+ - {name: listValue, type: json}
16
+ - {name: mapValue, type: json}
17
+
18
+ out:
19
+ type: stdout
20
+
@@ -0,0 +1,18 @@
1
+ in:
2
+ type: dynamodb
3
+ region: us-east-1
4
+ endpoint: http://localhost:8000
5
+ query:
6
+ key_condition_expression: "#x = :v"
7
+ expression_attribute_names:
8
+ "#x": primary-key
9
+ expression_attribute_values:
10
+ ":v": {S: key-1}
11
+ table: embulk-input-dynamodb_example
12
+ auth_method: basic
13
+ access_key_id: dummy
14
+ secret_access_key: dummy
15
+
16
+ out:
17
+ type: stdout
18
+
@@ -0,0 +1,22 @@
1
+ in:
2
+ type: dynamodb
3
+ region: us-east-1
4
+ endpoint: http://localhost:8000
5
+ query:
6
+ key_condition_expression: "#x = :v"
7
+ expression_attribute_names:
8
+ "#x": primary-key
9
+ expression_attribute_values:
10
+ ":v": {S: key-1}
11
+ table: embulk-input-dynamodb_example
12
+ auth_method: basic
13
+ access_key_id: dummy
14
+ secret_access_key: dummy
15
+ columns:
16
+ - {name: primary-key, type: string}
17
+ - {name: sort-key, type: long}
18
+ - {name: value, type: string}
19
+
20
+ out:
21
+ type: stdout
22
+
@@ -0,0 +1,18 @@
1
+ in:
2
+ type: dynamodb
3
+ region: us-east-1
4
+ endpoint: http://localhost:8000
5
+ scan:
6
+ total_segment: 20
7
+ table: embulk-input-dynamodb_example
8
+ auth_method: basic
9
+ access_key_id: dummy
10
+ secret_access_key: dummy
11
+ columns:
12
+ - {name: primary-key, type: string}
13
+ - {name: sort-key, type: long}
14
+ - {name: value, type: string}
15
+
16
+ out:
17
+ type: stdout
18
+
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+
3
+ if aws dynamodb describe-table --table-name='embulk-input-dynamodb_example' --endpoint-url http://localhost:8000 --region us-east-1 2>/dev/null; then
4
+ aws dynamodb delete-table --table-name='embulk-input-dynamodb_example' \
5
+ --endpoint-url http://localhost:8000 \
6
+ --region us-east-1
7
+ fi
8
+
9
+ aws dynamodb create-table \
10
+ --table-name='embulk-input-dynamodb_example' \
11
+ --attribute-definitions='[
12
+ {"AttributeName":"primary-key","AttributeType":"S"},
13
+ {"AttributeName":"sort-key","AttributeType":"N"}
14
+ ]' \
15
+ --key-schema='[
16
+ {"AttributeName":"primary-key","KeyType":"HASH"},
17
+ {"AttributeName":"sort-key","KeyType":"RANGE"}
18
+ ]' \
19
+ --provisioned-throughput='{"ReadCapacityUnits":5, "WriteCapacityUnits":5}' \
20
+ --endpoint-url http://localhost:8000 \
21
+ --region us-east-1
22
+
23
+ aws dynamodb put-item \
24
+ --table-name='embulk-input-dynamodb_example' \
25
+ --item='{
26
+ "primary-key" : { "S" : "key-1" },
27
+ "sort-key" : { "N" : "0" },
28
+ "doubleValue" : { "N" : "42.195" },
29
+ "boolValue" : { "BOOL" : true },
30
+ "listValue" : { "L":
31
+ [
32
+ { "S" : "list-value"},
33
+ { "N" : "123"}
34
+ ]
35
+ },
36
+ "mapValue" : { "M":
37
+ {
38
+ "map-key-1" : { "S" : "map-value-1" },
39
+ "map-key-2" : { "N" : "456" }
40
+ }
41
+ }
42
+ }' \
43
+ --endpoint-url http://localhost:8000 \
44
+ --region us-east-1
45
+
46
+ aws dynamodb put-item \
47
+ --table-name='embulk-input-dynamodb_example' \
48
+ --item='{
49
+ "primary-key" : { "S" : "key-1" },
50
+ "sort-key" : { "N" : "1" },
51
+ "doubleValue" : { "NULL" : true },
52
+ "boolValue" : { "N" : "1" },
53
+ "listValue" : { "L":
54
+ [
55
+ { "NULL" : true},
56
+ { "N" : "123"}
57
+ ]
58
+ },
59
+ "mapValue" : { "M":
60
+ {
61
+ "map-key-1" : { "S" : "map-value-1" },
62
+ "map-key-2" : { "N" : "456" }
63
+ }
64
+ }
65
+ }' \
66
+ --endpoint-url http://localhost:8000 \
67
+ --region us-east-1
Binary file
@@ -1,6 +1,5 @@
1
- #Wed Jan 13 12:41:02 JST 2016
2
1
  distributionBase=GRADLE_USER_HOME
3
2
  distributionPath=wrapper/dists
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-bin.zip
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
data/gradlew CHANGED
@@ -1,4 +1,20 @@
1
- #!/usr/bin/env bash
1
+ #!/usr/bin/env sh
2
+
3
+ #
4
+ # Copyright 2015 the original author or authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
2
18
 
3
19
  ##############################################################################
4
20
  ##
@@ -6,20 +22,38 @@
6
22
  ##
7
23
  ##############################################################################
8
24
 
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=""
25
+ # Attempt to set APP_HOME
26
+ # Resolve links: $0 may be a link
27
+ PRG="$0"
28
+ # Need this for relative symlinks.
29
+ while [ -h "$PRG" ] ; do
30
+ ls=`ls -ld "$PRG"`
31
+ link=`expr "$ls" : '.*-> \(.*\)$'`
32
+ if expr "$link" : '/.*' > /dev/null; then
33
+ PRG="$link"
34
+ else
35
+ PRG=`dirname "$PRG"`"/$link"
36
+ fi
37
+ done
38
+ SAVED="`pwd`"
39
+ cd "`dirname \"$PRG\"`/" >/dev/null
40
+ APP_HOME="`pwd -P`"
41
+ cd "$SAVED" >/dev/null
11
42
 
12
43
  APP_NAME="Gradle"
13
44
  APP_BASE_NAME=`basename "$0"`
14
45
 
46
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48
+
15
49
  # Use the maximum available, or set MAX_FD != -1 to use that value.
16
50
  MAX_FD="maximum"
17
51
 
18
- warn ( ) {
52
+ warn () {
19
53
  echo "$*"
20
54
  }
21
55
 
22
- die ( ) {
56
+ die () {
23
57
  echo
24
58
  echo "$*"
25
59
  echo
@@ -30,6 +64,7 @@ die ( ) {
30
64
  cygwin=false
31
65
  msys=false
32
66
  darwin=false
67
+ nonstop=false
33
68
  case "`uname`" in
34
69
  CYGWIN* )
35
70
  cygwin=true
@@ -40,31 +75,11 @@ case "`uname`" in
40
75
  MINGW* )
41
76
  msys=true
42
77
  ;;
78
+ NONSTOP* )
79
+ nonstop=true
80
+ ;;
43
81
  esac
44
82
 
45
- # For Cygwin, ensure paths are in UNIX format before anything is touched.
46
- if $cygwin ; then
47
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48
- fi
49
-
50
- # Attempt to set APP_HOME
51
- # Resolve links: $0 may be a link
52
- PRG="$0"
53
- # Need this for relative symlinks.
54
- while [ -h "$PRG" ] ; do
55
- ls=`ls -ld "$PRG"`
56
- link=`expr "$ls" : '.*-> \(.*\)$'`
57
- if expr "$link" : '/.*' > /dev/null; then
58
- PRG="$link"
59
- else
60
- PRG=`dirname "$PRG"`"/$link"
61
- fi
62
- done
63
- SAVED="`pwd`"
64
- cd "`dirname \"$PRG\"`/" >&-
65
- APP_HOME="`pwd -P`"
66
- cd "$SAVED" >&-
67
-
68
83
  CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69
84
 
70
85
  # Determine the Java command to use to start the JVM.
@@ -90,7 +105,7 @@ location of your Java installation."
90
105
  fi
91
106
 
92
107
  # Increase the maximum file descriptors if we can.
93
- if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
108
+ if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
94
109
  MAX_FD_LIMIT=`ulimit -H -n`
95
110
  if [ $? -eq 0 ] ; then
96
111
  if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -110,10 +125,11 @@ if $darwin; then
110
125
  GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111
126
  fi
112
127
 
113
- # For Cygwin, switch paths to Windows format before running java
114
- if $cygwin ; then
128
+ # For Cygwin or MSYS, switch paths to Windows format before running java
129
+ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
115
130
  APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116
131
  CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132
+ JAVACMD=`cygpath --unix "$JAVACMD"`
117
133
 
118
134
  # We build the pattern for arguments to be converted via cygpath
119
135
  ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -138,27 +154,30 @@ if $cygwin ; then
138
154
  else
139
155
  eval `echo args$i`="\"$arg\""
140
156
  fi
141
- i=$((i+1))
157
+ i=`expr $i + 1`
142
158
  done
143
159
  case $i in
144
- (0) set -- ;;
145
- (1) set -- "$args0" ;;
146
- (2) set -- "$args0" "$args1" ;;
147
- (3) set -- "$args0" "$args1" "$args2" ;;
148
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
160
+ 0) set -- ;;
161
+ 1) set -- "$args0" ;;
162
+ 2) set -- "$args0" "$args1" ;;
163
+ 3) set -- "$args0" "$args1" "$args2" ;;
164
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154
170
  esac
155
171
  fi
156
172
 
157
- # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158
- function splitJvmOpts() {
159
- JVM_OPTS=("$@")
173
+ # Escape application args
174
+ save () {
175
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176
+ echo " "
160
177
  }
161
- eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162
- JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
178
+ APP_ARGS=`save "$@"`
179
+
180
+ # Collect all arguments for the java command, following the shell quoting and substitution rules
181
+ eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
163
182
 
164
- exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
183
+ exec "$JAVACMD" "$@"
data/gradlew.bat CHANGED
@@ -1,3 +1,19 @@
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+
1
17
  @if "%DEBUG%" == "" @echo off
2
18
  @rem ##########################################################################
3
19
  @rem
@@ -8,14 +24,14 @@
8
24
  @rem Set local scope for the variables with windows NT shell
9
25
  if "%OS%"=="Windows_NT" setlocal
10
26
 
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
27
  set DIRNAME=%~dp0
15
28
  if "%DIRNAME%" == "" set DIRNAME=.
16
29
  set APP_BASE_NAME=%~n0
17
30
  set APP_HOME=%DIRNAME%
18
31
 
32
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34
+
19
35
  @rem Find java.exe
20
36
  if defined JAVA_HOME goto findJavaFromJavaHome
21
37
 
@@ -46,10 +62,9 @@ echo location of your Java installation.
46
62
  goto fail
47
63
 
48
64
  :init
49
- @rem Get command-line arguments, handling Windowz variants
65
+ @rem Get command-line arguments, handling Windows variants
50
66
 
51
67
  if not "%OS%" == "Windows_NT" goto win9xME_args
52
- if "%@eval[2+2]" == "4" goto 4NT_args
53
68
 
54
69
  :win9xME_args
55
70
  @rem Slurp the command line arguments.
@@ -60,11 +75,6 @@ set _SKIP=2
60
75
  if "x%~1" == "x" goto execute
61
76
 
62
77
  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
78
 
69
79
  :execute
70
80
  @rem Setup the command line
@@ -2,6 +2,7 @@
2
2
 
3
3
  docker run -i -t -d \
4
4
  -p 8000:8000 \
5
- tray/dynamodb-local \
5
+ amazon/dynamodb-local:latest \
6
+ -jar DynamoDBLocal.jar \
6
7
  -inMemory -sharedDb -port 8000
7
8
 
data/settings.gradle ADDED
@@ -0,0 +1 @@
1
+ rootProject.name = 'embulk-input-dynamodb'
@@ -0,0 +1,73 @@
1
+ package org.embulk.input.dynamodb
2
+
3
+ import java.util.{List => JList}
4
+
5
+ import org.embulk.config.{
6
+ ConfigDiff,
7
+ ConfigException,
8
+ ConfigSource,
9
+ TaskReport,
10
+ TaskSource
11
+ }
12
+ import org.embulk.input.dynamodb.aws.Aws
13
+ import org.embulk.input.dynamodb.deprecated.ope.{QueryOperation, ScanOperation}
14
+ import org.embulk.spi.{Exec, InputPlugin, PageOutput, Schema}
15
+
16
+ @deprecated(since = "0.3.0")
17
+ object DeprecatedDynamodbInputPlugin extends InputPlugin {
18
+
19
+ override def transaction(
20
+ config: ConfigSource,
21
+ control: InputPlugin.Control
22
+ ): ConfigDiff = {
23
+ val task: PluginTask = PluginTask.load(config)
24
+ val schema: Schema = task.getColumns.toSchema
25
+ if (schema.isEmpty)
26
+ throw new ConfigException("\"columns\" option must be set.")
27
+ val taskCount: Int = 1
28
+
29
+ control.run(task.dump(), schema, taskCount)
30
+ Exec.newConfigDiff()
31
+ }
32
+
33
+ override def resume(
34
+ taskSource: TaskSource,
35
+ schema: Schema,
36
+ taskCount: Int,
37
+ control: InputPlugin.Control
38
+ ): ConfigDiff = {
39
+ throw new UnsupportedOperationException
40
+ }
41
+
42
+ override def run(
43
+ taskSource: TaskSource,
44
+ schema: Schema,
45
+ taskIndex: Int,
46
+ output: PageOutput
47
+ ): TaskReport = {
48
+ val task: PluginTask = PluginTask.load(taskSource)
49
+
50
+ Aws(task).withDynamodb { dynamodb =>
51
+ task.getOperation.ifPresent { ope =>
52
+ val o = ope.toLowerCase match {
53
+ case "scan" => new ScanOperation(dynamodb)
54
+ case "query" => new QueryOperation(dynamodb)
55
+ }
56
+ o.execute(task, schema, output)
57
+ }
58
+ }
59
+
60
+ Exec.newTaskReport()
61
+ }
62
+
63
+ override def cleanup(
64
+ taskSource: TaskSource,
65
+ schema: Schema,
66
+ taskCount: Int,
67
+ successTaskReports: JList[TaskReport]
68
+ ): Unit = {}
69
+
70
+ override def guess(config: ConfigSource): ConfigDiff = {
71
+ throw new UnsupportedOperationException
72
+ }
73
+ }