Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
c51a5e18
Commit
c51a5e18
authored
Jul 08, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X ZBigArrray: Don't throw away data cache on e.g. .shape change
parent
cdc05b26
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
bigarray/array_zodb.py
bigarray/array_zodb.py
+11
-13
No files found.
bigarray/array_zodb.py
View file @
c51a5e18
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# Wendelin.bigarray | ZODB-Persistent BigArray
# Wendelin.bigarray | ZODB-Persistent BigArray
# Copyright (C) 2014-201
5
Nexedi SA and Contributors.
# Copyright (C) 2014-201
9
Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
# Kirill Smelkov <kirr@nexedi.com>
#
#
# This program is free software: you can Use, Study, Modify and Redistribute
# This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -56,7 +56,8 @@ class ZBigArray(BigArray,
...
@@ -56,7 +56,8 @@ class ZBigArray(BigArray,
self
.
zfile
=
ZBigFile
(
blksize
)
self
.
zfile
=
ZBigFile
(
blksize
)
self
.
_v_fileh
=
None
self
.
_v_fileh
=
None
# __setstate__ (re-)loads ZBigArray data from DB, e.g. after live ZBigArray
# object was invalidated.
def
__setstate__
(
self
,
state
):
def
__setstate__
(
self
,
state
):
super
(
ZBigArray
,
self
).
__setstate__
(
state
)
super
(
ZBigArray
,
self
).
__setstate__
(
state
)
...
@@ -68,18 +69,15 @@ class ZBigArray(BigArray,
...
@@ -68,18 +69,15 @@ class ZBigArray(BigArray,
if
not
hasattr
(
self
,
'_'
+
k
):
if
not
hasattr
(
self
,
'_'
+
k
):
setattr
(
self
,
'_'
+
k
,
v
)
setattr
(
self
,
'_'
+
k
,
v
)
# NOTE __setstate__() is done after either
# (re-)set ._v_fileh; make sure not to loose fileh and its cache if
# - 1st time loading from DB, or
# .zfile has not changed. By preserving fileh we don't throw away data
# - loading from DB after invalidation.
# cache on e.g. just .shape change.
#
# as invalidation can happen e.g. by just changing .shape in another DB
# connection (e.g. resizing array and appending some data), via always
# resetting ._v_fileh we discard all data from it.
#
#
# IOW we discard whole cache just because some data were appended.
# TODO test/bench that cache is preserved after .shape change (e.g. append)
#
_v_fileh
=
getattr
(
self
,
'_v_fileh'
,
None
)
# -> TODO (optimize) do not through ._v_fileh if we can (.zfile not changed, etc)
if
_v_fileh
is
not
None
and
self
.
zfile
is
not
_v_fileh
.
zfile
:
self
.
_v_fileh
=
None
_v_fileh
=
None
self
.
_v_fileh
=
_v_fileh
# open fileh lazily, so that when we open it, zfile was already associated
# open fileh lazily, so that when we open it, zfile was already associated
...
...
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