Commit 1cd36a0c authored by Hanno Schlichting's avatar Hanno Schlichting

Enhanced the internals of the DateRangeIndex based on an idea from...

Enhanced the internals of the DateRangeIndex based on an idea from experimental.daterangeindexoptimisations, thanks to Matt Hamilton.
parent cc43a699
...@@ -24,6 +24,9 @@ Features Added ...@@ -24,6 +24,9 @@ Features Added
- zope.session = 3.9.2 - zope.session = 3.9.2
- zope.tal = 3.5.2 - zope.tal = 3.5.2
- Enhanced the internals of the DateRangeIndex based on an idea from
experimental.daterangeindexoptimisations, thanks to Matt Hamilton.
- Updated the default value for ``management_page_charset`` from iso-8859-1 - Updated the default value for ``management_page_charset`` from iso-8859-1
to the nowadays more standard utf-8. to the nowadays more standard utf-8.
......
...@@ -316,26 +316,41 @@ class DateRangeIndex(UnIndex): ...@@ -316,26 +316,41 @@ class DateRangeIndex(UnIndex):
set = self._until_only.get( until, None ) set = self._until_only.get( until, None )
if set is None: if set is None:
set = self._until_only[ until ] = IISet() # XXX: Store an int? self._until_only[ until ] = documentId
else:
if isinstance(set, int):
set = self._until_only[ until ] = IISet((set, documentId))
else:
set.insert( documentId ) set.insert( documentId )
elif until is None: elif until is None:
set = self._since_only.get( since, None ) set = self._since_only.get( since, None )
if set is None: if set is None:
set = self._since_only[ since ] = IISet() # XXX: Store an int? self._since_only[ since ] = documentId
else:
if isinstance(set, int):
set = self._since_only[ since ] = IISet((set, documentId))
else:
set.insert( documentId ) set.insert( documentId )
else: else:
set = self._since.get( since, None ) set = self._since.get( since, None )
if set is None: if set is None:
set = self._since[ since ] = IISet() # XXX: Store an int? self._since[ since ] = documentId
else:
if isinstance(set, int):
set = self._since[ since ] = IISet((set, documentId))
else:
set.insert( documentId ) set.insert( documentId )
set = self._until.get( until, None ) set = self._until.get( until, None )
if set is None: if set is None:
set = self._until[ until ] = IISet() # XXX: Store an int? self._until[ until ] = documentId
else:
if isinstance(set, int):
set = self._until[ until ] = IISet((set, documentId))
else:
set.insert( documentId ) set.insert( documentId )
def _removeForwardIndexEntry( self, since, until, documentId ): def _removeForwardIndexEntry( self, since, until, documentId ):
...@@ -352,6 +367,9 @@ class DateRangeIndex(UnIndex): ...@@ -352,6 +367,9 @@ class DateRangeIndex(UnIndex):
set = self._until_only.get( until, None ) set = self._until_only.get( until, None )
if set is not None: if set is not None:
if isinstance(set, int):
del self._until_only[until]
else:
set.remove( documentId ) set.remove( documentId )
if not set: if not set:
...@@ -362,6 +380,9 @@ class DateRangeIndex(UnIndex): ...@@ -362,6 +380,9 @@ class DateRangeIndex(UnIndex):
set = self._since_only.get( since, None ) set = self._since_only.get( since, None )
if set is not None: if set is not None:
if isinstance(set, int):
del self._since_only[ since ]
else:
set.remove( documentId ) set.remove( documentId )
if not set: if not set:
...@@ -371,6 +392,10 @@ class DateRangeIndex(UnIndex): ...@@ -371,6 +392,10 @@ class DateRangeIndex(UnIndex):
set = self._since.get( since, None ) set = self._since.get( since, None )
if set is not None: if set is not None:
if isinstance(set, int):
del self._since[ since ]
else:
set.remove( documentId ) set.remove( documentId )
if not set: if not set:
...@@ -378,6 +403,10 @@ class DateRangeIndex(UnIndex): ...@@ -378,6 +403,10 @@ class DateRangeIndex(UnIndex):
set = self._until.get( until, None ) set = self._until.get( until, None )
if set is not None: if set is not None:
if isinstance(set, int):
del self._until[ until ]
else:
set.remove( documentId ) set.remove( documentId )
if not set: if not set:
......
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