ArcticDB
ArcticDB copied to clipboard
defragment_symbol_data shouldn't raise when is_symbol_fragmented returns false
Is your feature request related to a problem? Please describe.
When trying to use defragment_symbol_data
I need to either check with is_symbol_fragmented
or catch the exception to use it. This is more lines of code, slower, more fragile and more complicated with no obvious value added in the API.
Example 1:
if lib.is_symbol_fragmented('FOO'):
defragment_symbol_data('FOO')
This requires more lines of code and two calls to is_symbol_fragmented
(one within defragment_symbol_data
).
Example 2:
try:
defragment_symbol_data('FOO')
except InternalException:
# NB: InternalException is not specific enough
pass
This is more complicated and doesn't catch specific enough exception.
Describe the solution you'd like
defragment_symbol_data
returns a VersionedItem when defrag. occurs, just return something Falsy when no defrag occurs, e.g. False or None:
if defragment_symbol_data('FOO'):
print('Defrag occured')
I've made a start on fixing this and updating the API in this PR: https://github.com/man-group/ArcticDB/pull/1162
The main outstanding question is what the return type should be to be able to support reporting back whether any work was done.
Spoken to @jamesmunro regarding this ticket. We settle with the return value to be Optional[VersionedItem]
but the discussion is not closed yet.
Superseded by https://github.com/man-group/ArcticDB/issues/719