hipster_sql_to_hbase 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19f2e716a1abcfa1f4dbae04f38a01205f409b74
4
- data.tar.gz: 43e9d4b737023c8158f5c6d5ec90b60af3aad919
3
+ metadata.gz: df0c348233d87ffb7aacd423f8b64d475adb4d38
4
+ data.tar.gz: a6fb7bf800e3200a90349bfc02dcd412423b2ccc
5
5
  SHA512:
6
- metadata.gz: 8ac6ac133586ec4ffd03c98cc964b38d6a3f37a29eb2778e99d173a39acd0f64a8f79779e0283d6653eef34d4d6832f3084651af82c3aae16bb9ba9fc7487ea7
7
- data.tar.gz: 61d65c9cafbabc5c77db5319405e439f22fcf2e4e9b03fce00e9d6534c189d0cef8f27ae960a4a06a94e349cefdb00e3da6540353839876ef58f0ceeda6aea5a
6
+ metadata.gz: 9b22c41dd63997b3d537067e4139741620a9b69553f47652cc59625590f95bbac27aff24040457d7b3b4d07f0ded69b3cb76479abe0abefbd41474267e6842a0
7
+ data.tar.gz: 2e2c362810c8aed1c760dd874e721e0994d2acd67bb552355ff33c6916ffd63efa4ad91082c58abf2e1fa3b2be2c0a7c734659d13f6e2d809cc3c300dd1f0160
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "hipster_sql_to_hbase"
5
- s.version = "0.1.3"
5
+ s.version = "0.1.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jean Lescure"]
data/lib/adapter/hbase.rb CHANGED
@@ -20,6 +20,7 @@ module Hbase
20
20
  c_row
21
21
  end
22
22
  def getRowsByScanner(table,columns,filters,obj={})
23
+ start_time = Time.now
23
24
  scan = HBase::TScan.new
24
25
  filters = "(RowFilter(>=, 'binary:0'))" if filters == ''
25
26
  scan.filterString = filters
@@ -27,31 +28,25 @@ module Hbase
27
28
 
28
29
  results = []
29
30
  scan_end = false
30
- rows = []
31
31
 
32
32
  while !scan_end
33
33
  scan_result = scannerGet(scanner)
34
34
  if scan_result.length > 0
35
- rows << scan_result[0].row
36
- else
37
- scan_end = true
38
- end
39
- end
40
-
41
- rows.each do |row|
42
- row_results = []
43
- if columns[0] == '*'
44
- getRow(table,row,{})[0].columns.each do |val|
45
- row_results << { 'id' => row, val[0] => val[1].value }
35
+ if columns == '*'
36
+ results << scan_result[0].columns.each{ |k,v| scan_result[0].columns[k] = v.value }
37
+ else
38
+ row_result = {}
39
+ columns.each{ |k| row_result[k] = scan_result[0].columns[k].value }
40
+ results << row_result
46
41
  end
47
42
  else
48
- columns.each do |col|
49
- row_results << { 'id' => row, col => getRow(table,row,{})[0].columns["#{col}:"].value } rescue row_results << nil
50
- end
43
+ scannerClose(scanner)
44
+ scan_end = true
51
45
  end
52
- results << row_results
53
46
  end
54
-
47
+ #
48
+ end_time = Time.now
49
+ results << (end_time - start_time) * 1000
55
50
  results
56
51
  end
57
52
  end
@@ -97,8 +97,10 @@ module HipsterSqlToHbase
97
97
 
98
98
  # Generate a Thrift QualifierFilter and ValueFilter from key value pair.
99
99
  def filters_from_key_value_pair(kvp)
100
+ kvp[:qualifier] = kvp[:column].split(':')
101
+ kvp[:column] = kvp[:qualifier].shift
100
102
  if (kvp[:condition].to_s != "LIKE")
101
- "(ValueFilter(#{kvp[:condition]},'binary:#{kvp[:value]}') AND DependentColumnFilter('#{kvp[:column]}',''))"
103
+ "(SingleColumnValueFilter('#{kvp[:column]}','#{kvp[:qualifier].join(':')}',#{kvp[:condition]},'binary:#{kvp[:value]}',true,true))"
102
104
  else
103
105
  kvp[:value] = Regexp.escape(kvp[:value])
104
106
  kvp[:value].sub!(/^%/,"^.*")
@@ -111,7 +113,7 @@ module HipsterSqlToHbase
111
113
  while kvp[:value].match(/([^\\]{1,1})_/)
112
114
  kvp[:value].sub!(/([^\\]{1,1})_/,"#{$1}.")
113
115
  end
114
- "(ValueFilter(=,'regexstring:#{kvp[:value]}') AND DependentColumnFilter('#{kvp[:column]}',''))"
116
+ "(SingleColumnValueFilter('#{kvp[:column]}','#{kvp[:qualifier].join(':')}',=,'regexstring:#{kvp[:value]}',true,true))"
115
117
  end
116
118
  end
117
119
 
@@ -2,6 +2,6 @@ grammar SQLLimit
2
2
  include SQLPrimitives
3
3
 
4
4
  rule limit
5
- "LIMIT" SPACE number { def eval; Limit.new(number.eval); end }
5
+ "LIMIT" SPACE integer { def eval; integer.eval; end }
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hipster_sql_to_hbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Lescure