java - How shall I convert String to Writable object in my Hadoop Mapper -
this crazy problem hitting me since few hours.
any help highly appreciated.
i not able
public void map(object key, text value, context context) throws ioexception, interruptedexception { if (!value.tostring().equals("")) { gson gson = new gson(); boolean flag = true; system.out.println("000000000"); while(flag){ text tweetid = new text(); tweet tweet = gson.fromjson(value.tostring(), tweet.class); tweetid.set(tweet.getretweetstatus().getuser().getid().tostring()); system.out.println("tweet objects:" + tweet.tostring()); system.out.println("parentuserid:" + tweetid); context.write(tweetid, tweet); flag = false; } text tweetid = new text(); tweet tweet = gson.fromjson(value.tostring(), tweet.class); tweetid.set(tweet.getuser().getid().tostring()); string tweetreverse = (object) tweet.getretweetstatus().getuser().getid(); system.out.println("reverse::"); system.out.println("tweet objects:" + tweetreverse); system.out.println("parentuserid:" + tweetid); context.write(tweetid, tweetreverse); } }
i want convert string object 'tweetreverse' writable can utilize context.write function.
is possible?
what shall if not convert?
if alter generic type string, problems in class extends writable reading , writing values.
any help highly appreciated.
thanks lot in advance.
i have feeling need just
context.write(tweetid, new text(tweetreverse));
that is, create new text object (which implements writable) , pass string in constructor.
java apache hadoop twitter hbase
No comments:
Post a Comment