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 this: 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. hth, -Casey ----- Original Message ----- From: "Andy McKay" <andy@agmweb.ca> To: "Casey Duncan" <casey@zope.com>; <zope-dev@zope.org> 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 adding 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, see if anyone else wants it.
Now that begs the question, If you already know the path to the object you 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 accessing the object. In fact I'd be willing to be its slower, especially since you 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 many 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 http://www.agmweb.ca
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )