Given a method that you could return a catalog record given a path (which is
an obj's ZCatalog uid), then this would be faster then traversal I think
(probably a lot faster). So long as whatever you wanted could be gotten from
metadata. If you call getObject, that actually does traversal anyway.

Here is the code for an external method you could put in a ZCatalog to do

def getRecordFromPath(self, path):
    """Get a catalog record using its path"""
    rid = self._catalog.uids[path]
    return self._catalog[rid]

This same code could be put into a ZCatalog subclass or ZCatalog itself. It
would be a very fast method since it is just two BTree key lookups and
instantiating the brain class.



----- Original Message -----
From: "Andy McKay" <[EMAIL PROTECTED]>
Sent: Saturday, August 17, 2002 8:40 PM
Subject: Re: [Zope-dev] PathIndex doesn't index last part of path

> [snip]
> Hmm ok, I can see those reasons.
> > Unfortunately, ZCatalog does not expose this to the surface but you
> > can write a trivial external method to do it. And I might entertain
> a
> > ZCatalog API to do so if I had a good use case.
> Ah... I think this might be the best idea, I'll add that in to mine and,
> if anyone else wants it.
> > Now that begs the question, If you already know the path to the object
> > are looking for, why are you using the Catalog in the first place? I
> highly
> > doubt doing what you describe below is faster than just directly
> > the object. In fact I'd be willing to be its slower, especially since
> > are searching two indexes to get it.
> Okay so lets assume there is only index I need to search, the path index.
> Wouldn't it be faster to pull that out of the Catalog then do a traverse
> over to the sub object, wake up a bunch of objects to do that and get the
> object? It would be interesting to test that... perhaps Im just leaning on
> the old crutch that its faster to get stuff from the catalog than wake
> objects up. Suppose I have 100 such objects. I would have thought one
> catalog query on one index (even though its a big union) would be faster
> than 100 traversals.
> Anyway since I cant efficiently go and get an individual object from the
> catalog, this is what Im doing now...
> --
>   Andy McKay
>   Agmweb Consulting
> _______________________________________________
> Zope-Dev maillist  -  [EMAIL PROTECTED]
> **  No cross posts or HTML encoding!  **
> (Related lists -
> )

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to