Page 1 of 1

Javolution/Trove/Java

Posted: Thu Feb 18, 2010 9:43 pm
by Forsaiken
Hi.

Just wanted to give u some infos about all that FastMap/TIntHashs.

We start with: FastMap
A FastMap is nothing else then an regular HashMap/THashMap, but has a big difference... all entries are LINKED!
Thats also the reason why FastMap iterations are much faster then iterating over an HashMap or using forEach on THashMap.

Whats "setShared()" on FastMap?
This flag does 2 things:
1: The linked entries never loose it`s links to the prev/next entry which results in an "save" iteration while removing/adding values to an map.
2: It will self synchronized when adding/removing values, like "synchronized(map){map.put(key, value);}"
Ofc this synchronisation slows down the FastMap because it must enter the thread monitor when adding/removing values.

Well Trove is not far away form the Java originals (in basics) but as u know it use primitive datatypes as key/value. So far u need to sync every access to the map if u don`t want urgend exceptions or fails. ReentrantReadWriteLock is ur friend again.

When to use Trove, Java, Javolution?

Code: Select all

 using:THashMap<Integer, Object>TIntObjectHashMap<Object>FastMap<Integer, Object>HashMap<Integer, Object> Put (already in map)THashMap: 204%TIntObjectHashMap: 89%FastMap: 198%HashMap: 100% PutIfAbsent (already in map)THashMap: 160%TIntObjectHashMap: 45%FastMap: 100%HashMap: - Get (in map)THashMap: 189%TIntObjectHashMap: 49%FastMap: 137%HashMap: 100% Get (not in map)THashMap: 295%TIntObjectHashMap: 50%FastMap: 139%HashMap: 100% ContainsKey (in map)THashMap: 177%TIntObjectHashMap: 34%FastMap: 136%HashMap: 100% ContainsKey (not in map)THashMap: 292%TIntObjectHashMap: 39%FastMap: 145%HashMap: 100% ContainsValue (in map avg)THashMap: 143%TIntObjectHashMap: 150%FastMap: 57%HashMap: 100% ContainsValue (not in map)THashMap: 123%TIntObjectHashMap: 142%FastMap: 85%HashMap: 100% IterateTHashMap: 92%TIntObjectHashMap: 113%FastMap: 35%HashMap: 100% 
Less = better.
As u can see Trove is ONLY suitable for primitives!
So if u have to iterate more often or do not have an primitive as a key use Javolution.

And now about the lists....
FastList is an LINKED list. If u know the final size of the list or now that u have to add more then > 8 entrys an ArrayList is faster (even with expand)!!! Specialy those cases where u fill into FastList and use toArray()!!!

Hopefully this will help u somehow.

Re: Javolution/Trove/Java

Posted: Thu Feb 18, 2010 10:51 pm
by DrHouse
Thanks :) very interesting

Re: Javolution/Trove/Java

