Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store layer metadata #401

Merged
merged 67 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
1a26063
Converting projection list to json
maartenplieger Sep 2, 2024
c27cf13
Updated with remote branch
maartenplieger Sep 2, 2024
9152b17
Store and retrieve is working for layer boundingboxes
maartenplieger Sep 3, 2024
754708a
Merge branch 'master' of github.com:KNMI/adaguc-server into store-lay…
maartenplieger Sep 3, 2024
be6d15b
Renamed files
maartenplieger Sep 3, 2024
caa8ab7
Refactored CXMLGen
maartenplieger Sep 4, 2024
03faae3
Merge branch 'master' of github.com:KNMI/adaguc-server into store-lay…
maartenplieger Sep 4, 2024
be61a63
Reduced loggings
maartenplieger Sep 4, 2024
8cc797e
Refactored CXMLGen
maartenplieger Sep 5, 2024
cffe53d
Commit before fixing tests
maartenplieger Sep 5, 2024
a1d8ec3
Tests without store do work
maartenplieger Sep 5, 2024
79d71d5
Tests succeed
maartenplieger Sep 5, 2024
da373cc
Stylelist is ordered as before
maartenplieger Sep 6, 2024
38319b7
enablemetadatacache can be enabled/disabled via the settings
maartenplieger Sep 6, 2024
8d2afae
Metadatatable enabled by default
maartenplieger Sep 6, 2024
91e2483
Update on conflict is working based on the defaultValue of the time d…
maartenplieger Sep 6, 2024
71b50cb
Resolved comments
maartenplieger Sep 9, 2024
1fdf9b6
Fixed describecoverage
maartenplieger Sep 9, 2024
c719e01
Fixed tests
maartenplieger Sep 9, 2024
eb6b6d4
Resolved comments
maartenplieger Sep 9, 2024
5026730
added call to obtain metadata
maartenplieger Sep 9, 2024
526bbe0
Resolved comments
maartenplieger Sep 9, 2024
f51e22a
Resolved comments
maartenplieger Sep 10, 2024
7a27a30
Merge branch 'store-layer-metadata' of github.com:KNMI/adaguc-server …
maartenplieger Sep 10, 2024
f3e3b3b
Moved json generation to another file
maartenplieger Sep 10, 2024
cf262fd
Resolved comments
maartenplieger Sep 10, 2024
2e893d4
Merge branch 'store-layer-metadata' of github.com:KNMI/adaguc-server …
maartenplieger Sep 10, 2024
e5fff45
Resolved comments
maartenplieger Sep 10, 2024
086429d
Merge branch 'store-layer-metadata' of github.com:KNMI/adaguc-server …
maartenplieger Sep 10, 2024
a19f085
Added getmetadata call
maartenplieger Sep 11, 2024
3d0353d
Resolved comments
maartenplieger Sep 11, 2024
fecec15
Merged from master
maartenplieger Sep 11, 2024
a478bfd
Fixed nullptr issue
maartenplieger Sep 11, 2024
22d50c0
Added test
maartenplieger Sep 11, 2024
d7cced3
Resolved comments
maartenplieger Sep 11, 2024
39b7c69
Merge branch 'store-layer-metadata' of github.com:KNMI/adaguc-server …
maartenplieger Sep 11, 2024
bf2d1b9
Resolved comments
maartenplieger Sep 11, 2024
00d3cfa
merge from store-layer-metadata
maartenplieger Sep 11, 2024
9b1f648
Removed pointers
maartenplieger Sep 12, 2024
7ef7f50
Resolved comments
maartenplieger Sep 12, 2024
895f0cb
Resolved comments
maartenplieger Sep 12, 2024
84e93e6
Fix compare and struct initialisation.
lukas-phaf Sep 12, 2024
1764e17
Merged from store-layer-metadata
maartenplieger Sep 12, 2024
79e3b64
Stylelist and projected_extents are now returned in metadata call
maartenplieger Sep 12, 2024
85438af
Added exception logic in metadata call
maartenplieger Sep 12, 2024
6a82023
Fixed bbox listings in CXMLGen
maartenplieger Sep 12, 2024
23f53b6
Updated tests
maartenplieger Sep 12, 2024
11fd40d
Taking changes from get-layer-metadata
maartenplieger Sep 13, 2024
90c3e5e
up to date with store-layer metadata
maartenplieger Sep 13, 2024
33f5e1c
Fixed tests
maartenplieger Sep 13, 2024
52b2fa9
Using TIMESTAMPTZ in layermetadatatable
maartenplieger Sep 13, 2024
a48c9d2
Added --updatelayermetadata option to update layermetadata
maartenplieger Sep 13, 2024
552e28c
Using already existing data base filename loader
maartenplieger Sep 13, 2024
47186df
--updatelayermetadata does now clean as well
maartenplieger Sep 13, 2024
36841ec
Updated populateMetadataLayerStruct
maartenplieger Sep 13, 2024
552ef61
Merge branch 'get-layer-metadata' of github.com:KNMI/adaguc-server in…
maartenplieger Sep 13, 2024
ea4beec
Updated with store-layer-metadata
maartenplieger Sep 13, 2024
61a5b8a
Fixed tests
maartenplieger Sep 13, 2024
41e7dd5
Get rid of default constructor for LayerMetadataProjection.
lukas-phaf Sep 13, 2024
fdad104
Added advisory lock to lock layermetadatatable
maartenplieger Sep 23, 2024
38fce6e
Rewrite of updatelayer metadata from two nested maps into two sets
maartenplieger Sep 23, 2024
e9aa622
Merge branch 'store-layer-metadata' of github.com:KNMI/adaguc-server …
maartenplieger Sep 24, 2024
560c888
Added extra metadata entries
maartenplieger Sep 24, 2024
1518d19
Solved bug where brotli caused huge delays when storing cached data i…
maartenplieger Sep 24, 2024
ba09d04
Merge pull request #406 from KNMI/get-layer-metadata
ernstdevreede Sep 24, 2024
2ec2e62
Reverted brotli change
maartenplieger Sep 25, 2024
3da962d
Updated with master
maartenplieger Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions CCDFDataModel/CCDFVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,21 +291,29 @@ namespace CDF {
void setSize(size_t size) { currentSize = size; }
size_t getSize() { return currentSize; }

Attribute *getAttribute(const char *name) const {
bool hasAttribute(const char *name) const {
lukas-phaf marked this conversation as resolved.
Show resolved Hide resolved
for (size_t j = 0; j < attributes.size(); j++) {
if (attributes[j]->name.equals(name)) {
return attributes[j];
return true;
}
}
throw(CDF_E_ATTNOTFOUND);
return NULL;
return false;
}

Attribute *getAttribute(const char *name) const {
Attribute *a = getAttributeNE(name);
if (a == nullptr) {
throw(CDF_E_ATTNOTFOUND);
}
return a;
}
Attribute *getAttributeNE(const char *name) const {
lukas-phaf marked this conversation as resolved.
Show resolved Hide resolved
try {
return getAttribute(name);
} catch (int e) {
return NULL;
for (size_t j = 0; j < attributes.size(); j++) {
if (attributes[j]->name.equals(name)) {
lukas-phaf marked this conversation as resolved.
Show resolved Hide resolved
return attributes[j];
}
}
return nullptr;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ USER root
LABEL maintainer="[email protected]"

# Version should be same as in Definitions.h
LABEL version="2.27.0"
LABEL version="2.28.0"

# Try to update image packages
RUN apt-get -q -y update \
Expand Down Expand Up @@ -88,7 +88,7 @@ COPY python /adaguc/adaguc-server-master/python
# To run the tests against a postgres db, see docs/test_postgesql.md
FROM base AS test

ENV TEST_IN_CONTAINER 1
ENV TEST_IN_CONTAINER=1

COPY requirements-dev.txt /adaguc/adaguc-server-master/requirements-dev.txt
RUN pip install --no-cache-dir -r requirements-dev.txt
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**Version 2.28.0 2024-09-62**
lukas-phaf marked this conversation as resolved.
Show resolved Hide resolved
- Metadata for layer items like the projections, dimensions and styles can now be stored in a metadatatable


**Version 2.27.0 2024-09-02**
- PostgreSQL query from `getFilesAndIndicesForDimensions` has been rewritten, which fixes https://github.com/KNMI/adaguc-server/issues/341.
- Optimized existing PostgreSQL queries and reduced number of PostgreSQL queries in general. This results in better performance, the benchmark tool runs 9% faster.
Expand Down
9 changes: 5 additions & 4 deletions adagucserverEC/CAutoConfigure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,11 @@ int CAutoConfigure::justLoadAFileHeader(CDataSource *dataSource) {
return 0;
}

CT::string foundFileName;

/* Use the file specified as header file */
foundFileName = dataSource->headerFileName.c_str();
CT::string foundFileName = dataSource->getFileName();
if (foundFileName.empty()) {
/* Use the file specified as header file */
foundFileName = dataSource->headerFileName.c_str();
}
lukas-phaf marked this conversation as resolved.
Show resolved Hide resolved
if (foundFileName.empty()) {

/* Try to get a file from DB */
Expand Down
5 changes: 4 additions & 1 deletion adagucserverEC/CDBAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class CDBAdapter {
public:
CDBAdapter() {}
virtual ~CDBAdapter(){};
virtual ~CDBAdapter() {};

class GeoOptions {
public:
Expand Down Expand Up @@ -96,6 +96,9 @@ class CDBAdapter {

/** First use setFile<type> as many times as you whish, second use addFilesToDataBase to make it final*/
virtual int addFilesToDataBase() = 0;

virtual int storeLayerMetadata(const char *datasetName, const char *layerName, const char *metadataKey, const char *metadatablob) = 0;
virtual CT::string getLayerMetadata(const char *datasetName, const char *layerName, const char *metadataKey) = 0;
};

#endif
88 changes: 86 additions & 2 deletions adagucserverEC/CDBAdapterPostgreSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ CDBStore::Store *CDBAdapterPostgreSQL::getFilesAndIndicesForDimensions(CDataSour
CT::string whereStatement;
std::vector<CT::string> requestedDimVals = requestedDimMap[m.first];

for (int i = 0; i < requestedDimVals.size(); ++i) {
for (size_t i = 0; i < requestedDimVals.size(); ++i) {
if (requestedDimVals[i].equals("*")) continue;

if (i != 0) {
Expand Down Expand Up @@ -717,7 +717,7 @@ std::map<CT::string, DimInfo> CDBAdapterPostgreSQL::getTableNamesForPathFilterAn
}

// Found all tablenames for requested dimensions in lookup table
int found = tableDimStore->size();
size_t found = tableDimStore->size();
delete tableDimStore;
if (found == mapping.size()) {
#ifdef MEASURETIME
Expand Down Expand Up @@ -1080,3 +1080,87 @@ int CDBAdapterPostgreSQL::addFilesToDataBase() {
#endif
return 0;
}

int CDBAdapterPostgreSQL::storeLayerMetadata(const char *datasetName, const char *layerName, const char *metadataKey, const char *metadataBlob) {
lukas-phaf marked this conversation as resolved.
Show resolved Hide resolved
#ifdef MEASURETIME
StopWatch_Stop(">CDBAdapterPostgreSQL::storeLayerMetadata");
#endif
CPGSQLDB *dataBaseConnection = getDataBaseConnection();
if (dataBaseConnection == NULL) {
return -1;
belentorrente marked this conversation as resolved.
Show resolved Hide resolved
}

CT::string tableColumns("datasetname varchar (255), layername varchar (255), metadatakey varchar (255), updatetime TIMESTAMPTZ, blob JSONB, PRIMARY KEY (datasetname, layername, metadatakey)");
lukas-phaf marked this conversation as resolved.
Show resolved Hide resolved

int status = dataBaseConnection->checkTable("layermetadata", tableColumns.c_str());
if (status == 1) {
CDBError("\nFAIL: Table layermetadata could not be created: %s", tableColumns.c_str());
throw(__LINE__);
}

CT::string updateTime = CTime::currentDateTime().c_str();
updateTime.setSize(19);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Convert through c_str(), and resive?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to reduce the size because the postgresl timestamp column does not accept the trailing Z

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Another thing is that CTime::currentDateTime() already returns a CT::string, why go through c_str()?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check if the times in the table are correct if the DB and client are not running in UTC time zone?
Because I think inserting a time without timeonze into time TIMESTAMPTZ column might trigger timezone conversion.

See here:
For timestamp with time zone, the internally stored value is always in UTC (Universal Coordinated Time, traditionally known as Greenwich Mean Time, GMT). An input value that has an explicit time zone specified is converted to UTC using the appropriate offset for that time zone. If no time zone is stated in the input string, then it is assumed to be in the time zone indicated by the system's [TimeZone](https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-TIMEZONE) parameter, and is converted to UTC using the offset for the timezone zone.

Can we get the timestamp in a format like this to avoid the issue:
1999-01-08 04:05:06 -8:00

Maybe instead of resizing, just replace Z by 0:00?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not able to insert timestamps with the suggested format. But I changed the type from TIMESTAMPTZ to TIMESTAMP and now I see UTC timestamps in the table.

CT::string query;
query.print("INSERT INTO layermetadata values (E'%s',E'%s', E'%s', E'%s', E'%s') "
lukas-phaf marked this conversation as resolved.
Show resolved Hide resolved
"ON CONFLICT (datasetname, layername, metadatakey) "
"DO UPDATE SET blob = excluded.blob, updatetime = excluded.updatetime;",
datasetName, layerName, metadataKey, updateTime.c_str(), metadataBlob);

status = dataBaseConnection->query(query.c_str());
if (status != 0) {
CDBError("Unable to insert records: \"%s\"", query.c_str());
throw(__LINE__);
}
#ifdef MEASURETIME
StopWatch_Stop("<CDBAdapterPostgreSQL::storeLayerMetadata");
#endif
return 0;
}

CT::string CDBAdapterPostgreSQL::getLayerMetadata(const char *datasetName, const char *layerName, const char *metadataKey) {
#ifdef MEASURETIME
StopWatch_Stop(">CDBAdapterPostgreSQL::getLayerMetadata");
#endif

if (this->layerMetaDataStore == nullptr) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a cache, right? The idea is to avoid multiple queries to the DB when this function gets called for different layers and metadataKey, right?

What if this function get called again with a different datasetName?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is cache, in this case for this dataset.

There are currently no cases for multiple datasets in one process.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true (as all the tests works...), but at the very least the function comments should make this very clear. Or be safe and implement the case by storing the values in a map bydatasetName.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will be done in the follow up MR where we want to return all datasets with their layer info using one request.

#ifdef CDBAdapterPostgreSQL_DEBUG
CDBDebug("Need to query layer metadata for %s/%s/%s", datasetName, layerName, metadataKey);
#endif
CPGSQLDB *dataBaseConnection = getDataBaseConnection();
if (dataBaseConnection == NULL) {
CDBError("No database connection");
throw(__LINE__);
}
mgrunbauer marked this conversation as resolved.
Show resolved Hide resolved

CT::string query;
query.print("SELECT layername, metadatakey, blob from layermetadata where datasetname = '%s';", datasetName);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we haven't so far worried about SQL injection, but this one seems a bit easy to access:
Do a GetCapabilties call with a DROP TABLES some where in the dataset name would do the trick, I think?

Probably for the already existing DB tables, the queries are by layer name, and these are checked in the dataset configs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the datasetname is checked early in the process.

Nevertheless I added the same check, just in case we forget or misuse it in another way.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkIfPathHasValidTokens() is in other cases use to validate path, not sure it helps against SQL injection.

I'll look at the other check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use

CServerParams::checkForValidTokens(datasetName, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-:/."

lukas-phaf marked this conversation as resolved.
Show resolved Hide resolved
this->layerMetaDataStore = dataBaseConnection->queryToStore(query.c_str());
if (layerMetaDataStore == nullptr) {
#ifdef CDBAdapterPostgreSQL_DEBUG
CDBDebug("Unable query: \"%s\"", query.c_str());
#endif
throw(__LINE__);
}
if (layerMetaDataStore->size() == 0) {
CDBDebug("No results \"%s\"", query.c_str());
throw(__LINE__);
mgrunbauer marked this conversation as resolved.
Show resolved Hide resolved
}
}

auto records = layerMetaDataStore->getRecords();
for (auto record : records) {
if (record->get("layername")->equals(layerName) && record->get("metadatakey")->equals(metadataKey)) {
#ifdef MEASURETIME
StopWatch_Stop("<CDBAdapterPostgreSQL::getLayerMetadata");
#endif
return record->get("blob");
}
}
// CDBDebug(store->getRecord(0)->get("blob")->c_str());

#ifdef MEASURETIME
StopWatch_Stop("<CDBAdapterPostgreSQL::getLayerMetadata");
#endif
CDBDebug("No metadata entry found for %s %s %s", datasetName, layerName, metadataKey);
throw __LINE__;
}
4 changes: 4 additions & 0 deletions adagucserverEC/CDBAdapterPostgreSQL.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class CDBAdapterPostgreSQL : public CDBAdapter {
std::map<std::string, std::vector<std::string>> fileListPerTable;
int createDimTableOfType(const char *dimname, const char *tablename, int type);

CDBStore::Store *layerMetaDataStore = nullptr;
mgrunbauer marked this conversation as resolved.
Show resolved Hide resolved
lukas-phaf marked this conversation as resolved.
Show resolved Hide resolved

public:
CDBAdapterPostgreSQL();
~CDBAdapterPostgreSQL();
Expand Down Expand Up @@ -87,4 +89,6 @@ class CDBAdapterPostgreSQL : public CDBAdapter {
int setFileString(const char *tablename, const char *file, const char *dimvalue, int dimindex, const char *filedate, GeoOptions *geoOptions);
int setFileTimeStamp(const char *tablename, const char *file, const char *dimvalue, int dimindex, const char *filedate, GeoOptions *geoOptions);
int addFilesToDataBase();
int storeLayerMetadata(const char *datasetName, const char *layerName, const char *metadataKey, const char *metadatablob);
CT::string getLayerMetadata(const char *datasetName, const char *layerName, const char *metadataKey);
};
8 changes: 3 additions & 5 deletions adagucserverEC/CDBAdapterSQLLite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,11 +694,6 @@ CDBStore::Store *CDBAdapterSQLLite::getFilesAndIndicesForDimensions(CDataSource

int CDBAdapterSQLLite::autoUpdateAndScanDimensionTables(CDataSource *dataSource) {
CServerParams *srvParams = dataSource->srvParams;
;
// if(srvParams->isAutoLocalFileResourceEnabled()==false){
// CDBDebug("Auto update is not available");
// return 0;
// }
CServerConfig::XMLE_Layer *cfgLayer = dataSource->cfgLayer;
CSQLLiteDB *dataBaseConnection = getDataBaseConnection();
if (dataBaseConnection == NULL) {
Expand Down Expand Up @@ -1310,4 +1305,7 @@ CDBStore::Store *CDBAdapterSQLLite::getFilesForIndices(CDataSource *dataSource,
return store;
}

int CDBAdapterSQLLite::storeLayerMetadata(const char *, const char *, const char *, const char *) { return 0; }
CT::string CDBAdapterSQLLite::getLayerMetadata(const char *, const char *, const char *) { return ""; }

#endif
2 changes: 2 additions & 0 deletions adagucserverEC/CDBAdapterSQLLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,7 @@ class CDBAdapterSQLLite : public CDBAdapter {
int setFileString(const char *tablename, const char *file, const char *dimvalue, int dimindex, const char *filedate, GeoOptions *geoOptions);
int setFileTimeStamp(const char *tablename, const char *file, const char *dimvalue, int dimindex, const char *filedate, GeoOptions *geoOptions);
int addFilesToDataBase();
int storeLayerMetadata(const char *datasetName, const char *layerName, const char *metadataKey, const char *metadatablob);
CT::string getLayerMetadata(const char *datasetName, const char *layerName, const char *metadataKey);
lukas-phaf marked this conversation as resolved.
Show resolved Hide resolved
};
#endif
9 changes: 7 additions & 2 deletions adagucserverEC/CDBFileScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "CNetCDFDataWriter.h"
#include "CCreateTiles.h"
#include <set>
#include "utils/LayerMetadataStore.h"
const char *CDBFileScanner::className = "CDBFileScanner";
std::vector<CT::string> CDBFileScanner::tableNamesDone;
// #define CDBFILESCANNER_DEBUG
Expand Down Expand Up @@ -820,7 +821,7 @@ int CDBFileScanner::DBLoopFiles(CDataSource *dataSource, int removeNonExistingFi
// delete cdfObject;cdfObject=NULL;
// cdfObject=CDFObjectStore::getCDFObjectStore()->deleteCDFObject(&cdfObject);
} catch (int linenr) {
CDBError("Exception in DBLoopFiles at line %d");
CDBError("Exception in DBLoopFiles at line %d", linenr);
mgrunbauer marked this conversation as resolved.
Show resolved Hide resolved
CDBError(" *** SKIPPING FILE %s ***", (*fileList)[j].c_str());
// Close cdfObject. this is only needed if an exception occurs, otherwise it does nothing...
// delete cdfObject;cdfObject=NULL;
Expand Down Expand Up @@ -1052,6 +1053,10 @@ int CDBFileScanner::updatedb(CDataSource *dataSource, CT::string *_tailPath, CT:
}
}

if (scanFlags & CDBFILESCANNER_UPDATEDB) {
updateMetaDataTable(dataSource);
}

CDBDebug(" ==> *** Finished update layer [%s] ***", dataSource->cfgLayer->Name[0]->value.c_str());
return 0;
}
Expand Down Expand Up @@ -1101,7 +1106,7 @@ std::vector<std::string> CDBFileScanner::searchFileNames(const char *path, CT::s
if (expr.empty() == false) { // dataSource->cfgLayer->FilePath[0]->attr.filter.c_str()
fileFilterExpr.copy(&expr);
}
CDBDebug("Reading directory %s with filter %s", filePath.c_str(), fileFilterExpr.c_str());
// CDBDebug("Reading directory %s with filter %s", filePath.c_str(), fileFilterExpr.c_str());

CDirReader *dirReader = CCachedDirReader::getDirReader(filePath.c_str(), fileFilterExpr.c_str());
dirReader->listDirRecursive(filePath.c_str(), fileFilterExpr.c_str());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <ranges>
#include "CDataPostProcessor_IncludeLayer.h"
#include "CRequest.h"
#include <utils/LayerUtils.h>
/************************/
/*CDPPIncludeLayer */
/************************/
Expand All @@ -20,7 +21,7 @@ CDataSource *CDPPIncludeLayer::getDataSource(CServerConfig::XMLE_DataPostProc *p
size_t additionalLayerNo = 0;
for (size_t j = 0; j < dataSource->srvParams->cfg->Layer.size(); j++) {
CT::string layerName;
dataSource->srvParams->makeUniqueLayerName(&layerName, dataSource->srvParams->cfg->Layer[j]);
makeUniqueLayerName(&layerName, dataSource->srvParams->cfg->Layer[j]);
// CDBDebug("comparing for additionallayer %s==%s", additionalLayerName.c_str(), layerName.c_str());
if (additionalLayerName.equals(layerName)) {
additionalLayerNo = j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ int CDPPOperator::execute(CServerConfig::XMLE_DataPostProc *proc, CDataSource *d
newDataObject->cdfVariable->setAttributeText("units", proc->attr.units);
}

short attrData[3];
attrData[0] = -1;
double attrData[1];
attrData[0] = 0;
Comment on lines +67 to +68
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change intended?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the original fillvalue was wrong, I saw this in the tests.

newDataObject->cdfVariable->setAttribute("_FillValue", newDataObject->cdfVariable->getType(), attrData, 1);

newDataObject->cdfVariable->setCustomReader(CDF::Variable::CustomMemoryReaderInstance);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "CDataPostProcessor_WFP.h"
#include "CRequest.h"
#include "CGenericDataWarper.h"
#include <utils/LayerUtils.h>

/************************/
/* CDPPWFP */
Expand All @@ -25,7 +26,7 @@ CDataSource *CDPPWFP::getDataSource(CDataSource *dataSource, CT::string baseLaye
size_t additionalLayerNo = 0;
for (size_t j = 0; j < dataSource->srvParams->cfg->Layer.size(); j++) {
CT::string layerName;
dataSource->srvParams->makeUniqueLayerName(&layerName, dataSource->srvParams->cfg->Layer[j]);
makeUniqueLayerName(&layerName, dataSource->srvParams->cfg->Layer[j]);
if (baseLayerName.equals(layerName)) {
additionalLayerNo = j;
break;
Expand Down
13 changes: 1 addition & 12 deletions adagucserverEC/CDataReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ int CDataReader::parseDimensions(CDataSource *dataSource, int mode, int x, int y
#ifdef CDATAREADER_DEBUG
CDBDebug("Number of dimensions = %d", dataSource->dNetCDFNumDims);
#endif

// Determine the X and Y dimensions and variables.
determineXAndYDimIndices(dataSource, dataSourceVar);
if (!determineXandYVars(dataSource, dataSourceVar, cdfObject)) {
Expand Down Expand Up @@ -847,15 +846,10 @@ int CDataReader::open(CDataSource *dataSource, int mode, int x, int y, int *grid
if (x != -1 && y != -1) {
singleCellMode = true;
}

CT::string dataSourceFilename;
dataSourceFilename.copy(dataSource->getFileName());

// CCache cache;
// CT::string cacheFilename;
// pthread_mutex_lock(&CDataReader_open_lock);
CStyleConfiguration *styleConfiguration = dataSource->getStyle();
// pthread_mutex_unlock(&CDataReader_open_lock);

// Use autoscale of legendcolors when the legendscale factor has been set to zero.
if (styleConfiguration != NULL) {
if (dataSource->stretchMinMaxDone == false) {
Expand All @@ -867,7 +861,6 @@ int CDataReader::open(CDataSource *dataSource, int mode, int x, int y, int *grid
}

CDFObject *cdfObject = NULL;

#ifdef CDATAREADER_DEBUG
CDBDebug("Working on [%s] with mode %d and (%d,%d)", dataSourceFilename.c_str(), mode, x, y);

Expand All @@ -876,19 +869,16 @@ int CDataReader::open(CDataSource *dataSource, int mode, int x, int y, int *grid
CDBDebug("Working on [%s]", dataSourceFilename.c_str());
}
#endif

if (mode == CNETCDFREADER_MODE_OPEN_DIMENSIONS || mode == CNETCDFREADER_MODE_OPEN_HEADER) {
cdfObject = CDFObjectStore::getCDFObjectStore()->getCDFObjectHeader(dataSource, dataSource->srvParams, dataSourceFilename.c_str(), enableObjectCache);
}

if (mode == CNETCDFREADER_MODE_OPEN_ALL || mode == CNETCDFREADER_MODE_GET_METADATA || mode == CNETCDFREADER_MODE_OPEN_EXTENT) {
cdfObject = CDFObjectStore::getCDFObjectStore()->getCDFObject(dataSource, dataSourceFilename.c_str(), enableObjectCache);
}
if (cdfObject == NULL) {
CDBError("Unable to get CDFObject from store");
return 1;
}

if (dataSource->attachCDFObject(cdfObject) != 0) {
CDBError("Unable to attach CDFObject");
return 1;
Expand All @@ -914,7 +904,6 @@ int CDataReader::open(CDataSource *dataSource, int mode, int x, int y, int *grid
#ifdef MEASURETIME
StopWatch_Stop("parseDimensions done");
#endif

if (dataSource->useLonTransformation != -1 && gridExtent == NULL) {
for (size_t varNr = 0; varNr < dataSource->getNumDataObjects(); varNr++) {
Proc::swapPixelsAtLocation(dataSource, dataSource->getDataObject(varNr)->cdfVariable, 0);
Expand Down
Loading