Class: Hbase::Client
- Inherits:
-
Object
- Object
- Hbase::Client
- Defined in:
- lib/adapter/hbase.rb
Instance Method Summary collapse
- #getRowsByScanner(table, columns, filters, limit, obj = {}) ⇒ Object
- #incrementAndReturn(table_name, amount) ⇒ Object
Instance Method Details
#getRowsByScanner(table, columns, filters, limit, obj = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/adapter/hbase.rb', line 22 def getRowsByScanner(table,columns,filters,limit,obj={}) scan = HBase::TScan.new filters = "(RowFilter(>=, 'binary:0'))" if filters == '' scan.filterString = filters scanner = scannerOpenWithScan(table, scan, obj) results = [] scan_limit = limit || 100000 rows = scannerGetList(scanner, scan_limit) rows.each do |row| if columns[0] == '*' results << row.columns.each{ |k,v| row.columns[k] = v.value } else row_result = {} columns.each{ |k| row_result[k] = row.columns[k].value } results << row_result 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 |