embulk-filter-unique 0.1.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 +7 -0
- data/.gitignore +5 -0
- data/.ruby-version +1 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/Rakefile +3 -0
- data/embulk-filter-unique.gemspec +19 -0
- data/lib/embulk/filter/unique.rb +47 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f42e0283387bc5f08f1d7c53df8f9130db78eea0
|
4
|
+
data.tar.gz: 2a791dd680ce3ac5bd6fcae677e6dc6ddd7a566a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e254e74454344f8a04cae03b7c1bebd2086541ae36929dd35236dffa99d4869498b8872bd187b8fa437287d135dbbfbb1fad7781d20c3a83ce39ff4924e22775
|
7
|
+
data.tar.gz: 1180c33a64a20df9208cb0985db3d4d6080c134e51b081c930129bd651790daa886bb1196d4685b94a7813352340481e84736afedebc088f1b64ce6f9443bb36
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jruby-9.0.0.0
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -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.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Unique filter plugin for Embulk
|
2
|
+
|
3
|
+
This filter drop duplicated entries. The uniqueness is checked over
|
4
|
+
selected columns.
|
5
|
+
|
6
|
+
TODO: Write short description here and embulk-filter-unique.gemspec file.
|
7
|
+
|
8
|
+
## Overview
|
9
|
+
|
10
|
+
* **Plugin type**: filter
|
11
|
+
|
12
|
+
## Configuration
|
13
|
+
|
14
|
+
- **columns**: list of columns to check uniqueness (required)
|
15
|
+
|
16
|
+
## Example
|
17
|
+
|
18
|
+
```yaml
|
19
|
+
filters:
|
20
|
+
- type: unique
|
21
|
+
columns:
|
22
|
+
- foo
|
23
|
+
- bar
|
24
|
+
- baz
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
## Build
|
29
|
+
|
30
|
+
```
|
31
|
+
$ rake
|
32
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = "embulk-filter-unique"
|
4
|
+
spec.version = "0.1.0"
|
5
|
+
spec.authors = ["Naohiro Aota"]
|
6
|
+
spec.summary = "Unique filter plugin for Embulk"
|
7
|
+
spec.description = "Extract unique records"
|
8
|
+
spec.email = ["naota@elisp.net"]
|
9
|
+
spec.licenses = ["MIT"]
|
10
|
+
spec.homepage = "https://github.com/naota/embulk-filter-unique"
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_development_dependency 'embulk', ['~> 0.7.9']
|
17
|
+
spec.add_development_dependency 'bundler', ['~> 1.0']
|
18
|
+
spec.add_development_dependency 'rake', ['>= 10.0']
|
19
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module Embulk
|
4
|
+
module Filter
|
5
|
+
|
6
|
+
class Unique < FilterPlugin
|
7
|
+
Plugin.register_filter("unique", self)
|
8
|
+
|
9
|
+
def self.transaction(config, in_schema, &control)
|
10
|
+
task = {
|
11
|
+
"columns" => config.param("columns", :array),
|
12
|
+
}
|
13
|
+
|
14
|
+
yield(task, in_schema)
|
15
|
+
end
|
16
|
+
|
17
|
+
def init
|
18
|
+
@cols = task["columns"]
|
19
|
+
@exists = Set.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def close
|
23
|
+
end
|
24
|
+
|
25
|
+
def add(page)
|
26
|
+
page.each do |record|
|
27
|
+
part = {}
|
28
|
+
@cols.each do |c|
|
29
|
+
cs = page.schema.select{|s| s.name == c}
|
30
|
+
idx = cs[0].index
|
31
|
+
part[c] = record[idx]
|
32
|
+
end
|
33
|
+
|
34
|
+
unless @exists.include?(part)
|
35
|
+
page_builder.add(record)
|
36
|
+
@exists.add(part)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def finish
|
42
|
+
page_builder.finish
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-filter-unique
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Naohiro Aota
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: embulk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.7.9
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.7.9
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Extract unique records
|
56
|
+
email:
|
57
|
+
- naota@elisp.net
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".ruby-version"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- embulk-filter-unique.gemspec
|
69
|
+
- lib/embulk/filter/unique.rb
|
70
|
+
homepage: https://github.com/naota/embulk-filter-unique
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.4.8
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Unique filter plugin for Embulk
|
94
|
+
test_files: []
|