Add liberasurecode_get_fragment_size function
For get_segment_info function of PyECLib, liberasurecode should support get_fragment_size function because if pyeclib and liberasurecode have the calculation of fragment size each other, it might cause the size mismatch (i.e. it'll be a bug) in the future development work. This patch introduces liberasurecode_get_fragment_size function to return the fragment_size calculated at liberasurecode accoring to specified backend descriptor. It really usefull to help caller knows how large size it have to expect and all pyeclib has to do for retrieving fragment_size will be just calling the liberasurecode_get_fragment_size function on get_segment_info.
This commit is contained in:
parent
a8c8ed9adb
commit
54da656c65
|
@ -328,6 +328,18 @@ int liberasurecode_get_aligned_data_size(int desc, uint64_t data_len);
|
|||
*/
|
||||
int liberasurecode_get_minimum_encode_size(int desc);
|
||||
|
||||
/**
|
||||
* This will return the fragment size, which is each fragment data
|
||||
* length the backend will allocate when encoding.
|
||||
*
|
||||
* @param desc - liberasurecode descriptor/handle
|
||||
* from liberasurecode_instance_create()
|
||||
* @param data_len - original data length in bytes
|
||||
*
|
||||
* @return fragment size
|
||||
*/
|
||||
int liberasurecode_get_fragment_size(int desc, int data_len);
|
||||
|
||||
/* ==~=*=~===~=*=~==~=*=~== liberasurecode Error codes =~=*=~==~=~=*=~==~== */
|
||||
|
||||
/* Error codes */
|
||||
|
|
|
@ -1118,6 +1118,16 @@ int liberasurecode_get_minimum_encode_size(int desc)
|
|||
return liberasurecode_get_aligned_data_size(desc, 1);
|
||||
}
|
||||
|
||||
int liberasurecode_get_fragment_size(int desc, int data_len)
|
||||
{
|
||||
ec_backend_t instance = liberasurecode_backend_instance_get_by_desc(desc);
|
||||
// TODO: Create a common function to calculate fragment size also for preprocessing
|
||||
int aligned_data_len = get_aligned_data_size(instance, data_len);
|
||||
int size = (aligned_data_len / instance->args.uargs.k) + instance->common.metadata_adder;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=* misc *=~==~=*=~==~=*=~==~=*=~==~=*=~== */
|
||||
|
||||
#if 0
|
||||
|
|
Loading…
Reference in New Issue