rbhive 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rbhive/connection.rb +7 -0
- data/lib/rbhive/explain_result.rb +46 -0
- data/lib/rbhive.rb +1 -0
- metadata +4 -3
data/lib/rbhive/connection.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
class ExplainResult
|
2
|
+
def initialize(rows)
|
3
|
+
@rows = rows
|
4
|
+
end
|
5
|
+
|
6
|
+
def ast
|
7
|
+
by_section[:abstract_syntax_tree].first
|
8
|
+
end
|
9
|
+
|
10
|
+
def stage_count
|
11
|
+
stage_dependencies.length
|
12
|
+
end
|
13
|
+
|
14
|
+
def stage_dependencies
|
15
|
+
by_section[:stage_dependencies] || []
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_tsv
|
19
|
+
@rows.join("\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
def raw
|
23
|
+
@rows
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
to_tsv
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def by_section
|
33
|
+
current_section = nil
|
34
|
+
@rows.inject({}) do |sections, row|
|
35
|
+
if row.match(/^[A-Z]/)
|
36
|
+
current_section = row.chomp(':').downcase.gsub(' ', '_').to_sym
|
37
|
+
sections[current_section] = []
|
38
|
+
elsif row.length == 0
|
39
|
+
next sections
|
40
|
+
else
|
41
|
+
sections[current_section] << row.strip
|
42
|
+
end
|
43
|
+
sections
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/rbhive.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'rbhive', 'connection')
|
2
2
|
require File.join(File.dirname(__FILE__), 'rbhive', 'table_schema')
|
3
3
|
require File.join(File.dirname(__FILE__), 'rbhive', 'result_set')
|
4
|
+
require File.join(File.dirname(__FILE__), 'rbhive', 'explain_result')
|
4
5
|
require File.join(File.dirname(__FILE__), 'rbhive', 'schema_definition')
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbhive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 5
|
10
|
+
version: 0.2.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Forward Internet Group
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/rbhive/connection.rb
|
48
48
|
- lib/rbhive/table_schema.rb
|
49
49
|
- lib/rbhive/result_set.rb
|
50
|
+
- lib/rbhive/explain_result.rb
|
50
51
|
- lib/rbhive/schema_definition.rb
|
51
52
|
- lib/thrift/facebook_service.rb
|
52
53
|
- lib/thrift/fb303_constants.rb
|