[Commits] (twl) Batch query notifications to reduce performance
impact
commits at osafoundation.org
commits at osafoundation.org
Tue Aug 24 10:48:13 PDT 2004
Commit by: twl
Modified files:
chandler/parcels/osaf/contentmodel/ItemCollection.py 1.8 1.9
chandler/parcels/osaf/contentmodel/Query.py 1.4 1.5
chandler/repository/query/Query.py 1.2 1.3
Log message:
Batch query notifications to reduce performance impact
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/contentmodel/ItemCollection.py.diff?r1=text&tr1=1.8&r2=text&tr2=1.9
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/contentmodel/Query.py.diff?r1=text&tr1=1.4&r2=text&tr2=1.5
http://cvs.osafoundation.org/index.cgi/chandler/repository/query/Query.py.diff?r1=text&tr1=1.2&r2=text&tr2=1.3
Index: chandler/parcels/osaf/contentmodel/ItemCollection.py
diff -u chandler/parcels/osaf/contentmodel/ItemCollection.py:1.8 chandler/parcels/osaf/contentmodel/ItemCollection.py:1.9
--- chandler/parcels/osaf/contentmodel/ItemCollection.py:1.8 Mon Aug 23 19:09:24 2004
+++ chandler/parcels/osaf/contentmodel/ItemCollection.py Tue Aug 24 10:48:11 2004
@@ -1,5 +1,5 @@
-__revision__ = "$Revision: 1.8 $"
-__date__ = "$Date: 2004/08/24 02:09:24 $"
+__revision__ = "$Revision: 1.9 $"
+__date__ = "$Date: 2004/08/24 17:48:11 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -24,16 +24,19 @@
# our result cache
self.results = []
- self.onItemLoad()
+ self.__subscribe()
def onItemLoad(self):
log.debug("ItemCollection<%s>.onItemLoad:" % (self.itsUUID))
+ self.__subscribe()
+ # refresh the result cache
+ self.__refresh()
+
+ def __subscribe(self):
# subscribe to query_changed notifications incase our query changes
events = [Globals.repository.findPath('//parcels/osaf/framework/rule_changed')]
Globals.notificationManager.Subscribe(events, self.itsUUID, self._queryChangedCallback)
- # refresh the result cache
- self.__refresh()
def onItemUnload(self):
Globals.notificationManager.Unsubscribe(self.itsUUID)
Index: chandler/parcels/osaf/contentmodel/Query.py
diff -u chandler/parcels/osaf/contentmodel/Query.py:1.4 chandler/parcels/osaf/contentmodel/Query.py:1.5
--- chandler/parcels/osaf/contentmodel/Query.py:1.4 Mon Aug 23 19:09:24 2004
+++ chandler/parcels/osaf/contentmodel/Query.py Tue Aug 24 10:48:11 2004
@@ -4,7 +4,7 @@
import logging
log = logging.getLogger("ContentQuery")
-log.setLevel(logging.INFO)
+log.setLevel(logging.DEBUG)
class Query(Item.Item):
@@ -52,9 +52,9 @@
if name == 'data':
log.debug("ContentQuery<%s>.setAttribute: setting 'data' to %s" % (self.itsUUID, value))
self.__query.queryString = value
- #self.__changed = True @@@ should be able to do this but need some fixes in repo Query
+ self.__changed = True # @@@ should be able to do this but need some fixes in repo Query
# so for now do refresh
- self.__refresh()
+# self.__refresh()
def __iter__(self):
"""
@@ -72,7 +72,7 @@
"""
The notification callback handler for the repository level query's change notifications
"""
- log.debug("ContentQuery<%s>.onQueryChange: %s:%s" % (self.itsUUID, notification.data['query'], notification.data['action']))
+ log.debug("ContentQuery<%s>.onQueryChange: %s %s:%s" % (self.itsUUID, self.__query.queryString, notification.data['query'], notification.data['action']))
self.__changed = True
self.__dirty()
Index: chandler/repository/query/Query.py
diff -u chandler/repository/query/Query.py:1.2 chandler/repository/query/Query.py:1.3
--- chandler/repository/query/Query.py:1.2 Mon Aug 23 12:42:14 2004
+++ chandler/repository/query/Query.py Tue Aug 24 10:48:11 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.2 $"
-__date__ = "$Date: 2004/08/23 19:42:14 $"
+__revision__ = "$Revision: 1.3 $"
+__date__ = "$Date: 2004/08/24 17:48:11 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -54,6 +54,7 @@
tools.timing.begin("Analyzing query")
self._logical_plan = self.__analyze(self.ast)
tools.timing.end("Analyzing query")
+# tools.timing.results()
def subscribe(self):
"""
@@ -81,9 +82,11 @@
@type notification: string
"""
log.debug("RepoQuery.queryCallback for %s" % self.queryString)
- if self.queryString is None:
+ if self._logical_plan is None and self.queryString is not None:
+ self.execute()
+ elif self.queryString is None:
return
- #@@@ should batch notifications here
+ changed = False
for uuid, reason, kwds in changes:
i = self.__rep.findUUID(uuid)
#@@@ there's a big problem with this if there are paths through multiple items -- we're going to need something fairly sophisticated here.
@@ -94,12 +97,15 @@
else:
rightKind = i.itsKind is self._kind
if rightKind:
+ changed = True
+ #@@@ accumulate batch results
if eval(self._predicate):
action = "entered"
else:
action = "exited"
- log.debug("RepoQuery.queryCallback: %s %s query result" % (uuid, action))
- self.__rep.findPath('//parcels/osaf/framework/query_changed').Post( {'query' : i.itsUUID, 'action': action} )
+ if changed:
+ log.debug("RepoQuery.queryCallback: %s %s query result" % (uuid, action))
+ self.__rep.findPath('//parcels/osaf/framework/query_changed').Post( {'query' : i.itsUUID, 'action': action} )
def __iter__(self):
"""
@@ -219,6 +225,7 @@
collection = lookup_source(iter_source)
closure = compile_predicate(predicate)
+ self._predicate = closure
log.debug("analyze_for: collection = %s, closure = %s" % (collection, closure))
More information about the Commits
mailing list