embulk-plugin-input-random 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -13
- data/embulk-plugin-input-random.gemspec +2 -3
- metadata +3 -4
- data/lib/embulk/input_random.rb +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5607ba4bed61ca0fd5a224d2683b5f0c0f520acd
|
4
|
+
data.tar.gz: e89f2741c44527903282980afcb274840881537e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0b019a3155d084be6854160da4d81d7e9670ed55a979d8bcb25e0371ce8ece3ae2754e82c8f2529d76ea533e282d0f3c063b5e67ecc58548565eb8afcbd0898
|
7
|
+
data.tar.gz: c4cbb7b4d848ef3fdb775bf147a0e0f92594f4325a07ad9c21e2aeb45b73b47aae073c052be7f68a2afd360b8062923405317d587cbb720248ea10ea3bc4cbc8
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Expected to used to test or benchmark.
|
|
8
8
|
Run this command with your embulk binary.
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
java -jar embulk.jar gem install embulk-plugin-input-random
|
11
|
+
$ java -jar embulk.jar gem install embulk-plugin-input-random
|
12
12
|
```
|
13
13
|
|
14
14
|
## Usage
|
@@ -53,25 +53,29 @@ out:
|
|
53
53
|
and just run
|
54
54
|
|
55
55
|
```
|
56
|
-
$ java -jar embulk.jar
|
56
|
+
$ java -jar embulk.jar preview random.yml
|
57
57
|
```
|
58
58
|
|
59
59
|
will generate result like
|
60
60
|
|
61
61
|
```
|
62
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
63
|
Random generator input thread 0...
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
2,
|
72
|
-
|
73
|
-
|
74
|
-
|
64
|
+
+---------+---------------------------------------------+------------+
|
65
|
+
| id:long | name:string | score:long |
|
66
|
+
+---------+---------------------------------------------+------------+
|
67
|
+
| 0 | UPPYQ0S1oiKDddasQxOlXPhZ9ys-FtVwH6-DIywnHG8 | 875 |
|
68
|
+
| 1 | IT8KHcI48wM_0ygtm8OVSZQSR1xA4g5lntZ9xAQwY5Y | 2,652 |
|
69
|
+
| 2 | 6HOLiPz9-srgwV8bgBX0Whd7Dq6HRUPKusZdONRxesw | 8,560 |
|
70
|
+
| 3 | r8X3G5iVZsJJEAp5Wqy8LdUte-2wmnz2Zb9gMiiTp-Q | 2,288 |
|
71
|
+
| 4 | g7DDPm6J0y6G9FYGcDgsMk-V6Rewz03sLIu3VUfmp5M | 2,065 |
|
72
|
+
| 5 | fwNJWwztnraaa9MH01sq1Uhx2iz66djdkeUSw18DFnQ | 9,214 |
|
73
|
+
| 6 | EE2WZ3Z7UIFN4U93fgjWYmGqzWEruVBVBaWJXGjfCsQ | 9,972 |
|
74
|
+
| 7 | 70WHrnDYAPx5qNtRxcG2HF-Y4yMO1SXigMep0NFtOo8 | 2,988 |
|
75
|
+
| 8 | wbbi1qQlC3x0WY8uksUc_b0PvJjN6e6QhTrykMF7BJE | 831 |
|
76
|
+
| 9 | zNBjwP_l1Fu7t8b4xIiYz7dfEO0v0BHS5vZd-xqdmCk | 8,596 |
|
77
|
+
| 10 | Rj_NNmf4MG0UASImGbmEHPKf_MUOZe97Jyrs5RQA3q4 | 1,129 |
|
78
|
+
...
|
75
79
|
```
|
76
80
|
|
77
81
|
You can insert arbitrary storage via Embulk!
|
@@ -1,15 +1,14 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'embulk/plugin/input/random/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
6
|
spec.name = "embulk-plugin-input-random"
|
8
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.2"
|
9
8
|
spec.authors = ["KUMAZAKI Hiroki"]
|
10
9
|
spec.email = ["hiroki.kumazaki@gmail.com"]
|
11
10
|
spec.summary = %q{Random Table Generator for Embulk}
|
12
|
-
spec.description = %q{Create dummy table
|
11
|
+
spec.description = %q{Create dummy table}
|
13
12
|
spec.homepage = "https://github.com/kumagi/embulk-plugin-input-random"
|
14
13
|
spec.license = "MIT"
|
15
14
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-plugin-input-random
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KUMAZAKI Hiroki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
-
description: Create dummy table
|
41
|
+
description: Create dummy table
|
42
42
|
email:
|
43
43
|
- hiroki.kumazaki@gmail.com
|
44
44
|
executables: []
|
@@ -51,7 +51,6 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- embulk-plugin-input-random.gemspec
|
54
|
-
- lib/embulk/input_random.rb
|
55
54
|
- lib/embulk/plugin/input/random/version.rb
|
56
55
|
homepage: https://github.com/kumagi/embulk-plugin-input-random
|
57
56
|
licenses:
|
data/lib/embulk/input_random.rb
DELETED
@@ -1,75 +0,0 @@
|
|
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
|