forward-rbase 0.2.3 → 0.2.7
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.
- data/lib/rbase.rb +4 -0
- data/lib/rbase/client.rb +3 -1
- data/lib/rbase/table.rb +16 -8
- data/lib/rbase/thrift/hbase_extension.rb +69 -0
- metadata +28 -49
data/lib/rbase.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require File.join(File.dirname(__FILE__), 'rbase', 'thrift', 'hbase')
|
2
4
|
require File.join(File.dirname(__FILE__), 'rbase', 'thrift', 'hbase_constants')
|
3
5
|
require File.join(File.dirname(__FILE__), 'rbase', 'thrift', 'hbase_types')
|
4
6
|
|
7
|
+
require File.join(File.dirname(__FILE__), 'rbase', 'thrift', 'hbase_extension')
|
8
|
+
|
5
9
|
require File.join(File.dirname(__FILE__), 'rbase', 'client')
|
6
10
|
require File.join(File.dirname(__FILE__), 'rbase', 'table')
|
data/lib/rbase/client.rb
CHANGED
@@ -44,7 +44,9 @@ module Rbase
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def [](table_name)
|
47
|
-
@tables[table_name] ||=
|
47
|
+
@tables[table_name] ||= begin
|
48
|
+
Rbase::Table.new(@client, table_name) if table_exists?(table_name)
|
49
|
+
end
|
48
50
|
@tables[table_name]
|
49
51
|
end
|
50
52
|
end
|
data/lib/rbase/table.rb
CHANGED
@@ -4,16 +4,16 @@ module Rbase
|
|
4
4
|
@client = client
|
5
5
|
@table_name = table_name.to_s
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def find(row)
|
9
9
|
@client.getRow(@table_name,row).map { |row| row_to_hash(row) }
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def first(row)
|
13
13
|
find(row).first
|
14
14
|
end
|
15
15
|
alias_method :[], :first
|
16
|
-
|
16
|
+
|
17
17
|
def insert(row, hash)
|
18
18
|
hash.each do |family,value|
|
19
19
|
mutations = value.map do |column,val|
|
@@ -23,7 +23,7 @@ module Rbase
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
alias_method :[]=, :insert
|
26
|
-
|
26
|
+
|
27
27
|
def multi_insert(rows)
|
28
28
|
row_mutations = rows.map do |row, hash|
|
29
29
|
hash.map do |family,value|
|
@@ -35,7 +35,7 @@ module Rbase
|
|
35
35
|
end
|
36
36
|
@client.mutateRows(@table_name, row_mutations.flatten)
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def each_batch(batch_size=100, columns=[])
|
40
40
|
columns = [columns] unless columns.is_a?(Array)
|
41
41
|
scanner_id = @client.scannerOpen(@table_name, '', columns)
|
@@ -46,7 +46,7 @@ module Rbase
|
|
46
46
|
end
|
47
47
|
@client.scannerClose(scanner_id)
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def each(batch_size=100, columns=[])
|
51
51
|
each_batch(batch_size, columns) do |results|
|
52
52
|
results.each do |result|
|
@@ -54,13 +54,21 @@ module Rbase
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
def set_auto_flush(enabled)
|
59
|
+
@client.setAutoFlush(@table_name, enabled)
|
60
|
+
end
|
57
61
|
|
62
|
+
def increment(row, family, column, value)
|
63
|
+
@client.atomicIncrement(@table_name, row, "#{family}:#{column}", value)
|
64
|
+
end
|
65
|
+
|
58
66
|
private
|
59
|
-
|
67
|
+
|
60
68
|
def row_to_hash(row)
|
61
69
|
ret_val = {}
|
62
70
|
row.columns.each do |column,val|
|
63
|
-
family, key = *column.split(":")
|
71
|
+
family, key = *column.split(":", 2)
|
64
72
|
ret_val[family] ||= {}
|
65
73
|
ret_val[family][key] = val.value
|
66
74
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Apache
|
2
|
+
module Hadoop
|
3
|
+
module Hbase
|
4
|
+
module Thrift
|
5
|
+
module Hbase
|
6
|
+
class Client
|
7
|
+
def setAutoFlush(tableName, enabled)
|
8
|
+
send_setAutoFlush(tableName, enabled)
|
9
|
+
return recv_setAutoFlush()
|
10
|
+
end
|
11
|
+
|
12
|
+
def send_setAutoFlush(tableName, enabled)
|
13
|
+
send_message('setAutoFlush', SetAutoFlush_args, :tableName => tableName, :enabled => enabled)
|
14
|
+
end
|
15
|
+
|
16
|
+
def recv_setAutoFlush()
|
17
|
+
receive_message(SetAutoFlush_result)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class SetAutoFlush_args
|
22
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
23
|
+
TABLENAME = 1
|
24
|
+
ENABLED = 2
|
25
|
+
|
26
|
+
FIELDS = {
|
27
|
+
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tableName', :binary => true},
|
28
|
+
ENABLED => {:type => ::Thrift::Types::BOOL, :name => 'enabled'}
|
29
|
+
}
|
30
|
+
|
31
|
+
def struct_fields; FIELDS; end
|
32
|
+
|
33
|
+
def validate
|
34
|
+
end
|
35
|
+
|
36
|
+
::Thrift::Struct.generate_accessors self
|
37
|
+
end
|
38
|
+
|
39
|
+
class SetAutoFlush_result
|
40
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
41
|
+
|
42
|
+
FIELDS = {}
|
43
|
+
|
44
|
+
def struct_fields; FIELDS; end
|
45
|
+
|
46
|
+
def validate
|
47
|
+
end
|
48
|
+
|
49
|
+
::Thrift::Struct.generate_accessors self
|
50
|
+
end
|
51
|
+
|
52
|
+
class Processor
|
53
|
+
def process_setAutoFlush(seqid, iprot, oprot)
|
54
|
+
args = read_args(iprot, SetAutoFlush_args)
|
55
|
+
result = SetAutoFlush_result.new()
|
56
|
+
begin
|
57
|
+
result.success = @handler.setAutoFlush()
|
58
|
+
rescue Apache::Hadoop::Hbase::Thrift::IOError => io
|
59
|
+
result.io = io
|
60
|
+
end
|
61
|
+
write_result(result, oprot, 'setAutoFlush', seqid)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
metadata
CHANGED
@@ -1,83 +1,62 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: forward-rbase
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 3
|
9
|
-
version: 0.2.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.7
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Forward Internet Group
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-02-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: thrift
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70106085781280 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
- 4
|
31
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
32
21
|
version: 0.4.0
|
33
22
|
type: :runtime
|
34
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70106085781280
|
35
25
|
description: Simple lib for executing hbase lookups
|
36
26
|
email: andy@forward.co.uk
|
37
27
|
executables: []
|
38
|
-
|
39
28
|
extensions: []
|
40
|
-
|
41
29
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
30
|
+
files:
|
44
31
|
- lib/rbase.rb
|
45
32
|
- lib/rbase/client.rb
|
46
33
|
- lib/rbase/table.rb
|
47
34
|
- lib/rbase/thrift/hbase.rb
|
48
35
|
- lib/rbase/thrift/hbase_constants.rb
|
49
36
|
- lib/rbase/thrift/hbase_types.rb
|
50
|
-
|
37
|
+
- lib/rbase/thrift/hbase_extension.rb
|
51
38
|
homepage: http://github.com/forward/rbase
|
52
39
|
licenses: []
|
53
|
-
|
54
40
|
post_install_message:
|
55
41
|
rdoc_options: []
|
56
|
-
|
57
|
-
require_paths:
|
42
|
+
require_paths:
|
58
43
|
- lib
|
59
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
45
|
none: false
|
61
|
-
requirements:
|
62
|
-
- -
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
|
65
|
-
|
66
|
-
version: "0"
|
67
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
51
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
- 0
|
74
|
-
version: "0"
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
75
56
|
requirements: []
|
76
|
-
|
77
57
|
rubyforge_project:
|
78
|
-
rubygems_version: 1.
|
58
|
+
rubygems_version: 1.8.11
|
79
59
|
signing_key:
|
80
60
|
specification_version: 3
|
81
61
|
summary: Simple lib for executing hbase lookups
|
82
62
|
test_files: []
|
83
|
-
|