Skip to content

Commit

Permalink
Remove InputFileCatalog::logicalFileNames as unnecessary
Browse files Browse the repository at this point in the history
The logicalFileNames() was not used, so removing the member allows
avoiding one copy of the LFNs.
  • Loading branch information
makortel committed Jan 7, 2025
1 parent cff58ae commit 3b2822e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 35 deletions.
7 changes: 4 additions & 3 deletions FWCore/Catalog/interface/InputFileCatalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,19 @@ namespace edm {

~InputFileCatalog();
std::vector<FileCatalogItem> const& fileCatalogItems() const { return fileCatalogItems_; }
std::vector<std::string> const& logicalFileNames() const { return logicalFileNames_; }
std::vector<std::string> fileNames(unsigned iCatalog) const;
bool empty() const { return fileCatalogItems_.empty(); }
static bool isPhysical(std::string const& name) { return (name.empty() || name.find(':') != std::string::npos); }

private:
void init(std::string const& override, bool useLFNasPFNifLFNnotFound, edm::CatalogType catType);
void init(std::vector<std::string> logicalFileNames,
std::string const& override,
bool useLFNasPFNifLFNnotFound,
edm::CatalogType catType);
void findFile(std::string const& lfn,
std::vector<std::string>& pfns,
bool useLFNasPFNifLFNnotFound,
edm::CatalogType catType);
std::vector<std::string> logicalFileNames_;
std::vector<FileCatalogItem> fileCatalogItems_;
edm::propagate_const<std::unique_ptr<FileLocator>> overrideFileLocator_;

Expand Down
11 changes: 6 additions & 5 deletions FWCore/Catalog/src/InputFileCatalog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace edm {
std::string const& override,
bool useLFNasPFNifLFNnotFound,
edm::CatalogType catType)
: logicalFileNames_(fileNames), fileCatalogItems_(), overrideFileLocator_() {
init(override, useLFNasPFNifLFNnotFound, catType);
: fileCatalogItems_(), overrideFileLocator_() {
init(fileNames, override, useLFNasPFNifLFNnotFound, catType);
}

InputFileCatalog::~InputFileCatalog() {}
Expand All @@ -36,7 +36,8 @@ namespace edm {
return tmp;
}

void InputFileCatalog::init(std::string const& inputOverride,
void InputFileCatalog::init(std::vector<std::string> logicalFileNames,
std::string const& inputOverride,
bool useLFNasPFNifLFNnotFound,
edm::CatalogType catType) {
typedef std::vector<std::string>::iterator iter;
Expand Down Expand Up @@ -123,7 +124,7 @@ namespace edm {
throw ex;
}

for (auto& lfn : logicalFileNames_) {
for (auto& lfn : logicalFileNames) {
boost::trim(lfn);
std::vector<std::string> pfns;
if (lfn.empty()) {
Expand All @@ -147,7 +148,7 @@ namespace edm {
}
lfn.shrink_to_fit(); // try to release memory

fileCatalogItems_.emplace_back(std::move(pfns), lfn);
fileCatalogItems_.emplace_back(std::move(pfns), std::move(lfn));
}
}

Expand Down
24 changes: 0 additions & 24 deletions FWCore/Catalog/test/InputFileCatalog_t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ TEST_CASE("InputFileCatalog with Rucio data catalog", "[FWCore/Catalog]") {

edm::InputFileCatalog catalog(std::vector<std::string>{"/store/foo/bar", " file:/foo/bar", "root://foobar "}, "");

SECTION("logicalFileNames") {
auto const& lfns = catalog.logicalFileNames();
REQUIRE(lfns.size() == 3);
CHECK(lfns[0] == "/store/foo/bar");
CHECK(lfns[1] == ""); // was PFN
CHECK(lfns[2] == ""); // was PFN
}

SECTION("fileNames") {
SECTION("Catalog 0") {
auto const names = catalog.fileNames(0);
Expand Down Expand Up @@ -76,14 +68,6 @@ TEST_CASE("InputFileCatalog with Rucio data catalog", "[FWCore/Catalog]") {
edm::InputFileCatalog catalog(std::vector<std::string>{"/store/foo/bar", " file:/foo/bar", "root://foobar "},
"T1_US_FNAL,,T1_US_FNAL,FNAL_dCache_EOS,XRootD");

SECTION("logicalFileNames") {
auto const& lfns = catalog.logicalFileNames();
REQUIRE(lfns.size() == 3);
CHECK(lfns[0] == "/store/foo/bar");
CHECK(lfns[1] == ""); // was PFN
CHECK(lfns[2] == ""); // was PFN
}

SECTION("fileNames") {
auto const names = catalog.fileNames(0);
REQUIRE(names.size() == 3);
Expand Down Expand Up @@ -116,14 +100,6 @@ TEST_CASE("InputFileCatalog with Rucio data catalog", "[FWCore/Catalog]") {
edm::InputFileCatalog catalog(
std::vector<std::string>{"/store/foo/bar", "/tmp/foo/bar", "root://foobar "}, "", true);

SECTION("logicalFileNames") {
auto const& lfns = catalog.logicalFileNames();
REQUIRE(lfns.size() == 3);
CHECK(lfns[0] == "/store/foo/bar");
CHECK(lfns[1] == "/tmp/foo/bar");
CHECK(lfns[2] == ""); // was PFN
}

SECTION("fileNames") {
SECTION("Catalog 0") {
auto const names = catalog.fileNames(0);
Expand Down
1 change: 0 additions & 1 deletion FWCore/Sources/interface/FromFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace edm {
FromFiles(ParameterSet const& pset);
~FromFiles();

std::vector<std::string> const& logicalFileNames() const { return catalog_.logicalFileNames(); }
std::vector<std::string> fileNames(unsigned iCatalog) const { return catalog_.fileNames(iCatalog); }
InputFileCatalog& catalog() { return catalog_; }

Expand Down
1 change: 0 additions & 1 deletion FWCore/Sources/interface/ProducerSourceFromFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace edm {

using FromFiles::catalog;
using FromFiles::fileNames;
using FromFiles::logicalFileNames;

static void fillDescription(ParameterSetDescription& desc);

Expand Down
1 change: 0 additions & 1 deletion FWCore/Sources/interface/RawInputSourceFromFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace edm {
~RawInputSourceFromFiles() override;

using FromFiles::catalog;
using FromFiles::logicalFileNames;

static void fillDescription(ParameterSetDescription& desc);

Expand Down

0 comments on commit 3b2822e

Please sign in to comment.