I tried to wire CQEngine with OpenHFT HugeCollection as the underlying Set, however randomly CQEngine's ResultSet is empty while being iterated. It just happens randomly and I can't really figure out when it will be empty and when it won't be empty.
Do you know what it might happen? It doesn't behave that way if the underlying set is from JDK Set.
Do I also need to wire the Map used for indexing with HugeCollection?
Hi Winarto,
I'm away at the moment so can't check this until next week.
But in general:
- CQEngine expects that all of the data structures wired in, support multithreaded access
- If you wire in a custom implementation, ensure that it is thread safe. If the implementation is not inherently thread safe though, you can make it thread safe by wrapping access to it in a read-write lock.
- It's important to do this on write paths to prevent corruption by multiple competing writes (obviously). But it's also important to do this on the read paths to attain volatile semantics, so that reading threads actually see data written by the writing threads. Without this, reading threads may not see objects written by other threads.
- CQEngine ResultSets are not designed to be iterated by more than one thread in parallel (but of course multiple threads may be iterating different resultsets in parallel). So when setting up your parallel streams, ensure that the stream is parallelized after a single threaded stage which iterates the ResultSet. That is a single reader, feeds objects to a pool of multiple worker threads.
HTH,
Niall
Sent from my HTC
--
-- You received this message because you are subscribed to the "cqengine-discuss" group.
http://groups.google.com/group/cqengine-discuss
---
You received this message because you are subscribed to the Google Groups "cqengine-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cqengine-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.