I think you can do both.
you can encode and decode your values to a json formatted text every time you write them to or read them from your value classes.
I personally added some logic to my VertexValue, thus I donít encode my data.
So for the latter you will need to write custom input formats because you now need to create an instance of your edge and/or vertex value class.
The input format is the place where you can do this.
Take the LongLongNullTextInputFormat in giraph.io.formats.
Replace the NullWritable with you custom EdgeValue and adjust the
protected Iterable<Edge<LongWritable, NullWritable>> getEdges(String tokens)
protected Iterable<Edge<LongWritable, CustomEdgeValue>> getEdges(String tokens)
and change the body to create you your custom value.
You can also look at the Okapi Files. They also provide nice implementations:
Hope that helps
Hi again Pascal
That is realy very helpful. I donít know how can I thank you.
I have another question, do I need to create a new custom input format? I do not think so.
I can use jason format because the other edge values i will set them in compute function. do you agree with me.
Thank you so so much
all you need to do is writing your own EdgeValue and VertexValue class by implementing the Writable Interface.
You can use any field you like. Just make sure you write or read them in the Writeable methods.
Hereís VertexValue I use (There may be better ways for writing list, but it works just fine)
In your compute method get the VertexValue with vertex.getValue() and apply your changes. Thatís it.
Whatever you write into it in step one, you will be able to read or modify in step two.
Hello Pankaj Malhotra,
Yes, I need to assign more than values to the edge. I need the edge has [flow, capacity, distinction, source]
You says I need to create a new class type for edge, How can I pass it to json class and how can I make json class read my new edge object.
I need to submit my code next week, so any answer or recommendation will definitely help.
If I get your point-1 right, you want to have a vertex class type other than the ones available, for example: Text. If this is what you want, you can have a class having as many fields as you want. Then convert the objects of that class to Json
objects using Gson for example. Then, you can use the Json string to set the fields of the Text class.