I have to check the differences between the two protobuf messages for my program(C++). I am trying MessageDifferencer::Compare and MessageDifferencer::Equals for this.
I have a map
field inside the proto message, which as we know is not guaranteed to be ordered. So, I want to know what is the MessageDifferencer
take on this? Is anyone out of Compare
or Equals
functions have something to handle this case?
I mean that if the map is not ordered, how we can be sure that all of the elements in the first message are compared to the right elements in the second message?
My message is something like:
message foo
{
// some-fields
map<string, int64> bar = 2;
// more-fields
}
I am new to both C++ and protobuf, so any idea in the right direction will be helpful.
UPDATES:
Even if I am comparing the same message, it is showing mismatch and I can see in the difference-report that it is because the same field is not getting match against each other.
From the protobuf documentation:
Wire format ordering and map iteration ordering of map values is undefined, so you cannot rely on your map items being in a particular order.