Posted: Sat Oct 09, 2010 9:10 am
by Phantom2005
So what you're basically saying is.. change knownlist FastList's to ArrayList?
(since there's a big chance u have to add more than 8 )

Interesting thread btw.

Re: Javolution/Trove/Java

Posted: Tue Oct 12, 2010 4:41 pm
by VISTALL
big thx link for my friend :o


If u dont read api docs of javolution http://javolution.org/target/site/apido ... stMap.html

Image

FastMap is use better if too many values(more than 10k) if values size is lower need use HashMap

Re: Javolution/Trove/Java

Posted: Thu Oct 14, 2010 3:39 pm
by issle88
VISTALL wrote:big thx link for my friend :o


If u dont read api docs of javolution http://javolution.org/target/site/apido ... stMap.html

Image

FastMap is use better if too many values(more than 10k) if values size is lower need use HashMap
That depends on the functionallity your data structure is intended to do. Each data structure performs in a different way based on the operation you are performing to it ( insertion, search, removal ).

Here's an example: The SkillsTable. It gets loaded whenever the server gets started or you call //reload skills. But it gets read very often , much more often than it gets inserted. So in that case, a data structure with small search complexity would be preffered over a data structure with small insertion complexity, since in total we got more "reads" than "insertions.

Re: Javolution/Trove/Java

Posted: Thu Oct 14, 2010 8:17 pm
by VISTALL
Issle wrote:
VISTALL wrote:big thx link for my friend :o


If u dont read api docs of javolution http://javolution.org/target/site/apido ... stMap.html

Image

FastMap is use better if too many values(more than 10k) if values size is lower need use HashMap
That depends on the functionallity your data structure is intended to do. Each data structure performs in a different way based on the operation you are performing to it ( insertion, search, removal ).

Here's an example: The SkillsTable. It gets loaded whenever the server gets started or you call //reload skills. But it gets read very often , much more often than it gets inserted. So in that case, a data structure with small search complexity would be preffered over a data structure with small insertion complexity, since in total we got more "reads" than "insertions.
yeah is data is static(put only at start is not really difference), but if is ad L2World and Map of moving characters is use good FastMap

Re: Javolution/Trove/Java

Posted: Mon Sep 12, 2011 10:21 pm
by MELERIX
Trove 3.0.0 Final Stable has been released today

Changelog:
--- 3.0.0 ---
  - !!! Major restructuring of classes and packages !!!
    Interfaces have been broken out to allow for alternate implementations.
    The package changes will require code migration, although it should mainly
    consist of simply updating import statements. However, because everything is
    in new packages, both Trove 2.x and Trove 3.x can co-exist in a classpath
    (to hopefully ease the migration burden).
  - Broke out classes that allow custom hashing for performance reasons.
    New collections are:
       - TCustomHashMap
       - TCustomHashSet
       - TObject*CustomHashMap (ex: TObjectIntCustomHashMap)
    IdentityHashingStrategy is available for identity-based hash maps.
  - [ 3152276 ] Add sum() method to T*List
  - [ 3159432 ] THashMap.entrySet().remove() throws on non-Entries
  - [ 3153005 ] fix for null keys in Object maps
  - Benchmarks for comparing different libraries. Currently java.util, Colt,
    Trove 2 and Trove 3.
  - Fixes to serialVersionUID's and where Serializable is marked. For example,
    Serializable has been removed from the interfaces for various collections
    (to better match how it's done in java.util).
  - Many bug fixes, particularly to TLinkedList.
Download link: http://sourceforge.net/projects/trove4j ... p/download

Re: Javolution/Trove/Java

Posted: Fri Oct 14, 2011 4:00 am
by MELERIX
Trove 3.0.1 is now available for downloads. This is mainly a bug fix release with a number of minor features.

Changelog:
--- 3.0.1 ---
Bugs Fixed:
- fix for ClassCastException in equals(T,T) when comparing with REMOVED
- [3408129] Benchmarks don't run correctly
- [3394094] Args to gnu.trove.generator.Generator not basedir-relative
- Re-introduce TLinkableAdapter class
New Features:
- [3412967] Need TMap interface
- .zip and .tgz files now expand into a sub-directory
- Documentation for generator patterns and replicated blocks
- Maven artifact generation now a bit more automatic
Download Link: http://sourceforge.net/projects/trove4j ... p/download

Re: Javolution/Trove/Java

Posted: Thu Nov 24, 2011 8:18 am
by MELERIX
Trove 3.0.2 has been released. This release contains a couple of significant bug fixes and is highly recommended for all 3.x users.

Changelog:
Bug Fixed:
■ [3429703] TIntObjectHashMap losing entry
■ [3431135] ArrayIndexOutOfBoundsException at TIntIntHashMap.keys
■ [3432212] entrySet() does not unwrap in cased of no_entry_value or no_entrykey
■ [3432175] Decorator entrySet() -keySet() impl - Minor problem with the way null keys are unwarped
Download Link: http://sourceforge.net/projects/trove4j ... p/download

Re: Javolution/Trove/Java

Posted: Fri Jun 15, 2012 9:00 pm
by MELERIX
Trove 3.0.3 has been released. This release is a minor bugfix release recommended for all users.
Bugs Fixed:
- [3445639] ArrayIndexOutOfBoundsException from TIntHashSet.retainAll
- [3460395] no_entry_value is set always to 0 in map default constructor
Download Link: http://sourceforge.net/projects/trove4j ... ove/3.0.3/

Re: Javolution/Trove/Java

Posted: Wed Aug 08, 2012 2:21 am
by Ahmed
MELERIX wrote:Trove 3.0.3 has been released. This release is a minor bugfix release recommended for all users.
Bugs Fixed:
- [3445639] ArrayIndexOutOfBoundsException from TIntHashSet.retainAll
- [3460395] no_entry_value is set always to 0 in map default constructor
Download Link: http://sourceforge.net/projects/trove4j ... ove/3.0.3/
Anyone using 3.0.3 have any issues? or should we update it in our lib?

Re: Javolution/Trove/Java

Posted: Wed Aug 08, 2012 4:17 am
by MELERIX
3.0.3 give some errors with L2J (you can see them in eclipse), I guess is due some parts of code require update.

Re: Javolution/Trove/Java

Posted: Wed Aug 08, 2012 4:27 am
by Ahmed
MELERIX wrote:3.0.3 give some errors with L2J (you can see them in eclipse), I guess is due some parts of code require update.
Thanks will look into it and keep you posted :)

Trove 3.0.2
values
public V[] values()
  • Returns the values of the map as an array of int values. Changes to the array of values will not be reflected in the map nor vice-versa.

Specified by:
  1. values in interface TIntObjectMap<V>
Returns:
  • the values of the map as an array of int values.
Trove 3.0.3
values
public java.lang.Object[] values()
  • Returns the values of the map as an Object array. Note that the array returned is typed as an Object[] and may not be cast to a more specific type. See #values(V[]) for a version which allows specifically typed arrays. Changes to the array of values will not be reflected in the map nor vice-versa.

Specified by:
  1. values in interface TIntObjectMap<V>
Returns:
  • the values of the map as an array of int values.

Re: Javolution/Trove/Java

Posted: Tue Aug 14, 2012 7:51 am
by UnAfraid
They seriously don't have what todo..