moremore0812 / cqengine

Automatically exported from code.google.com/p/cqengine
0 stars 0 forks source link

Enhancement :Allow to set the concurrency level in order to reduce memory #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Insert  100000 object total around 5 mb memory size, with single index field 
of integer.  
2.
3.

What is the expected output? What do you see instead?

Memory consumed by the concurrent hashmap@segment more than 80mb. 

What version of the product are you using? On what operating system?
Win7

Please provide any additional information below.
It is suggests to allow providing factory of the underlying concurrent hashmap 
such that level of currency, load factor , etc can be customized.

Original issue reported on code.google.com by kin...@gmail.com on 12 Nov 2012 at 12:19

GoogleCodeExporter commented 9 years ago
This is a good suggestion, thanks. And fairly easy to implement.

I'll look into adding some proper support as suggested over the next few days. 

However in the meantime, there is a way to achieve this in the current release, 
even though it's a bit awkward. (I guess you might have done this already...)

You can subclass HashIndex as (say) CustomHashIndex, and override the 
getIndexMap() method. That method should return the same ConcurrentMap every 
time it's called, but you can construct the map with concurrency/load factor 
however you like. Your effectively custom index would then be usable with 
CQEngine as normal.

Expect less awkward support for this in the next few days, in the built-in 
HashIndex and others. Hopefully I'll get time to package this as a 1.0.1 
release at the weekend.

Original comment by ni...@npgall.com on 12 Nov 2012 at 1:47

GoogleCodeExporter commented 9 years ago
EDIT: actually subclassing alone won't be enough. The current code access the 
map field directly. Grrr. Theoretically for [unvalidated] performance reasons. 
So the temporary workaround might be to copy and paste the code into a 
subclass. ...yes better support for this is definitely required.

Original comment by ni...@npgall.com on 12 Nov 2012 at 1:54

GoogleCodeExporter commented 9 years ago
Thanks, looking forward to the 1.0.1.

Original comment by kin...@gmail.com on 12 Nov 2012 at 1:59

GoogleCodeExporter commented 9 years ago

Original comment by ni...@npgall.com on 13 Nov 2012 at 11:24

GoogleCodeExporter commented 9 years ago
Changes in trunk, will prepare 1.0.1 release over the next few days.

Original comment by ni...@npgall.com on 16 Nov 2012 at 12:02

GoogleCodeExporter commented 9 years ago
Done.

HashIndex, NavigableIndex and CompoundIndex now optionally accept Factories to 
customize the construction of maps and sets which those indexes use internally.

Example of new methods added to HashIndex:

public static <A,O> HashIndex<A,O> onAttribute(
    Factory<ConcurrentMap<A,StoredResultSet<O>>> indexMapFactory,
    Factory<StoredResultSet<O>> valueSetFactory,
    Attribute<O,A> attribute)

Release 1.0.1 is queued for sync with maven central.

Original comment by ni...@npgall.com on 17 Nov 2012 at 11:29