feedx 0.10.2 → 0.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +3 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +12 -2
- data/Gemfile +0 -2
- data/Gemfile.lock +50 -30
- data/Makefile +10 -5
- data/compression.go +18 -0
- data/compression_test.go +12 -0
- data/consumer_test.go +5 -4
- data/ext/parquet/decoder.go +170 -0
- data/ext/parquet/decoder_test.go +88 -0
- data/ext/parquet/go.mod +12 -0
- data/ext/parquet/go.sum +134 -0
- data/ext/parquet/parquet.go +78 -0
- data/ext/parquet/parquet_test.go +28 -0
- data/ext/parquet/reader.go +89 -0
- data/ext/parquet/testdata/alltypes_plain.parquet +0 -0
- data/ext/parquet/types.go +51 -0
- data/feedx.gemspec +3 -2
- data/feedx_test.go +8 -24
- data/format.go +50 -20
- data/format_test.go +8 -6
- data/go.mod +9 -11
- data/go.sum +76 -28
- data/internal/testdata/testdata.pb.go +223 -0
- data/internal/testdata/testdata.proto +15 -0
- data/lib/feedx/cache/abstract.rb +2 -2
- data/lib/feedx/cache/memory.rb +1 -0
- data/lib/feedx/compression.rb +11 -4
- data/lib/feedx/compression/abstract.rb +2 -2
- data/lib/feedx/compression/gzip.rb +14 -16
- data/lib/feedx/compression/none.rb +4 -4
- data/lib/feedx/consumer.rb +15 -9
- data/lib/feedx/format.rb +18 -9
- data/lib/feedx/format/abstract.rb +42 -13
- data/lib/feedx/format/json.rb +12 -8
- data/lib/feedx/format/parquet.rb +102 -0
- data/lib/feedx/format/protobuf.rb +16 -8
- data/lib/feedx/producer.rb +27 -22
- data/lib/feedx/stream.rb +36 -23
- data/producer_test.go +1 -2
- data/reader_test.go +6 -6
- data/spec/feedx/compression/gzip_spec.rb +2 -2
- data/spec/feedx/compression/none_spec.rb +2 -2
- data/spec/feedx/compression_spec.rb +9 -9
- data/spec/feedx/consumer_spec.rb +1 -1
- data/spec/feedx/format/abstract_spec.rb +11 -8
- data/spec/feedx/format/json_spec.rb +17 -16
- data/spec/feedx/format/parquet_spec.rb +30 -0
- data/spec/feedx/format/protobuf_spec.rb +12 -11
- data/spec/feedx/format_spec.rb +8 -8
- data/spec/feedx/producer_spec.rb +6 -0
- data/spec/feedx/stream_spec.rb +43 -6
- data/spec/spec_helper.rb +17 -1
- metadata +33 -5
data/spec/feedx/producer_spec.rb
CHANGED
@@ -64,4 +64,10 @@ RSpec.describe Feedx::Producer do
|
|
64
64
|
size = described_class.perform 'mock:///dir/file.json', last_modified: Time.at(1515151516), enum: enumerable
|
65
65
|
expect(size).to eq(15900)
|
66
66
|
end
|
67
|
+
|
68
|
+
it 'should accept downstream options' do
|
69
|
+
expect do
|
70
|
+
described_class.perform 'mock:///dir/file.jsonz', enum: enumerable, x: 1, y: 'v', z: true
|
71
|
+
end.not_to raise_error
|
72
|
+
end
|
67
73
|
end
|
data/spec/feedx/stream_spec.rb
CHANGED
@@ -2,10 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Feedx::Stream do
|
4
4
|
let(:bucket) { BFS::Bucket::InMem.new }
|
5
|
-
|
5
|
+
let(:compressed) { described_class.new('mock:///dir/file.json.gz') }
|
6
6
|
|
7
7
|
subject { described_class.new('mock:///dir/file.json') }
|
8
|
-
|
8
|
+
|
9
|
+
before { allow(BFS).to receive(:resolve).and_return(bucket) }
|
10
|
+
after { subject.close }
|
11
|
+
after { compressed.close }
|
9
12
|
|
10
13
|
it 'should reject invalid inputs' do
|
11
14
|
expect do
|
@@ -13,16 +16,38 @@ RSpec.describe Feedx::Stream do
|
|
13
16
|
end.to raise_error(/unable to detect format/)
|
14
17
|
end
|
15
18
|
|
19
|
+
it 'should accept custom formats' do
|
20
|
+
format = Class.new do
|
21
|
+
def encoder(io, &block)
|
22
|
+
Feedx::Format::JSON::Encoder.open(io, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def decoder(io, &block)
|
26
|
+
Feedx::Format::JSON::Decoder.open(io, &block)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
result = described_class.open('mock:///dir/file.txt', format: format.new) do |stream|
|
31
|
+
stream.create {|s| s.encode Feedx::TestCase::Model.new('X') }
|
32
|
+
21
|
33
|
+
end
|
34
|
+
expect(result).to eq(21)
|
35
|
+
|
36
|
+
expect(bucket.read('dir/file.txt')).to eq(<<~JSON)
|
37
|
+
{"title":"X","updated_at":"2018-01-05 11:25:15 UTC"}
|
38
|
+
JSON
|
39
|
+
end
|
40
|
+
|
16
41
|
it 'should encode' do
|
17
42
|
subject.create do |s|
|
18
43
|
s.encode(Feedx::TestCase::Model.new('X'))
|
19
44
|
s.encode(Feedx::TestCase::Model.new('Y'))
|
20
45
|
end
|
21
46
|
|
22
|
-
expect(bucket.
|
23
|
-
|
24
|
-
|
25
|
-
|
47
|
+
expect(bucket.read('dir/file.json')).to eq(<<~JSON)
|
48
|
+
{"title":"X","updated_at":"2018-01-05 11:25:15 UTC"}
|
49
|
+
{"title":"Y","updated_at":"2018-01-05 11:25:15 UTC"}
|
50
|
+
JSON
|
26
51
|
end
|
27
52
|
|
28
53
|
it 'should encode compressed' do
|
@@ -42,6 +67,18 @@ RSpec.describe Feedx::Stream do
|
|
42
67
|
expect(bucket.info('dir/file.json').metadata).to eq('X' => '5')
|
43
68
|
end
|
44
69
|
|
70
|
+
it 'should abort encode on errors (if compressed)' do
|
71
|
+
stop = RuntimeError.new('STOP')
|
72
|
+
expect do
|
73
|
+
compressed.create do |s|
|
74
|
+
s.encode(Feedx::TestCase::Model.new('X'))
|
75
|
+
raise stop
|
76
|
+
end
|
77
|
+
end.to raise_error(stop)
|
78
|
+
|
79
|
+
expect(bucket.ls('**').to_a).to be_empty
|
80
|
+
end
|
81
|
+
|
45
82
|
it 'should decode' do
|
46
83
|
subject.create do |s|
|
47
84
|
s.encode(Feedx::TestCase::Model.new('X'))
|
data/spec/spec_helper.rb
CHANGED
@@ -28,13 +28,29 @@ module Feedx
|
|
28
28
|
end
|
29
29
|
alias eql? ==
|
30
30
|
|
31
|
+
def updated_at
|
32
|
+
Time.at(1515151515).utc
|
33
|
+
end
|
34
|
+
|
31
35
|
def from_json(data, *)
|
32
36
|
hash = ::JSON.parse(data)
|
33
37
|
@title = hash['title'] if hash.is_a?(Hash)
|
34
38
|
end
|
35
39
|
|
36
40
|
def to_json(*)
|
37
|
-
::JSON.dump(title: @title, updated_at:
|
41
|
+
::JSON.dump(title: @title, updated_at: updated_at)
|
42
|
+
end
|
43
|
+
|
44
|
+
def from_parquet(rec)
|
45
|
+
rec.each_pair do |name, value|
|
46
|
+
@title = value if name == 'title'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_parquet(schema, *)
|
51
|
+
schema.fields.map do |field|
|
52
|
+
send(field.name)
|
53
|
+
end
|
38
54
|
end
|
39
55
|
end
|
40
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feedx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Black Square Media Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bfs
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.8.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: red-parquet
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.0.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +143,15 @@ files:
|
|
129
143
|
- compression_test.go
|
130
144
|
- consumer.go
|
131
145
|
- consumer_test.go
|
146
|
+
- ext/parquet/decoder.go
|
147
|
+
- ext/parquet/decoder_test.go
|
148
|
+
- ext/parquet/go.mod
|
149
|
+
- ext/parquet/go.sum
|
150
|
+
- ext/parquet/parquet.go
|
151
|
+
- ext/parquet/parquet_test.go
|
152
|
+
- ext/parquet/reader.go
|
153
|
+
- ext/parquet/testdata/alltypes_plain.parquet
|
154
|
+
- ext/parquet/types.go
|
132
155
|
- feedx.gemspec
|
133
156
|
- feedx.go
|
134
157
|
- feedx_test.go
|
@@ -136,6 +159,8 @@ files:
|
|
136
159
|
- format_test.go
|
137
160
|
- go.mod
|
138
161
|
- go.sum
|
162
|
+
- internal/testdata/testdata.pb.go
|
163
|
+
- internal/testdata/testdata.proto
|
139
164
|
- lib/feedx.rb
|
140
165
|
- lib/feedx/cache.rb
|
141
166
|
- lib/feedx/cache/abstract.rb
|
@@ -149,6 +174,7 @@ files:
|
|
149
174
|
- lib/feedx/format.rb
|
150
175
|
- lib/feedx/format/abstract.rb
|
151
176
|
- lib/feedx/format/json.rb
|
177
|
+
- lib/feedx/format/parquet.rb
|
152
178
|
- lib/feedx/format/protobuf.rb
|
153
179
|
- lib/feedx/producer.rb
|
154
180
|
- lib/feedx/pusher.rb
|
@@ -165,6 +191,7 @@ files:
|
|
165
191
|
- spec/feedx/consumer_spec.rb
|
166
192
|
- spec/feedx/format/abstract_spec.rb
|
167
193
|
- spec/feedx/format/json_spec.rb
|
194
|
+
- spec/feedx/format/parquet_spec.rb
|
168
195
|
- spec/feedx/format/protobuf_spec.rb
|
169
196
|
- spec/feedx/format_spec.rb
|
170
197
|
- spec/feedx/producer_spec.rb
|
@@ -191,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
218
|
- !ruby/object:Gem::Version
|
192
219
|
version: '0'
|
193
220
|
requirements: []
|
194
|
-
rubygems_version: 3.1.
|
221
|
+
rubygems_version: 3.1.4
|
195
222
|
signing_key:
|
196
223
|
specification_version: 4
|
197
224
|
summary: Exchange data between components via feeds
|
@@ -204,6 +231,7 @@ test_files:
|
|
204
231
|
- spec/feedx/consumer_spec.rb
|
205
232
|
- spec/feedx/format/abstract_spec.rb
|
206
233
|
- spec/feedx/format/json_spec.rb
|
234
|
+
- spec/feedx/format/parquet_spec.rb
|
207
235
|
- spec/feedx/format/protobuf_spec.rb
|
208
236
|
- spec/feedx/format_spec.rb
|
209
237
|
- spec/feedx/producer_spec.rb
|