From 9363aa9241026c470e91550d06f64260d3b01139 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Wed, 23 Oct 2024 19:09:48 +0200 Subject: [PATCH 1/3] ECC-1898: Remove alias from cache --- src/action_class_alias.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/action_class_alias.cc b/src/action_class_alias.cc index 3ae756cbe..b5bf7f179 100644 --- a/src/action_class_alias.cc +++ b/src/action_class_alias.cc @@ -137,6 +137,8 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) if (x->name_space_ == NULL) x->name_space_ = act->name_space; + // TODO(maee): Make sure that the accessor is added to the trie + grib_context_log(p->h->context, GRIB_LOG_DEBUG, "alias: add only namespace: %s.%s", act->name_space, act->name); i = 0; @@ -178,6 +180,13 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) act->name_space, act->name, y->name_); /* printf("[%s %s]\n",y->all_names_[i], y->all_name_spaces_[i]); */ + // ECC-1898: Remove accessor from cache + grib_handle* hand = grib_handle_of_accessor(y); + if (hand->use_trie && y->all_name_spaces_[i] != NULL && strcmp(y->name_, act->name) != 0) { + int id = grib_hash_keys_get_id(hand->context->keys, act->name); + hand->accessors[id] = NULL; + } + while (i < MAX_ACCESSOR_NAMES - 1) { y->all_names_[i] = y->all_names_[i + 1]; y->all_name_spaces_[i] = y->all_name_spaces_[i + 1]; From 34d49445c7cb0db04d69f4f527d140f8fb2b2258 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Thu, 24 Oct 2024 12:22:39 +0200 Subject: [PATCH 2/3] ECC-1898: Add test --- tests/CMakeLists.txt | 1 + tests/grib_ecc-1898.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 tests/grib_ecc-1898.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e103b3231..493386a5e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -276,6 +276,7 @@ if( HAVE_BUILD_TOOLS ) grib_ecc-1764 grib_ecc-1792 grib_ecc-1806 + grib_ecc-1898 grib_ecc-1907 grib_ecc-1941 grib_ecc-1942 diff --git a/tests/grib_ecc-1898.sh b/tests/grib_ecc-1898.sh new file mode 100755 index 000000000..0c6aaf44f --- /dev/null +++ b/tests/grib_ecc-1898.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="grib_ecc-1898_test" + +tempGrib=temp.$label.grib +tempOut=temp.${label}.txt + +$tools_dir/grib_dump -Da $samp_dir/reduced_gg_pl_32_grib2.tmpl > $tempOut +grep -q '288-288 g2level level = 1000 \[vertical.level, mars.levelist\]' $tempOut + +# For given MARS stream/types, we unalias the mars.levelist key +$tools_dir/grib_set -s stream=gfas,type=gsd $samp_dir/reduced_gg_pl_32_grib2.tmpl $tempGrib + +# Check that the key is unaliased +$tools_dir/grib_dump -Da $tempGrib > $tempOut +grep -q '288-288 g2level level = 1000 \[vertical.level\]' $tempOut + +$tools_dir/grib_dump -p levelist -Da $tempGrib 2> $tempOut +grep -q 'levelist: Key/value not found' $tempOut + +set +e +$tools_dir/grib_get -p levelist $tempGrib 2> $tempOut +set -e +grep -q 'levelist (Key/value not found)' $tempOut + +set +e +$tools_dir/grib_get -p mars.levelist $tempGrib 2> $tempOut +set -e +grep -q 'mars.levelist (Key/value not found)' $tempOut + +rm -f $tempGrib $tempOut From 6180c42ef6a52a0b6f87b28f52e86742ee39508d Mon Sep 17 00:00:00 2001 From: shahramn Date: Mon, 28 Oct 2024 15:36:35 +0000 Subject: [PATCH 3/3] ECC-1898: Add more tests --- tests/grib_ecc-1898.sh | 13 +++++-------- tests/grib_uerra.sh | 11 +++++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/grib_ecc-1898.sh b/tests/grib_ecc-1898.sh index 0c6aaf44f..6718dc868 100755 --- a/tests/grib_ecc-1898.sh +++ b/tests/grib_ecc-1898.sh @@ -28,14 +28,11 @@ grep -q '288-288 g2level level = 1000 \[vertical.level\]' $tempOut $tools_dir/grib_dump -p levelist -Da $tempGrib 2> $tempOut grep -q 'levelist: Key/value not found' $tempOut -set +e -$tools_dir/grib_get -p levelist $tempGrib 2> $tempOut -set -e -grep -q 'levelist (Key/value not found)' $tempOut +result=$($tools_dir/grib_get -fp levelist $tempGrib) +[ "$result" = "not_found" ] -set +e -$tools_dir/grib_get -p mars.levelist $tempGrib 2> $tempOut -set -e -grep -q 'mars.levelist (Key/value not found)' $tempOut +result=$($tools_dir/grib_get -fp mars.levelist $tempGrib) +[ "$result" = "not_found" ] +# Clean up rm -f $tempGrib $tempOut diff --git a/tests/grib_uerra.sh b/tests/grib_uerra.sh index 9b6ec7bd3..0c4c5a8da 100755 --- a/tests/grib_uerra.sh +++ b/tests/grib_uerra.sh @@ -98,5 +98,16 @@ $grib2_sample $temp1 grib_check_key_equals $temp1 'marsExpver,mars.expver' '0078 0078' +# Stream 'dame' +${tools_dir}/grib_set -s productionStatusOfProcessedData=10 $grib2_sample $temp1 +grib_check_key_equals $temp1 'mars.time,mars.step' '1200 0' + +${tools_dir}/grib_set -s \ + productionStatusOfProcessedData=10,productDefinitionTemplateNumber=8,outerLoopTypeOfTimeIncrement=1,outerLoopLengthOfTimeRange=21 \ + $grib2_sample $temp1 +grib_check_key_equals $temp1 'mars.stream' 'dame' +result=$(${tools_dir}/grib_get -fp mars.time,mars.step $temp1) +[ "$result" = "not_found not_found" ] + # Clean up rm -f $temp1 $temp2 $tempSample