A
Alfonso Morra
I am implementing an application which requires the storage of a large
number of items in a cache.
I have 3-tuple key reprented by a struct, as well as an n-tuple (n is
fixed) dataset, also represented by a struct. At run time, I will no
exactly the number of items in the hashtable (I will have populated it
myself by loading the data from a database). During the course of the
applications lifetime, I will retrieve data in the hashtable and update it.
My question about the suitability of using a hashtable (as opposed to a
simple array of structs) is this:
The table will be 100% full - and I know that hashtables begin to suffer
a performance hit once they get to about 70% filled. (or maybe I should
create the hashtable to be able to hold a larger number of items than I
know I will need? - The number is fixed and does not vary after initial
population).
If my key was a single item, then it would be relatively trivial to
implement the cache as an array of structs. However, The are three items
that uniquely identify a record (this 3-tuple actually form the
composite primary key loaded from the db schema).
I would much prefer to implement this as a hashtable, as I can easily
use the composite lookup key. I have also chosen the keys to be
integers, to further speed the computation of the has key. I would
appreciate any feedback on this choice.
Thanks
number of items in a cache.
I have 3-tuple key reprented by a struct, as well as an n-tuple (n is
fixed) dataset, also represented by a struct. At run time, I will no
exactly the number of items in the hashtable (I will have populated it
myself by loading the data from a database). During the course of the
applications lifetime, I will retrieve data in the hashtable and update it.
My question about the suitability of using a hashtable (as opposed to a
simple array of structs) is this:
The table will be 100% full - and I know that hashtables begin to suffer
a performance hit once they get to about 70% filled. (or maybe I should
create the hashtable to be able to hold a larger number of items than I
know I will need? - The number is fixed and does not vary after initial
population).
If my key was a single item, then it would be relatively trivial to
implement the cache as an array of structs. However, The are three items
that uniquely identify a record (this 3-tuple actually form the
composite primary key loaded from the db schema).
I would much prefer to implement this as a hashtable, as I can easily
use the composite lookup key. I have also chosen the keys to be
integers, to further speed the computation of the has key. I would
appreciate any feedback on this choice.
Thanks