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
Tatuya Kamada
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
Show 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
...
@@ -83,24 +83,35 @@ class DataBucketStream(Document):
...
@@ -83,24 +83,35 @@ class DataBucketStream(Document):
"""
"""
return
self
.
_tree
.
pop
(
key
)
return
self
.
_tree
.
pop
(
key
)
def
itervalues
(
self
,
min
_key
=
None
,
count
=
None
):
def
getBucketKeySequence
(
self
,
start
_key
=
None
,
count
=
None
):
"""
"""
Yield complete buckets of data.
Get a lazy sequence of bucket values
"""
"""
for
i
,
chunk
in
enumerate
(
self
.
_tree
.
itervalues
(
min_key
)):
excludemin
=
start_key
is
not
None
if
count
is
not
None
and
i
>
count
-
1
:
sequence
=
self
.
_tree
.
keys
(
min
=
start_key
,
excludemin
=
excludemin
)
break
if
count
is
None
:
out
=
chunk
.
value
return
sequence
# Free memory used by chunk. Helps avoiding thrashing connection
return
sequence
[:
count
]
# cache by discarding chunks earlier.
chunk
.
_p_deactivate
()
yield
out
def
readBucketList
(
self
,
min
_key
=
None
,
count
=
None
):
def
getBucketValueSequence
(
self
,
start
_key
=
None
,
count
=
None
):
"""
"""
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
.
values
(
min
=
start_key
,
excludemin
=
excludemin
)
if
count
is
None
:
return
sequence
return
sequence
[:
count
]
def
getBucketItemSequence
(
self
,
start_key
=
None
,
count
=
True
):
"""
Get a lazy sequence of bucket values
"""
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
):
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