java - ClassCastException while using HFileOutputFormat2 -
i trying upload data file in hdfs hbase table using hfileoutputformat2 outputformat getting following exception,
java.lang.exception: java.lang.classcastexception: org.apache.hadoop.hbase.client.put cannot cast org.apache.hadoop.hbase.cell @ org.apache.hadoop.mapred.localjobrunner$job.runtasks(localjobrunner.java:462) @ org.apache.hadoop.mapred.localjobrunner$job.run(localjobrunner.java:522) caused by: java.lang.classcastexception: org.apache.hadoop.hbase.client.put cannot cast org.apache.hadoop.hbase.cell @ org.apache.hadoop.hbase.mapreduce.hfileoutputformat2$1.write(hfileoutputformat2.java:148) @ org.apache.hadoop.mapred.maptask$newdirectoutputcollector.write(maptask.java:635) @ org.apache.hadoop.mapreduce.task.taskinputoutputcontextimpl.write(taskinputoutputcontextimpl.java:89) @ org.apache.hadoop.mapreduce.lib.map.wrappedmapper$context.write(wrappedmapper.java:112) @ com.xogito.ingestion.mr.hbase.cseventshbasemapper.map(cseventshbasemapper.java:90) @ com.xogito.ingestion.mr.hbase.cseventshbasemapper.map(cseventshbasemapper.java:1) @ org.apache.hadoop.mapreduce.mapper.run(mapper.java:145) @ org.apache.hadoop.mapred.maptask.runnewmapper(maptask.java:764) @ org.apache.hadoop.mapred.maptask.run(maptask.java:340) @ org.apache.hadoop.mapred.localjobrunner$job$maptaskrunnable.run(localjobrunner.java:243) @ java.util.concurrent.executors$runnableadapter.call(executors.java:441) @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:303) @ java.util.concurrent.futuretask.run(futuretask.java:138) @ java.util.concurrent.threadpoolexecutor$worker.runtask(threadpoolexecutor.java:886) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:908) @ java.lang.thread.run(thread.java:662)
following code of job
@override public int run(string[] args) throws exception { configuration conf = getconf(); job = job.getinstance(conf, "my_job"); job.setjarbyclass(getclass()); job.setmapoutputkeyclass(immutablebyteswritable.class); job.setmapoutputvalueclass(put.class); job.setspeculativeexecution(false); job.setreducespeculativeexecution(false); job.setmapperclass(custommapper.class);//custom mapper job.setinputformatclass(textinputformat.class); job.setoutputformatclass(hfileoutputformat.class); string parentinputpath = args[0]; string parentoutputpath = args[1]; fileinputformat.addinputpaths(job, inputpath); hfileoutputformat.setoutputpath(job,new path(parentoutputpath)); configuration hconf = hbaseconfiguration.create(conf); hconf.set("hbase.zookeeper.quorum", "x.x.x.x"); hconf.set("hbase.zookeeper.property.clientport", "2181"); htable htable = new htable(hconf, "mytable"); // htable.setautoflush(false, true); // htable.setwritebuffersize(1024 * 1024 * 12); hfileoutputformat.configureincrementalload(job, htable); job.setnumreducetasks(0); job.submit(); }
and mapper's code following,
@override public void map(writablecomparable key, writable val, context context) throws ioexception, interruptedexception{ string data = val.tostring(); string[] splitted = data.split("\t"); string account = splitted[1]; matcher match = account.matcher(account); int clientid = 0; if (match.find()) { clientid = integer.valueof(integer.parseint(match .group(1))); } string userid = splitted[2]; long timestamp = 0l; try { timestamp = long.valueof(splitted[10]); } catch (exception e) { logger.error(e.getmessage(), e); } string rowkeytext = "somtext"; immutablebyteswritable rowkey = new immutablebyteswritable(bytes.tobytes(rowkeytext)); put put = new put(bytes.tobytes(rowkeytext)); put.add(cf,column, value); context.write(rowkey, put); }
hfileoutputformat
or new version hfileoutputformat2
needs keyvalue
final class. maybe putsortreducer
not correctly applied converts put
keyvalue
instances.
in case not using mapreduce spark, creating keyvalue
's directly instead of put
's
Comments
Post a Comment