15 using namespace eckit;
23 MetaData::MetaData() :
std::vector<
Column*>(), rowsNumber_(0) {}
30 rowsNumber_(md.rowsNumber_),
31 dataSize_(md.dataSize_) {
46 else if (
type ==
"REAL")
return REAL;
47 else if (
type ==
"FLOAT")
return REAL;
51 else if (
type.find(
"BITFIELD") != std::string::npos)
return BITFIELD;
52 else throw eckit::UserError(
"Unsupported column type: " +
type);
59 for (
size_t i = 0;
i < size(); ++
i)
60 (*md)[
i]->coder((*
this)[
i]->coder().clone());
66 size_t oldSize = size();
68 for (
size_t i = n;
i < oldSize; ++
i)
71 std::vector<Column*>::resize(n, 0);
73 for (
size_t i = oldSize;
i < n; ++
i)
79 for (size_type
i = 0;
i < size();
i++)
89 for (
size_t i = 0;
i < size();
i++)
90 if (at(
i)->name() ==
name || at(
i)->name().find(
name +
"@") == 0)
97 std::vector<size_t> indices;
99 for (
size_t i = 0;
i < size();
i++)
100 if (at(
i)->name() ==
name || at(
i)->name().find(
name +
"@") == 0)
101 indices.push_back(
i);
103 if (indices.size() > 1)
104 throw eckit::UserError(std::string(
"Ambiguous column name: '") +
name +
"'");
106 if (indices.size() == 0)
107 throw eckit::UserError(std::string(
"Column '") +
name +
"' not found.");
117 if (size() != other.size())
119 for (size_type
i=0;
i < size();
i++)
124 resize(other.size(), PColumn(0));
126 for (size_type
i=0;
i < size();
i++)
127 (*
this)[
i] =
new Column(*
this);
130 for (size_type
i=0;
i < size();
i++)
131 *(*
this)[
i] = *other[
i];
138 for (
size_t i = 0;
i < rhs.size(); ++
i)
153 ASSERT(size() == other.size());
154 for (
size_t i = 0;
i < size(); ++
i)
156 ASSERT((*
this)[
i]->
name() == other[
i]->
name());
157 ASSERT((*
this)[
i]->
type() == other[
i]->
type());
159 (*this)[
i]->coder().gatherStats(other[
i]->max());
160 (*this)[
i]->coder().gatherStats(other[
i]->min());
173 std::ostream& L = Log::debug();
174 for (
size_t i = 0;
i < constColumns.size(); ++
i)
176 const std::string& columnName = constColumns[
i];
177 L <<
"MetaData::equalsIncludingConstants: check " << columnName << std::endl;
187 L <<
"MetaData::equalsIncludingConstants: c1 " << c1 <<
" " << c1.
coder() << std::endl;
188 L <<
"MetaData::equalsIncludingConstants: c2 " << c2 <<
" " << c2.
coder() << std::endl;
189 L <<
"MetaData::equalsIncludingConstants: column '" << columnName <<
"'" << std::endl;
196 if ( codec1.
min() != codec2.
min() )
198 L <<
"MetaData::equalsIncludingConstants: column '" << columnName <<
"'" << std::endl;
199 L <<
"MetaData::equalsIncludingConstants: min1=" << codec1.
min() <<
", max1=" << codec1.
max() << std::endl;
200 L <<
"MetaData::equalsIncludingConstants: min2=" << codec2.
min() <<
", max2=" << codec2.
max() << std::endl;
201 L <<
"MetaData::equalsIncludingConstants: c1.coder: " << codec1 << std::endl;
202 L <<
"MetaData::equalsIncludingConstants: c2.coder: " << codec2 << std::endl;
208 L <<
"MetaData::equalsIncludingConstants: yes" << std::endl;
218 if (size() != other.size()) {
222 for (
size_t i = 0;
i < size(); ++
i) {
223 if (!at(
i)->equals(*other[
i], compareDataSizes)) {
235 if (size() != other.size())
return false;
238 for (
size_t i = 0;
i < size(); ++
i) {
239 if (*(*
this)[
i] != *other[
i]) {
245 if (equal)
return true;
249 std::map<std::string, Column*> columnLookup;
250 for (
Column* col : *
this) {
251 columnLookup.emplace(col->
name(), col);
254 for (
Column* col : other) {
255 auto it = columnLookup.find(col->
name());
256 if (it == columnLookup.end())
return false;
257 if (*it->second != *col)
return false;
266 for (
size_t i = 0;
i < size();
i++) {
267 (*this)[
i]->resetStats();
274 for (
size_t i = 0;
i < size();
i++) {
275 s <<
i <<
". " << *at(
i) << std::endl;
281 return addColumnPrivate<SameByteOrder>(
name,
type);
289 for (
size_t i = 0;
i < size();
i++) {
290 if (!(*
this)[
i]->hasInitialisedCoder())
299 return addBitfieldPrivate<SameByteOrder>(
name, bf);
void name(const std::string name)