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:
Kota Tsuyuzaki 2015-02-20 10:46:08 +09:00
parent 238edcf4ca
commit 7b2b759a2f
2 changed files with 12 additions and 0 deletions

View File

@ -328,6 +328,8 @@ int liberasurecode_get_aligned_data_size(int desc, uint64_t data_len);
*/
int liberasurecode_get_minimum_encode_size(int desc);
int liberasurecode_get_fragment_size(int desc, int size);
/* ==~=*=~===~=*=~==~=*=~== liberasurecode Error codes =~=*=~==~=~=*=~==~== */
/* Error codes */

View File

@ -1121,6 +1121,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 orig_data_size)
{
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, orig_data_size);
int size = (aligned_data_len / instance->args.uargs.k) + instance->common.metadata_adder;
return size;
}
/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=* misc *=~==~=*=~==~=*=~==~=*=~==~=*=~== */
#if 0