Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

HBase JRuby program error "NoMethodError: undefined method `add' for nil:NilClass"

avatar

I am using HDP2.4 sandbox and I have a Hive external table on top of HBase, my application suppose to load data from Hive.

Below JRuby program runs once in a day to give me custom filter on my INT column values.

import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.client.HTable
import org.apache.hadoop.hbase.client.Get
import org.apache.hadoop.hbase.util.Bytes
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Result;
import java.util.ArrayList;


def delete_get_some()
var_table = "tiny_hbase_table1"
htable = HTable.new(HBaseConfiguration.new, var_table)
rs = htable.getScanner(Bytes.toBytes("o"), Bytes.toBytes("kingdomKey"))
output = ArrayList.new output.add "ROW\t\t\t\t\t\tCOLUMN\+CELL"
rs.each { |r| r.raw.each { |kv|
row = Bytes.toInt(kv.getRow)
fam = kv.getFamily
ql = Bytes.toString(kv.getQualifier)
ts = kv.getTimestamp
val = Bytes.toInt(kv.getValue)
rowval = Bytes.toInt(kv.getRow)
output.add "#{row} #{ql} #{val}"
}
}
output.each {|line| puts "#{line}\n"}
end


delete_get_some

But i am getting "NoMethodError: undefined method `add' for nil:NilClass" error while running this program.

Suggestions or advice please on this issue...

1 ACCEPTED SOLUTION

avatar
Expert Contributor

@Mukesh Could you check your syntax?

It should be the one below

output = ArrayList.new
output.add "ROW\t\t\t\t\t\tCOLUMN\+CELL"

View solution in original post

4 REPLIES 4

avatar
Expert Contributor

@Mukesh Could you check your syntax?

It should be the one below

output = ArrayList.new
output.add "ROW\t\t\t\t\t\tCOLUMN\+CELL"

avatar

Thankyou!!! yes its syntax error caused the issue and now i am able to run program successfully...

avatar
Master Mentor

Please post the error

avatar

Error Message is below:-

hbase(main):027:0* delete_get_some NameError: undefined local variable or method `output' for #<Object:0x714863bd>