embulk-plugin-input-random 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +105 -0
- data/Rakefile +2 -0
- data/embulk-plugin-input-random.gemspec +23 -0
- data/lib/embulk/input_random.rb +75 -0
- data/lib/embulk/plugin/input/random/version.rb +3 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8364449a38b8532afc93e4e0335068a5d95bfc0
|
4
|
+
data.tar.gz: bc62e978be480abf942719fd05395c638c58346d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ba0469a8a7ab6c71deba01e9675e73a5e2ddc48c6711e457a670ac48e998e26c87ab2557686591814a3e3f114c0014a1bfdea9f2d793de51b324fb554f31ab6
|
7
|
+
data.tar.gz: e3d3f693849b4a54176ad13391fba844ed7af0b0d3c9a2c203aa305782946c9f954e3a7ab92e9d49534933a9729f9c0e01f644dfecf13986b0b75eee958d6776
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 KUMAZAKI Hiroki
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# Embulk::Plugin::Input::Random
|
2
|
+
|
3
|
+
Random data generator for [Embulk](https://github.com/embulk/embulk).
|
4
|
+
Expected to used to test or benchmark.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Run this command with your embulk binary.
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
java -jar embulk.jar gem install embulk-plugin-input-random
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Specify in your config.yml file
|
17
|
+
|
18
|
+
```yaml
|
19
|
+
in:
|
20
|
+
type: random
|
21
|
+
rows: 100
|
22
|
+
threads: 2
|
23
|
+
schema:
|
24
|
+
myid: primary_key
|
25
|
+
name: string
|
26
|
+
score: integer
|
27
|
+
```
|
28
|
+
|
29
|
+
- type: specify this plugin as `random`
|
30
|
+
- rows: number of inserting rows (required)
|
31
|
+
- threads: number of thread (optional)
|
32
|
+
- schema: specify the attribute of table and data type (required)
|
33
|
+
|
34
|
+
|
35
|
+
### Try
|
36
|
+
|
37
|
+
You can try this plugin with saving below as random.yaml
|
38
|
+
|
39
|
+
```
|
40
|
+
exec: {}
|
41
|
+
in:
|
42
|
+
type: random
|
43
|
+
rows: 100
|
44
|
+
threads: 1
|
45
|
+
schema:
|
46
|
+
id: primary_key
|
47
|
+
name: string
|
48
|
+
score: integer
|
49
|
+
out:
|
50
|
+
type: stdout
|
51
|
+
```
|
52
|
+
|
53
|
+
and just run
|
54
|
+
|
55
|
+
```
|
56
|
+
$ java -jar embulk.jar run random.yml
|
57
|
+
```
|
58
|
+
|
59
|
+
will generate result like
|
60
|
+
|
61
|
+
```
|
62
|
+
Random generation started.
|
63
|
+
2015-01-29 02:13:15,497 [INFO]: main:org.embulk.exec.LocalExecutor: Running 4 tasks using 8 local threads
|
64
|
+
2015-01-29 02:13:15,498 [INFO]: main:org.embulk.exec.LocalExecutor: {done: 0 / 4, running: 0}
|
65
|
+
Random generator input thread 2...
|
66
|
+
Random generator input thread 0...
|
67
|
+
Random generator input thread 1...
|
68
|
+
Random generator input thread 3...
|
69
|
+
0,FamwnrENyzxADpecnTQP2lClzJPO1acRC1506d3VUf4,3791
|
70
|
+
1,aAA6K0T8L6plLrux9dqd2oFLZWBkYyNnZKGstN3sRRA,9942
|
71
|
+
2,tgGcwBPxZ-tQgJmTdIJXgiv-MDBvbUKnMMn1KjNixlo,5907
|
72
|
+
3,SyxFHOepjo5WbNgukUEZY7CVT5Y6XGeVb8Gdsdq_EI8,6378
|
73
|
+
4,5vfOwlw_xLhaYkd5dXCUaC3TsAyzDbD12GHohy2SXsM,6132
|
74
|
+
5,-C_6oNt1Z07RKlGKQ8_OVbCCuHbC-LOLFl5HrIE8y9c,7520
|
75
|
+
```
|
76
|
+
|
77
|
+
You can insert arbitrary storage via Embulk!
|
78
|
+
|
79
|
+
### Data Type
|
80
|
+
|
81
|
+
Now supported types are belows
|
82
|
+
- string: 32bytes of ascii code string
|
83
|
+
- integer: random integer 0 to 10000
|
84
|
+
- primary_key: increasing number for each rows
|
85
|
+
- float: random floating point 0 to 10000
|
86
|
+
- date: random date from 1970 to now
|
87
|
+
|
88
|
+
More and more types will be appended...
|
89
|
+
|
90
|
+
## Todo
|
91
|
+
|
92
|
+
- Add more data type to generate
|
93
|
+
- fake user names
|
94
|
+
- flexible length of strings
|
95
|
+
- flexible range of numerics
|
96
|
+
- random generator with gaussian
|
97
|
+
- binary
|
98
|
+
|
99
|
+
## Contributing
|
100
|
+
|
101
|
+
1. Fork it ( https://github.com/kumagi]/embulk-plugin-input-random/fork )
|
102
|
+
2. Create your feature branch (`git checkout -b my-cool-feature`)
|
103
|
+
3. Commit your changes (`git commit -am 'Add cool feature'`)
|
104
|
+
4. Push to the branch (`git push origin my-cool-feature`)
|
105
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'embulk/plugin/input/random/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "embulk-plugin-input-random"
|
8
|
+
spec.version = "0.0.1"
|
9
|
+
spec.authors = ["KUMAZAKI Hiroki"]
|
10
|
+
spec.email = ["hiroki.kumazaki@gmail.com"]
|
11
|
+
spec.summary = %q{Random Table Generator for Embulk}
|
12
|
+
spec.description = %q{Create dummy table for test or benchmark}
|
13
|
+
spec.homepage = "https://github.com/kumagi/embulk-plugin-input-random"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Embulk
|
2
|
+
require 'securerandom'
|
3
|
+
class InputRandom < InputPlugin
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
Plugin.register_input('random', self)
|
7
|
+
|
8
|
+
def self.transaction(config, &control)
|
9
|
+
schema = config.param('schema', :hash)
|
10
|
+
rows = config.param('rows', :integer, default: 5000)
|
11
|
+
threads = config.param('threads', :integer, default: 1)
|
12
|
+
|
13
|
+
columns = schema.each_with_index.map{|column, index|
|
14
|
+
attr, type = column
|
15
|
+
# TODO: type should more flexible
|
16
|
+
case type.downcase
|
17
|
+
when "boolean"
|
18
|
+
Column.new(index, attr, :boolean)
|
19
|
+
when "string"
|
20
|
+
Column.new(index, attr, :string)
|
21
|
+
when "integer", "int", "long", "primary_key"
|
22
|
+
Column.new(index, attr, :long)
|
23
|
+
when "double", "float"
|
24
|
+
Column.new(index, attr, :double)
|
25
|
+
when "date"
|
26
|
+
Column.new(index, attr, :timestamp)
|
27
|
+
end
|
28
|
+
}
|
29
|
+
|
30
|
+
task = {'schema' => schema, 'rows' => rows}
|
31
|
+
|
32
|
+
puts "Random generation started."
|
33
|
+
commit_reports = yield(task, columns, threads)
|
34
|
+
puts "Random input finished. Commit reports = #{commit_reports.to_json}"
|
35
|
+
|
36
|
+
return {}
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize(task, schema, index, page_builder)
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def run
|
44
|
+
puts "Random generator input thread #{@index}..."
|
45
|
+
rows = @task['rows']
|
46
|
+
schema = @task['schema']
|
47
|
+
|
48
|
+
rows.times{|n|
|
49
|
+
@page_builder.add(schema.map{|attr, type|
|
50
|
+
case type
|
51
|
+
when "string"
|
52
|
+
SecureRandom.urlsafe_base64(32)
|
53
|
+
when "integer", "int", "long"
|
54
|
+
(Random.rand * 10000).to_i
|
55
|
+
when "primary_key"
|
56
|
+
n
|
57
|
+
when 'float', 'double'
|
58
|
+
Random.rand * 10000
|
59
|
+
when 'date'
|
60
|
+
Time.at(rand * Time.now.to_f)
|
61
|
+
else
|
62
|
+
raise "unknown type: #{type}"
|
63
|
+
end
|
64
|
+
})
|
65
|
+
}
|
66
|
+
@page_builder.finish
|
67
|
+
|
68
|
+
{ # commit report
|
69
|
+
"rows" => rows,
|
70
|
+
"columns" => schema.size
|
71
|
+
}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-plugin-input-random
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- KUMAZAKI Hiroki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Create dummy table for test or benchmark
|
42
|
+
email:
|
43
|
+
- hiroki.kumazaki@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- embulk-plugin-input-random.gemspec
|
54
|
+
- lib/embulk/input_random.rb
|
55
|
+
- lib/embulk/plugin/input/random/version.rb
|
56
|
+
homepage: https://github.com/kumagi/embulk-plugin-input-random
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Random Table Generator for Embulk
|
80
|
+
test_files: []
|
81
|
+
has_rdoc:
|