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

Feature/fdb 389 dump tools #75

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
4 changes: 2 additions & 2 deletions src/fdb5/toc/TocCatalogueWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool TocCatalogueWriter::selectIndex(const Key& idxKey) {
fdb5LustreapiFileCreate(indexPath, stripeIndexLustreSettings());
}

indexes_[idxKey] = Index(new TocIndex(idxKey, *this, indexPath, 0, TocIndex::WRITE));
indexes_[idxKey] = Index(new TocIndex(idxKey, indexPath, 0, TocIndex::WRITE));
}

current_ = indexes_[idxKey];
Expand All @@ -88,7 +88,7 @@ bool TocCatalogueWriter::selectIndex(const Key& idxKey) {
fdb5LustreapiFileCreate(indexPath, stripeIndexLustreSettings());
}

fullIndexes_[idxKey] = Index(new TocIndex(idxKey, *this, indexPath, 0, TocIndex::WRITE));
fullIndexes_[idxKey] = Index(new TocIndex(idxKey, indexPath, 0, TocIndex::WRITE));
}

currentFull_ = fullIndexes_[idxKey];
Expand Down
15 changes: 8 additions & 7 deletions src/fdb5/toc/TocEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace fdb5 {

//----------------------------------------------------------------------------------------------------------------------

void TocEngine::scan_dbs(const std::string& path, std::list<std::string>& dbs) const {
void TocEngine::scan_dbs(const std::string& path, std::list<std::string>& dbs, bool lowercase) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be moved into unnamed namespace
it's always lowercase=true, need it ?


eckit::StdDir d(path.c_str());

Expand Down Expand Up @@ -73,7 +73,7 @@ void TocEngine::scan_dbs(const std::string& path, std::list<std::string>& dbs) c
#if defined(eckit_HAVE_DIRENT_D_TYPE)
do_stat = false;
if (e->d_type == DT_DIR) {
dbs.push_back(full);
dbs.push_back(lowercase ? eckit::StringTools::lower(full) : full);
} else if (e->d_type == DT_UNKNOWN) {
do_stat = true;
}
Expand All @@ -83,7 +83,7 @@ void TocEngine::scan_dbs(const std::string& path, std::list<std::string>& dbs) c
if(eckit::Stat::stat(full.c_str(), &info) == 0)
{
if(S_ISDIR(info.st_mode)) {
dbs.push_back(full);
dbs.push_back(lowercase ? eckit::StringTools::lower(full) : full);
}
}
else Log::error() << "Cannot stat " << full << Log::syserr << std::endl;
Expand Down Expand Up @@ -138,17 +138,18 @@ std::map<eckit::PathName, const Rule*> TocEngine::databases(const std::map<Key,

LOG_DEBUG_LIB(LibFdb5) << "Scanning for TOC FDBs in root " << *j << std::endl;

std::string regex_prefix = "^" + eckit::StringTools::lower(Regex::escape(j->asString())) + "/";
std::list<std::string> dbs;
scan_dbs(*j, dbs);
scan_dbs(*j, dbs, true);

for (const auto& [key, rule] : keys) {

std::vector<std::string> dbpaths = CatalogueRootManager(config).possibleDbPathNames(key, regexForMissingValues);

for(const std::string& dbpath : dbpaths) {

std::string regex = "^" + Regex::escape(j->asString()) + "/" + dbpath + "$";
std::regex reg(regex, std::regex::icase | std::regex::optimize);
std::string regex = regex_prefix + eckit::StringTools::lower(dbpath) + "$";
eckit::Regex reg(regex);

LOG_DEBUG_LIB(LibFdb5) << " -> key " << key
<< " dbpath " << dbpath
Expand All @@ -163,7 +164,7 @@ std::map<eckit::PathName, const Rule*> TocEngine::databases(const std::map<Key,
continue;
}

if (std::regex_match(*k, m, reg)) {
if (reg.match(*k)) {
result[*k] = rule;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/toc/TocEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TocEngine : public fdb5::Engine {
std::vector<eckit::URI> databases(const metkit::mars::MarsRequest& rq, const std::vector<eckit::PathName>& dirs,
const Config& config) const;

void scan_dbs(const std::string& path, std::list<std::string>& dbs) const;
void scan_dbs(const std::string& path, std::list<std::string>& dbs, bool lowercase = false) const;
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be removed


protected: // methods

Expand Down
8 changes: 4 additions & 4 deletions src/fdb5/toc/TocHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ std::vector<Index> TocHandler::loadIndexes(const Catalogue& catalogue, bool sort
s >> offset;
s >> type;
LOG_DEBUG(debug, LibFdb5) << "TocRecord TOC_INDEX " << path << " - " << offset << std::endl;
tocindexes[entry.seqNo] = new TocIndex(s, catalogue, entry.datap->header_.serialisationVersion_,
tocindexes[entry.seqNo] = new TocIndex(s, entry.datap->header_.serialisationVersion_,
Copy link
Contributor

Choose a reason for hiding this comment

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

could you remove catalogue from 1- lambda, and 2- ::loadIndexes() .. also from enumerateMasked ?

Copy link
Contributor

Choose a reason for hiding this comment

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

not this PR but can add threads.reserve(nthreads); above ?

entry.tocDirectoryName,
entry.tocDirectoryName / path,
offset, preloadBTree_);
Expand Down Expand Up @@ -1443,7 +1443,7 @@ void TocHandler::dump(std::ostream& out, bool simple, bool walkSubTocs) const {
s >> type;
out << " Path: " << path << ", offset: " << offset << ", type: " << type;
if(!simple) { out << std::endl; }
Index index(new TocIndex(s, *(dynamic_cast<const TocCatalogue*>(this)), r->header_.serialisationVersion_,
Index index(new TocIndex(s, r->header_.serialisationVersion_,
currentDirectory(), currentDirectory() / path, offset));
index.dump(out, " ", simple);
break;
Expand Down Expand Up @@ -1500,7 +1500,7 @@ void TocHandler::dumpIndexFile(std::ostream& out, const eckit::PathName& indexFi
if ((currentDirectory() / path).sameAs(eckit::LocalPathName{indexFile})) {
r->dump(out, true);
out << std::endl << " Path: " << path << ", offset: " << offset << ", type: " << type;
Index index(new TocIndex(s, *(dynamic_cast<const TocCatalogue*>(this)), r->header_.serialisationVersion_,
Index index(new TocIndex(s, r->header_.serialisationVersion_,
currentDirectory(), currentDirectory() / path, offset));
index.dump(out, " ", false, true);
}
Expand Down Expand Up @@ -1609,7 +1609,7 @@ void TocHandler::enumerateMasked(const Catalogue& catalogue, std::set<std::pair<
std::pair<eckit::LocalPathName, size_t> key(absPath.baseName(), offset);
if (maskedEntries_.find(key) != maskedEntries_.end()) {
if (absPath.exists()) {
Index index(new TocIndex(s, *(dynamic_cast<const TocCatalogue*>(this)), r->header_.serialisationVersion_, directory_, absPath, offset));
Index index(new TocIndex(s, r->header_.serialisationVersion_, directory_, absPath, offset));
for (const auto& dataURI : index.dataURIs()) data.insert(dataURI);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/fdb5/toc/TocIndex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class TocIndexCloser {
/// the members of TocIndex

TocIndex::TocIndex(const Key& key,
const Catalogue& catalogue,
const eckit::PathName& path,
off_t offset,
Mode mode,
Expand All @@ -60,7 +59,6 @@ TocIndex::TocIndex(const Key& key,
preloadBTree_(false) { }

TocIndex::TocIndex(eckit::Stream& s,
const Catalogue& catalogue,
const int version,
const eckit::PathName& directory,
const eckit::PathName& path,
Expand Down
2 changes: 0 additions & 2 deletions src/fdb5/toc/TocIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ class TocIndex :
public: // methods

TocIndex(const Key& key,
const Catalogue& catalogue,
const eckit::PathName &path,
off_t offset,
Mode mode,
const std::string& type = defaulType());

TocIndex(eckit::Stream &,
const Catalogue& catalogue,
const int version,
const eckit::PathName &directory,
const eckit::PathName &path,
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/tools/fdb-read.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void FDBRead::execute(const eckit::option::CmdArgs &args) {

std::unique_ptr<eckit::DataHandle> dh(handles.dataHandle());

dh->copyTo(out);
dh->saveInto(out);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why have we changed copyTo into saveInto? That changes behaviour.

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'm reverting to saveInto
with copyTo we lack the statistics

}


Expand Down
Loading