hbase-jruby 0.2.6-java → 0.3.0-java

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/test/test_util.rb CHANGED
@@ -54,21 +54,21 @@ class TestUtil < Test::Unit::TestCase
54
54
  end
55
55
 
56
56
  def test_parse_column_name
57
- assert_equal ['abc', 'def'], parse_to_str('abc:def')
57
+ assert_equal ['abc', 'def' ], parse_to_str('abc:def')
58
58
  assert_equal ['abc', 'def:'], parse_to_str('abc:def:')
59
- assert_equal ['abc', ''], parse_to_str('abc:')
60
- assert_equal ['abc', nil], parse_to_str('abc')
61
- assert_equal ['abc', ':::'], parse_to_str('abc::::')
59
+ assert_equal ['abc', '' ], parse_to_str('abc:')
60
+ assert_equal ['abc', nil ], parse_to_str('abc')
61
+ assert_equal ['abc', ':::' ], parse_to_str('abc::::')
62
62
 
63
- assert_equal [:abc, :def], parse_to_str([:abc, :def], :symbol)
64
- assert_equal [123, 456], parse_to_str([123, 456], :fixnum)
63
+ assert_equal [:abc, :def ], parse_to_str([:abc, :def], :symbol)
64
+ assert_equal [123, 456 ], parse_to_str([123, 456], :fixnum)
65
65
  assert_equal ['abc', 'def'], parse_to_str(
66
66
  org.apache.hadoop.hbase.KeyValue.new(
67
67
  'rowkey'.to_java_bytes,
68
68
  'abc'.to_java_bytes,
69
69
  'def'.to_java_bytes))
70
70
 
71
- assert_equal [:abc, :def], parse_to_str(HBase::ColumnKey.new(:abc, :def), :symbol)
71
+ assert_equal [:abc, :def], parse_to_str([:abc, :def], :symbol)
72
72
 
73
73
  assert_raise(ArgumentError) { Util.parse_column_name(nil) }
74
74
  assert_raise(ArgumentError) { Util.parse_column_name('') }
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: hbase-jruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.6
5
+ version: 0.3.0
6
6
  platform: java
7
7
  authors:
8
8
  - Junegunn Choi
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-08 00:00:00.000000000 Z
12
+ date: 2013-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit
@@ -65,11 +65,11 @@ files:
65
65
  - lib/hbase-jruby/admin.rb
66
66
  - lib/hbase-jruby/byte_array.rb
67
67
  - lib/hbase-jruby/cell.rb
68
- - lib/hbase-jruby/column_key.rb
69
68
  - lib/hbase-jruby/dependency.rb
70
69
  - lib/hbase-jruby/hbase.rb
71
70
  - lib/hbase-jruby/pom/pom.xml.erb
72
71
  - lib/hbase-jruby/row.rb
72
+ - lib/hbase-jruby/schema.rb
73
73
  - lib/hbase-jruby/scoped.rb
74
74
  - lib/hbase-jruby/scoped/aggregation.rb
75
75
  - lib/hbase-jruby/table.rb
@@ -81,8 +81,8 @@ files:
81
81
  - test/test_aggregation.rb
82
82
  - test/test_byte_array.rb
83
83
  - test/test_cell.rb
84
- - test/test_column_key.rb
85
84
  - test/test_hbase.rb
85
+ - test/test_schema.rb
86
86
  - test/test_scoped.rb
87
87
  - test/test_table.rb
88
88
  - test/test_table_admin.rb
@@ -119,8 +119,8 @@ test_files:
119
119
  - test/test_aggregation.rb
120
120
  - test/test_byte_array.rb
121
121
  - test/test_cell.rb
122
- - test/test_column_key.rb
123
122
  - test/test_hbase.rb
123
+ - test/test_schema.rb
124
124
  - test/test_scoped.rb
125
125
  - test/test_table.rb
126
126
  - test/test_table_admin.rb
