hbase-driver 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/hbase/record.rb +11 -0
- data/lib/hbase/table.rb +9 -7
- data/readme.md +7 -2
- metadata +4 -4
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ task :default => :spec
|
|
10
10
|
|
11
11
|
spec = Gem::Specification.new do |s|
|
12
12
|
s.name = "hbase-driver"
|
13
|
-
s.version = '0.0.
|
13
|
+
s.version = '0.0.2'
|
14
14
|
s.summary = "HBase Ruby Driver"
|
15
15
|
s.homepage = "http://github.com/railsware/hbase-driver"
|
16
16
|
s.email = ["Alexey.Petrushin@railsware.com", "dmitry.larkin@railsware.com"]
|
data/lib/hbase/record.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
class HBase
|
2
2
|
class Record
|
3
3
|
attr_reader :cells
|
4
|
+
attr_accessor :id
|
4
5
|
|
5
6
|
def initialize
|
6
7
|
@cells = {}
|
@@ -18,5 +19,15 @@ class HBase
|
|
18
19
|
def size
|
19
20
|
cells.size
|
20
21
|
end
|
22
|
+
|
23
|
+
def to_hash(with_id = false)
|
24
|
+
hash = {}
|
25
|
+
hash['id'] = id if with_id and id and !id.empty?
|
26
|
+
cells.each do |k, v|
|
27
|
+
hash[k.sub(/^[^:]*:/, '')] = v.value
|
28
|
+
end
|
29
|
+
hash
|
30
|
+
end
|
31
|
+
alias_method :to_h, :to_hash
|
21
32
|
end
|
22
33
|
end
|
data/lib/hbase/table.rb
CHANGED
@@ -9,6 +9,7 @@ class HBase
|
|
9
9
|
def get(key, with_timestamps = false)
|
10
10
|
begin
|
11
11
|
record = Record.new
|
12
|
+
record.id = key
|
12
13
|
old_row = stargate.show_row(table_name, key)
|
13
14
|
old_row.columns.each do |old_cell|
|
14
15
|
record.cells[old_cell.name] = Cell.new old_cell.value, old_cell.timestamp
|
@@ -57,14 +58,15 @@ class HBase
|
|
57
58
|
|
58
59
|
scanner = stargate.open_scanner(table_name, stargate_options)
|
59
60
|
begin
|
60
|
-
old_rows = stargate.get_rows(scanner)
|
61
|
+
old_rows = stargate.get_rows(scanner)
|
61
62
|
records = []
|
62
|
-
old_rows.each do |old_row|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
63
|
+
old_rows.each do |old_row|
|
64
|
+
record = Record.new
|
65
|
+
record.id = old_row.name
|
66
|
+
old_row.columns.each do |old_cell|
|
67
|
+
record.cells[old_cell.name] = Cell.new old_cell.value, old_cell.timestamp
|
68
|
+
end
|
69
|
+
records << record
|
68
70
|
end
|
69
71
|
records
|
70
72
|
ensure
|
data/readme.md
CHANGED
@@ -14,7 +14,7 @@ Small and handy Ruby driver for HBase (via Stargate RESTfull interface).
|
|
14
14
|
hbase.create 'users'
|
15
15
|
|
16
16
|
# listing all tables
|
17
|
-
p hbase.all # => ['users']
|
17
|
+
p hbase.all.collect{|t| t.name} # => ['users']
|
18
18
|
|
19
19
|
# create record
|
20
20
|
users.update 'john', 'attr:email' => 'john@mail.com'
|
@@ -44,4 +44,9 @@ Small and handy Ruby driver for HBase (via Stargate RESTfull interface).
|
|
44
44
|
|
45
45
|
For installation of HBase and Stargate please see HBase docs (google it).
|
46
46
|
|
47
|
-
**Warning:** currently HBase distributed with RESTful interface called 'rest' and it's deprecated and broken. And because it looks very similar to Stargate it's easy to mix it up. So, be aware, you need to install and use the Stargate, not default and broken HBase REST client.
|
47
|
+
**Warning:** currently HBase distributed with RESTful interface called 'rest' and it's deprecated and broken. And because it looks very similar to Stargate it's easy to mix it up. So, be aware, you need to install and use the Stargate, not default and broken HBase REST client.
|
48
|
+
|
49
|
+
# Contributors
|
50
|
+
|
51
|
+
- [Alexey Petrushin](http://github.com/alexeypetrushin)
|
52
|
+
- [Dmitry Larkin](http://github.com/dml)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hbase-driver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alexey Petrushin
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2011-01-08 00:00:00 +03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|