embulk-filter-hash 0.3.2 → 0.4.0
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 +1 -1
- data/build.gradle +6 -6
- data/gradle.properties +1 -1
- data/src/main/kotlin/org/embulk/filter/hash/HashFilterPlugin.kt +26 -16
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 681859abe9dc6462e1ca8bfc9d32da28b11be9d4
|
4
|
+
data.tar.gz: 364021a86b7841541741d68ad0dfa2c4a42e196a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0cb9f3e5b8fd629e6ab69940a605ff5c2631494d3b4f63968f602f66225c5596f3016c30bbf108017c83491b1421a28babb21509657efce9fe5696c522a1c09
|
7
|
+
data.tar.gz: 3229e2f0fdff0a6bd9617c8a977d2473c64a3d4e11f341d48ef41a8c69a13d6ae25bfe46b09cd1244675527517281dff74e7b03dc6132685e6d167380581188a
|
data/README.md
CHANGED
data/build.gradle
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
buildscript {
|
2
|
-
ext.kotlinVersion = '1.
|
2
|
+
ext.kotlinVersion = '1.2.31'
|
3
3
|
repositories {
|
4
4
|
mavenCentral()
|
5
5
|
jcenter()
|
@@ -22,21 +22,21 @@ repositories {
|
|
22
22
|
maven { url 'http://kamatama41.github.com/maven-repository/repository' }
|
23
23
|
}
|
24
24
|
|
25
|
-
sourceCompatibility = 1.
|
26
|
-
targetCompatibility = 1.
|
25
|
+
sourceCompatibility = 1.8
|
26
|
+
targetCompatibility = 1.8
|
27
27
|
|
28
28
|
dependencies {
|
29
29
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
|
30
|
-
testCompile "com.github.kamatama41:embulk-test-helpers:0.
|
30
|
+
testCompile "com.github.kamatama41:embulk-test-helpers:0.4.0"
|
31
31
|
}
|
32
32
|
|
33
33
|
embulk {
|
34
|
-
version = "0.
|
34
|
+
version = "0.9.7"
|
35
35
|
category = "filter"
|
36
36
|
name = "hash"
|
37
37
|
authors = ["Shinichi Ishimura"]
|
38
38
|
email = "shiketaudonko41@gmail.com"
|
39
|
-
description = "Embulk filter plugin to convert
|
39
|
+
description = "Embulk filter plugin to convert an input to a hash value."
|
40
40
|
licenses = ["MIT"]
|
41
41
|
homepage = "https://github.com/kamatama41/embulk-filter-hash"
|
42
42
|
}
|
data/gradle.properties
CHANGED
@@ -1 +1 @@
|
|
1
|
-
version=0.
|
1
|
+
version=0.4.0
|
@@ -66,49 +66,59 @@ class HashFilterPlugin : FilterPlugin {
|
|
66
66
|
override fun add(page: Page) {
|
67
67
|
reader.setPage(page)
|
68
68
|
while (reader.nextRecord()) {
|
69
|
-
|
69
|
+
setRowValue()
|
70
70
|
builder.addRecord()
|
71
71
|
}
|
72
72
|
}
|
73
73
|
|
74
|
-
private fun
|
74
|
+
private fun setRowValue() {
|
75
75
|
for (inputColumn in inputSchema.columns) {
|
76
76
|
if (reader.isNull(inputColumn)) {
|
77
77
|
builder.setNull(inputColumn)
|
78
78
|
continue
|
79
79
|
}
|
80
80
|
|
81
|
-
|
82
|
-
val inputValue: Any = when (inputColumn.type) {
|
81
|
+
when (inputColumn.type) {
|
83
82
|
Types.STRING -> {
|
84
|
-
|
83
|
+
setColumnValue(inputColumn, reader::getString, builder::setString)
|
85
84
|
}
|
86
85
|
Types.BOOLEAN -> {
|
87
|
-
|
86
|
+
setColumnValue(inputColumn, reader::getBoolean, builder::setBoolean)
|
88
87
|
}
|
89
88
|
Types.DOUBLE -> {
|
90
|
-
|
89
|
+
setColumnValue(inputColumn, reader::getDouble, builder::setDouble)
|
91
90
|
}
|
92
91
|
Types.LONG -> {
|
93
|
-
|
92
|
+
setColumnValue(inputColumn, reader::getLong, builder::setLong)
|
94
93
|
}
|
95
94
|
Types.TIMESTAMP -> {
|
96
|
-
|
95
|
+
setColumnValue(inputColumn, reader::getTimestamp, builder::setTimestamp)
|
97
96
|
}
|
98
97
|
Types.JSON -> {
|
99
|
-
|
98
|
+
setColumnValue(inputColumn, reader::getJson, builder::setJson)
|
100
99
|
}
|
101
100
|
else -> {
|
102
101
|
throw DataException("Unexpected type:" + inputColumn.type)
|
103
102
|
}
|
104
103
|
}
|
104
|
+
}
|
105
|
+
}
|
105
106
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
107
|
+
private fun <T> setColumnValue(
|
108
|
+
inputColumn: Column,
|
109
|
+
getter: (inputColumn: Column) -> T,
|
110
|
+
setter: (inputColumn: Column, value: T) -> Unit
|
111
|
+
) {
|
112
|
+
val inputValue = getter(inputColumn)
|
113
|
+
|
114
|
+
hashColumnMap[inputColumn.name]?.let { hashColumn ->
|
115
|
+
// Write hashed value if it's hash column.
|
116
|
+
val outputColumn = outputColumnMap[hashColumn.newName.or(inputColumn.name)]
|
117
|
+
val hashedValue = generateHash(inputValue.toString(), hashColumn.algorithm.get())
|
118
|
+
builder.setString(outputColumn, hashedValue)
|
119
|
+
} ?: run {
|
120
|
+
// Write the original data
|
121
|
+
setter(inputColumn, inputValue)
|
112
122
|
}
|
113
123
|
}
|
114
124
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-filter-hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shinichi Ishimura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
-
description: Embulk filter plugin to convert
|
41
|
+
description: Embulk filter plugin to convert an input to a hash value.
|
42
42
|
email:
|
43
43
|
- shiketaudonko41@gmail.com
|
44
44
|
executables: []
|
@@ -62,9 +62,9 @@ files:
|
|
62
62
|
- src/test/resources/yaml/input_basic.yml
|
63
63
|
- src/test/resources/yaml/input_column_types.yml
|
64
64
|
- src/test/resources/yaml/input_null_column.yml
|
65
|
-
- classpath/kotlin-stdlib-1.
|
65
|
+
- classpath/kotlin-stdlib-1.2.31.jar
|
66
66
|
- classpath/annotations-13.0.jar
|
67
|
-
- classpath/embulk-filter-hash-0.
|
67
|
+
- classpath/embulk-filter-hash-0.4.0.jar
|
68
68
|
homepage: https://github.com/kamatama41/embulk-filter-hash
|
69
69
|
licenses:
|
70
70
|
- MIT
|