mirror of https://github.com/ecmwf/eccodes.git
GRIB lightweight clone: Rename
This commit is contained in:
parent
7be67dc31b
commit
23ae3e8bba
|
@ -175,9 +175,9 @@ grib_handle* codes_handle_clone(const grib_handle* h)
|
|||
{
|
||||
return grib_handle_clone(h);
|
||||
}
|
||||
grib_handle* codes_handle_clone_lightweight(const grib_handle* h)
|
||||
grib_handle* codes_handle_clone_headers_only(const grib_handle* h)
|
||||
{
|
||||
return grib_handle_clone_lightweight(h);
|
||||
return grib_handle_clone_headers_only(h);
|
||||
}
|
||||
|
||||
int codes_handle_delete(grib_handle* h)
|
||||
|
|
|
@ -495,7 +495,7 @@ codes_handle* codes_handle_new_from_samples(codes_context* c, const char* sample
|
|||
* @return the new handle, NULL if the message is invalid or a problem is encountered
|
||||
*/
|
||||
codes_handle* codes_handle_clone(const codes_handle* h);
|
||||
codes_handle* codes_handle_clone_lightweight(const codes_handle* h);
|
||||
codes_handle* codes_handle_clone_headers_only(const codes_handle* h);
|
||||
|
||||
/**
|
||||
* Frees a handle, also frees the message if it is not a user message
|
||||
|
|
|
@ -507,7 +507,7 @@ grib_handle* grib_handle_new_from_samples(grib_context* c, const char* sample_na
|
|||
* @return the new handle, NULL if the message is invalid or a problem is encountered
|
||||
*/
|
||||
grib_handle* grib_handle_clone(const grib_handle* h);
|
||||
grib_handle* grib_handle_clone_lightweight(const grib_handle* h);
|
||||
grib_handle* grib_handle_clone_headers_only(const grib_handle* h);
|
||||
|
||||
/**
|
||||
* Frees a handle, also frees the message if it is not a user message
|
||||
|
|
|
@ -326,7 +326,7 @@ grib_handle* grib_handle_clone(const grib_handle* h)
|
|||
return result;
|
||||
}
|
||||
|
||||
static bool can_create_clone_lightweight(const grib_handle* h)
|
||||
static bool can_create_clone_headers_only(const grib_handle* h)
|
||||
{
|
||||
// Only for GRIB, not BUFR etc
|
||||
if (h->product_kind != PRODUCT_GRIB) return false;
|
||||
|
@ -339,14 +339,14 @@ static bool can_create_clone_lightweight(const grib_handle* h)
|
|||
return true;
|
||||
}
|
||||
|
||||
grib_handle* grib_handle_clone_lightweight(const grib_handle* h)
|
||||
grib_handle* grib_handle_clone_headers_only(const grib_handle* h)
|
||||
{
|
||||
int err = 0;
|
||||
grib_handle* result = NULL;
|
||||
grib_context* c = h->context;
|
||||
|
||||
if (!can_create_clone_lightweight(h)) {
|
||||
// Lightweight clone not possible. Do a normal clone
|
||||
if (!can_create_clone_headers_only(h)) {
|
||||
// Headers-only clone not possible. Do a normal clone
|
||||
return grib_handle_clone(h);
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ grib_handle* grib_handle_clone_lightweight(const grib_handle* h)
|
|||
snprintf(sample_name, sizeof(sample_name), "GRIB%ld", edition);
|
||||
grib_handle* h_sample = grib_handle_new_from_samples(c, sample_name);
|
||||
if (!h_sample) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "Failed to create lightweight clone using sample %s", sample_name);
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "Failed to create headers_only clone using sample %s", sample_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ grib_handle* grib_handle_clone_lightweight(const grib_handle* h)
|
|||
const int sections_to_copy = GRIB_SECTION_PRODUCT | GRIB_SECTION_LOCAL | GRIB_SECTION_GRID;
|
||||
result = grib_util_sections_copy((grib_handle*)h, h_sample, sections_to_copy, &err);
|
||||
if (!result || err) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "Failed to create lightweight clone: Unable to copy sections");
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "Failed to create headers_only clone: Unable to copy sections");
|
||||
grib_handle_delete(h_sample);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ list(APPEND test_c_bins
|
|||
grib_indexing
|
||||
grib_fieldset
|
||||
grib_multi_from_message
|
||||
grib_clone_lightweight
|
||||
grib_clone_headers_only
|
||||
grib_read_index
|
||||
unit_tests
|
||||
bufr_keys_iter
|
||||
|
@ -172,7 +172,7 @@ if( HAVE_BUILD_TOOLS )
|
|||
grib_headers_only
|
||||
grib_unpack_subarray
|
||||
grib_count
|
||||
grib_clone_lightweight
|
||||
grib_clone_headers_only
|
||||
bufr_templates
|
||||
bufr_dump_data
|
||||
bufr_dump_descriptors
|
||||
|
|
|
@ -42,7 +42,7 @@ int main(int argc, char* argv[])
|
|||
assert(out);
|
||||
|
||||
while ((source_handle = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err)) != NULL) {
|
||||
codes_handle* clone_handle = codes_handle_clone_lightweight(source_handle);
|
||||
codes_handle* clone_handle = codes_handle_clone_headers_only(source_handle);
|
||||
assert(clone_handle);
|
||||
|
||||
codes_get_long(source_handle, "isConstant", &isConstant_src);
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
. ./include.ctest.sh
|
||||
|
||||
label="grib_clone_lightweight_test"
|
||||
label="grib_clone_headers_only_test"
|
||||
temp=temp.$label.grib
|
||||
|
||||
inputs="
|
||||
|
@ -22,7 +22,7 @@ inputs="
|
|||
for f in $inputs; do
|
||||
infile=$data_dir/$f
|
||||
rm -f $temp
|
||||
$EXEC ${test_dir}/grib_clone_lightweight $infile $temp
|
||||
$EXEC ${test_dir}/grib_clone_headers_only $infile $temp
|
||||
${tools_dir}/grib_compare -H -b totalLength $infile $temp
|
||||
done
|
||||
|
Loading…
Reference in New Issue