Class: Hbase::Client
- Inherits:
-
Object
- Object
- Hbase::Client
- Defined in:
- lib/adapter/hbase.rb
Instance Method Summary collapse
- #getRowsByScanner(table, columns, filters, obj = {}) ⇒ Object
- #incrementAndReturn(table_name, amount) ⇒ Object
Instance Method Details
#getRowsByScanner(table, columns, filters, obj = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/adapter/hbase.rb', line 22 def getRowsByScanner(table,columns,filters,obj={}) scan = HBase::TScan.new filters = "(RowFilter(>=, 'binary:0'))" if filters == '' scan.filterString = filters scanner = scannerOpenWithScan(table, scan, obj) results = [] scan_end = false while !scan_end scan_result = scannerGet(scanner) if scan_result.length > 0 if columns == '*' results << scan_result[0].columns.each{ |k,v| scan_result[0].columns[k] = v.value } else row_result = {} columns.each{ |k| row_result[k] = scan_result[0].columns[k].value } results << row_result end else scannerClose(scanner) scan_end = true end end results end |
#incrementAndReturn(table_name, amount) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/adapter/hbase.rb', line 16 def incrementAndReturn(table_name,amount) c_row = get('table_indices','0',table_name,{})[0].value.to_i n_row = c_row+amount mutateRow('table_indices','0',[HBase::Mutation.new(column: table_name, value: n_row.to_s)],{}) c_row end |