Skip to content

Commit 3b441f5

Browse files
author
Johannes Gijsbers
committed
Some cleanup:
* indexer_rdbms.Indexer now subclasses from indexer_common.Indexer instead of indexer_dbm.Indexer * rdbms_common doesn't call save_index anymore * so we can remove save_index from indexer_rdbms and back_tsearch2 * indexer_rdbms.Indexer.rollback() wasn't used at all, so remove it * move is_stopword code to indexer_common
1 parent 9ebe063 commit 3b441f5

File tree

5 files changed

+20
-34
lines changed

5 files changed

+20
-34
lines changed

roundup/backends/back_tsearch2.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: back_tsearch2.py,v 1.8 2005-01-08 11:25:23 jlgijsbers Exp $
1+
#$Id: back_tsearch2.py,v 1.9 2005-01-08 16:16:59 jlgijsbers Exp $
22

33
# Note: this backend is EXPERIMENTAL. Do not use if you value your data.
44
import re
@@ -134,9 +134,6 @@ def tsearchQuery(self, classname, search_terms):
134134
# These only exist to satisfy the interface that's expected from indexers.
135135
def force_reindex(self):
136136
pass
137-
138-
def save_index(self):
139-
pass
140137

141138
def add_text(self, identifier, text, mime_type=None):
142139
pass

roundup/backends/indexer_common.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
#$Id: indexer_common.py,v 1.3 2005-01-08 11:25:23 jlgijsbers Exp $
1+
#$Id: indexer_common.py,v 1.4 2005-01-08 16:16:59 jlgijsbers Exp $
22
import re
33

44
from roundup import hyperdb
55

6+
stopwords = [
7+
"A", "AND", "ARE", "AS", "AT", "BE", "BUT", "BY",
8+
"FOR", "IF", "IN", "INTO", "IS", "IT",
9+
"NO", "NOT", "OF", "ON", "OR", "SUCH",
10+
"THAT", "THE", "THEIR", "THEN", "THERE", "THESE",
11+
"THEY", "THIS", "TO", "WAS", "WILL", "WITH"
12+
]
13+
14+
is_stopword = {}
15+
for word in stopwords:
16+
is_stopword[word] = None
17+
is_stopword = is_stopword.has_key
18+
619
def _isLink(propclass):
720
return (isinstance(propclass, hyperdb.Link) or
821
isinstance(propclass, hyperdb.Multilink))

roundup/backends/indexer_dbm.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# that promote freedom, but obviously am giving up any rights
1515
# to compel such.
1616
#
17-
#$Id: indexer_dbm.py,v 1.4 2005-01-05 22:14:21 jlgijsbers Exp $
17+
#$Id: indexer_dbm.py,v 1.5 2005-01-08 16:16:59 jlgijsbers Exp $
1818
'''This module provides an indexer class, RoundupIndexer, that stores text
1919
indices in a roundup instance. This class makes searching the content of
2020
messages, string properties and text files possible.
@@ -23,19 +23,7 @@
2323

2424
import os, shutil, re, mimetypes, marshal, zlib, errno
2525
from roundup.hyperdb import Link, Multilink
26-
from roundup.backends.indexer_common import Indexer
27-
28-
stopwords = [
29-
"A", "AND", "ARE", "AS", "AT", "BE", "BUT", "BY",
30-
"FOR", "IF", "IN", "INTO", "IS", "IT",
31-
"NO", "NOT", "OF", "ON", "OR", "SUCH",
32-
"THAT", "THE", "THEIR", "THEN", "THERE", "THESE",
33-
"THEY", "THIS", "TO", "WAS", "WILL", "WITH"
34-
]
35-
is_stopword = {}
36-
for word in stopwords:
37-
is_stopword[word] = None
38-
is_stopword = is_stopword.has_key
26+
from roundup.backends.indexer_common import Indexer, is_stopword
3927

4028
class Indexer(Indexer):
4129
'''Indexes information from roundup's hyperdb to allow efficient

roundup/backends/indexer_rdbms.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#$Id: indexer_rdbms.py,v 1.7 2005-01-08 11:25:23 jlgijsbers Exp $
1+
#$Id: indexer_rdbms.py,v 1.8 2005-01-08 16:16:59 jlgijsbers Exp $
22
''' This implements the full-text indexer over two RDBMS tables. The first
33
is a mapping of words to occurance IDs. The second maps the IDs to (Class,
44
propname, itemid) instances.
55
'''
66
import re
77

8-
from indexer_dbm import Indexer, is_stopword
8+
from indexer_common import Indexer, is_stopword
99

1010
class Indexer(Indexer):
1111
def __init__(self, db):
@@ -129,11 +129,3 @@ def find(self, wordlist):
129129

130130
return self.db.cursor.fetchall()
131131

132-
def save_index(self):
133-
# the normal RDBMS backend transaction mechanisms will handle this
134-
pass
135-
136-
def rollback(self):
137-
# the normal RDBMS backend transaction mechanisms will handle this
138-
pass
139-

roundup/backends/rdbms_common.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.145 2005-01-06 17:35:34 a1s Exp $
1+
# $Id: rdbms_common.py,v 1.146 2005-01-08 16:16:59 jlgijsbers Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -320,7 +320,6 @@ def reindex(self, classname=None):
320320
for klass in classes:
321321
for nodeid in klass.list():
322322
klass.index(nodeid)
323-
self.indexer.save_index()
324323

325324
hyperdb_to_sql_datatypes = {
326325
hyperdb.String : 'TEXT',
@@ -1176,9 +1175,6 @@ def commit(self):
11761175
for method, args in self.transactions:
11771176
method(*args)
11781177

1179-
# save the indexer state
1180-
self.indexer.save_index()
1181-
11821178
# clear out the transactions
11831179
self.transactions = []
11841180

0 commit comments

Comments
 (0)