ArcticDB icon indicating copy to clipboard operation
ArcticDB copied to clipboard

defragment_symbol_data shouldn't raise when is_symbol_fragmented returns false

Open jamesmunro opened this issue 1 year ago • 1 comments

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')

jamesmunro avatar Aug 08 '23 08:08 jamesmunro

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.

joe-iddon avatar Dec 14 '23 13:12 joe-iddon

Spoken to @jamesmunro regarding this ticket. We settle with the return value to be Optional[VersionedItem] but the discussion is not closed yet.

phoebusm avatar May 21 '24 11:05 phoebusm

Superseded by https://github.com/man-group/ArcticDB/issues/719

alexowens90 avatar May 30 '24 11:05 alexowens90