Wednesday 15 April 2015

java - How to serialize List collection object in Hadoop? -


Is Serial Java Storage in Hadop?

Writeable Interface is for Java primitives only. I have class features.

  Private string keywords; Private listing & lt; Status & gt; Tweets; Private long query time = 0; Public Tweet Status (String Keys, List & lt; Status & gt; Tweets, Long Query Time) {this.keywords = keys; This.tweets = Tweets; This.queryTime = queryTime; }   

How can I sort the list object?

Write-able interface is only for Java primitives.

In fact, you need to break your object in the sequence of objects, which you can serial.

So, from the first principles, to sort the inventory to sort the list size and then to list each element. In this way, when you need to deserialize, you need to know how many elements deserialize.

You should meet something like writing (Hydro!) Track:

  class TweetStatusWritable implies writeable {private string keyword; Private listing & lt; Status & gt; Tweets; Private long query time; // Add getters for the above three areas Public Zero ReadField (DataInput in) {this.keywords = in.readUTF (); Int size = in.readInt (); This.tweets = new list & lt; Status & gt; (); (Int i = 0; i & lt; size; i ++) {status status = // an example of status tweets deserialize.add (status); } This.queryTime = in.readLong (); } Public Zero write (data output out) {out.writeUTF (this.keywords); Out.writeInt (this.tweets.size ()); For (Int i = 0; I & lt; this.tweets.size (); i ++) {// Serial Tweets [I] Outside} Out Write long (query time); } Public TweetStatusWritable (string keyword, list & lt; status & gt; tweets, long query time) {this.keywords = keywords; This.tweets = Tweets; This.queryTime = queryTime; }}    

No comments:

Post a Comment