-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Python API: Allow to cache object metadata and location #2009
Python API: Allow to cache object metadata and location #2009
Conversation
e2147d0
to
8984c29
Compare
Codecov Report
@@ Coverage Diff @@
## 4.x #2009 +/- ##
==========================================
- Coverage 80.84% 80.69% -0.14%
==========================================
Files 359 375 +16
Lines 69015 70709 +1694
==========================================
+ Hits 55788 57053 +1265
- Misses 13227 13534 +307
- Partials 0 122 +122
Continue to review full report at Codecov.
|
oio/api/object_storage.py
Outdated
cid = cid or cid_from_name(account, container) | ||
cid = cid.upper() | ||
return '/'.join(("meta", cid, obj)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be we should add a helper function _del_metadata_cache
since lot of code is related to remove entry from cache
oio/api/object_storage.py
Outdated
chunks[float(position)] = chunk | ||
|
||
if meta is None or chunks is None: | ||
meta = kwargs.get('meta') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why saving meta
if line below it is overwritten ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an oversight, this line should have been deleted.
oio/api/object_storage.py
Outdated
meta = None | ||
chunks = None | ||
cache = kwargs.get('cache') | ||
if cache is not None and not version: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if cache and not version
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the cache (dict
) is empty, this condition remains true.
oio/api/object_storage.py
Outdated
cid=None): | ||
if not obj: | ||
raise ValueError('Missing object name to use the cache') | ||
cid = cid or cid_from_name(account, container) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to measure impact of cid_from_name
since it will always compute a SHA256
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cid_from_name
is already used in _object_prepare
and object_fetch
computes it (unless there was the cid
)
oio/api/object_storage.py
Outdated
else: | ||
chunk_method = meta['chunk_method'] | ||
storage_method = STORAGE_METHODS.load(chunk_method) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be nice to split this code in few function but I don't have idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the cache management to container/client.py
, so finally this code is no longer modified.
3e4f9f1
to
f780d55
Compare
content_meta = content_meta.copy() | ||
if properties: | ||
metadata['properties'] = content_meta['properties'] | ||
content_meta['properties'] = dict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this. Why is there metadata['properties']
and metadata['meta']['properties']
?
By the way, when reading this, it's hard to get what is content_meta
and what is metadata
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache_value['meta']['properties']
is always an empty dictionary. While cache_value['properties']
only exists if the object properties have been retrieved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache_value['meta']['properties']
is always an empty dictionary.
Then why do we need it?
f780d55
to
83e7f88
Compare
83e7f88
to
6a58d85
Compare
@@ -89,12 +91,15 @@ def __init__(self, namespace, logger=None, perfdata=None, **kwargs): | |||
conf = {"namespace": self.namespace} | |||
self.logger = logger or get_logger(conf) | |||
self.perfdata = perfdata | |||
self.cache = cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this field. Also, I don't think cache
needs to appear in this method's signature. Adding 'cache'
to EXTRA_KEYWORDS
would do the trick.
content_meta = content_meta.copy() | ||
if properties: | ||
metadata['properties'] = content_meta['properties'] | ||
content_meta['properties'] = dict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache_value['meta']['properties']
is always an empty dictionary.
Then why do we need it?
SUMMARY
Allow to cache object metadata
ISSUE TYPE
COMPONENT NAME
SDS VERSION