impala 0.1.0

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.
Files changed (86) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +2 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +28 -0
  5. data/Rakefile +15 -0
  6. data/impala.gemspec +25 -0
  7. data/lib/impala.rb +33 -0
  8. data/lib/impala/connection.rb +93 -0
  9. data/lib/impala/cursor.rb +86 -0
  10. data/lib/impala/protocol.rb +6 -0
  11. data/lib/impala/protocol/beeswax_constants.rb +14 -0
  12. data/lib/impala/protocol/beeswax_service.rb +747 -0
  13. data/lib/impala/protocol/beeswax_types.rb +192 -0
  14. data/lib/impala/protocol/data_constants.rb +12 -0
  15. data/lib/impala/protocol/data_sinks_constants.rb +12 -0
  16. data/lib/impala/protocol/data_sinks_types.rb +107 -0
  17. data/lib/impala/protocol/data_types.rb +77 -0
  18. data/lib/impala/protocol/descriptors_constants.rb +12 -0
  19. data/lib/impala/protocol/descriptors_types.rb +266 -0
  20. data/lib/impala/protocol/exprs_constants.rb +12 -0
  21. data/lib/impala/protocol/exprs_types.rb +345 -0
  22. data/lib/impala/protocol/facebook_service.rb +706 -0
  23. data/lib/impala/protocol/fb303_constants.rb +14 -0
  24. data/lib/impala/protocol/fb303_types.rb +24 -0
  25. data/lib/impala/protocol/frontend_constants.rb +12 -0
  26. data/lib/impala/protocol/frontend_types.rb +347 -0
  27. data/lib/impala/protocol/hive_metastore_constants.rb +52 -0
  28. data/lib/impala/protocol/hive_metastore_types.rb +697 -0
  29. data/lib/impala/protocol/impala_internal_service.rb +244 -0
  30. data/lib/impala/protocol/impala_internal_service_constants.rb +12 -0
  31. data/lib/impala/protocol/impala_internal_service_types.rb +362 -0
  32. data/lib/impala/protocol/impala_plan_service.rb +310 -0
  33. data/lib/impala/protocol/impala_plan_service_constants.rb +12 -0
  34. data/lib/impala/protocol/impala_plan_service_types.rb +36 -0
  35. data/lib/impala/protocol/impala_service.rb +260 -0
  36. data/lib/impala/protocol/impala_service_constants.rb +12 -0
  37. data/lib/impala/protocol/impala_service_types.rb +46 -0
  38. data/lib/impala/protocol/java_constants_constants.rb +42 -0
  39. data/lib/impala/protocol/java_constants_types.rb +14 -0
  40. data/lib/impala/protocol/opcodes_constants.rb +12 -0
  41. data/lib/impala/protocol/opcodes_types.rb +309 -0
  42. data/lib/impala/protocol/partitions_constants.rb +12 -0
  43. data/lib/impala/protocol/partitions_types.rb +44 -0
  44. data/lib/impala/protocol/plan_nodes_constants.rb +12 -0
  45. data/lib/impala/protocol/plan_nodes_types.rb +345 -0
  46. data/lib/impala/protocol/planner_constants.rb +12 -0
  47. data/lib/impala/protocol/planner_types.rb +78 -0
  48. data/lib/impala/protocol/runtime_profile_constants.rb +12 -0
  49. data/lib/impala/protocol/runtime_profile_types.rb +97 -0
  50. data/lib/impala/protocol/state_store_service.rb +244 -0
  51. data/lib/impala/protocol/state_store_service_constants.rb +12 -0
  52. data/lib/impala/protocol/state_store_service_types.rb +185 -0
  53. data/lib/impala/protocol/state_store_subscriber_service.rb +82 -0
  54. data/lib/impala/protocol/state_store_subscriber_service_constants.rb +12 -0
  55. data/lib/impala/protocol/state_store_subscriber_service_types.rb +67 -0
  56. data/lib/impala/protocol/statestore_types_constants.rb +12 -0
  57. data/lib/impala/protocol/statestore_types_types.rb +77 -0
  58. data/lib/impala/protocol/status_constants.rb +12 -0
  59. data/lib/impala/protocol/status_types.rb +44 -0
  60. data/lib/impala/protocol/thrift_hive_metastore.rb +4707 -0
  61. data/lib/impala/protocol/types_constants.rb +12 -0
  62. data/lib/impala/protocol/types_types.rb +86 -0
  63. data/lib/impala/version.rb +3 -0
  64. data/thrift/Data.thrift +52 -0
  65. data/thrift/DataSinks.thrift +61 -0
  66. data/thrift/Descriptors.thrift +115 -0
  67. data/thrift/Exprs.thrift +134 -0
  68. data/thrift/Frontend.thrift +193 -0
  69. data/thrift/ImpalaInternalService.thrift +265 -0
  70. data/thrift/ImpalaPlanService.thrift +44 -0
  71. data/thrift/ImpalaService.thrift +105 -0
  72. data/thrift/JavaConstants.thrift +60 -0
  73. data/thrift/Opcodes.thrift +317 -0
  74. data/thrift/Partitions.thrift +41 -0
  75. data/thrift/PlanNodes.thrift +184 -0
  76. data/thrift/Planner.thrift +72 -0
  77. data/thrift/RuntimeProfile.thrift +58 -0
  78. data/thrift/StateStoreService.thrift +121 -0
  79. data/thrift/StateStoreSubscriberService.thrift +64 -0
  80. data/thrift/StatestoreTypes.thrift +50 -0
  81. data/thrift/Status.thrift +31 -0
  82. data/thrift/Types.thrift +71 -0
  83. data/thrift/beeswax.thrift +175 -0
  84. data/thrift/fb303.thrift +112 -0
  85. data/thrift/hive_metastore.thrift +528 -0
  86. metadata +206 -0
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Colin Marc
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # impala-ruby
2
+
3
+ This is an ruby client for [Cloudera's Impala][1]. You use it like this:
4
+
5
+ ```ruby
6
+ require 'impala'
7
+
8
+ Impala.connect('host', 21000) do |conn|
9
+ conn.query('SELECT zip, income FROM zipcode_incomes LIMIT 5')
10
+ end
11
+ # => [{:zip=>'02446', :income=>89597}, ...]
12
+ ```
13
+
14
+ You can also use cursors to avoid loading the entire result set into memory:
15
+
16
+ ```ruby
17
+ conn = Impala.connect('host', 21000)
18
+ cursor = conn.execute('SELECT zip, income FROM zipcode_incomes ORDER BY income DESC')
19
+
20
+ one_row = cursor.fetch_row
21
+ cursor.each do |row|
22
+ # etc
23
+ end
24
+
25
+ conn.close
26
+ ```
27
+
28
+ [1]: https://ccp.cloudera.com/display/IMPALA10BETADOC/Introducing+Cloudera+Impala
@@ -0,0 +1,15 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ THRIFT_FILES = FileList['./thrift/*.thrift']
4
+ GENNED_FILES = FileList['./lib/impala/protocol/*']
5
+
6
+ task :gen do
7
+ THRIFT_FILES.each do |f|
8
+ sh "thrift -out lib/impala/protocol --gen rb #{f}"
9
+ end
10
+ sh "eden rewrite lib/impala/protocol/*.rb"
11
+ end
12
+
13
+ task :clean do
14
+ GENNED_FILES.each { |f| rm f }
15
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'impala/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "impala"
8
+ gem.version = Impala::VERSION
9
+ gem.authors = ["Colin Marc"]
10
+ gem.email = ["colinmarc@gmail.com"]
11
+ gem.description = %q{A ruby client for Cloudera's Impala}
12
+ gem.summary = %q{A ruby client for Cloudera's Impala}
13
+ gem.homepage = "https://github.com/colinmarc/impala-ruby"
14
+
15
+ gem.add_dependency('thrift', '~> 0.9')
16
+
17
+ gem.add_development_dependency('rake')
18
+ gem.add_development_dependency('eden')
19
+ gem.add_development_dependency('pry')
20
+
21
+ gem.files = `git ls-files`.split($/)
22
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
23
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
24
+ gem.require_paths = ["lib"]
25
+ end
@@ -0,0 +1,33 @@
1
+
2
+ # the generated ruby files use a relative require, so we need to add the
3
+ # generated directory to $LOAD_PATH
4
+ this_dir = File.expand_path(File.dirname(__FILE__))
5
+ gen_dir = File.join(this_dir, 'impala/protocol')
6
+ $LOAD_PATH.push(gen_dir) unless $LOAD_PATH.include?(gen_dir)
7
+
8
+ require 'impala/version'
9
+
10
+ require 'thrift'
11
+ require 'impala/protocol'
12
+ require 'impala/cursor'
13
+ require 'impala/connection'
14
+
15
+ module Impala
16
+ KNOWN_COMMANDS = ['select', 'show', 'describe', 'use']
17
+ class InvalidQueryError < StandardError; end
18
+ class ConnectionError < StandardError; end
19
+ class CursorError < StandardError; end
20
+
21
+ def self.connect(host='localhost', port=21000)
22
+ connection = Connection.new(host, port)
23
+
24
+ if block_given?
25
+ ret = yield connection
26
+ connection.close
27
+ else
28
+ ret = connection
29
+ end
30
+
31
+ ret
32
+ end
33
+ end
@@ -0,0 +1,93 @@
1
+ module Impala
2
+ class Connection
3
+ SLEEP_INTERVAL = 0.1
4
+
5
+ def initialize(host='localhost', port=21000)
6
+ @host = host
7
+ @port = port
8
+ @connected = false
9
+ open
10
+ end
11
+
12
+ def open
13
+ return if @connected
14
+
15
+ socket = Thrift::Socket.new(@host, @port)
16
+
17
+ @transport = Thrift::BufferedTransport.new(socket)
18
+ @transport.open
19
+
20
+ proto = Thrift::BinaryProtocol.new(@transport)
21
+ @service = Protocol::ImpalaService::Client.new(proto)
22
+ @connected = true
23
+ end
24
+
25
+ def close
26
+ @transport.close
27
+ @connected = false
28
+ end
29
+
30
+ def open?
31
+ @connected
32
+ end
33
+
34
+ def query(raw_query)
35
+ execute(raw_query).fetch_all
36
+ end
37
+
38
+ def execute(raw_query)
39
+ raise ConnectionError.new("Connection closed") unless open?
40
+
41
+ words = raw_query.split
42
+ if words.empty?
43
+ raise InvalidQueryError.new("Empty query")
44
+ elsif !KNOWN_COMMANDS.include?(words.first.downcase)
45
+ raise InvalidQueryError.new("Unrecognized command: '#{words.first}'")
46
+ end
47
+
48
+ query = sanitize_query(raw_query)
49
+ handle = send_query(query)
50
+
51
+ wait_for_result(handle)
52
+ Cursor.new(handle, @service)
53
+ end
54
+
55
+ private
56
+
57
+ def sanitize_query(raw)
58
+ #TODO?
59
+ raw.downcase
60
+ end
61
+
62
+ def send_query(sanitized_query)
63
+ query = Protocol::Beeswax::Query.new
64
+ query.query = sanitized_query
65
+
66
+ @service.query(query)
67
+ end
68
+
69
+ def wait_for_result(handle)
70
+ begin
71
+ #TODO select here, or something
72
+ while true
73
+ state = @service.get_state(handle)
74
+ if state == Protocol::Beeswax::QueryState::FINISHED
75
+ break
76
+ elsif state == Protocol::Beeswax::QueryState::EXCEPTION
77
+ close_handle(handle)
78
+ raise ConnectionError.new("The query was aborted")
79
+ end
80
+
81
+ sleep(SLEEP_INTERVAL)
82
+ end
83
+ rescue Interrupt
84
+ close_handle(handle)
85
+ raise
86
+ end
87
+ end
88
+
89
+ def close_handle(handle)
90
+ @service.close(handle)
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,86 @@
1
+ module Impala
2
+ class Cursor
3
+ include Enumerable
4
+
5
+ def initialize(handle, service, buffer_length=1024)
6
+ @handle = handle
7
+ @service = service
8
+ @metadata = @service.get_results_metadata(@handle)
9
+
10
+ @buffer_length = buffer_length
11
+ @row_buffer = []
12
+
13
+ @done = false
14
+ @closed = false
15
+ end
16
+
17
+ def each
18
+ while row = fetch_row
19
+ yield row
20
+ end
21
+ end
22
+
23
+ def fetch_row
24
+ raise CursorError.new("Cursor has expired or been closed") if @closed
25
+
26
+ if @row_buffer.empty?
27
+ if @done
28
+ return nil
29
+ else
30
+ fetch_more
31
+ end
32
+ end
33
+
34
+ @row_buffer.shift
35
+ end
36
+
37
+ def fetch_all
38
+ self.to_a
39
+ end
40
+
41
+ def close
42
+ @closed = true
43
+ @service.close(@handle)
44
+ end
45
+
46
+ private
47
+
48
+ def fetch_more
49
+ return if @done
50
+
51
+ begin
52
+ res = @service.fetch(@handle, false, @buffer_length)
53
+ rescue Protocol::Beeswax::BeeswaxException => e
54
+ @closed = true
55
+ raise CursorError.new("Cursor has expired or been closed")
56
+ end
57
+
58
+ rows = res.data.map { |raw| parse_row(raw) }
59
+ @row_buffer.concat(rows)
60
+ @done = true unless res.has_more
61
+ end
62
+
63
+ def parse_row(raw)
64
+ row = {}
65
+ fields = raw.split(@metadata.delim)
66
+
67
+ fields.zip(@metadata.schema.fieldSchemas).each do |raw_value, schema|
68
+ value = convert_raw_value(raw_value, schema)
69
+ row[schema.name.to_sym] = value
70
+ end
71
+
72
+ row
73
+ end
74
+
75
+ def convert_raw_value(value, schema)
76
+ case schema.type
77
+ when 'string'
78
+ value
79
+ when 'tinyint', 'int', 'bigint'
80
+ value.to_i
81
+ else
82
+ raise "Unknown type: #{schema.type}" #TODO
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,6 @@
1
+ require 'impala/protocol/impala_service'
2
+
3
+ module Impala
4
+ module Protocol
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.8.0)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'beeswax_types'
8
+
9
+ module Impala
10
+ module Protocol
11
+ module Beeswax
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,747 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.8.0)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'beeswax_types'
9
+
10
+ module Impala
11
+ module Protocol
12
+ module Beeswax
13
+ module BeeswaxService
14
+ class Client
15
+ include ::Thrift::Client
16
+
17
+ def query(query)
18
+ send_query(query)
19
+ return recv_query()
20
+ end
21
+
22
+ def send_query(query)
23
+ send_message('query', Query_args, :query => query)
24
+ end
25
+
26
+ def recv_query()
27
+ result = receive_message(Query_result)
28
+ return result.success unless result.success.nil?
29
+ raise result.error unless result.error.nil?
30
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'query failed: unknown result')
31
+ end
32
+
33
+ def executeAndWait(query, clientCtx)
34
+ send_executeAndWait(query, clientCtx)
35
+ return recv_executeAndWait()
36
+ end
37
+
38
+ def send_executeAndWait(query, clientCtx)
39
+ send_message('executeAndWait', ExecuteAndWait_args, :query => query, :clientCtx => clientCtx)
40
+ end
41
+
42
+ def recv_executeAndWait()
43
+ result = receive_message(ExecuteAndWait_result)
44
+ return result.success unless result.success.nil?
45
+ raise result.error unless result.error.nil?
46
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'executeAndWait failed: unknown result')
47
+ end
48
+
49
+ def explain(query)
50
+ send_explain(query)
51
+ return recv_explain()
52
+ end
53
+
54
+ def send_explain(query)
55
+ send_message('explain', Explain_args, :query => query)
56
+ end
57
+
58
+ def recv_explain()
59
+ result = receive_message(Explain_result)
60
+ return result.success unless result.success.nil?
61
+ raise result.error unless result.error.nil?
62
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'explain failed: unknown result')
63
+ end
64
+
65
+ def fetch(query_id, start_over, fetch_size)
66
+ send_fetch(query_id, start_over, fetch_size)
67
+ return recv_fetch()
68
+ end
69
+
70
+ def send_fetch(query_id, start_over, fetch_size)
71
+ send_message('fetch', Fetch_args, :query_id => query_id, :start_over => start_over, :fetch_size => fetch_size)
72
+ end
73
+
74
+ def recv_fetch()
75
+ result = receive_message(Fetch_result)
76
+ return result.success unless result.success.nil?
77
+ raise result.error unless result.error.nil?
78
+ raise result.error2 unless result.error2.nil?
79
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'fetch failed: unknown result')
80
+ end
81
+
82
+ def get_state(handle)
83
+ send_get_state(handle)
84
+ return recv_get_state()
85
+ end
86
+
87
+ def send_get_state(handle)
88
+ send_message('get_state', Get_state_args, :handle => handle)
89
+ end
90
+
91
+ def recv_get_state()
92
+ result = receive_message(Get_state_result)
93
+ return result.success unless result.success.nil?
94
+ raise result.error unless result.error.nil?
95
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_state failed: unknown result')
96
+ end
97
+
98
+ def get_results_metadata(handle)
99
+ send_get_results_metadata(handle)
100
+ return recv_get_results_metadata()
101
+ end
102
+
103
+ def send_get_results_metadata(handle)
104
+ send_message('get_results_metadata', Get_results_metadata_args, :handle => handle)
105
+ end
106
+
107
+ def recv_get_results_metadata()
108
+ result = receive_message(Get_results_metadata_result)
109
+ return result.success unless result.success.nil?
110
+ raise result.error unless result.error.nil?
111
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_results_metadata failed: unknown result')
112
+ end
113
+
114
+ def echo(s)
115
+ send_echo(s)
116
+ return recv_echo()
117
+ end
118
+
119
+ def send_echo(s)
120
+ send_message('echo', Echo_args, :s => s)
121
+ end
122
+
123
+ def recv_echo()
124
+ result = receive_message(Echo_result)
125
+ return result.success unless result.success.nil?
126
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'echo failed: unknown result')
127
+ end
128
+
129
+ def dump_config()
130
+ send_dump_config()
131
+ return recv_dump_config()
132
+ end
133
+
134
+ def send_dump_config()
135
+ send_message('dump_config', Dump_config_args)
136
+ end
137
+
138
+ def recv_dump_config()
139
+ result = receive_message(Dump_config_result)
140
+ return result.success unless result.success.nil?
141
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'dump_config failed: unknown result')
142
+ end
143
+
144
+ def get_log(context)
145
+ send_get_log(context)
146
+ return recv_get_log()
147
+ end
148
+
149
+ def send_get_log(context)
150
+ send_message('get_log', Get_log_args, :context => context)
151
+ end
152
+
153
+ def recv_get_log()
154
+ result = receive_message(Get_log_result)
155
+ return result.success unless result.success.nil?
156
+ raise result.error unless result.error.nil?
157
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_log failed: unknown result')
158
+ end
159
+
160
+ def get_default_configuration(include_hadoop)
161
+ send_get_default_configuration(include_hadoop)
162
+ return recv_get_default_configuration()
163
+ end
164
+
165
+ def send_get_default_configuration(include_hadoop)
166
+ send_message('get_default_configuration', Get_default_configuration_args, :include_hadoop => include_hadoop)
167
+ end
168
+
169
+ def recv_get_default_configuration()
170
+ result = receive_message(Get_default_configuration_result)
171
+ return result.success unless result.success.nil?
172
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_default_configuration failed: unknown result')
173
+ end
174
+
175
+ def close(handle)
176
+ send_close(handle)
177
+ recv_close()
178
+ end
179
+
180
+ def send_close(handle)
181
+ send_message('close', Close_args, :handle => handle)
182
+ end
183
+
184
+ def recv_close()
185
+ result = receive_message(Close_result)
186
+ raise result.error unless result.error.nil?
187
+ raise result.error2 unless result.error2.nil?
188
+ return
189
+ end
190
+
191
+ def clean(log_context)
192
+ send_clean(log_context)
193
+ recv_clean()
194
+ end
195
+
196
+ def send_clean(log_context)
197
+ send_message('clean', Clean_args, :log_context => log_context)
198
+ end
199
+
200
+ def recv_clean()
201
+ result = receive_message(Clean_result)
202
+ return
203
+ end
204
+
205
+ end
206
+
207
+ class Processor
208
+ include ::Thrift::Processor
209
+
210
+ def process_query(seqid, iprot, oprot)
211
+ args = read_args(iprot, Query_args)
212
+ result = Query_result.new()
213
+ begin
214
+ result.success = @handler.query(args.query)
215
+ rescue Impala::Protocol::Beeswax::BeeswaxException => error
216
+ result.error = error
217
+ end
218
+ write_result(result, oprot, 'query', seqid)
219
+ end
220
+
221
+ def process_executeAndWait(seqid, iprot, oprot)
222
+ args = read_args(iprot, ExecuteAndWait_args)
223
+ result = ExecuteAndWait_result.new()
224
+ begin
225
+ result.success = @handler.executeAndWait(args.query, args.clientCtx)
226
+ rescue Impala::Protocol::Beeswax::BeeswaxException => error
227
+ result.error = error
228
+ end
229
+ write_result(result, oprot, 'executeAndWait', seqid)
230
+ end
231
+
232
+ def process_explain(seqid, iprot, oprot)
233
+ args = read_args(iprot, Explain_args)
234
+ result = Explain_result.new()
235
+ begin
236
+ result.success = @handler.explain(args.query)
237
+ rescue Impala::Protocol::Beeswax::BeeswaxException => error
238
+ result.error = error
239
+ end
240
+ write_result(result, oprot, 'explain', seqid)
241
+ end
242
+
243
+ def process_fetch(seqid, iprot, oprot)
244
+ args = read_args(iprot, Fetch_args)
245
+ result = Fetch_result.new()
246
+ begin
247
+ result.success = @handler.fetch(args.query_id, args.start_over, args.fetch_size)
248
+ rescue Impala::Protocol::Beeswax::QueryNotFoundException => error
249
+ result.error = error
250
+ rescue Impala::Protocol::Beeswax::BeeswaxException => error2
251
+ result.error2 = error2
252
+ end
253
+ write_result(result, oprot, 'fetch', seqid)
254
+ end
255
+
256
+ def process_get_state(seqid, iprot, oprot)
257
+ args = read_args(iprot, Get_state_args)
258
+ result = Get_state_result.new()
259
+ begin
260
+ result.success = @handler.get_state(args.handle)
261
+ rescue Impala::Protocol::Beeswax::QueryNotFoundException => error
262
+ result.error = error
263
+ end
264
+ write_result(result, oprot, 'get_state', seqid)
265
+ end
266
+
267
+ def process_get_results_metadata(seqid, iprot, oprot)
268
+ args = read_args(iprot, Get_results_metadata_args)
269
+ result = Get_results_metadata_result.new()
270
+ begin
271
+ result.success = @handler.get_results_metadata(args.handle)
272
+ rescue Impala::Protocol::Beeswax::QueryNotFoundException => error
273
+ result.error = error
274
+ end
275
+ write_result(result, oprot, 'get_results_metadata', seqid)
276
+ end
277
+
278
+ def process_echo(seqid, iprot, oprot)
279
+ args = read_args(iprot, Echo_args)
280
+ result = Echo_result.new()
281
+ result.success = @handler.echo(args.s)
282
+ write_result(result, oprot, 'echo', seqid)
283
+ end
284
+
285
+ def process_dump_config(seqid, iprot, oprot)
286
+ args = read_args(iprot, Dump_config_args)
287
+ result = Dump_config_result.new()
288
+ result.success = @handler.dump_config()
289
+ write_result(result, oprot, 'dump_config', seqid)
290
+ end
291
+
292
+ def process_get_log(seqid, iprot, oprot)
293
+ args = read_args(iprot, Get_log_args)
294
+ result = Get_log_result.new()
295
+ begin
296
+ result.success = @handler.get_log(args.context)
297
+ rescue Impala::Protocol::Beeswax::QueryNotFoundException => error
298
+ result.error = error
299
+ end
300
+ write_result(result, oprot, 'get_log', seqid)
301
+ end
302
+
303
+ def process_get_default_configuration(seqid, iprot, oprot)
304
+ args = read_args(iprot, Get_default_configuration_args)
305
+ result = Get_default_configuration_result.new()
306
+ result.success = @handler.get_default_configuration(args.include_hadoop)
307
+ write_result(result, oprot, 'get_default_configuration', seqid)
308
+ end
309
+
310
+ def process_close(seqid, iprot, oprot)
311
+ args = read_args(iprot, Close_args)
312
+ result = Close_result.new()
313
+ begin
314
+ @handler.close(args.handle)
315
+ rescue Impala::Protocol::Beeswax::QueryNotFoundException => error
316
+ result.error = error
317
+ rescue Impala::Protocol::Beeswax::BeeswaxException => error2
318
+ result.error2 = error2
319
+ end
320
+ write_result(result, oprot, 'close', seqid)
321
+ end
322
+
323
+ def process_clean(seqid, iprot, oprot)
324
+ args = read_args(iprot, Clean_args)
325
+ result = Clean_result.new()
326
+ @handler.clean(args.log_context)
327
+ write_result(result, oprot, 'clean', seqid)
328
+ end
329
+
330
+ end
331
+
332
+ # HELPER FUNCTIONS AND STRUCTURES
333
+
334
+ class Query_args
335
+ include ::Thrift::Struct, ::Thrift::Struct_Union
336
+ QUERY = 1
337
+
338
+ FIELDS = {
339
+ QUERY => { :type => ::Thrift::Types::STRUCT, :name => 'query', :class => Impala::Protocol::Beeswax::Query }
340
+ }
341
+
342
+ def struct_fields; FIELDS; end
343
+
344
+ def validate
345
+ end
346
+
347
+ ::Thrift::Struct.generate_accessors self
348
+ end
349
+
350
+ class Query_result
351
+ include ::Thrift::Struct, ::Thrift::Struct_Union
352
+ SUCCESS = 0
353
+ ERROR = 1
354
+
355
+ FIELDS = {
356
+ SUCCESS => { :type => ::Thrift::Types::STRUCT, :name => 'success', :class => Impala::Protocol::Beeswax::QueryHandle },
357
+ ERROR => { :type => ::Thrift::Types::STRUCT, :name => 'error', :class => Impala::Protocol::Beeswax::BeeswaxException }
358
+ }
359
+
360
+ def struct_fields; FIELDS; end
361
+
362
+ def validate
363
+ end
364
+
365
+ ::Thrift::Struct.generate_accessors self
366
+ end
367
+
368
+ class ExecuteAndWait_args
369
+ include ::Thrift::Struct, ::Thrift::Struct_Union
370
+ QUERY = 1
371
+ CLIENTCTX = 2
372
+
373
+ FIELDS = {
374
+ QUERY => { :type => ::Thrift::Types::STRUCT, :name => 'query', :class => Impala::Protocol::Beeswax::Query },
375
+ CLIENTCTX => { :type => ::Thrift::Types::STRING, :name => 'clientCtx' }
376
+ }
377
+
378
+ def struct_fields; FIELDS; end
379
+
380
+ def validate
381
+ end
382
+
383
+ ::Thrift::Struct.generate_accessors self
384
+ end
385
+
386
+ class ExecuteAndWait_result
387
+ include ::Thrift::Struct, ::Thrift::Struct_Union
388
+ SUCCESS = 0
389
+ ERROR = 1
390
+
391
+ FIELDS = {
392
+ SUCCESS => { :type => ::Thrift::Types::STRUCT, :name => 'success', :class => Impala::Protocol::Beeswax::QueryHandle },
393
+ ERROR => { :type => ::Thrift::Types::STRUCT, :name => 'error', :class => Impala::Protocol::Beeswax::BeeswaxException }
394
+ }
395
+
396
+ def struct_fields; FIELDS; end
397
+
398
+ def validate
399
+ end
400
+
401
+ ::Thrift::Struct.generate_accessors self
402
+ end
403
+
404
+ class Explain_args
405
+ include ::Thrift::Struct, ::Thrift::Struct_Union
406
+ QUERY = 1
407
+
408
+ FIELDS = {
409
+ QUERY => { :type => ::Thrift::Types::STRUCT, :name => 'query', :class => Impala::Protocol::Beeswax::Query }
410
+ }
411
+
412
+ def struct_fields; FIELDS; end
413
+
414
+ def validate
415
+ end
416
+
417
+ ::Thrift::Struct.generate_accessors self
418
+ end
419
+
420
+ class Explain_result
421
+ include ::Thrift::Struct, ::Thrift::Struct_Union
422
+ SUCCESS = 0
423
+ ERROR = 1
424
+
425
+ FIELDS = {
426
+ SUCCESS => { :type => ::Thrift::Types::STRUCT, :name => 'success', :class => Impala::Protocol::Beeswax::QueryExplanation },
427
+ ERROR => { :type => ::Thrift::Types::STRUCT, :name => 'error', :class => Impala::Protocol::Beeswax::BeeswaxException }
428
+ }
429
+
430
+ def struct_fields; FIELDS; end
431
+
432
+ def validate
433
+ end
434
+
435
+ ::Thrift::Struct.generate_accessors self
436
+ end
437
+
438
+ class Fetch_args
439
+ include ::Thrift::Struct, ::Thrift::Struct_Union
440
+ QUERY_ID = 1
441
+ START_OVER = 2
442
+ FETCH_SIZE = 3
443
+
444
+ FIELDS = {
445
+ QUERY_ID => { :type => ::Thrift::Types::STRUCT, :name => 'query_id', :class => Impala::Protocol::Beeswax::QueryHandle },
446
+ START_OVER => { :type => ::Thrift::Types::BOOL, :name => 'start_over' },
447
+ FETCH_SIZE => { :type => ::Thrift::Types::I32, :name => 'fetch_size', :default => -1 }
448
+ }
449
+
450
+ def struct_fields; FIELDS; end
451
+
452
+ def validate
453
+ end
454
+
455
+ ::Thrift::Struct.generate_accessors self
456
+ end
457
+
458
+ class Fetch_result
459
+ include ::Thrift::Struct, ::Thrift::Struct_Union
460
+ SUCCESS = 0
461
+ ERROR = 1
462
+ ERROR2 = 2
463
+
464
+ FIELDS = {
465
+ SUCCESS => { :type => ::Thrift::Types::STRUCT, :name => 'success', :class => Impala::Protocol::Beeswax::Results },
466
+ ERROR => { :type => ::Thrift::Types::STRUCT, :name => 'error', :class => Impala::Protocol::Beeswax::QueryNotFoundException },
467
+ ERROR2 => { :type => ::Thrift::Types::STRUCT, :name => 'error2', :class => Impala::Protocol::Beeswax::BeeswaxException }
468
+ }
469
+
470
+ def struct_fields; FIELDS; end
471
+
472
+ def validate
473
+ end
474
+
475
+ ::Thrift::Struct.generate_accessors self
476
+ end
477
+
478
+ class Get_state_args
479
+ include ::Thrift::Struct, ::Thrift::Struct_Union
480
+ HANDLE = 1
481
+
482
+ FIELDS = {
483
+ HANDLE => { :type => ::Thrift::Types::STRUCT, :name => 'handle', :class => Impala::Protocol::Beeswax::QueryHandle }
484
+ }
485
+
486
+ def struct_fields; FIELDS; end
487
+
488
+ def validate
489
+ end
490
+
491
+ ::Thrift::Struct.generate_accessors self
492
+ end
493
+
494
+ class Get_state_result
495
+ include ::Thrift::Struct, ::Thrift::Struct_Union
496
+ SUCCESS = 0
497
+ ERROR = 1
498
+
499
+ FIELDS = {
500
+ SUCCESS => { :type => ::Thrift::Types::I32, :name => 'success', :enum_class => Impala::Protocol::Beeswax::QueryState },
501
+ ERROR => { :type => ::Thrift::Types::STRUCT, :name => 'error', :class => Impala::Protocol::Beeswax::QueryNotFoundException }
502
+ }
503
+
504
+ def struct_fields; FIELDS; end
505
+
506
+ def validate
507
+ unless @success.nil? || Impala::Protocol::Beeswax::QueryState::VALID_VALUES.include?(@success)
508
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field success!')
509
+ end
510
+ end
511
+
512
+ ::Thrift::Struct.generate_accessors self
513
+ end
514
+
515
+ class Get_results_metadata_args
516
+ include ::Thrift::Struct, ::Thrift::Struct_Union
517
+ HANDLE = 1
518
+
519
+ FIELDS = {
520
+ HANDLE => { :type => ::Thrift::Types::STRUCT, :name => 'handle', :class => Impala::Protocol::Beeswax::QueryHandle }
521
+ }
522
+
523
+ def struct_fields; FIELDS; end
524
+
525
+ def validate
526
+ end
527
+
528
+ ::Thrift::Struct.generate_accessors self
529
+ end
530
+
531
+ class Get_results_metadata_result
532
+ include ::Thrift::Struct, ::Thrift::Struct_Union
533
+ SUCCESS = 0
534
+ ERROR = 1
535
+
536
+ FIELDS = {
537
+ SUCCESS => { :type => ::Thrift::Types::STRUCT, :name => 'success', :class => Impala::Protocol::Beeswax::ResultsMetadata },
538
+ ERROR => { :type => ::Thrift::Types::STRUCT, :name => 'error', :class => Impala::Protocol::Beeswax::QueryNotFoundException }
539
+ }
540
+
541
+ def struct_fields; FIELDS; end
542
+
543
+ def validate
544
+ end
545
+
546
+ ::Thrift::Struct.generate_accessors self
547
+ end
548
+
549
+ class Echo_args
550
+ include ::Thrift::Struct, ::Thrift::Struct_Union
551
+ S = 1
552
+
553
+ FIELDS = {
554
+ S => { :type => ::Thrift::Types::STRING, :name => 's' }
555
+ }
556
+
557
+ def struct_fields; FIELDS; end
558
+
559
+ def validate
560
+ end
561
+
562
+ ::Thrift::Struct.generate_accessors self
563
+ end
564
+
565
+ class Echo_result
566
+ include ::Thrift::Struct, ::Thrift::Struct_Union
567
+ SUCCESS = 0
568
+
569
+ FIELDS = {
570
+ SUCCESS => { :type => ::Thrift::Types::STRING, :name => 'success' }
571
+ }
572
+
573
+ def struct_fields; FIELDS; end
574
+
575
+ def validate
576
+ end
577
+
578
+ ::Thrift::Struct.generate_accessors self
579
+ end
580
+
581
+ class Dump_config_args
582
+ include ::Thrift::Struct, ::Thrift::Struct_Union
583
+
584
+ FIELDS = {
585
+
586
+ }
587
+
588
+ def struct_fields; FIELDS; end
589
+
590
+ def validate
591
+ end
592
+
593
+ ::Thrift::Struct.generate_accessors self
594
+ end
595
+
596
+ class Dump_config_result
597
+ include ::Thrift::Struct, ::Thrift::Struct_Union
598
+ SUCCESS = 0
599
+
600
+ FIELDS = {
601
+ SUCCESS => { :type => ::Thrift::Types::STRING, :name => 'success' }
602
+ }
603
+
604
+ def struct_fields; FIELDS; end
605
+
606
+ def validate
607
+ end
608
+
609
+ ::Thrift::Struct.generate_accessors self
610
+ end
611
+
612
+ class Get_log_args
613
+ include ::Thrift::Struct, ::Thrift::Struct_Union
614
+ CONTEXT = 1
615
+
616
+ FIELDS = {
617
+ CONTEXT => { :type => ::Thrift::Types::STRING, :name => 'context' }
618
+ }
619
+
620
+ def struct_fields; FIELDS; end
621
+
622
+ def validate
623
+ end
624
+
625
+ ::Thrift::Struct.generate_accessors self
626
+ end
627
+
628
+ class Get_log_result
629
+ include ::Thrift::Struct, ::Thrift::Struct_Union
630
+ SUCCESS = 0
631
+ ERROR = 1
632
+
633
+ FIELDS = {
634
+ SUCCESS => { :type => ::Thrift::Types::STRING, :name => 'success' },
635
+ ERROR => { :type => ::Thrift::Types::STRUCT, :name => 'error', :class => Impala::Protocol::Beeswax::QueryNotFoundException }
636
+ }
637
+
638
+ def struct_fields; FIELDS; end
639
+
640
+ def validate
641
+ end
642
+
643
+ ::Thrift::Struct.generate_accessors self
644
+ end
645
+
646
+ class Get_default_configuration_args
647
+ include ::Thrift::Struct, ::Thrift::Struct_Union
648
+ INCLUDE_HADOOP = 1
649
+
650
+ FIELDS = {
651
+ INCLUDE_HADOOP => { :type => ::Thrift::Types::BOOL, :name => 'include_hadoop' }
652
+ }
653
+
654
+ def struct_fields; FIELDS; end
655
+
656
+ def validate
657
+ end
658
+
659
+ ::Thrift::Struct.generate_accessors self
660
+ end
661
+
662
+ class Get_default_configuration_result
663
+ include ::Thrift::Struct, ::Thrift::Struct_Union
664
+ SUCCESS = 0
665
+
666
+ FIELDS = {
667
+ SUCCESS => { :type => ::Thrift::Types::LIST, :name => 'success', :element => { :type => ::Thrift::Types::STRUCT, :class => Impala::Protocol::Beeswax::ConfigVariable } }
668
+ }
669
+
670
+ def struct_fields; FIELDS; end
671
+
672
+ def validate
673
+ end
674
+
675
+ ::Thrift::Struct.generate_accessors self
676
+ end
677
+
678
+ class Close_args
679
+ include ::Thrift::Struct, ::Thrift::Struct_Union
680
+ HANDLE = 1
681
+
682
+ FIELDS = {
683
+ HANDLE => { :type => ::Thrift::Types::STRUCT, :name => 'handle', :class => Impala::Protocol::Beeswax::QueryHandle }
684
+ }
685
+
686
+ def struct_fields; FIELDS; end
687
+
688
+ def validate
689
+ end
690
+
691
+ ::Thrift::Struct.generate_accessors self
692
+ end
693
+
694
+ class Close_result
695
+ include ::Thrift::Struct, ::Thrift::Struct_Union
696
+ ERROR = 1
697
+ ERROR2 = 2
698
+
699
+ FIELDS = {
700
+ ERROR => { :type => ::Thrift::Types::STRUCT, :name => 'error', :class => Impala::Protocol::Beeswax::QueryNotFoundException },
701
+ ERROR2 => { :type => ::Thrift::Types::STRUCT, :name => 'error2', :class => Impala::Protocol::Beeswax::BeeswaxException }
702
+ }
703
+
704
+ def struct_fields; FIELDS; end
705
+
706
+ def validate
707
+ end
708
+
709
+ ::Thrift::Struct.generate_accessors self
710
+ end
711
+
712
+ class Clean_args
713
+ include ::Thrift::Struct, ::Thrift::Struct_Union
714
+ LOG_CONTEXT = 1
715
+
716
+ FIELDS = {
717
+ LOG_CONTEXT => { :type => ::Thrift::Types::STRING, :name => 'log_context' }
718
+ }
719
+
720
+ def struct_fields; FIELDS; end
721
+
722
+ def validate
723
+ end
724
+
725
+ ::Thrift::Struct.generate_accessors self
726
+ end
727
+
728
+ class Clean_result
729
+ include ::Thrift::Struct, ::Thrift::Struct_Union
730
+
731
+ FIELDS = {
732
+
733
+ }
734
+
735
+ def struct_fields; FIELDS; end
736
+
737
+ def validate
738
+ end
739
+
740
+ ::Thrift::Struct.generate_accessors self
741
+ end
742
+
743
+ end
744
+
745
+ end
746
+ end
747
+ end