metkitlib 1.16.0.9__cp312-cp312-manylinux_2_28_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. metkitlib/__init__.py +3 -0
  2. metkitlib/bin/bufr-sanity-check +0 -0
  3. metkitlib/bin/compare-mars-requests.py +265 -0
  4. metkitlib/bin/mars-archive-script +0 -0
  5. metkitlib/bin/parse-mars-request +0 -0
  6. metkitlib/include/metkit/api/metkit_c.h +255 -0
  7. metkitlib/include/metkit/codes/BUFRDecoder.h +47 -0
  8. metkitlib/include/metkit/codes/BufrContent.h +43 -0
  9. metkitlib/include/metkit/codes/CodesContent.h +67 -0
  10. metkitlib/include/metkit/codes/CodesHandleDeleter.h +41 -0
  11. metkitlib/include/metkit/codes/CodesSplitter.h +40 -0
  12. metkitlib/include/metkit/codes/GRIBDecoder.h +42 -0
  13. metkitlib/include/metkit/codes/GribAccessor.h +75 -0
  14. metkitlib/include/metkit/codes/GribHandle.h +121 -0
  15. metkitlib/include/metkit/codes/GribIterator.h +48 -0
  16. metkitlib/include/metkit/codes/LibEccodes.h +38 -0
  17. metkitlib/include/metkit/codes/MallocCodesContent.h +46 -0
  18. metkitlib/include/metkit/codes/api/CodesAPI.h +365 -0
  19. metkitlib/include/metkit/codes/api/CodesTypes.h +93 -0
  20. metkitlib/include/metkit/codes/api/GeoIterator.h +104 -0
  21. metkitlib/include/metkit/codes/api/KeyIterator.h +187 -0
  22. metkitlib/include/metkit/config/LibMetkit.h +56 -0
  23. metkitlib/include/metkit/fields/FieldIndex.h +58 -0
  24. metkitlib/include/metkit/fields/FieldIndexList.h +40 -0
  25. metkitlib/include/metkit/fields/SimpleFieldIndex.h +41 -0
  26. metkitlib/include/metkit/hypercube/HyperCube.h +105 -0
  27. metkitlib/include/metkit/hypercube/HyperCubePayloaded.h +88 -0
  28. metkitlib/include/metkit/mars/BaseProtocol.h +95 -0
  29. metkitlib/include/metkit/mars/ClientTask.h +206 -0
  30. metkitlib/include/metkit/mars/DHSProtocol.h +106 -0
  31. metkitlib/include/metkit/mars/MarsExpandContext.h +42 -0
  32. metkitlib/include/metkit/mars/MarsExpansion.h +83 -0
  33. metkitlib/include/metkit/mars/MarsExpension.h +28 -0
  34. metkitlib/include/metkit/mars/MarsHandle.h +83 -0
  35. metkitlib/include/metkit/mars/MarsLanguage.h +106 -0
  36. metkitlib/include/metkit/mars/MarsLocation.h +100 -0
  37. metkitlib/include/metkit/mars/MarsParsedRequest.h +44 -0
  38. metkitlib/include/metkit/mars/MarsParser.h +70 -0
  39. metkitlib/include/metkit/mars/MarsRequest.h +198 -0
  40. metkitlib/include/metkit/mars/MarsRequestHandle.h +79 -0
  41. metkitlib/include/metkit/mars/Matcher.h +88 -0
  42. metkitlib/include/metkit/mars/Param.b +43 -0
  43. metkitlib/include/metkit/mars/Param.h +84 -0
  44. metkitlib/include/metkit/mars/ParamID.h +306 -0
  45. metkitlib/include/metkit/mars/Parameter.h +87 -0
  46. metkitlib/include/metkit/mars/Quantile.h +73 -0
  47. metkitlib/include/metkit/mars/RequestEnvironment.h +58 -0
  48. metkitlib/include/metkit/mars/StepRange.b +43 -0
  49. metkitlib/include/metkit/mars/StepRange.h +164 -0
  50. metkitlib/include/metkit/mars/StepRangeNormalise.h +95 -0
  51. metkitlib/include/metkit/mars/Type.h +265 -0
  52. metkitlib/include/metkit/mars/TypeAny.h +39 -0
  53. metkitlib/include/metkit/mars/TypeDate.h +42 -0
  54. metkitlib/include/metkit/mars/TypeEnum.h +67 -0
  55. metkitlib/include/metkit/mars/TypeExpver.h +40 -0
  56. metkitlib/include/metkit/mars/TypeFloat.h +41 -0
  57. metkitlib/include/metkit/mars/TypeInteger.h +55 -0
  58. metkitlib/include/metkit/mars/TypeLowercase.h +38 -0
  59. metkitlib/include/metkit/mars/TypeMixed.h +47 -0
  60. metkitlib/include/metkit/mars/TypeParam.h +45 -0
  61. metkitlib/include/metkit/mars/TypeRange.h +41 -0
  62. metkitlib/include/metkit/mars/TypeRegex.h +49 -0
  63. metkitlib/include/metkit/mars/TypeTime.h +44 -0
  64. metkitlib/include/metkit/mars/TypeToByList.h +137 -0
  65. metkitlib/include/metkit/mars/TypeToByListQuantile.h +41 -0
  66. metkitlib/include/metkit/mars/TypesFactory.h +92 -0
  67. metkitlib/include/metkit/metkit_config.h +26 -0
  68. metkitlib/include/metkit/metkit_ecbuild_config.h +72 -0
  69. metkitlib/include/metkit/metkit_version.h +30 -0
  70. metkitlib/include/metkit/pointdb/DataSource.h +91 -0
  71. metkitlib/include/metkit/pointdb/FieldIndexer.h +128 -0
  72. metkitlib/include/metkit/pointdb/GribDataSource.h +47 -0
  73. metkitlib/include/metkit/pointdb/GribFieldInfo.h +76 -0
  74. metkitlib/include/metkit/pointdb/GribHandleDataSource.h +58 -0
  75. metkitlib/include/metkit/pointdb/PointIndex.h +121 -0
  76. metkitlib/include/metkit/pointdb/bits.h +1834 -0
  77. metkitlib/include/metkit/pointdb/masks.h +22 -0
  78. metkitlib/include/metkit/tool/MetkitTool.h +79 -0
  79. metkitlib/lib64/cmake/metkit/metkit-config-version.cmake +43 -0
  80. metkitlib/lib64/cmake/metkit/metkit-config.cmake +112 -0
  81. metkitlib/lib64/cmake/metkit/metkit-import.cmake +14 -0
  82. metkitlib/lib64/cmake/metkit/metkit-targets-relwithdebinfo.cmake +46 -0
  83. metkitlib/lib64/cmake/metkit/metkit-targets.cmake +116 -0
  84. metkitlib/lib64/libmetkit.so +0 -0
  85. metkitlib/lib64/pkgconfig/metkit.pc +33 -0
  86. metkitlib/share/metkit/axis.yaml +63 -0
  87. metkitlib/share/metkit/bufr-subtypes.yaml +140 -0
  88. metkitlib/share/metkit/chemids.yaml +209 -0
  89. metkitlib/share/metkit/language.yaml +1707 -0
  90. metkitlib/share/metkit/modifiers.yaml +341 -0
  91. metkitlib/share/metkit/obstype.yaml +182 -0
  92. metkitlib/share/metkit/odb/marsrequest.yaml +9 -0
  93. metkitlib/share/metkit/param-matching.yaml +16 -0
  94. metkitlib/share/metkit/paramids.yaml +24034 -0
  95. metkitlib/share/metkit/params-static.yaml +212 -0
  96. metkitlib/share/metkit/params.yaml +9833 -0
  97. metkitlib/share/metkit/reportype.yaml +525 -0
  98. metkitlib/share/metkit/shortname-context.yaml +192 -0
  99. metkitlib-1.16.0.9.dist-info/METADATA +75 -0
  100. metkitlib-1.16.0.9.dist-info/RECORD +104 -0
  101. metkitlib-1.16.0.9.dist-info/WHEEL +5 -0
  102. metkitlib-1.16.0.9.dist-info/licenses/AUTHORS +12 -0
  103. metkitlib-1.16.0.9.dist-info/licenses/LICENSE +190 -0
  104. metkitlib-1.16.0.9.dist-info/top_level.txt +1 -0
@@ -0,0 +1,187 @@
1
+ /*
2
+ * (C) Copyright 2025- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include "metkit/codes/api/CodesTypes.h"
14
+
15
+ #include <memory>
16
+ #include <string>
17
+ #include <vector>
18
+
19
+
20
+ namespace metkit::codes {
21
+
22
+ /// A namepspace is defined through the definition files and represented as a string.
23
+ using Namespace = std::string;
24
+
25
+
26
+ /// Commonly used eccodes namespacess.
27
+ namespace namespaces {
28
+
29
+ /// LS namespace contains a collection of descriptive keys as used by `grib_ls`.
30
+ const Namespace ls{"ls"};
31
+
32
+ const Namespace parameter{"parameter"};
33
+ const Namespace statistics{"statistics"};
34
+ const Namespace time{"time"};
35
+ const Namespace geography{"geography"};
36
+ const Namespace vertical{"vertical"};
37
+
38
+ /// MARS namespace contains keys used for indexation
39
+ const Namespace mars{"mars"};
40
+
41
+ }; // namespace namespaces
42
+
43
+ /// Flag to control/filter key iterator.
44
+ ///
45
+ /// Use `AllKeys` to disable filtering.
46
+ /// Use combination of `Skip*` to filter.
47
+ enum class KeyIteratorFlags : unsigned int {
48
+ /// Default - Will iterate all keys in a namespace.
49
+ AllKeys = 0,
50
+ SkipReadOnly = 1 << 0,
51
+ SkipOptional = 1 << 1,
52
+ SkipEditionSpecific = 1 << 2,
53
+ SkipCoded = 1 << 3,
54
+ SkipComputed = 1 << 4,
55
+ SkipDuplicates = 1 << 5,
56
+ SkipFunction = 1 << 6,
57
+ };
58
+
59
+ KeyIteratorFlags operator|(KeyIteratorFlags a, KeyIteratorFlags b);
60
+ KeyIteratorFlags operator&(KeyIteratorFlags a, KeyIteratorFlags b);
61
+ KeyIteratorFlags operator^(KeyIteratorFlags a, KeyIteratorFlags b);
62
+ KeyIteratorFlags operator~(KeyIteratorFlags a);
63
+
64
+ /// Optional helper to check if a flag is set.
65
+ bool hasFlag(KeyIteratorFlags value, KeyIteratorFlags flag);
66
+
67
+
68
+ //----------------------------------------------------------------------------------------------------------------------
69
+
70
+ class KeyRange;
71
+
72
+ /// Abstract interface wrapping C API calls on on key_iterator.
73
+ class KeyIterator {
74
+ friend class KeyRange;
75
+
76
+ public:
77
+
78
+ virtual ~KeyIterator() = default;
79
+
80
+ /// Get the name of the iterated key.
81
+ /// @return Name of the iterated key.
82
+ virtual std::string name() const = 0;
83
+
84
+ /// Get the value of the key.
85
+ ///
86
+ /// High-level functionality:
87
+ /// Inspection on the contained valued is performed with `type` and `size`.
88
+ /// Then the more specific `getXXX` call is performed.
89
+ /// @return Variant of all possible value types.
90
+ virtual CodesValue get() const = 0;
91
+
92
+ /// Get the type of the iterated key.
93
+ /// @return Type of the iterated key.
94
+ virtual NativeType type() const = 0;
95
+
96
+ /// Get the contained value for a key as long.
97
+ /// @return Retrieved value contained for the iterated key.
98
+ virtual long getLong() const = 0;
99
+
100
+ /// Get the contained value for a key as double.
101
+ /// @return Retrieved value contained for the iterated key.
102
+ virtual double getDouble() const = 0;
103
+
104
+ /// Get the contained value for a key as float.
105
+ /// @return Retrieved value contained for the iterated key.
106
+ virtual float getFloat() const = 0;
107
+
108
+ /// Get the contained value for a key as string.
109
+ ///
110
+ /// This should be possible for all key types.
111
+ /// @return Retrieved value contained for the iterated key.
112
+ virtual std::string getString() const = 0;
113
+
114
+ /// Get the contained values for a key as array of long.
115
+ /// @return Retrieved values contained for the iterated key.
116
+ virtual std::vector<long> getLongArray() const = 0;
117
+
118
+ /// Get the contained values for a key as array of double.
119
+ /// @return Retrieved values contained for the iterated key.
120
+ virtual std::vector<double> getDoubleArray() const = 0;
121
+
122
+ /// Get the contained values for a key as array of float.
123
+ /// @return Retrieved values contained for the iterated key.
124
+ virtual std::vector<float> getFloatArray() const = 0;
125
+
126
+ /// Get the contained values for a key as array of string.
127
+ /// @return Retrieved values contained for the iterated key.
128
+ virtual std::vector<std::string> getStringArray() const = 0;
129
+
130
+ /// Get the contained values for a key as array of uint8_t (bytes).
131
+ /// @return Retrieved values contained for the iterated key.
132
+ virtual std::vector<std::uint8_t> getBytes() const = 0;
133
+
134
+
135
+ protected:
136
+
137
+ /// Iterates the next element.
138
+ virtual void next() = 0;
139
+
140
+ /// Check if the iterator is valid.
141
+ /// @return True if the iterator is still valid and holds a value. False indicates end of iteration.
142
+ virtual bool isValid() const = 0;
143
+ };
144
+
145
+
146
+ //----------------------------------------------------------------------------------------------------------------------
147
+
148
+ /// Implements the key iterator (codes_key_iterator) based on a C++ range.
149
+ /// Enables use of range-based for-loop.
150
+ class KeyRange {
151
+ public:
152
+
153
+ struct EndIterator;
154
+
155
+ struct Iterator {
156
+ friend struct EndIterator;
157
+
158
+ Iterator& operator++() {
159
+ state->next();
160
+ return *this;
161
+ };
162
+ const KeyIterator& operator*() const { return *state; };
163
+ const KeyIterator* operator->() const { return state; };
164
+
165
+ inline bool operator!=(const KeyRange::EndIterator&) { return state->isValid(); }
166
+
167
+ KeyIterator* state;
168
+ };
169
+
170
+ struct EndIterator {
171
+ inline bool operator!=(const KeyRange::Iterator& it) { return it.state->isValid(); }
172
+ };
173
+
174
+ Iterator begin() const { return Iterator{impl_.get()}; };
175
+ EndIterator end() const { return {}; };
176
+
177
+ KeyRange(std::unique_ptr<KeyIterator> impl) : impl_{std::move(impl)} {};
178
+
179
+ private:
180
+
181
+ std::unique_ptr<KeyIterator> impl_;
182
+ };
183
+
184
+
185
+ //----------------------------------------------------------------------------------------------------------------------
186
+
187
+ } // namespace metkit::codes
@@ -0,0 +1,56 @@
1
+ /*
2
+ * (C) Copyright 1996- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ /// @author Baudouin Raoult
12
+ /// @author Tiago Quintino
13
+ /// @date August 2016
14
+
15
+ #ifndef mir_LibMetkit_H
16
+ #define mir_LibMetkit_H
17
+
18
+ #include "eckit/filesystem/PathName.h"
19
+ #include "eckit/system/Library.h"
20
+
21
+ //----------------------------------------------------------------------------------------------------------------------
22
+
23
+ namespace metkit {
24
+
25
+ class LibMetkit : public eckit::system::Library {
26
+ public:
27
+
28
+ LibMetkit();
29
+
30
+ static eckit::PathName configFile(const std::string& filename);
31
+
32
+ static eckit::PathName languageYamlFile();
33
+ static std::vector<eckit::PathName> modifiersYamlFiles();
34
+ static eckit::PathName paramYamlFile();
35
+ static eckit::PathName paramStaticYamlFile();
36
+ static eckit::PathName paramIDYamlFile();
37
+ static eckit::PathName paramMatchingYamlFile();
38
+ static eckit::PathName shortnameContextYamlFile();
39
+ static eckit::PathName bufrSubtypesYamlFile();
40
+
41
+ static const LibMetkit& instance();
42
+
43
+ protected:
44
+
45
+ const void* addr() const;
46
+
47
+ virtual std::string version() const;
48
+
49
+ virtual std::string gitsha1(unsigned int count) const;
50
+ };
51
+
52
+ } // namespace metkit
53
+
54
+ //----------------------------------------------------------------------------------------------------------------------
55
+
56
+ #endif
@@ -0,0 +1,58 @@
1
+ /*
2
+ * (C) Copyright 1996- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ #ifndef metkit_FieldIndex_H
12
+ #define metkit_FieldIndex_H
13
+
14
+ #include "eckit/memory/NonCopyable.h"
15
+ #include "eckit/serialisation/Stream.h"
16
+
17
+ namespace eckit {
18
+ namespace message {
19
+ class Message;
20
+ }
21
+ } // namespace eckit
22
+
23
+ namespace metkit {
24
+ namespace fields {
25
+
26
+ class FieldIndex : private eckit::NonCopyable {
27
+ public:
28
+
29
+ FieldIndex();
30
+ FieldIndex(const eckit::message::Message&);
31
+
32
+ FieldIndex(eckit::Stream&);
33
+
34
+ virtual ~FieldIndex();
35
+
36
+ void getValue(const std::string& name, double& value);
37
+ void getValue(const std::string& name, long& value);
38
+ void getValue(const std::string& name, std::string& value);
39
+
40
+ std::string substitute(const std::string& pattern) const;
41
+
42
+ void encode(eckit::Stream&) const;
43
+
44
+ void setValue(const std::string& name, double value);
45
+ void setValue(const std::string& name, long value);
46
+ void setValue(const std::string& name, const std::string& value);
47
+
48
+ protected: // members
49
+
50
+ std::map<std::string, std::string> stringValues_;
51
+ std::map<std::string, long> longValues_;
52
+ std::map<std::string, double> doubleValues_;
53
+ };
54
+
55
+ } // namespace fields
56
+ } // namespace metkit
57
+
58
+ #endif
@@ -0,0 +1,40 @@
1
+ /*
2
+ * (C) Copyright 1996- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ #ifndef metkit_FieldIndexList_H
12
+ #define metkit_FieldIndexList_H
13
+
14
+ #include "eckit/io/Offset.h"
15
+ #include "eckit/serialisation/Stream.h"
16
+ #include "eckit/types/Types.h"
17
+
18
+ namespace metkit {
19
+ namespace fields {
20
+
21
+ class FieldIndex;
22
+
23
+ class FieldIndexList {
24
+ public:
25
+
26
+ ~FieldIndexList();
27
+
28
+ void readFrom(eckit::Stream& s);
29
+ void sendTo(eckit::Stream& s) const;
30
+
31
+ eckit::OffsetList offset_;
32
+ eckit::LengthList length_;
33
+ std::vector<FieldIndex*> fields_;
34
+ };
35
+
36
+ } // namespace fields
37
+ } // namespace metkit
38
+
39
+
40
+ #endif
@@ -0,0 +1,41 @@
1
+ /*
2
+ * (C) Copyright 1996- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ #ifndef metkit_SimpleFieldIndex_H
12
+ #define metkit_SimpleFieldIndex_H
13
+
14
+ #include "metkit/fields/FieldIndex.h"
15
+ namespace metkit {
16
+ namespace fields {
17
+ // struct grib_handle;
18
+
19
+ class SimpleFieldIndex : public FieldIndex {
20
+ public:
21
+
22
+ // -- Contructors
23
+
24
+ SimpleFieldIndex(eckit::Stream&);
25
+
26
+ // -- Destructor
27
+
28
+ virtual ~SimpleFieldIndex() override;
29
+
30
+ // -- Methods
31
+
32
+ private: // members
33
+
34
+ // friend std::ostream& operator<<(std::ostream& s,const SimpleFieldIndex& p)
35
+ // { p.print(s); return s; }
36
+ };
37
+
38
+ } // namespace fields
39
+ } // namespace metkit
40
+
41
+ #endif
@@ -0,0 +1,105 @@
1
+ /*
2
+ * (C) Copyright 2017- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ /// @author Baudouin Raoult
12
+ /// @date Aug 2017
13
+
14
+
15
+ #ifndef metkit_HyperCube_H
16
+ #define metkit_HyperCube_H
17
+
18
+ #include <iosfwd>
19
+ #include <map>
20
+ #include <memory>
21
+ #include <vector>
22
+
23
+ #include "eckit/utils/HyperCube.h"
24
+
25
+ #include "metkit/config/LibMetkit.h"
26
+ #include "metkit/mars/MarsRequest.h"
27
+
28
+
29
+ namespace metkit {
30
+ namespace hypercube {
31
+
32
+ class Axis;
33
+
34
+ class AxisOrder {
35
+ public: // methods
36
+
37
+ static AxisOrder& instance();
38
+
39
+ const std::vector<std::string>& axes() { return axes_; }
40
+ size_t index(const std::string& axis) const;
41
+
42
+ private: // methods
43
+
44
+ AxisOrder();
45
+
46
+ eckit::PathName axisYamlFile() { return "~metkit/share/metkit/axis.yaml"; }
47
+
48
+ private: // members
49
+
50
+ std::vector<std::string> axes_;
51
+ std::map<std::string, size_t> axisIndex_;
52
+ };
53
+
54
+ class HyperCube {
55
+ public:
56
+
57
+ HyperCube(const metkit::mars::MarsRequest&);
58
+ ~HyperCube();
59
+
60
+ bool contains(const metkit::mars::MarsRequest&) const;
61
+ bool clear(const metkit::mars::MarsRequest&);
62
+
63
+ size_t count() const;
64
+ size_t countVacant() const;
65
+ size_t size() const { return cube_.count(); }
66
+
67
+ size_t fieldOrdinal(const metkit::mars::MarsRequest&, bool noholes = true) const;
68
+ std::vector<metkit::mars::MarsRequest> vacantRequests() const { return aggregatedRequests(true); }
69
+ std::vector<metkit::mars::MarsRequest> requests() const { return aggregatedRequests(false); }
70
+
71
+ protected:
72
+
73
+ std::vector<metkit::mars::MarsRequest> aggregatedRequests(bool remaining) const;
74
+ int indexOf(const metkit::mars::MarsRequest&) const;
75
+ bool clear(int index);
76
+ metkit::mars::MarsRequest requestOf(size_t index) const;
77
+
78
+ // Given a set of indices, build the *minimal* collection of Mars requests that cover them.
79
+ // Each entry in the result vector is: { merged_request, number_of_points_covered_by_that_request }
80
+ /// @note: This does not take into account whether the point is "set" or not
81
+ std::vector<std::pair<metkit::mars::MarsRequest, size_t>> request(const std::set<size_t>& idxs) const;
82
+
83
+ private:
84
+
85
+ std::string verb_;
86
+ std::vector<Axis*> axes_;
87
+ std::map<std::string, Axis*> axesByName_;
88
+ std::vector<bool> set_;
89
+ eckit::HyperCube cube_;
90
+ size_t count_;
91
+
92
+
93
+ void print(std::ostream&) const;
94
+
95
+ friend std::ostream& operator<<(std::ostream& s, const HyperCube& p) {
96
+ p.print(s);
97
+ return s;
98
+ }
99
+ };
100
+
101
+ } // namespace hypercube
102
+ } // namespace metkit
103
+
104
+
105
+ #endif
@@ -0,0 +1,88 @@
1
+ /*
2
+ * (C) Copyright 2017- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ /// @author Emanuele Danovaro
12
+ /// @date Aug 2020
13
+
14
+
15
+ #ifndef metkit_HyperCubePayloaded_H
16
+ #define metkit_HyperCubePayloaded_H
17
+
18
+ #include "metkit/hypercube/HyperCube.h"
19
+
20
+
21
+ namespace metkit {
22
+ namespace hypercube {
23
+
24
+ template <typename T>
25
+ class Deduplicator {
26
+ public:
27
+
28
+ virtual bool toReplace(const T& existing, const T& replacement) const = 0;
29
+ };
30
+
31
+ template <typename T>
32
+ class HyperCubePayloaded : public HyperCube {
33
+ public:
34
+
35
+ HyperCubePayloaded(const metkit::mars::MarsRequest& request, const Deduplicator<T>& deduplicator) :
36
+ HyperCube(request), dedup_(deduplicator) {
37
+
38
+
39
+ // throw error for default dedup
40
+ }
41
+
42
+
43
+ void add(const metkit::mars::MarsRequest& request, T payload) {
44
+
45
+ int idx = indexOf(request);
46
+
47
+ ASSERT(0 <= idx && idx < size());
48
+
49
+ auto entry = entries_.find(idx);
50
+ if (entry == entries_.end()) {
51
+ entries_.emplace(idx, payload);
52
+ clear(idx);
53
+ }
54
+ else {
55
+ if (dedup_.toReplace(entry->second, payload)) {
56
+ entry->second = payload;
57
+ }
58
+ }
59
+ }
60
+
61
+ const T& at(size_t idx) {
62
+ ASSERT(0 <= idx);
63
+ ASSERT(idx < size());
64
+
65
+ return entries_[idx];
66
+ }
67
+
68
+ bool find(size_t idx, T& payload) {
69
+ auto it = entries_.find(idx);
70
+
71
+ if (it == entries_.end())
72
+ return false;
73
+
74
+ payload = it->second;
75
+ return true;
76
+ }
77
+
78
+ private:
79
+
80
+ const Deduplicator<T>& dedup_;
81
+ std::map<size_t, T> entries_;
82
+ };
83
+
84
+ } // namespace hypercube
85
+ } // namespace metkit
86
+
87
+
88
+ #endif
@@ -0,0 +1,95 @@
1
+ /*
2
+ * (C) Copyright 1996- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ // File BaseProtocol.h
12
+ // Baudouin Raoult - (c) ECMWF Feb 12
13
+
14
+ #ifndef BaseProtocol_H
15
+ #define BaseProtocol_H
16
+
17
+ #include "eckit/io/Length.h"
18
+ #include "eckit/serialisation/Streamable.h"
19
+
20
+ namespace eckit {
21
+ class Configuration;
22
+ }
23
+
24
+ namespace metkit {
25
+ namespace mars {
26
+
27
+ class MarsRequest;
28
+
29
+ class BaseProtocol : public eckit::Streamable {
30
+
31
+ public:
32
+
33
+ BaseProtocol();
34
+ BaseProtocol(eckit::Stream&);
35
+ BaseProtocol(const eckit::Configuration&);
36
+
37
+ virtual ~BaseProtocol() override;
38
+
39
+ virtual eckit::Length retrieve(const MarsRequest&) = 0;
40
+ virtual void archive(const MarsRequest&, const eckit::Length&) = 0;
41
+
42
+ virtual long read(void* buffer, long len) = 0;
43
+ virtual long write(const void* buffer, long len) = 0;
44
+ virtual void cleanup() = 0;
45
+
46
+ // -- Overridden methods (from Streamable)
47
+ static const eckit::ClassSpec& classSpec();
48
+
49
+ protected:
50
+
51
+ virtual void print(std::ostream&) const = 0;
52
+ virtual void encode(eckit::Stream&) const override;
53
+
54
+ private:
55
+
56
+ friend std::ostream& operator<<(std::ostream& s, const BaseProtocol& p) {
57
+ p.print(s);
58
+ return s;
59
+ }
60
+ };
61
+
62
+
63
+ class ProtocolFactory {
64
+
65
+ std::string name_;
66
+
67
+ virtual BaseProtocol* make(const eckit::Configuration&) = 0;
68
+
69
+ protected:
70
+
71
+ ProtocolFactory(const std::string&);
72
+
73
+ virtual ~ProtocolFactory();
74
+
75
+ public:
76
+
77
+ static BaseProtocol* build(const eckit::Configuration&);
78
+
79
+ static void list(std::ostream&);
80
+ };
81
+
82
+
83
+ template <class T>
84
+ class ProtocolBuilder : public ProtocolFactory {
85
+ virtual BaseProtocol* make(const eckit::Configuration& param) override { return new T(param); }
86
+
87
+ public:
88
+
89
+ ProtocolBuilder(const std::string& name) : ProtocolFactory(name) {}
90
+ };
91
+
92
+ } // namespace mars
93
+ } // namespace metkit
94
+
95
+ #endif