Does CQEngine support transactional update?

176 views Asked by At

I wish to have a queryable on-heap mirror of some underlying resource. When using CQEngine to index a class not under our control (*), how can we implement a transactional update (what's the point of all this concurrency if readers lose data because of the remove+add semantics!).

(*) TransactionalIndexedCollection insists on mauling the type's equals method so that equivalent objects are no longer equals()!

Also, the provided equals method covers "all fields" not "pk fields" so causes duplicates. How do I create an atomically updateable collection with my own PK?

1

There are 1 answers

1
npgall On

If you want to use TransactionalIndexedCollection for atomic updates, you will have to follow its guidance on how to implement equals() and hashCode() on the objects you will store in it.

However, you don't need to store the objects you don't control directly in the indexed collection. For example you could write a wrapper object which you will store in the collection - and this will implement equals() and hashCode() per the guidance. This way you won't need to modify the objects you don't control.

You can write your attributes so that given a wrapper object, they actually read the fields or call the getter methods from the inner object.