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 +4 -4
- data/VERSION +1 -1
- data/hipster_sql_to_hbase.gemspec +1 -1
- data/lib/adapter/hbase.rb +12 -17
- data/lib/result_tree_to_hbase_converter.rb +4 -2
- data/lib/sql_parser/sql_limit.treetop +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df0c348233d87ffb7aacd423f8b64d475adb4d38
|
4
|
+
data.tar.gz: a6fb7bf800e3200a90349bfc02dcd412423b2ccc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b22c41dd63997b3d537067e4139741620a9b69553f47652cc59625590f95bbac27aff24040457d7b3b4d07f0ded69b3cb76479abe0abefbd41474267e6842a0
|
7
|
+
data.tar.gz: 2e2c362810c8aed1c760dd874e721e0994d2acd67bb552355ff33c6916ffd63efa4ad91082c58abf2e1fa3b2be2c0a7c734659d13f6e2d809cc3c300dd1f0160
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
49
|
-
|
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
|
-
"(
|
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
|
-
"(
|
116
|
+
"(SingleColumnValueFilter('#{kvp[:column]}','#{kvp[:qualifier].join(':')}',=,'regexstring:#{kvp[:value]}',true,true))"
|
115
117
|
end
|
116
118
|
end
|
117
119
|
|