I have a situation where I need to trust that the data that a Predicate used for filtering is the same data as I get
when I peruse the returned entry set.
Let's assume that I have a Predicate with an apply() method like:
public boolean apply(MapEntry<String, String> entry) {
return "some value".equals(entry.getValue());
}
and that I use the predicate in a for loop like so:
for(Map.Entry<String,String> entry : myMap.entrySet(myPredicate)) {
String value = entry.getValue();
...
}
What happens if some other thread or process is changing the value for a particular key sometime between the call to
predicate.apply() and when I obtain value for that key in the for loop? Will the value then be changed or is it somehow
guaranteed that the entrySet() returns the same entry unmodified?
- thomas
- thomas
--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.
Hi Thomas,
Hazelcast can not guarantee it at the moment. It would be very costly to guarantee such a thing and would make queries a lot useless. Instead upon receiving you can apply the predicate yourself for double checking.
-fuad
On Fri, Jan 27, 2012 at 10:04 AM, Thomas Hallgren <tho...@tada.se> wrote:
Hi,
I have a situation where I need to trust that the data that a Predicate used for filtering is the same data as I get when I peruse the returned entry set.
Let's assume that I have a Predicate with an apply() method like:
public boolean apply(MapEntry<String, String> entry) {
return "some value".equals(entry.getValue());
}
and that I use the predicate in a for loop like so:
for(Map.Entry<String,String> entry : myMap.entrySet(myPredicate)) {
String value = entry.getValue();
...
}
What happens if some other thread or process is changing the value for a particular key sometime between the call to predicate.apply() and when I obtain value for that key in the for loop? Will the value then be changed or is it somehow guaranteed that the entrySet() returns the same entry unmodified?
- thomas
--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.
--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.