On Wednesday 13 August 2008 12:44, Ian Clarke wrote:
> On Sun, Aug 10, 2008 at 12:44 PM, <batosai at freenetproject.org> wrote:
> > public Identity getIdentityByURI(FreenetURI uri) {
> >
> > + String searched = uri.toString().substring(0,
uri.toString().indexOf("/"));
> > Identity identity = null;
> >
> > // This is ugly, I could not find a request able to find
the good identity
> > ObjectSet<Identity> search =
db.queryByExample(Identity.class);
> > while (search.hasNext()) {
> > Identity id = search.next();
> > -
if(id.getRequestURI().getRoutingKey().equals(uri.getRoutingKey())) {
> > + String found =
id.getRequestURI().toString().substring(0,
id.getRequestURI().toString().indexOf("/"));
> > + if(found.equals(searched)) {
> > identity = id;
> > break;
> > }
>
> Ouch, this could be extremely inefficient, how many Identity objects
> is this going to search through? Isn't there some way to do this that
> will allow db4o to use an index?
The best way I have found is to make a string member and then search for that.
Most obvious ways of doing this result in db4o instantiating every object
itself in order to compare...
>
> Ian.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20080813/5cf1165c/attachment.pgp>