sishen-hbase-ruby 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -25,19 +25,40 @@ Here is the example:
25
25
  require 'hbase'
26
26
 
27
27
  client = HBase::Client.new("http://localhost:60010/api") # this url is the default.
28
- tables = client.list_tables # list available tables
29
28
 
29
+ # Table Operation
30
+ tables = client.list_tables # list available tables
30
31
  table = client.create_table('users', 'habbit') # create a table whose column_family is habbit
31
-
32
32
  table = client.show_table('users') # show the meta info of table users
33
+ client.disable_table('users') # disable table users
34
+ client.enable_table('users') # enable table users
35
+ client.delete_table('users') # delete table users
33
36
 
37
+ # Row Operation
34
38
  row = client.show_row('users', 'sishen') # show the data of row 'sishen' in table 'users'
35
-
36
39
  row2 = client.create_row('users', 'sishen', Time.now.to_i, {:name => 'habbit:football', :value => 'i like football'}) # create the row 'sishen' with the data in the table 'users'
37
-
38
40
  client.delete_row('users', 'sishen', nil, 'habbit:football') # delete the row 'sishen' of table 'users' with the optional column 'habbit:football'
41
+
42
+ # Scanner Operation
43
+ scanner = client.open_scanner('users', 'habbit:')
44
+ rows = client.get_rows(scanner)
45
+ client.close_scanner(scanner)
39
46
  }}}
40
47
 
48
+ == Testing
49
+
50
+ First you want to install rspec gem:
51
+
52
+ {{{
53
+ sudo gem install rspec
54
+ }}}
55
+
56
+ Now, you can run the spec by following rake task:
57
+
58
+ {{{
59
+ rake examples
60
+ }}}
61
+
41
62
  == Copyright
42
63
 
43
64
  Copyright (c) 2008 Dingding Ye <yedingding@gmail.com>
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'hoe'
3
3
 
4
- Hoe.new('sishen-hbase-ruby', '0.4.2') do |p|
4
+ Hoe.new('sishen-hbase-ruby', '0.4.3') do |p|
5
5
  p.rubyforge_name = 'sishen-hbase-ruby'
6
6
  p.author = 'Ye Dingding'
7
7
  p.email = 'yedingding@gmail.com'
@@ -9,5 +9,5 @@ Hoe.new('sishen-hbase-ruby', '0.4.2') do |p|
9
9
  p.summary = 'a pure ruby client for hbase using REST interface'
10
10
  p.description = 'hbase-ruby is a pure ruby client for hbase and enable the ruby app enjoy the power of HBase'
11
11
  end
12
-
12
+
13
13
  Dir['tasks/**/*.rake'].each { |rake| load rake }
data/hbase-ruby.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{hbase-ruby}
3
- s.version = "0.4.2"
3
+ s.version = "0.4.3"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Ye Dingding"]
@@ -22,10 +22,13 @@ Gem::Specification.new do |s|
22
22
 
23
23
  if current_version >= 3 then
24
24
  s.add_development_dependency(%q<hoe>, [">= 1.7.0"])
25
+ s.add_development_dependency(%q<rspec>, [">= 1.1.4"])
25
26
  else
26
27
  s.add_dependency(%q<hoe>, [">= 1.7.0"])
28
+ s.add_dependency(%q<rspec>, [">= 1.1.4"])
27
29
  end
28
30
  else
29
31
  s.add_dependency(%q<hoe>, [">= 1.7.0"])
32
+ s.add_dependency(%q<rspec>, [">= 1.1.4"])
30
33
  end
31
34
  end
@@ -8,6 +8,20 @@ module HBase
8
8
  def initialize(path)
9
9
  @path = path
10
10
  end
11
+
12
+
13
+ protected
14
+
15
+ def pack_params columns
16
+ if columns.is_a? String
17
+ columns = [columns]
18
+ elsif columns.is_a? Array
19
+ else
20
+ raise StandardError, "Only String or Array type allows for columns"
21
+ end
22
+
23
+ columns.collect { |column| "column=#{column}" }.join('&')
24
+ end
11
25
  end
12
26
  end
13
27
  end
@@ -5,9 +5,11 @@ module HBase
5
5
  attr_reader :name
6
6
  attr_reader :timestamp
7
7
 
8
- def initialize(table_name, name, timestamp)
8
+ def initialize(table_name, name, timestamp=nil)
9
9
  @table_name, @name, @timestamp = CGI.escape(table_name), CGI.escape(name), timestamp
10
- super("/#{@table_name}/row/#{@name}/#{@timestamp}")
10
+ path = "/#{@table_name}/row/#{@name}"
11
+ path << "/#{@timestamp}" if timestamp
12
+ super(path)
11
13
  end
12
14
 
13
15
  def show(columns = nil, version = nil)
@@ -26,13 +28,6 @@ module HBase
26
28
  @path << "?#{pack_params(columns)}" if columns
27
29
  @path
28
30
  end
29
-
30
- private
31
-
32
- def pack_params columns
33
- columns = [columns] unless columns.is_a? Array
34
- columns.collect { |column| "column=#{column}" }.join('&')
35
- end
36
31
  end
37
32
  end
38
33
  end
@@ -10,12 +10,12 @@ module HBase
10
10
  end
11
11
 
12
12
  def show
13
- member_path
13
+ @path << "/#{name}"
14
14
  end
15
15
 
16
16
  def regions(start_row = nil, end_row = nil)
17
17
  #TODO no handle the args!
18
- member_path << "/regions"
18
+ @path << "/#{name}/regions"
19
19
  end
20
20
 
21
21
  def create
@@ -23,37 +23,22 @@ module HBase
23
23
  end
24
24
 
25
25
  def update
26
- member_path
26
+ @path << "/#{name}"
27
27
  end
28
28
 
29
29
  def enable
30
- member_path << "/enable"
30
+ @path << "/#{name}/enable"
31
31
  end
32
32
 
33
33
  def disable
34
- member_path << "/disable"
34
+ @path << "/#{name}/disable"
35
35
  end
36
36
 
37
37
  def delete(columns = nil)
38
- if columns
39
- if columns.is_a? String
40
- columns = [columns]
41
- elsif columns.is_a? Array
42
- else
43
- raise StandardError, "Only String or Array type allows for columns"
44
- end
45
- params = columns.collect { |column| "column=#{column}" }.join('%')
46
- member_path << "?#{params}"
47
- end
38
+ @path << "/#{name}"
39
+ @path << "?#{pack_params(columns)}" if columns
48
40
  @path
49
41
  end
50
-
51
- private
52
-
53
- def member_path
54
- @path << "/#{name}"
55
- @path
56
- end
57
42
  end
58
43
  end
59
44
  end
@@ -7,7 +7,7 @@ module HBase
7
7
  columns = []
8
8
  row.elements.each("column") do |col|
9
9
  name = col.elements["name"].text.strip.unpack("m").first
10
- value = col.elements["value"].text.strip.unpack("m").first
10
+ value = col.elements["value"].text.strip.unpack("m").first rescue nil
11
11
  timestamp = col.elements["timestamp"].text.strip.to_i
12
12
  columns << Model::Column.new(:name => name,
13
13
  :value => value,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sishen-hbase-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ye Dingding
@@ -21,6 +21,15 @@ dependencies:
21
21
  - !ruby/object:Gem::Version
22
22
  version: 1.7.0
23
23
  version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: rspec
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.1.4
32
+ version:
24
33
  description: hbase-ruby is a pure ruby client for hbase and enable the ruby app enjoy the power of HBase
25
34
  email: yedingding@gmail.com
26
35
  executables: []