Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate UniqueIndex patch by Kinz Liu #8

Closed
GoogleCodeExporter opened this issue Aug 23, 2015 · 4 comments
Closed

Integrate UniqueIndex patch by Kinz Liu #8

GoogleCodeExporter opened this issue Aug 23, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

Following discussion in the forum: 
http://groups.google.com/group/cqengine-discuss

Patch attached.

Original issue reported on code.google.com by ni...@npgall.com on 4 Dec 2012 at 11:27

Attachments:

@GoogleCodeExporter
Copy link
Author

Done, included in CQEngine 1.0.3.

I made some minor changes to the patch:

 - If an object is added to the IndexedCollection and it already exists in UniqueIndex, UniqueIndex will not throw an exception if the condition newObject.equals(existingObject) is true. This change brings UniqueIndex in line with the behaviour of other indexes (which safely can be notified multiple times about the same object), to avoid the need to add special logic for UniqueIndex in IndexedCollection

 - I added support for MultiValueAttribute. Attribute values become the keys in the index, so there is no problem per-se in an object having a multiple values for an attribute. The object will be added to the index multiple times, against one key for each of its attribute values. 

Multi-valued attributes can be used with unique index, as long as there is no 
overlap in values between objects. For example Car{features=radio,cd_player} 
and Car{features=sunroof,spare_tyre} can both be added to a UniqueIndex. But a 
third Car{features=alarm,sunroof} would cause an exception because there would 
already be an entry for sunroof. This is a contrived example, but some 
applications might have fields which contain multiple but naturally disjoint 
values, for example foreign key-type references, like 
Customer{List<CustomerOrder>}.

This will be a great addition so thanks again to Kinz Liu.

Original comment by ni...@npgall.com on 7 Dec 2012 at 10:46

  • Changed state: Done

@GoogleCodeExporter
Copy link
Author

I updated the benchmark page: http://code.google.com/p/cqengine/wiki/Benchmark

UniqueIndex is *significantly* faster:
3600% faster than HashIndex at indexing unique attributes
30% faster than HashIndex in query performance

Actual figures are here: http://cqengine.googlecode.com/svn/wiki/documents/

Original comment by ni...@npgall.com on 8 Dec 2012 at 12:02

@GoogleCodeExporter
Copy link
Author

I see the above patch missing in IndexedCollectionImpl.java in the latest 
release 1.2.1. Any reason this was not included in the release? 

Original comment by rubba...@gmail.com on 8 Oct 2013 at 9:31

@GoogleCodeExporter
Copy link
Author

No features were removed AFAIK. UniqueIndex is still there (it's a core 
feature).

IndexedCollectionImpl no longer exists however. In version 1.1.0 it was renamed 
to ConcurrentIndexedCollection, because an additional implementation 
ObjectLockingIndexedCollection was also added.

What was in IndexedCollectionImpl.java is now in 
ConcurrentIndexedCollection.java, so see that class instead. Let me know if you 
don't find what you are looking for!

Original comment by ni...@npgall.com on 8 Oct 2013 at 9:59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants