ok_hbase 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Welcome HBase cowboys.
4
4
 
5
- Read the [wiki](https://github.com/okcwest/ok-hbase/wiki)!
5
+ Read the [pages site](http://okcwest.github.io/ok_hbase/)!
6
6
 
7
7
  ## Installation
8
8
 
@@ -20,22 +20,47 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- ```bash
24
- $ bundle console
25
- Resolving dependencies...
26
- irb(main):030:0> connection = OkHbase::Connection.new(host: "hbase-dev")
27
- => #<OkHbase::Connection:0x00000002440140 <snip>
28
- irb(main):031:0> table = OkHbase::Table.new(mytable, connection)
29
- => #<OkHbase::Table:0x00000002449f38 <snip>
30
- irb(main):032:0> count = 0
31
- => 0
32
- irb(main):033:0> table.scan row_prefix: [ myid, 1, 5, 1, 0 ].pack("L>CCCC") do |row, col|
33
- irb(main):034:1* count += 1
34
- irb(main):035:1> end
35
- => nil
36
- irb(main):036:0> count
37
- => 1072
38
- irb(main):037:0> connection.close
23
+ ```ruby
24
+ # simple example showing how to:
25
+ # 1) connect
26
+ # 2) create a table
27
+ # 3) write rows
28
+ # 4) scan for rows
29
+ # 5) get a row by key
30
+ # 6) delete a table
31
+
32
+ require 'ok_hbase'
33
+
34
+ # get a connection
35
+ conn = OkHbase::Connection.new(
36
+ host: 'localhost',
37
+ port: 9090,
38
+ auto_connect: true
39
+ )
40
+
41
+ # create a new table with column family 'd'
42
+ table = conn.create_table('ok_hbase_test', d: {})
43
+
44
+ # put a bunch of data in the table
45
+ ('hbaaa'..'hbzzz').each_with_index do |row_key, index|
46
+ table.put(
47
+ row_key,
48
+ {
49
+ 'd:row_number' => "#{index+1}",
50
+ 'd:message' => "this is row number #{index+1}"
51
+ }
52
+ )
53
+ print "wrote row: #{row_key}\r"
54
+ end
55
+
56
+ # scan for all rows beginning with 'hba'
57
+ table.scan(row_prefix: 'hba')
58
+
59
+ # get the row with the row key 'hbase'
60
+ table.row('hbase')
61
+
62
+ # clean up
63
+ conn.delete_table('ok_hbase_test', true)
39
64
  ```
40
65
 
41
66
  ## Contributing
@@ -8,7 +8,7 @@ module OkHbase
8
8
  end
9
9
 
10
10
  def rows(row_keys, columns = nil, timestamp = nil, include_timestamp = false)
11
- super.map.with_index! { |data, i| self.row_class.new table: self, row_key: row_keys[i], default_column_family: self.default_column_family, raw_data: data }
11
+ super.map { |row_key, data| self.row_class.new table: self, row_key: row_key, default_column_family: self.default_column_family, raw_data: data }
12
12
  end
13
13
 
14
14
  def scan(opts={})
@@ -86,7 +86,7 @@ module OkHbase
86
86
  self.connection.client.getRowsWithColumns(self.connection.table_name(table_name), row_keys, columns)
87
87
  end
88
88
 
89
- rows.map { |row| _make_row(row.columns, include_timestamp) }
89
+ rows.map { |row| [row.row, _make_row(row.columns, include_timestamp) ]}
90
90
  end
91
91
 
92
92
  def cells(row_key, column, versions = nil, timestamp = nil, include_timestamp = nil)
@@ -1,3 +1,3 @@
1
1
  module OkHbase
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -126,11 +126,11 @@ module OkHbase
126
126
  subject.put(row_key2, row_data2.merge('d:foo' => 'OldFoo2'), timestamp-5)
127
127
  subject.put(row_key2, row_data2, timestamp)
128
128
 
129
- subject.rows([row_key1, row_key2]).should == [row_data1, row_data2]
130
- subject.rows([row_key1, row_key2], nil, timestamp-9).should == [row_data1, row_data2.merge('d:foo' => 'OldFoo1')]
129
+ subject.rows([row_key1, row_key2]).should == [[row_key1, row_data1], [row_key2, row_data2]]
130
+ subject.rows([row_key1, row_key2], nil, timestamp-9).should == [[row_key1, row_data1], [row_key2, row_data2.merge('d:foo' => 'OldFoo1')]]
131
131
 
132
- subject.rows([row_key1, row_key2], row_data1.keys - ['d:foo']).should == [row_data1.except('d:foo'), row_data2.except('d:foo')]
133
- subject.rows([row_key1, row_key2], row_data1.keys - ['d:foo'], timestamp-5).should == [row_data1.except('d:foo'), row_data2.except('d:foo')]
132
+ subject.rows([row_key1, row_key2], row_data1.keys - ['d:foo']).should == [[row_key1, row_data1.except('d:foo')], [row_key2, row_data2.except('d:foo')]]
133
+ subject.rows([row_key1, row_key2], row_data1.keys - ['d:foo'], timestamp-5).should == [[row_key1, row_data1.except('d:foo')], [row_key2, row_data2.except('d:foo')]]
134
134
 
135
135
  end
136
136
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ok_hbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-13 00:00:00.000000000 Z
12
+ date: 2013-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thrift
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 1.8.24
114
+ rubygems_version: 1.8.25
115
115
  signing_key:
116
116
  specification_version: 3
117
117
  summary: Lightweight Ruby Hbase Client