ruby-druid 0.1.3 → 0.1.4
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 +15 -0
- data/README.md +26 -17
- data/lib/druid/console.rb +1 -1
- data/lib/druid/query.rb +21 -6
- data/ruby-druid.gemspec +1 -1
- data/spec/lib/query_spec.rb +8 -0
- metadata +5 -17
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
ZTljYWNlZjVkNjI3OTg4MmRiNDViNDljNGE3YjQ1OTdmNmUxNWIyZA==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
OTRmNjRmNTQ4YmU2ODg5YzY2ZDlmOTJjZmJkOTFlZTg2ZDY1MGE1ZQ==
|
|
7
|
+
!binary "U0hBNTEy":
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
MTc1Njk1NzZjNmUzMDg3ZDczNDkyZjIyYTY3Yzk2YzA0MmRlMzQ4ZWQ3NTRm
|
|
10
|
+
M2YzNDkwZTEyOGVjZjNiZjE5YzVjZTg2OWU5NjFjZGEwNjc2ZWM0Yjg5YTgy
|
|
11
|
+
ZTc4OThkZDFmMTE1OTA4YzNiMTAxMTM4ZDRlYzE5ZWUzMmNiYTY=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
NDRkZTFkMTE3MTgxY2ViNTNjMDA2ZjI2MzM4ZGMzNGQ1MWUwYWRiM2Q4YjI4
|
|
14
|
+
NWI2NjM0ODdjZDAzNTA4YTYyM2EwODM5OGYwNmI0Y2RhOGY2N2M3N2M1YWU2
|
|
15
|
+
ZmRjODM5YjQ2NDZmMGNjMWFlNjU1YmI2YzkyNDQ2NmZlMTc2NDQ=
|
data/README.md
CHANGED
|
@@ -215,11 +215,12 @@ $ bin/dripl
|
|
|
215
215
|
>> metrics
|
|
216
216
|
[
|
|
217
217
|
[0] "actions"
|
|
218
|
+
[1] "words"
|
|
218
219
|
]
|
|
219
220
|
|
|
220
221
|
>> dimensions
|
|
221
222
|
[
|
|
222
|
-
[0] "
|
|
223
|
+
[0] "type"
|
|
223
224
|
]
|
|
224
225
|
|
|
225
226
|
>> long_sum(:actions)
|
|
@@ -229,21 +230,24 @@ $ bin/dripl
|
|
|
229
230
|
| 98575 |
|
|
230
231
|
+---------+
|
|
231
232
|
|
|
232
|
-
>> long_sum(:actions)[-
|
|
233
|
-
|
|
234
|
-
|
|
|
235
|
-
|
|
236
|
-
| 2013-
|
|
237
|
-
|
|
238
|
-
|
|
|
239
|
-
|
|
240
|
-
| 2013-
|
|
241
|
-
|
|
242
|
-
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
233
|
+
>> long_sum(:actions, :words)[-3.days].granularity(:day)
|
|
234
|
+
+---------------+---------------+
|
|
235
|
+
| actions | words |
|
|
236
|
+
+---------------+---------------+
|
|
237
|
+
| 2013-12-11T00:00:00.000+01:00 |
|
|
238
|
+
+---------------+---------------+
|
|
239
|
+
| 537345 | 68974 |
|
|
240
|
+
+---------------+---------------+
|
|
241
|
+
| 2013-12-12T00:00:00.000+01:00 |
|
|
242
|
+
+---------------+---------------+
|
|
243
|
+
| 675431 | 49253 |
|
|
244
|
+
+---------------+---------------+
|
|
245
|
+
| 2013-12-13T00:00:00.000+01:00 |
|
|
246
|
+
+---------------+---------------+
|
|
247
|
+
| 749034 | 87542 |
|
|
248
|
+
+---------------+---------------+
|
|
249
|
+
|
|
250
|
+
>> long_sum(:actions, :words)[-3.days].granularity(:day).properties
|
|
247
251
|
{
|
|
248
252
|
:dataSource => "events",
|
|
249
253
|
:granularity => {
|
|
@@ -252,7 +256,7 @@ $ bin/dripl
|
|
|
252
256
|
:timeZone => "Europe/Berlin"
|
|
253
257
|
},
|
|
254
258
|
:intervals => [
|
|
255
|
-
[0] "2013-
|
|
259
|
+
[0] "2013-12-11T00:00:00+01:00/2013-12-13T09:41:10+01:00"
|
|
256
260
|
],
|
|
257
261
|
:queryType => :groupBy,
|
|
258
262
|
:aggregations => [
|
|
@@ -260,6 +264,11 @@ $ bin/dripl
|
|
|
260
264
|
:type => "longSum",
|
|
261
265
|
:name => :actions,
|
|
262
266
|
:fieldName => :actions
|
|
267
|
+
},
|
|
268
|
+
[1] {
|
|
269
|
+
:type => "longSum",
|
|
270
|
+
:name => :words,
|
|
271
|
+
:fieldName => :words
|
|
263
272
|
}
|
|
264
273
|
]
|
|
265
274
|
}
|
data/lib/druid/console.rb
CHANGED
|
@@ -67,6 +67,6 @@ module Druid
|
|
|
67
67
|
client.query(@source)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
def_delegators :query, :group_by, :sum, :long_sum, :double_sum, :postagg, :interval, :granularity, :filter, :time_series
|
|
70
|
+
def_delegators :query, :group_by, :sum, :long_sum, :double_sum, :postagg, :interval, :granularity, :filter, :time_series, :topn
|
|
71
71
|
end
|
|
72
72
|
end
|
data/lib/druid/query.rb
CHANGED
|
@@ -53,6 +53,14 @@ module Druid
|
|
|
53
53
|
@properties[:dimensions] = dimensions.flatten
|
|
54
54
|
self
|
|
55
55
|
end
|
|
56
|
+
|
|
57
|
+
def topn(dimension, metric, threshold)
|
|
58
|
+
query_type(:topN)
|
|
59
|
+
@properties[:dimension] = dimension
|
|
60
|
+
@properties[:metric] = metric
|
|
61
|
+
@properties[:threshold] = threshold
|
|
62
|
+
self
|
|
63
|
+
end
|
|
56
64
|
|
|
57
65
|
def time_series(*aggregations)
|
|
58
66
|
query_type(:timeseries)
|
|
@@ -67,15 +75,16 @@ module Druid
|
|
|
67
75
|
|
|
68
76
|
define_method method_name do |*metrics|
|
|
69
77
|
query_type(get_query_type())
|
|
70
|
-
aggregations = @properties[:aggregations]
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
@properties[:aggregations] = [] if @properties[:aggregations].nil?
|
|
79
|
+
|
|
80
|
+
metrics.flatten.each do |metric|
|
|
81
|
+
@properties[:aggregations] << {
|
|
73
82
|
:type => agg_type,
|
|
74
83
|
:name => metric.to_s,
|
|
75
84
|
:fieldName => metric.to_s
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
} unless contains_aggregation?(metric)
|
|
86
|
+
end
|
|
87
|
+
|
|
79
88
|
self
|
|
80
89
|
end
|
|
81
90
|
end
|
|
@@ -171,5 +180,11 @@ module Druid
|
|
|
171
180
|
to = DateTime.parse(to.to_s) unless to.respond_to? :iso8601
|
|
172
181
|
"#{from.iso8601}/#{to.iso8601}"
|
|
173
182
|
end
|
|
183
|
+
|
|
184
|
+
def contains_aggregation?(metric)
|
|
185
|
+
return false if @properties[:aggregations].nil?
|
|
186
|
+
@properties[:aggregations].index { |aggregation| aggregation[:fieldName] == metric.to_s }
|
|
187
|
+
end
|
|
174
188
|
end
|
|
189
|
+
|
|
175
190
|
end
|
data/ruby-druid.gemspec
CHANGED
data/spec/lib/query_spec.rb
CHANGED
|
@@ -31,6 +31,14 @@ describe Druid::Query do
|
|
|
31
31
|
JSON.parse(@query.to_json)['dimensions'].should == ['a', 'b', 'c']
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
it 'takes dimension, metric and threshold from topn method' do
|
|
35
|
+
@query.topn(:a, :b, 25)
|
|
36
|
+
result = JSON.parse(@query.to_json)
|
|
37
|
+
result['dimension'].should == 'a'
|
|
38
|
+
result['metric'].should == 'b'
|
|
39
|
+
result['threshold'].should == 25
|
|
40
|
+
end
|
|
41
|
+
|
|
34
42
|
it 'build a post aggregation with a constant right' do
|
|
35
43
|
@query.postagg{(a + 1).as ctr }
|
|
36
44
|
|
metadata
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-druid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.1.4
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- LiquidM, Inc.
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: zk
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
17
|
- - ! '>='
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
@@ -22,7 +20,6 @@ dependencies:
|
|
|
22
20
|
type: :runtime
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
24
|
- - ! '>='
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
@@ -30,7 +27,6 @@ dependencies:
|
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
|
31
28
|
name: rest-client
|
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
30
|
requirements:
|
|
35
31
|
- - ! '>='
|
|
36
32
|
- !ruby/object:Gem::Version
|
|
@@ -38,7 +34,6 @@ dependencies:
|
|
|
38
34
|
type: :runtime
|
|
39
35
|
prerelease: false
|
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
37
|
requirements:
|
|
43
38
|
- - ! '>='
|
|
44
39
|
- !ruby/object:Gem::Version
|
|
@@ -76,33 +71,26 @@ files:
|
|
|
76
71
|
homepage: https://github.com/liquidm/ruby-druid
|
|
77
72
|
licenses:
|
|
78
73
|
- MIT
|
|
74
|
+
metadata: {}
|
|
79
75
|
post_install_message:
|
|
80
76
|
rdoc_options: []
|
|
81
77
|
require_paths:
|
|
82
78
|
- lib
|
|
83
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
|
-
none: false
|
|
85
80
|
requirements:
|
|
86
81
|
- - ! '>='
|
|
87
82
|
- !ruby/object:Gem::Version
|
|
88
83
|
version: '0'
|
|
89
|
-
segments:
|
|
90
|
-
- 0
|
|
91
|
-
hash: -4499616778972236254
|
|
92
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
|
-
none: false
|
|
94
85
|
requirements:
|
|
95
86
|
- - ! '>='
|
|
96
87
|
- !ruby/object:Gem::Version
|
|
97
88
|
version: '0'
|
|
98
|
-
segments:
|
|
99
|
-
- 0
|
|
100
|
-
hash: -4499616778972236254
|
|
101
89
|
requirements: []
|
|
102
90
|
rubyforge_project:
|
|
103
|
-
rubygems_version:
|
|
91
|
+
rubygems_version: 2.0.5
|
|
104
92
|
signing_key:
|
|
105
|
-
specification_version:
|
|
93
|
+
specification_version: 4
|
|
106
94
|
summary: Ruby client for metamx druid
|
|
107
95
|
test_files:
|
|
108
96
|
- spec/lib/client_spec.rb
|