embulk-formatter-fast_jsonl 0.1.0 → 0.1.1
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/README.md +5 -0
- data/build.gradle +2 -1
- data/src/main/scala/org/embulk/formatter/fast_jsonl/PageOutput.scala +4 -2
- data/src/main/scala/org/embulk/formatter/fast_jsonl/PluginTask.scala +3 -0
- data/src/main/scala/org/embulk/formatter/fast_jsonl/json/ColumnVisitor.scala +6 -1
- data/src/main/scala/org/embulk/formatter/fast_jsonl/json/JsonParser.scala +1 -1
- data/src/test/scala/org/embulk/formatter/fast_jsonl/json/JsonEncoderSpec.scala +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d506f3bbc729a3fbe07de916c993300443ed3f53
|
4
|
+
data.tar.gz: c93417de99924a0227d2db91652b16e690abcf1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 838f1f2b97e9bec0345ca7b16c691e60e0a7fa43697b0bf4511d3fe17ff3ece745ebae4a0de784f1af416fe62accebce8e27c14f126480ffbddaea44a1b7b22a
|
7
|
+
data.tar.gz: 7d85448d372cb567bb494be1f4678733e2417d93ca3f48d6b4cb5d96debd60afd40fcae529191b9664628f249b5d3cea40fa2935712071b5c86664678f2ad011
|
data/README.md
CHANGED
@@ -16,6 +16,9 @@ Format json as 1 json in single line.
|
|
16
16
|
- **explode_json_columns**: json column's explode to top fields. (array default:[])
|
17
17
|
- **json_columns**: json formatted as string column name. (array default:[])
|
18
18
|
|
19
|
+
### additional mode
|
20
|
+
- **suffix_key**: append suffix of key and value.(map Map[String,String]: {} )
|
21
|
+
|
19
22
|
## Example
|
20
23
|
|
21
24
|
```yaml
|
@@ -26,6 +29,8 @@ out:
|
|
26
29
|
explode_json_columns:
|
27
30
|
- JSON_COLUMN_1
|
28
31
|
- JSON_COLUMN_2
|
32
|
+
suffix_key:
|
33
|
+
append_key: append_value
|
29
34
|
```
|
30
35
|
|
31
36
|
## Run Examples
|
data/build.gradle
CHANGED
@@ -13,7 +13,7 @@ configurations {
|
|
13
13
|
provided
|
14
14
|
}
|
15
15
|
|
16
|
-
version = "0.1.
|
16
|
+
version = "0.1.1"
|
17
17
|
|
18
18
|
sourceCompatibility = 1.7
|
19
19
|
targetCompatibility = 1.7
|
@@ -24,6 +24,7 @@ dependencies {
|
|
24
24
|
compile group: 'io.circe', name: 'circe-core_2.11', version: '0.8.0'
|
25
25
|
compile group: 'io.circe', name: 'circe-generic_2.11', version: '0.8.0'
|
26
26
|
compile group: 'io.circe', name: 'circe-parser_2.11', version: '0.8.0'
|
27
|
+
testCompile group: 'org.scalatest', name: 'scalatest_2.11', version: '3.0.1'
|
27
28
|
provided "org.embulk:embulk-core:0.8.22"
|
28
29
|
}
|
29
30
|
|
@@ -19,7 +19,8 @@ case class PageOutput(schema: Schema, task: PluginTask, output: FileOutput)
|
|
19
19
|
val reader: PageReader = new PageReader(schema)
|
20
20
|
val explodeColumns: Seq[String] = task.getExplodeJsonColumns().asScala
|
21
21
|
val jsonColumns: Seq[String] = task.getJsonColumns().asScala
|
22
|
-
|
22
|
+
val suffixKey: Map[String, String] = task.getSuffixKey().asScala.toMap
|
23
|
+
private var opened: Boolean = false
|
23
24
|
|
24
25
|
val timestampFormatter: TimestampFormatter =
|
25
26
|
new TimestampFormatter(task, Optional.absent())
|
@@ -36,7 +37,8 @@ case class PageOutput(schema: Schema, task: PluginTask, output: FileOutput)
|
|
36
37
|
ColumnVisitor(reader,
|
37
38
|
timestampFormatter,
|
38
39
|
explodeColumns,
|
39
|
-
jsonColumns
|
40
|
+
jsonColumns,
|
41
|
+
suffixKey)
|
40
42
|
schema.visitColumns(visitor)
|
41
43
|
encoder.addLine(visitor.getLine)
|
42
44
|
}
|
@@ -11,7 +11,8 @@ import org.embulk.spi.{
|
|
11
11
|
case class ColumnVisitor(reader: PageReader,
|
12
12
|
timestampFormatter: TimestampFormatter,
|
13
13
|
explodeColumns: Seq[String],
|
14
|
-
jsonColumns: Seq[String]
|
14
|
+
jsonColumns: Seq[String],
|
15
|
+
suffixKey: Map[String, String])
|
15
16
|
extends EmbulkColumnVisitor {
|
16
17
|
import scala.collection.mutable
|
17
18
|
|
@@ -80,6 +81,10 @@ case class ColumnVisitor(reader: PageReader,
|
|
80
81
|
case (key, json) =>
|
81
82
|
recordMap.put(key, json)
|
82
83
|
}
|
84
|
+
suffixKey.foreach {
|
85
|
+
case (key, value) =>
|
86
|
+
recordMap.put(key, Json.fromString(value))
|
87
|
+
}
|
83
88
|
JsonEncoder(recordMap).noSpaces
|
84
89
|
}
|
85
90
|
|
@@ -24,7 +24,8 @@ class JsonEncoderSpec extends FlatSpec with Matchers {
|
|
24
24
|
map.put(string, json)
|
25
25
|
}
|
26
26
|
val jsonString = JsonEncoder(map).noSpaces
|
27
|
-
jsonString should be(
|
27
|
+
jsonString should be(
|
28
|
+
"{\"salutation\":\"Hey\",\"person\":{\"name\":\"Chris\"},\"exclamationMarks\":3}")
|
28
29
|
}
|
29
30
|
|
30
31
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-formatter-fast_jsonl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- smdmts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +80,7 @@ files:
|
|
80
80
|
- classpath/circe-jawn_2.11-0.8.0.jar
|
81
81
|
- classpath/circe-numbers_2.11-0.8.0.jar
|
82
82
|
- classpath/circe-parser_2.11-0.8.0.jar
|
83
|
-
- classpath/embulk-formatter-fast_jsonl-0.1.
|
83
|
+
- classpath/embulk-formatter-fast_jsonl-0.1.1.jar
|
84
84
|
- classpath/jawn-parser_2.11-0.10.4.jar
|
85
85
|
- classpath/machinist_2.11-0.6.1.jar
|
86
86
|
- classpath/macro-compat_2.11-1.1.1.jar
|