Commit a93df48e authored by Christopher Petrilli's avatar Christopher Petrilli

Merge of lexicon cleanup and text index merge along with some misc stuff.

parent 41eb6fe8
...@@ -101,6 +101,7 @@ from zLOG import LOG, ERROR ...@@ -101,6 +101,7 @@ from zLOG import LOG, ERROR
from Lazy import LazyMap, LazyFilter, LazyCat from Lazy import LazyMap, LazyFilter, LazyCat
from CatalogBrains import AbstractCatalogBrain, NoBrainer from CatalogBrains import AbstractCatalogBrain, NoBrainer
import time
class KWMultiMapping(MultiMapping): class KWMultiMapping(MultiMapping):
def has_key(self, name): def has_key(self, name):
try: try:
...@@ -347,18 +348,30 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -347,18 +348,30 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
data = self.data data = self.data
if self.uids.has_key(uid): if self.uids.has_key(uid):
i = self.uids[uid] index = self.uids[uid]
elif data: elif data:
i = data.keys()[-1] + 1 # find the next available unique id index = data.keys()[-1] + 1 # find the next available unique id
self.uids[uid] = index
self.paths[index] = uid
else: else:
i = 0 index = 0
self.uids[uid] = index
self.paths[index] = uid
self.uids[uid] = i
self.paths[i] = uid
# meta_data is stored as a tuple for efficiency # meta_data is stored as a tuple for efficiency
data[i] = self.recordify(object) newDataRecord = self.recordify(object)
oldDataRecord = data.get(index, None)
# Now we need to compare the tuples before we update them!
if oldDataRecord is not None:
for i in range(len(newDataRecord)):
if newDataRecord[i] != oldDataRecord[i]:
data[index] = newDataRecord
break
else:
data[index] = newDataRecord
total = 0 total = 0
for x in self.indexes.values(): for x in self.indexes.values():
## tricky! indexes need to acquire now, and because they ## tricky! indexes need to acquire now, and because they
...@@ -366,7 +379,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -366,7 +379,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
## acquisition doesn't kick in, we must explicitly wrap! ## acquisition doesn't kick in, we must explicitly wrap!
x = x.__of__(self) x = x.__of__(self)
if hasattr(x, 'index_object'): if hasattr(x, 'index_object'):
blah = x.index_object(i, object, threshold) blah = x.index_object(index, object, threshold)
total = total + blah total = total + blah
else: else:
LOG('Catalog', ERROR, ('catalogObject was passed ' LOG('Catalog', ERROR, ('catalogObject was passed '
...@@ -480,11 +493,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -480,11 +493,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
handling intSets and IIBuckets. handling intSets and IIBuckets.
""" """
## import pdb
## pdb.set_trace()
## I use this so much I'm just leaving it commented out -michel
rs=None rs=None
data=self.data data=self.data
...@@ -570,8 +578,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -570,8 +578,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
type(''): Query.String, type(''): Query.String,
}, **kw): }, **kw):
# Get search arguments: # Get search arguments:
if REQUEST is None and not kw: if REQUEST is None and not kw:
try: REQUEST=self.REQUEST try: REQUEST=self.REQUEST
...@@ -605,7 +611,8 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -605,7 +611,8 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
# Perform searches with indexes and sort_index # Perform searches with indexes and sort_index
r=[] r=[]
used=self._indexedSearch(kw, sort_index, r.append, used) used=self._indexedSearch(kw, sort_index, r.append, used)
if not r: return LazyCat(r) if not r:
return LazyCat(r)
# Sort/merge sub-results # Sort/merge sub-results
if len(r)==1: if len(r)==1:
......
...@@ -318,8 +318,11 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -318,8 +318,11 @@ class ZCatalog(Folder, Persistent, Implicit):
elapse = time.time() - elapse elapse = time.time() - elapse
c_elapse = time.clock() - c_elapse c_elapse = time.clock() - c_elapse
RESPONSE.redirect(URL1 + '/manage_catalogView?manage_tabs_message=' + RESPONSE.redirect(URL1 +
urllib.quote('Catalog Updated<br>Total time: %s<br>Total CPU time: %s' % (`elapse`, `c_elapse`))) '/manage_catalogAdvanced?manage_tabs_message=' +
urllib.quote('Catalog Updated<br>'
'Total time: %s<br>'
'Total CPU time: %s' % (`elapse`, `c_elapse`)))
def manage_catalogClear(self, REQUEST=None, RESPONSE=None, URL1=None): def manage_catalogClear(self, REQUEST=None, RESPONSE=None, URL1=None):
...@@ -327,7 +330,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -327,7 +330,7 @@ class ZCatalog(Folder, Persistent, Implicit):
self._catalog.clear() self._catalog.clear()
if REQUEST and RESPONSE: if REQUEST and RESPONSE:
RESPONSE.redirect(URL1 + '/manage_catalogView?manage_tabs_message=Catalog%20Cleared') RESPONSE.redirect(URL1 + '/manage_catalogAdvanced?manage_tabs_message=Catalog%20Cleared')
def manage_catalogFoundItems(self, REQUEST, RESPONSE, URL2, URL1, def manage_catalogFoundItems(self, REQUEST, RESPONSE, URL2, URL1,
......
...@@ -98,7 +98,9 @@ ...@@ -98,7 +98,9 @@
<dtml-if threshold> <dtml-if threshold>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<p class="form-help">The Subtransaction threshold is the number of words the catalog <p class="form-help">The Subtransaction threshold is the number of
objects cataloged
in the context of a single transaction that the catalog
will index before it commits a subtransaction. If this number will index before it commits a subtransaction. If this number
is low, the Catalog will take longer to index but consume less is low, the Catalog will take longer to index but consume less
memory. If this number is higher, the Catalog will index memory. If this number is higher, the Catalog will index
......
...@@ -9,48 +9,58 @@ ...@@ -9,48 +9,58 @@
word(s). word(s).
</p> </p>
<dtml-in words previous size=20 start=query_start > <dtml-in words previous size=20 start=query_start >
<div class="list-nav"> <span class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var previous-sequence-start-number>"> <a href="<dtml-var URL>?query_start=<dtml-var previous-sequence-start-number>">
[Previous <dtml-var previous-sequence-size> entries] [Previous <dtml-var previous-sequence-size> entries]
</a> </a>
</div> </span>
</dtml-in> </dtml-in>
<dtml-in words next size=20 start=query_start > <dtml-in words next size=20 start=query_start >
<div class="list-nav"> <span class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var next-sequence-start-number>"> <a href="<dtml-var URL>?query_start=<dtml-var next-sequence-start-number>">
[Next <dtml-var next-sequence-size> entries] [Next <dtml-var next-sequence-size> entries]
</a> </a>
</div> </span>
</dtml-in> </dtml-in>
<table> <table width="100%" cellspacing="0" cellpadding="2" border="0">
<dtml-in words size=20 start=query_start > <dtml-in words size=20 start=query_start >
<tr valign=top> <dtml-if name="sequence-start">
<td valign="top" align="left"> <tr class="list-header">
<div class="form-text"> <td width="80%" align="left" valign="top">
<dtml-var sequence-item> (<dtml-var sequence-key>) <div class="list-item">Word</div></td>
</div> <td width="20%" align="left" valign="top">
</td> <div class="list-item">Word ID</div></td>
</tr> </tr>
</dtml-in> </dtml-if>
</table> <dtml-if name="sequence-odd"><tr class="row-normal">
<dtml-else><tr class="row-hilite"></dtml-if>
<dtml-in words previous size=20 start=query_start > <td valign="top" align="left">
<div class="list-nav"> <div class="form-text">&dtml-sequence-key;</div>
<a href="<dtml-var URL>?query_start=<dtml-var previous-sequence-start-number>"> </td>
[Previous <dtml-var previous-sequence-size> entries] <td valign="top" align="left">
</a> <div class="form-text">&dtml-sequence-item;</div>
</div> </td>
</dtml-in> </tr>
<dtml-in words next size=20 start=query_start >
<div class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var next-sequence-start-number>">
[Next <dtml-var next-sequence-size> entries]
</a>
</div>
</dtml-in> </dtml-in>
</table>
<dtml-in words previous size=20 start=query_start >
<div class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var previous-sequence-start-number>">
[Previous <dtml-var previous-sequence-size> entries]
</a>
</div>
</dtml-in>
<dtml-in words next size=20 start=query_start >
<div class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var next-sequence-start-number>">
[Next <dtml-var next-sequence-size> entries]
</a>
</div>
</dtml-in>
<dtml-else> <dtml-else>
......
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