hbase_thrift_ruby 0.9.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.
@@ -0,0 +1,14 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ module Apache
8
+ module Hadoop
9
+ module Hbase
10
+ module Thrift
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,282 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ module Apache
8
+ module Hadoop
9
+ module Hbase
10
+ module Thrift
11
+ # TCell - Used to transport a cell value (byte[]) and the timestamp it was
12
+ # stored with together as a result for get and getRow methods. This promotes
13
+ # the timestamp of a cell to a first-class value, making it easy to take
14
+ # note of temporal data. Cell is used all the way from HStore up to HTable.
15
+ class TCell
16
+ include ::Thrift::Struct, ::Thrift::Struct_Union
17
+ VALUE = 1
18
+ TIMESTAMP = 2
19
+
20
+ FIELDS = {
21
+ VALUE => {:type => ::Thrift::Types::STRING, :name => 'value', :binary => true},
22
+ TIMESTAMP => {:type => ::Thrift::Types::I64, :name => 'timestamp'}
23
+ }
24
+
25
+ def struct_fields; FIELDS; end
26
+
27
+ def validate
28
+ end
29
+
30
+ ::Thrift::Struct.generate_accessors self
31
+ end
32
+
33
+ # An HColumnDescriptor contains information about a column family
34
+ # such as the number of versions, compression settings, etc. It is
35
+ # used as input when creating a table or adding a column.
36
+ class ColumnDescriptor
37
+ include ::Thrift::Struct, ::Thrift::Struct_Union
38
+ NAME = 1
39
+ MAXVERSIONS = 2
40
+ COMPRESSION = 3
41
+ INMEMORY = 4
42
+ BLOOMFILTERTYPE = 5
43
+ BLOOMFILTERVECTORSIZE = 6
44
+ BLOOMFILTERNBHASHES = 7
45
+ BLOCKCACHEENABLED = 8
46
+ TIMETOLIVE = 9
47
+
48
+ FIELDS = {
49
+ NAME => {:type => ::Thrift::Types::STRING, :name => 'name', :binary => true},
50
+ MAXVERSIONS => {:type => ::Thrift::Types::I32, :name => 'maxVersions', :default => 3},
51
+ COMPRESSION => {:type => ::Thrift::Types::STRING, :name => 'compression', :default => %q"NONE"},
52
+ INMEMORY => {:type => ::Thrift::Types::BOOL, :name => 'inMemory', :default => false},
53
+ BLOOMFILTERTYPE => {:type => ::Thrift::Types::STRING, :name => 'bloomFilterType', :default => %q"NONE"},
54
+ BLOOMFILTERVECTORSIZE => {:type => ::Thrift::Types::I32, :name => 'bloomFilterVectorSize', :default => 0},
55
+ BLOOMFILTERNBHASHES => {:type => ::Thrift::Types::I32, :name => 'bloomFilterNbHashes', :default => 0},
56
+ BLOCKCACHEENABLED => {:type => ::Thrift::Types::BOOL, :name => 'blockCacheEnabled', :default => false},
57
+ TIMETOLIVE => {:type => ::Thrift::Types::I32, :name => 'timeToLive', :default => -1}
58
+ }
59
+
60
+ def struct_fields; FIELDS; end
61
+
62
+ def validate
63
+ end
64
+
65
+ ::Thrift::Struct.generate_accessors self
66
+ end
67
+
68
+ # A TRegionInfo contains information about an HTable region.
69
+ class TRegionInfo
70
+ include ::Thrift::Struct, ::Thrift::Struct_Union
71
+ STARTKEY = 1
72
+ ENDKEY = 2
73
+ ID = 3
74
+ NAME = 4
75
+ VERSION = 5
76
+ SERVERNAME = 6
77
+ PORT = 7
78
+
79
+ FIELDS = {
80
+ STARTKEY => {:type => ::Thrift::Types::STRING, :name => 'startKey', :binary => true},
81
+ ENDKEY => {:type => ::Thrift::Types::STRING, :name => 'endKey', :binary => true},
82
+ ID => {:type => ::Thrift::Types::I64, :name => 'id'},
83
+ NAME => {:type => ::Thrift::Types::STRING, :name => 'name', :binary => true},
84
+ VERSION => {:type => ::Thrift::Types::BYTE, :name => 'version'},
85
+ SERVERNAME => {:type => ::Thrift::Types::STRING, :name => 'serverName', :binary => true},
86
+ PORT => {:type => ::Thrift::Types::I32, :name => 'port'}
87
+ }
88
+
89
+ def struct_fields; FIELDS; end
90
+
91
+ def validate
92
+ end
93
+
94
+ ::Thrift::Struct.generate_accessors self
95
+ end
96
+
97
+ # A Mutation object is used to either update or delete a column-value.
98
+ class Mutation
99
+ include ::Thrift::Struct, ::Thrift::Struct_Union
100
+ ISDELETE = 1
101
+ COLUMN = 2
102
+ VALUE = 3
103
+ WRITETOWAL = 4
104
+
105
+ FIELDS = {
106
+ ISDELETE => {:type => ::Thrift::Types::BOOL, :name => 'isDelete', :default => false},
107
+ COLUMN => {:type => ::Thrift::Types::STRING, :name => 'column', :binary => true},
108
+ VALUE => {:type => ::Thrift::Types::STRING, :name => 'value', :binary => true},
109
+ WRITETOWAL => {:type => ::Thrift::Types::BOOL, :name => 'writeToWAL', :default => true}
110
+ }
111
+
112
+ def struct_fields; FIELDS; end
113
+
114
+ def validate
115
+ end
116
+
117
+ ::Thrift::Struct.generate_accessors self
118
+ end
119
+
120
+ # A BatchMutation object is used to apply a number of Mutations to a single row.
121
+ class BatchMutation
122
+ include ::Thrift::Struct, ::Thrift::Struct_Union
123
+ ROW = 1
124
+ MUTATIONS = 2
125
+
126
+ FIELDS = {
127
+ ROW => {:type => ::Thrift::Types::STRING, :name => 'row', :binary => true},
128
+ MUTATIONS => {:type => ::Thrift::Types::LIST, :name => 'mutations', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Apache::Hadoop::Hbase::Thrift::Mutation}}
129
+ }
130
+
131
+ def struct_fields; FIELDS; end
132
+
133
+ def validate
134
+ end
135
+
136
+ ::Thrift::Struct.generate_accessors self
137
+ end
138
+
139
+ # For increments that are not incrementColumnValue
140
+ # equivalents.
141
+ class TIncrement
142
+ include ::Thrift::Struct, ::Thrift::Struct_Union
143
+ TABLE = 1
144
+ ROW = 2
145
+ COLUMN = 3
146
+ AMMOUNT = 4
147
+
148
+ FIELDS = {
149
+ TABLE => {:type => ::Thrift::Types::STRING, :name => 'table', :binary => true},
150
+ ROW => {:type => ::Thrift::Types::STRING, :name => 'row', :binary => true},
151
+ COLUMN => {:type => ::Thrift::Types::STRING, :name => 'column', :binary => true},
152
+ AMMOUNT => {:type => ::Thrift::Types::I64, :name => 'ammount'}
153
+ }
154
+
155
+ def struct_fields; FIELDS; end
156
+
157
+ def validate
158
+ end
159
+
160
+ ::Thrift::Struct.generate_accessors self
161
+ end
162
+
163
+ # Holds row name and then a map of columns to cells.
164
+ class TRowResult
165
+ include ::Thrift::Struct, ::Thrift::Struct_Union
166
+ ROW = 1
167
+ COLUMNS = 2
168
+
169
+ FIELDS = {
170
+ ROW => {:type => ::Thrift::Types::STRING, :name => 'row', :binary => true},
171
+ COLUMNS => {:type => ::Thrift::Types::MAP, :name => 'columns', :key => {:type => ::Thrift::Types::STRING, :binary => true}, :value => {:type => ::Thrift::Types::STRUCT, :class => ::Apache::Hadoop::Hbase::Thrift::TCell}}
172
+ }
173
+
174
+ def struct_fields; FIELDS; end
175
+
176
+ def validate
177
+ end
178
+
179
+ ::Thrift::Struct.generate_accessors self
180
+ end
181
+
182
+ # A Scan object is used to specify scanner parameters when opening a scanner.
183
+ class TScan
184
+ include ::Thrift::Struct, ::Thrift::Struct_Union
185
+ STARTROW = 1
186
+ STOPROW = 2
187
+ TIMESTAMP = 3
188
+ COLUMNS = 4
189
+ CACHING = 5
190
+ FILTERSTRING = 6
191
+
192
+ FIELDS = {
193
+ STARTROW => {:type => ::Thrift::Types::STRING, :name => 'startRow', :binary => true, :optional => true},
194
+ STOPROW => {:type => ::Thrift::Types::STRING, :name => 'stopRow', :binary => true, :optional => true},
195
+ TIMESTAMP => {:type => ::Thrift::Types::I64, :name => 'timestamp', :optional => true},
196
+ COLUMNS => {:type => ::Thrift::Types::LIST, :name => 'columns', :element => {:type => ::Thrift::Types::STRING, :binary => true}, :optional => true},
197
+ CACHING => {:type => ::Thrift::Types::I32, :name => 'caching', :optional => true},
198
+ FILTERSTRING => {:type => ::Thrift::Types::STRING, :name => 'filterString', :binary => true, :optional => true}
199
+ }
200
+
201
+ def struct_fields; FIELDS; end
202
+
203
+ def validate
204
+ end
205
+
206
+ ::Thrift::Struct.generate_accessors self
207
+ end
208
+
209
+ # An IOError exception signals that an error occurred communicating
210
+ # to the Hbase master or an Hbase region server. Also used to return
211
+ # more general Hbase error conditions.
212
+ class IOError < ::Thrift::Exception
213
+ include ::Thrift::Struct, ::Thrift::Struct_Union
214
+ def initialize(message=nil)
215
+ super()
216
+ self.message = message
217
+ end
218
+
219
+ MESSAGE = 1
220
+
221
+ FIELDS = {
222
+ MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
223
+ }
224
+
225
+ def struct_fields; FIELDS; end
226
+
227
+ def validate
228
+ end
229
+
230
+ ::Thrift::Struct.generate_accessors self
231
+ end
232
+
233
+ # An IllegalArgument exception indicates an illegal or invalid
234
+ # argument was passed into a procedure.
235
+ class IllegalArgument < ::Thrift::Exception
236
+ include ::Thrift::Struct, ::Thrift::Struct_Union
237
+ def initialize(message=nil)
238
+ super()
239
+ self.message = message
240
+ end
241
+
242
+ MESSAGE = 1
243
+
244
+ FIELDS = {
245
+ MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
246
+ }
247
+
248
+ def struct_fields; FIELDS; end
249
+
250
+ def validate
251
+ end
252
+
253
+ ::Thrift::Struct.generate_accessors self
254
+ end
255
+
256
+ # An AlreadyExists exceptions signals that a table with the specified
257
+ # name already exists
258
+ class AlreadyExists < ::Thrift::Exception
259
+ include ::Thrift::Struct, ::Thrift::Struct_Union
260
+ def initialize(message=nil)
261
+ super()
262
+ self.message = message
263
+ end
264
+
265
+ MESSAGE = 1
266
+
267
+ FIELDS = {
268
+ MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
269
+ }
270
+
271
+ def struct_fields; FIELDS; end
272
+
273
+ def validate
274
+ end
275
+
276
+ ::Thrift::Struct.generate_accessors self
277
+ end
278
+
279
+ end
280
+ end
281
+ end
282
+ end
@@ -0,0 +1,59 @@
1
+ require 'thrift'
2
+
3
+ require File.join(File.dirname(__FILE__), 'hbase', 'hbase_constants')
4
+ require File.join(File.dirname(__FILE__), 'hbase', 'hbase_types')
5
+ require File.join(File.dirname(__FILE__), 'hbase', 'hbase')
6
+
7
+ # Try to make the crazy nesting that Thrift generates a little less painful
8
+ module Hbase
9
+ Client = ::Apache::Hadoop::Hbase::Thrift::Hbase::Client
10
+
11
+ Apache::Hadoop::Hbase::Thrift.constants.each do |constant|
12
+ const_set(constant, Apache::Hadoop::Hbase::Thrift.const_get(constant))
13
+ end
14
+
15
+ class Client
16
+ def incrementRow(table_name,amount)
17
+ c_row = get('table_indices','0',table_name,{})[0].value.to_i
18
+ n_row = c_row+amount
19
+ mutateRow('table_indices','0',[HBase::Mutation.new(column: table_name, value: n_row.to_s)],{})
20
+ c_row
21
+ end
22
+ def get(table,columns,filters,obj={})
23
+ scan = HBase::TScan.new
24
+ scan.filterString = filters
25
+ scanner = scannerOpenWithScan(table, scan, obj)
26
+
27
+ results = []
28
+ scan_end = false
29
+ rows = []
30
+
31
+ while !scan_end
32
+ scan_result = scannerGet(scanner)
33
+ if scan_result.length > 0
34
+ rows << scan_result[0].row
35
+ else
36
+ scan_end = true
37
+ end
38
+ end
39
+
40
+ rows.each do |row|
41
+ row_results = []
42
+ if columns[0] == '*'
43
+ getRow(table,row,{})[0].columns.each do |val|
44
+ row_results << val[1].value
45
+ end
46
+ else
47
+ columns.each do |col|
48
+ col = "#{col}:" if col.match(/:/).nil?
49
+ row_results << getRow(table,row,{})[0].columns[col].value rescue row_results << nil
50
+ end
51
+ end
52
+ results << row_results
53
+ end
54
+
55
+ results
56
+ end
57
+ end
58
+ end
59
+ HBase = Hbase
@@ -0,0 +1,12 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "HBase" do
4
+
5
+ context "Has Thrift Client" do
6
+ let(:response) { HipsterSqlToHbase.parse("select") }
7
+ it "succeed" do
8
+ !(Thrift::Client).nil?
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,3 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'hbase_thrift_ruby'
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hbase_thrift_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Jean Lescure
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jml_thrift
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 4.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 4.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: jfish
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.1.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.1.1
83
+ description: This is an updated HBase wrapper based on Thrift 1.0.0, gemified and
84
+ ready to be used with Ruby.
85
+ email: jeanmlescure@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files:
89
+ - LICENSE.txt
90
+ - README.md
91
+ files:
92
+ - lib/hbase/hbase.rb
93
+ - lib/hbase/hbase_constants.rb
94
+ - lib/hbase/hbase_types.rb
95
+ - lib/Hbase.thrift
96
+ - lib/hbase_thrift_ruby.rb
97
+ - spec/hbase_thrift_ruby_spec.rb
98
+ - spec/spec_helper.rb
99
+ - .document
100
+ - Gemfile
101
+ - LICENSE.txt
102
+ - README.md
103
+ - Rakefile
104
+ - VERSION
105
+ - hbase_thrift_ruby.gemspec
106
+ homepage: http://github.com/jeanlescure/hbase_thrift_ruby
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.0.14
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Simplified HBase Thrift API wrapper for Ruby.
130
+ test_files: []