----- Original Message -----
From: "Andrus Adamchik" <andru..bjectstyle.org>
To: <cayenne-deve..bjectstyle.org>
Sent: Thursday, October 23, 2003 6:35 PM
Subject: Re: Does Cayenne handle binary primary keys (Sybase) in
relationships?
> Moving this to devel...
>
> Andriy,
>
> As you may have noticed I relied on HashCodeBuilder in the new
> implementation . The main reason was to have a generic implementation
> for all kinds of values in the map... Those can realistically be
> Strings, Numbers, BigDecimal, byte[], Date (yikes!), etc. Do you think
> it is worthwhile revisiting this? BTW, since ObjectId is immutable, I
> am caching a hashCode computed on demand during the first call to
> "hashCode()"
>
> Andrus
>
HashCodeBuilder works OK, to my belief. In fact, the only really important
requirement to a hash key generation algorithm is producing values
distributed as uniformly as possible. This directly affects the average size
of a bucket and, therefore, the access time. Without statistical
measurements it is quite difficult to judge the actual quality of the
HashCodeBuilder application, especially in the case of diverse original
primary key types and values. There might be another interesting approach
(hard to say whether it is good and worth any trouble, but still...). One
could generate artificial very well distributed keys used as the base for
DataObject IDs in ObjectStore (there are algorithms to generate good String
keys in the community, TheServerSide.com once had extensive discussions on
the matter, I believe, also Apache Commons Lang seems to already have ID
generators in the nightly builds, so forth). Such keys would be excellent to
use in any hash map implemention and easily benchmarked. They would be all
one needs to identify the objects in memory or in the distributed system.
And the only time one could want to know which key corresponds to the actual
primary key value is when there is a need to update the existing objects
from the database. For this purpose the table should be maintained where by
DbEntity and primary key value the registered keys of the objects in memory
could be found. From a certain point of view it makes for the purer ObjectId
concept, reducing the significance of the db primary keys inside the
application. Just a thought I wanted to share...
Andriy.
This archive was generated by hypermail 2.0.0 : Thu Oct 23 2003 - 15:58:53 EDT