streamingly 0.0.2 → 0.0.3.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/streamingly.rb +8 -1
- data/lib/streamingly/kv.rb +19 -0
- data/lib/streamingly/serde.rb +36 -0
- data/lib/streamingly/serde_iterable.rb +15 -0
- data/lib/streamingly/version.rb +1 -1
- metadata +15 -15
data/lib/streamingly.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
require "streamingly/version"
|
2
2
|
require "streamingly/reducer"
|
3
|
+
require "streamingly/kv"
|
4
|
+
require "streamingly/serde"
|
5
|
+
require "streamingly/serde_iterable"
|
3
6
|
|
4
7
|
module Streamingly
|
5
|
-
|
8
|
+
|
9
|
+
def self.kv(key, value)
|
10
|
+
KV.new(key, value).to_s
|
11
|
+
end
|
12
|
+
|
6
13
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Streamingly
|
2
|
+
|
3
|
+
class KV < Struct.new(:key, :value)
|
4
|
+
def to_s
|
5
|
+
[ SerDe.to_csv(key), SerDe.to_csv(value) ].join("\t")
|
6
|
+
end
|
7
|
+
|
8
|
+
# TODO: remove .strip from https://github.com/swipely/streamingly/blob/master/lib/streamingly/reducer.rb#L11
|
9
|
+
def strip
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
# TODO: remove .split from https://github.com/swipely/streamingly/blob/master/lib/streamingly/reducer.rb#L28
|
14
|
+
def split(char="\t")
|
15
|
+
[key, value]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Streamingly
|
2
|
+
|
3
|
+
module SerDe
|
4
|
+
def self.to_csv(record)
|
5
|
+
case record
|
6
|
+
when String
|
7
|
+
record
|
8
|
+
when Struct
|
9
|
+
tokens = *record.map { |token|
|
10
|
+
case token
|
11
|
+
when BigDecimal
|
12
|
+
token.to_s('F')
|
13
|
+
else
|
14
|
+
token
|
15
|
+
end
|
16
|
+
}
|
17
|
+
|
18
|
+
CSV.generate_line( [ record.class.name, *tokens ]).rstrip
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.from_csv(string)
|
23
|
+
tokens = CSV.parse_line(string)
|
24
|
+
klass = Kernel.const_get(tokens.first)
|
25
|
+
klass.new(*tokens[1..-1])
|
26
|
+
rescue NameError
|
27
|
+
tokens
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.from_tabbed_csv(string)
|
31
|
+
k,v = string.split("\t")
|
32
|
+
KV.new(from_csv(k), from_csv(v))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lib/streamingly/version.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: streamingly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3.pre
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matt Gillooly
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70240236845400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.3'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70240236845400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70240236844760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70240236844760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70240236865540 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70240236865540
|
47
47
|
description: Helpful classes for writing streaming Hadoop jobs in Ruby
|
48
48
|
email:
|
49
49
|
- matt@swipely.com
|
@@ -58,7 +58,10 @@ files:
|
|
58
58
|
- README.md
|
59
59
|
- Rakefile
|
60
60
|
- lib/streamingly.rb
|
61
|
+
- lib/streamingly/kv.rb
|
61
62
|
- lib/streamingly/reducer.rb
|
63
|
+
- lib/streamingly/serde.rb
|
64
|
+
- lib/streamingly/serde_iterable.rb
|
62
65
|
- lib/streamingly/version.rb
|
63
66
|
- spec/spec_helper.rb
|
64
67
|
- spec/streamingly/reducer_spec.rb
|
@@ -78,16 +81,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
81
|
version: '0'
|
79
82
|
segments:
|
80
83
|
- 0
|
81
|
-
hash:
|
84
|
+
hash: -4472679935685112026
|
82
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
86
|
none: false
|
84
87
|
requirements:
|
85
|
-
- - ! '
|
88
|
+
- - ! '>'
|
86
89
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
88
|
-
segments:
|
89
|
-
- 0
|
90
|
-
hash: 1521604442353934601
|
90
|
+
version: 1.3.1
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
93
|
rubygems_version: 1.8.11
|