embulk-input-datastore 0.1.2 → 0.1.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fb4d8225c41ef045739963c1dc302f052f2eccde963a3c53809fd7d9716143b6
|
4
|
+
data.tar.gz: 3ab43445f15ba9b2a19f3bf200de824cd5260dc3ab1df2bec449fa421de82b98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88355309b23f98ff603a890f8908d8ae9f9a748e69e5c786c0b5f0b7213b0a030b64f1e91c7b4ce8d1e2d2b27936cdde81a67ec3ac65af3af50b647ad6805839
|
7
|
+
data.tar.gz: fbf1a095f19d8c4adc6182ea1e60d5149c83b8ea152fcbb545b425f7906115370f80a6966b25bee8b50d560b8e710e024bc7f2eaffaf9a67e128aa2adf341e6a
|
@@ -6,9 +6,9 @@ in:
|
|
6
6
|
|
7
7
|
out:
|
8
8
|
type: stdout
|
9
|
-
#type: file
|
10
|
-
#path_prefix: out
|
11
|
-
#file_ext: json
|
12
|
-
#formatter:
|
13
|
-
#
|
14
|
-
#
|
9
|
+
# type: file
|
10
|
+
# path_prefix: out
|
11
|
+
# file_ext: json
|
12
|
+
# formatter:
|
13
|
+
# type: single_value
|
14
|
+
# column_name: "record"
|
@@ -10,13 +10,13 @@ import org.embulk.config.TaskSource
|
|
10
10
|
import org.embulk.spi.*
|
11
11
|
import org.embulk.spi.json.JsonParser
|
12
12
|
import org.embulk.spi.type.Types
|
13
|
-
import org.msgpack.value.ValueFactory
|
14
13
|
import java.io.FileInputStream
|
15
14
|
import java.util.Base64
|
16
15
|
|
17
16
|
class DatastoreInputPlugin(doLogging: Boolean = true) : InputPlugin {
|
18
17
|
// number of run() method calls
|
19
18
|
private val TASK_COUNT = 1
|
19
|
+
private val KEY_KEY = "__key__"
|
20
20
|
|
21
21
|
private val logger = if (doLogging) {
|
22
22
|
Exec.getLogger(javaClass)
|
@@ -70,7 +70,6 @@ class DatastoreInputPlugin(doLogging: Boolean = true) : InputPlugin {
|
|
70
70
|
.forEach { entity ->
|
71
71
|
logger?.debug(entity.toString())
|
72
72
|
|
73
|
-
|
74
73
|
val json = when (entity) {
|
75
74
|
is FullEntity<*> -> entityToJsonObject(entity)
|
76
75
|
is ProjectionEntity -> entityToJsonObject(entity)
|
@@ -123,7 +122,14 @@ class DatastoreInputPlugin(doLogging: Boolean = true) : InputPlugin {
|
|
123
122
|
val strVal = valueToField(dsValue)
|
124
123
|
strVal?.let { listOf("\"${name}\":${it}") } ?: listOf()
|
125
124
|
}
|
126
|
-
|
125
|
+
|
126
|
+
// Append KEY values if it exists
|
127
|
+
val keyFields = getEntityKey(entity)?.let {
|
128
|
+
listOf("\"${KEY_KEY}\":${it}")
|
129
|
+
} ?: listOf()
|
130
|
+
val decoratedFields = fields.plus(keyFields)
|
131
|
+
|
132
|
+
return "{" + decoratedFields.joinToString() + "}"
|
127
133
|
}
|
128
134
|
|
129
135
|
/**
|
@@ -184,4 +190,22 @@ class DatastoreInputPlugin(doLogging: Boolean = true) : InputPlugin {
|
|
184
190
|
Query.ResultType.PROJECTION_ENTITY
|
185
191
|
}
|
186
192
|
}
|
193
|
+
|
194
|
+
/**
|
195
|
+
* Get KEY info string (with calling private method ...)
|
196
|
+
*/
|
197
|
+
private fun getEntityKey(entity: BaseEntity<*>): String? {
|
198
|
+
if (entity.hasKey()) {
|
199
|
+
val key = entity.key
|
200
|
+
|
201
|
+
// NOTE: getLeaf() is not public ...
|
202
|
+
val mirror = BaseKey::class.java.getDeclaredMethod("getLeaf")
|
203
|
+
mirror.isAccessible = true
|
204
|
+
val pe = mirror.invoke(key) as PathElement
|
205
|
+
|
206
|
+
return "{\"kind\":\"${pe.kind}\",\"id\":\"${pe.id}\",\"name\":\"${pe.name}\"}"
|
207
|
+
} else {
|
208
|
+
return null
|
209
|
+
}
|
210
|
+
}
|
187
211
|
}
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-datastore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- syucream
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
|
-
- - ~>
|
17
|
+
- - "~>"
|
17
18
|
- !ruby/object:Gem::Version
|
18
19
|
version: '1.0'
|
19
|
-
name: bundler
|
20
|
-
prerelease: false
|
21
20
|
type: :development
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '10.0'
|
33
|
-
name: rake
|
34
|
-
prerelease: false
|
35
34
|
type: :development
|
35
|
+
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
description: Loads records from datastore.
|
@@ -45,17 +45,11 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
48
|
+
- ".gitignore"
|
49
49
|
- LICENSE
|
50
50
|
- Makefile
|
51
51
|
- README.md
|
52
52
|
- build.gradle
|
53
|
-
- examples/datastore2stdout.yaml
|
54
|
-
- gradle.properties
|
55
|
-
- lib/embulk/input/datastore.rb
|
56
|
-
- src/main/java/org/embulk/input/datastore/DatastoreInputPlugin.kt
|
57
|
-
- src/main/java/org/embulk/input/datastore/PluginTask.kt
|
58
|
-
- src/test/java/org/embulk/input/datastore/DatastoreInputPluginSpec.kt
|
59
53
|
- classpath/annotations-13.0.jar
|
60
54
|
- classpath/api-common-1.5.0.jar
|
61
55
|
- classpath/commons-codec-1.3.jar
|
@@ -96,28 +90,34 @@ files:
|
|
96
90
|
- classpath/protobuf-java-3.5.1.jar
|
97
91
|
- classpath/protobuf-java-util-3.5.1.jar
|
98
92
|
- classpath/threetenbp-1.3.3.jar
|
93
|
+
- examples/datastore2stdout.yaml
|
94
|
+
- gradle.properties
|
95
|
+
- lib/embulk/input/datastore.rb
|
96
|
+
- src/main/java/org/embulk/input/datastore/DatastoreInputPlugin.kt
|
97
|
+
- src/main/java/org/embulk/input/datastore/PluginTask.kt
|
98
|
+
- src/test/java/org/embulk/input/datastore/DatastoreInputPluginSpec.kt
|
99
99
|
homepage: https://github.com/syucream/embulk-input-datastore
|
100
100
|
licenses:
|
101
101
|
- MIT
|
102
102
|
metadata: {}
|
103
|
-
post_install_message:
|
103
|
+
post_install_message:
|
104
104
|
rdoc_options: []
|
105
105
|
require_paths:
|
106
106
|
- lib
|
107
107
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
rubyforge_project:
|
119
|
-
rubygems_version: 2.
|
120
|
-
signing_key:
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.7.7
|
120
|
+
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Datastore input plugin for Embulk
|
123
123
|
test_files: []
|