@@ -1,72 +0,0 @@
1
- class HBase
2
- class << self
3
- # Shortcut method to HBase::ColumnKey.new
4
- # @param [Object] cf Column family
5
- # @param [Object] cq Column qualifier
6
- def ColumnKey cf, cq
7
- ColumnKey.new cf, cq
8
- end
9
- end
10
- # Boxed class for column keys
11
- # @!attribute [r] cf
12
- # @return [String] The column family
13
- class ColumnKey
14
- attr_reader :cf
15
- alias family cf
16
-
17
- # Creates a ColumnKey object
18
- # @param [Object] cf Column family
19
- # @param [Object] cq Column qualifier
20
- def initialize cf, cq
21
- @cf = String.from_java_bytes Util.to_bytes(cf)
22
- @cq = Util.to_bytes(cq)
23
- end
24
-
25
- # Returns the column qualifer decoded as the given type
26
- # @param [Symbol] type
27
- def cq type = :string
28
- Util.from_bytes type, @cq
29
- end
30
- alias qualifier cq
31
-
32
- # Checks whether if the two ColumnKeys are equal
33
- # @param [Object] other
34
- def eql? other
35
- other = other_as_ck(other)
36
- @cf == other.cf && Arrays.equals(@cq, other.cq(:raw))
37
- end
38
- alias == eql?
39
-
40
- # Compares two ColumnKeys
41
- # @param [Object] other
42
- def <=> other
43
- other = other_as_ck(other)
44
- d = @cf <=> other.cf
45
- d != 0 ? d : Bytes.compareTo(@cq, other.cq(:raw))
46
- end
47
-
48
- # Returns a hash number for this ColumnKey
49
- # @return [Fixnum]
50
- def hash
51
- [@cf, Arrays.java_send(:hashCode, [Util::JAVA_BYTE_ARRAY_CLASS], @cq)].hash
52
- end
53
-
54
- # Returns String representation of the column key (Qualifier decoded as a String)
55
- # @return [String]
56
- def to_s
57
- [@cf, @cq.empty? ? nil : cq].compact.join(':')
58
- end
59
-
60
- private
61
- def other_as_ck other
62
- case other
63
- when ColumnKey
64
- other
65
- else
66
- cf, cq = Util.parse_column_name(other)
67
- ColumnKey.new(cf, cq)
68
- end
69
- end
70
- end#ColumnKey
71
- end#HBase
72
-
@@ -1,49 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift File.expand_path('..', __FILE__)
4
- require 'helper'
5
-
6
- class TestColumnKey < Test::Unit::TestCase
7
- Util = HBase::Util
8
-
9
- def test_types
10
- ck = HBase::ColumnKey("hello", "world")
11
- assert_equal "hello", ck.family
12
- assert_equal "hello", ck.cf
13
- assert_equal "world", ck.qualifier
14
- assert_equal "world", ck.cq
15
- assert_equal 'hello:world', ck.to_s
16
-
17
- ck = HBase::ColumnKey("hello".to_java_bytes, 123)
18
- assert_equal "hello", ck.family
19
- assert_equal "hello", ck.cf
20
- assert_equal 123, ck.qualifier(:fixnum)
21
- assert_equal 123, ck.cq(:fixnum)
22
-
23
- ck = HBase::ColumnKey(:hello, nil)
24
- assert_equal "hello", ck.family
25
- assert_equal "hello", ck.cf
26
- assert_equal '', ck.qualifier(:string)
27
- assert_equal '', ck.cq(:string)
28
- assert_equal 'hello', ck.to_s
29
- end
30
-
31
- def test_eql
32
- ck1 = HBase::ColumnKey(:hello, :world)
33
- ck2 = HBase::ColumnKey("hello", "world")
34
-
35
- assert_equal ck1, ck2
36
- assert_equal ck1, "hello:world"
37
- end
38
-
39
- def test_order
40
- assert_equal (1..100).to_a,
41
- (1..100).to_a.reverse.map { |cq|
42
- HBase::ColumnKey(:cf, cq)
43
- }.sort.map { |ck| ck.cq :fixnum }
44
- end
45
-
46
- def test_as_hash_key
47
- assert({ HBase::ColumnKey(:hello, :world) => true }[ ck2 = HBase::ColumnKey("hello", "world") ])
48
- end
49
- end