Commit cfe07ebe authored by Michel Pelletier's avatar Michel Pelletier

Undid optimization that eats up all your hardrive space and kills your

children.
parent 5a8fc050
...@@ -90,7 +90,6 @@ from SearchIndex import UnIndex, UnTextIndex, Query ...@@ -90,7 +90,6 @@ from SearchIndex import UnIndex, UnTextIndex, Query
import regex, pdb import regex, pdb
import Record import Record
from Missing import MV from Missing import MV
from DateTime import DateTime
from Lazy import LazyMap, LazyFilter, LazyCat from Lazy import LazyMap, LazyFilter, LazyCat
...@@ -146,7 +145,6 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -146,7 +145,6 @@ class Catalog(Persistent, Acquisition.Implicit):
self.data = BTree.BTree() # mapping of rid to meta_data self.data = BTree.BTree() # mapping of rid to meta_data
self.uids = OIBTree.BTree() # mapping of uid to rid self.uids = OIBTree.BTree() # mapping of uid to rid
self.paths = IOBTree.BTree() # mapping of rid to uid self.paths = IOBTree.BTree() # mapping of rid to uid
self.dates = IOBTree.BTree() # mapping of rid to date indexed
if brains is not None: if brains is not None:
self._v_brains = brains self._v_brains = brains
...@@ -191,7 +189,7 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -191,7 +189,7 @@ class Catalog(Persistent, Acquisition.Implicit):
def addColumn(self, name, default_value=None): def addColumn(self, name, default_value=None):
""" adds a row to the meta_data schema """ """ adds a row to the meta data schema """
schema = self.schema schema = self.schema
names = list(self.names) names = list(self.names)
...@@ -206,8 +204,6 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -206,8 +204,6 @@ class Catalog(Persistent, Acquisition.Implicit):
schema[name] = 0 schema[name] = 0
names.append(name) names.append(name)
if default_value is None or default_value == '': if default_value is None or default_value == '':
default_value = MV default_value = MV
...@@ -225,7 +221,7 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -225,7 +221,7 @@ class Catalog(Persistent, Acquisition.Implicit):
def delColumn(self, name): def delColumn(self, name):
""" deletes a row from the meta_data schema """ """ deletes a row from the meta data schema """
names = list(self.names) names = list(self.names)
_index = names.index(name) _index = names.index(name)
...@@ -279,9 +275,15 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -279,9 +275,15 @@ class Catalog(Persistent, Acquisition.Implicit):
# the cataloging API # the cataloging API
def catalogObject(self, object, uid): def catalogObject(self, object, uid):
""" adds an object to the Catalog """
Adds an object to the Catalog by iteratively applying it
all indexes.
'object' is the object to be cataloged 'object' is the object to be cataloged
'uid' is the unique Catalog identifier for this object 'uid' is the unique Catalog identifier for this object
""" """
data = self.data data = self.data
...@@ -307,11 +309,15 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -307,11 +309,15 @@ class Catalog(Persistent, Acquisition.Implicit):
def uncatalogObject(self, uid): def uncatalogObject(self, uid):
""" Uncatalog and object from the Catalog. """
and 'uid' is a unique Catalog identifier
Uncatalog and object from the Catalog. and 'uid' is a unique
Catalog identifier
Note, the uid must be the same as when the object was Note, the uid must be the same as when the object was
cataloged, otherwise it will not get removed from the catalog """ cataloged, otherwise it will not get removed from the catalog
"""
if uid not in self.uids.keys(): if uid not in self.uids.keys():
'no object with uid %s' % uid 'no object with uid %s' % uid
...@@ -344,6 +350,13 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -344,6 +350,13 @@ class Catalog(Persistent, Acquisition.Implicit):
""" return unique values for FieldIndex name """ """ return unique values for FieldIndex name """
return self.indexes[name].uniqueValues() return self.indexes[name].uniqueValues()
def hasuid(self, uid):
""" return the rid if catalog contains an object with uid """
if uid in self.uids.keys():
return self.uids[uid]
else:
return None
def recordify(self, object): def recordify(self, object):
""" turns an object into a record tuple """ """ turns an object into a record tuple """
...@@ -407,7 +420,8 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -407,7 +420,8 @@ class Catalog(Persistent, Acquisition.Implicit):
for k, intset in sort_index.items(): for k, intset in sort_index.items():
__traceback_info__=intset, intset.__class__ __traceback_info__=intset, intset.__class__
intset=intset.intersection(rs) intset=intset.intersection(rs)
if intset: append((k,LazyMap(self.__getitem__, intset))) if intset:
append((k,LazyMap(self.__getitem__, intset)))
return used return used
......
...@@ -88,6 +88,7 @@ from Globals import HTMLFile, MessageDialog ...@@ -88,6 +88,7 @@ from Globals import HTMLFile, MessageDialog
import Globals import Globals
from OFS.Folder import Folder from OFS.Folder import Folder
from OFS.FindSupport import FindSupport from OFS.FindSupport import FindSupport
from DateTime import DateTime
from SearchIndex import Query from SearchIndex import Query
import string, regex, urlparse, urllib, os, sys import string, regex, urlparse, urllib, os, sys
import Products import Products
...@@ -96,6 +97,7 @@ from Persistence import Persistent ...@@ -96,6 +97,7 @@ from Persistence import Persistent
from Catalog import Catalog, orify from Catalog import Catalog, orify
import pdb, traceback import pdb, traceback
from SearchIndex import UnIndex, UnTextIndex from SearchIndex import UnIndex, UnTextIndex
import IOBTree
manage_addZCatalogForm=HTMLFile('addZCatalog',globals()) manage_addZCatalogForm=HTMLFile('addZCatalog',globals())
...@@ -170,6 +172,9 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit): ...@@ -170,6 +172,9 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
self._catalog.addColumn('bobobase_modification_time') self._catalog.addColumn('bobobase_modification_time')
self._catalog.addIndex('bobobase_modification_time', 'FieldIndex') self._catalog.addIndex('bobobase_modification_time', 'FieldIndex')
self._catalog.addColumn('summary')
self._catalog.addIndex('PrincipiaSearchSource', 'TextIndex')
def manage_catalogObject(self, REQUEST, urls=None, blah=None): def manage_catalogObject(self, REQUEST, urls=None, blah=None):
""" index all Zope objects that 'urls' point to """ """ index all Zope objects that 'urls' point to """
...@@ -302,11 +307,13 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit): ...@@ -302,11 +307,13 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
def catalog_object(self, obj, uid): def catalog_object(self, obj, uid):
""" wrapper around catalog """ """ wrapper around catalog """
self._catalog.catalogObject(obj, uid) self._catalog.catalogObject(obj, uid)
def uncatalog_object(self, uid): def uncatalog_object(self, uid):
""" wrapper around catalog """ """ wrapper around catalog """
self._catalog.uncatalogObject(uid) self._catalog.uncatalogObject(uid)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment