Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
wendelin
Commits
b948d032
Commit
b948d032
authored
Mar 28, 2017
by
Klaus Wölfel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make use of lazy sequence in data bucket stream api
parent
317f0836
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
16 deletions
+27
-16
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataBucketStream.py
...eItem/portal_components/document.erp5.DataBucketStream.py
+27
-16
No files found.
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataBucketStream.py
View file @
b948d032
...
...
@@ -82,25 +82,36 @@ class DataBucketStream(Document):
Remove one Bucket
"""
return
self
.
_tree
.
pop
(
key
)
def
itervalues
(
self
,
min_key
=
None
,
count
=
None
):
"""
Yield complete buckets of data.
"""
for
i
,
chunk
in
enumerate
(
self
.
_tree
.
itervalues
(
min_key
)):
if
count
is
not
None
and
i
>
count
-
1
:
break
out
=
chunk
.
value
# Free memory used by chunk. Helps avoiding thrashing connection
# cache by discarding chunks earlier.
chunk
.
_p_deactivate
()
yield
out
def
getBucketKeySequence
(
self
,
start_key
=
None
,
count
=
None
):
"""
Get a lazy sequence of bucket values
"""
excludemin
=
start_key
is
not
None
sequence
=
self
.
_tree
.
keys
(
min
=
start_key
,
excludemin
=
excludemin
)
if
count
is
None
:
return
sequence
return
sequence
[:
count
]
def
readBucketList
(
self
,
min_key
=
None
,
count
=
None
):
def
getBucketValueSequence
(
self
,
start_key
=
None
,
count
=
None
):
"""
Get a lazy sequence of bucket values
"""
excludemin
=
start_key
is
not
None
sequence
=
self
.
_tree
.
values
(
min
=
start_key
,
excludemin
=
excludemin
)
if
count
is
None
:
return
sequence
return
sequence
[:
count
]
def
getBucketItemSequence
(
self
,
start_key
=
None
,
count
=
True
):
"""
Get
complete buckets of data.
Get
a lazy sequence of bucket values
"""
return
[
bucket
for
bucket
in
self
.
itervalues
(
min_key
,
count
)]
excludemin
=
start_key
is
not
None
sequence
=
self
.
_tree
.
items
(
min
=
start_key
,
excludemin
=
excludemin
)
if
count
is
None
:
return
sequence
return
sequence
[:
count
]
def
getItemList
(
self
):
"""
...
...
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