Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
67235350
Commit
67235350
authored
Sep 16, 1999
by
Michel Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added KeywordIndexes, and optimized subtransaction processing to kick
the cache
parent
09576b0b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
5 deletions
+69
-5
lib/python/SearchIndex/UnKeywordIndex.py
lib/python/SearchIndex/UnKeywordIndex.py
+59
-0
lib/python/SearchIndex/UnTextIndex.py
lib/python/SearchIndex/UnTextIndex.py
+10
-5
No files found.
lib/python/SearchIndex/UnKeywordIndex.py
0 → 100644
View file @
67235350
from
UnIndex
import
UnIndex
,
MV
,
intSet
from
types
import
ListType
,
TupleType
class
UnKeywordIndex
(
UnIndex
):
"""
Like an UnIndex only it indexs sequences of items
Searches match any keyword.
"""
def
index_object
(
self
,
i
,
obj
,
threshold
=
None
):
""" index an object 'obj' with integer id 'i'"""
index
=
self
.
_index
unindex
=
self
.
_unindex
id
=
self
.
id
try
:
kws
=
getattr
(
obj
,
id
)
if
callable
(
kws
):
kws
=
kws
()
except
:
kws
=
[
MV
]
# index each item in the sequence
for
kw
in
kws
:
set
=
index
.
get
(
kw
)
if
set
is
None
:
index
[
kw
]
=
set
=
intSet
()
set
.
insert
(
i
)
unindex
[
i
]
=
kws
self
.
_index
=
index
self
.
_unindex
=
unindex
return
1
def
unindex_object
(
self
,
i
):
""" Unindex the object with integer id 'i' """
index
=
self
.
_index
unindex
=
self
.
_unindex
kws
=
unindex
[
i
]
if
kws
is
None
:
return
None
for
kw
in
kws
:
set
=
index
.
get
(
kw
)
if
set
is
not
None
:
set
.
remove
(
i
)
del
unindex
[
i
]
self
.
_index
=
index
self
.
_unindex
=
unindex
lib/python/SearchIndex/UnTextIndex.py
View file @
67235350
...
@@ -87,7 +87,7 @@
...
@@ -87,7 +87,7 @@
"""
"""
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
10
$'
[
11
:
-
2
]
from
Globals
import
Persistent
from
Globals
import
Persistent
import
BTree
,
IIBTree
,
IOBTree
,
OIBTree
import
BTree
,
IIBTree
,
IOBTree
,
OIBTree
...
@@ -162,7 +162,7 @@ class UnTextIndex(Persistent):
...
@@ -162,7 +162,7 @@ class UnTextIndex(Persistent):
def
index_object
(
self
,
i
,
obj
,
threshold
=
None
,
tupleType
=
type
(()),
def
index_object
(
self
,
i
,
obj
,
threshold
=
None
,
tupleType
=
type
(()),
dictType
=
type
({}),
callable
=
callable
):
dictType
=
type
({}),
strType
=
type
(
""
),
callable
=
callable
):
""" Please document """
""" Please document """
...
@@ -199,9 +199,14 @@ class UnTextIndex(Persistent):
...
@@ -199,9 +199,14 @@ class UnTextIndex(Persistent):
times
=
0
times
=
0
for
word
,
score
in
d
.
items
():
for
word
,
score
in
d
.
items
():
if
times
>
threshold
:
if
threshold
is
not
None
:
get_transaction
().
commit
(
1
)
if
times
>
threshold
:
times
=
0
# commit a subtransaction
get_transaction
().
commit
(
1
)
# kick the cache
self
.
_p_jar
.
cacheFullSweep
(
1
)
times
=
0
r
=
get
(
word
)
r
=
get
(
word
)
if
r
is
not
None
:
if
r
is
not
None
:
r
=
index
[
word
]
r
=
index
[
word
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment