Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

SOLVED Go to solution
Highlighted

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

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

Accepted Solutions

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

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"
4 REPLIES 4

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

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"

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

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

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

Mentor

Please post the error

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

Error Message is below:-

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