Permalink
Browse files

if switched on yield size as first value in query or lazy

  • Loading branch information...
jensens committed Jul 31, 2012
1 parent e456786 commit 4a4e2578eab46011a09f0a56683da55691ae616f
Showing with 14 additions and 10 deletions.
  1. +14 −10 src/souper/soup.py
View
@@ -90,19 +90,23 @@ def add(self, record):
return record.intid
def query(self, queryobject, sort_index=None, limit=None, sort_type=None,
- reverse=False, names=None):
- result = self.catalog.query(queryobject, sort_index=sort_index,
- limit=limit, sort_type=sort_type,
- reverse=reverse, names=names)
- for iid in result[1]:
+ reverse=False, names=None, with_size=False):
+ size, iids = self.catalog.query(queryobject, sort_index=sort_index,
+ limit=limit, sort_type=sort_type,
+ reverse=reverse, names=names)
+ if with_size:
+ yield size
+ for iid in iids:
yield self.data[iid]
def lazy(self, queryobject, sort_index=None, limit=None, sort_type=None,
- reverse=False, names=None):
- result = self.catalog.query(queryobject, sort_index=sort_index,
- limit=limit, sort_type=sort_type,
- reverse=reverse, names=names)
- for iid in result[1]:
+ reverse=False, names=None, with_size=False):
+ size, iids = self.catalog.query(queryobject, sort_index=sort_index,
+ limit=limit, sort_type=sort_type,
+ reverse=reverse, names=names)
+ if with_size:
+ yield size
+ for iid in iids:
yield LazyRecord(iid, self)
def clear(self):

0 comments on commit 4a4e257

Please sign in to comment.