-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Matthew Toseland a ?crit :
> 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...

Done in #21783
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIovgEmY5qNqKdYw0RAsgDAJ9IiBGJc7bFi+BSUIxC1ZQXHR+I8QCbBrJL
32zU3XASk6bjtbW008PQClE=
=WcYJ
-----END PGP SIGNATURE-----

Reply via email to