Optimal diff between object lists in Java
Posted
by Philipp
on Stack Overflow
See other posts from Stack Overflow
or by Philipp
Published on 2010-04-16T07:51:43Z
Indexed on
2010/04/16
7:53 UTC
Read the original article
Hit count: 155
I have a List of Java objects on my server which is sent to the client through some serialization mechanism. Once in a while the List of objects gets updated on the server, that is, some objects get added, some get deleted and others just change their place in the List. I want to update the List on the client side as well, but send the least possible data. Especially, I don't want to resend Objects which are already available on the client.
Is there a library available which will produce some sort of diff from the two lists, so that I can only send the difference and the new Objects accross the wire?
I have found several Java implementation of the unix diff command, but this algorithm is unpractical for order changes. ie. [A,B,C] -> [C,B,A] could be sent as only place changes [1->3] [3->1], while diff will want to resend the whole A and C objects (as far as I understand).
© Stack Overflow or respective owner