GRIB lightweight clone: Rename

This commit is contained in:
Shahram Najm 2023-12-19 15:16:37 +00:00
parent 7be67dc31b
commit 23ae3e8bba
7 changed files with 15 additions and 15 deletions

View File

@ -175,9 +175,9 @@ grib_handle* codes_handle_clone(const grib_handle* h)
{ {
return grib_handle_clone(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) int codes_handle_delete(grib_handle* h)

View File

@ -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 * @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(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 * Frees a handle, also frees the message if it is not a user message

View File

@ -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 * @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(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 * Frees a handle, also frees the message if it is not a user message

View File

@ -326,7 +326,7 @@ grib_handle* grib_handle_clone(const grib_handle* h)
return result; 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 // Only for GRIB, not BUFR etc
if (h->product_kind != PRODUCT_GRIB) return false; if (h->product_kind != PRODUCT_GRIB) return false;
@ -339,14 +339,14 @@ static bool can_create_clone_lightweight(const grib_handle* h)
return true; 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; int err = 0;
grib_handle* result = NULL; grib_handle* result = NULL;
grib_context* c = h->context; grib_context* c = h->context;
if (!can_create_clone_lightweight(h)) { if (!can_create_clone_headers_only(h)) {
// Lightweight clone not possible. Do a normal clone // Headers-only clone not possible. Do a normal clone
return grib_handle_clone(h); 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); snprintf(sample_name, sizeof(sample_name), "GRIB%ld", edition);
grib_handle* h_sample = grib_handle_new_from_samples(c, sample_name); grib_handle* h_sample = grib_handle_new_from_samples(c, sample_name);
if (!h_sample) { 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; 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; 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); result = grib_util_sections_copy((grib_handle*)h, h_sample, sections_to_copy, &err);
if (!result || 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); grib_handle_delete(h_sample);
return NULL; return NULL;
} }

View File

@ -17,7 +17,7 @@ list(APPEND test_c_bins
grib_indexing grib_indexing
grib_fieldset grib_fieldset
grib_multi_from_message grib_multi_from_message
grib_clone_lightweight grib_clone_headers_only
grib_read_index grib_read_index
unit_tests unit_tests
bufr_keys_iter bufr_keys_iter
@ -172,7 +172,7 @@ if( HAVE_BUILD_TOOLS )
grib_headers_only grib_headers_only
grib_unpack_subarray grib_unpack_subarray
grib_count grib_count
grib_clone_lightweight grib_clone_headers_only
bufr_templates bufr_templates
bufr_dump_data bufr_dump_data
bufr_dump_descriptors bufr_dump_descriptors

View File

@ -42,7 +42,7 @@ int main(int argc, char* argv[])
assert(out); assert(out);
while ((source_handle = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err)) != NULL) { 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); assert(clone_handle);
codes_get_long(source_handle, "isConstant", &isConstant_src); codes_get_long(source_handle, "isConstant", &isConstant_src);

View File

@ -10,7 +10,7 @@
. ./include.ctest.sh . ./include.ctest.sh
label="grib_clone_lightweight_test" label="grib_clone_headers_only_test"
temp=temp.$label.grib temp=temp.$label.grib
inputs=" inputs="
@ -22,7 +22,7 @@ inputs="
for f in $inputs; do for f in $inputs; do
infile=$data_dir/$f infile=$data_dir/$f
rm -f $temp 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 ${tools_dir}/grib_compare -H -b totalLength $infile $temp
done done