Skip to content

Commit

Permalink
[ntuple] change filesystem::path to std::string for fOutputPath
Browse files Browse the repository at this point in the history
  • Loading branch information
silverweed committed Dec 13, 2024
1 parent a3422dd commit c01239c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions tree/ntupleutil/v7/inc/ROOT/RNTupleExporter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#ifndef ROOT7_RNTupleExporter
#define ROOT7_RNTupleExporter

#include <filesystem>
#include <cstdint>
#include <string>
#include <vector>

namespace ROOT::Experimental::Internal {
Expand All @@ -35,7 +36,7 @@ public:
kDefaults = kShowProgressBar
};

std::filesystem::path fOutputPath;
std::string fOutputPath;
std::uint64_t fFlags;

RPagesOptions() : fOutputPath("."), fFlags(kDefaults) {}
Expand Down
2 changes: 1 addition & 1 deletion tree/ntupleutil/v7/src/RNTupleExporter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ RNTupleExporter::RPagesResult RNTupleExporter::ExportPages(RPageSource &source,
const bool incChecksum = (options.fFlags & RPagesOptions::kIncludeChecksums) != 0 && pageInfo.fHasChecksum;
const std::size_t maybeChecksumSize = incChecksum * 8;
const std::uint64_t pageBufSize = pageInfo.fLocator.fBytesOnStorage + maybeChecksumSize;
std::ostringstream ss{options.fOutputPath.string(), std::ios_base::ate};
std::ostringstream ss{options.fOutputPath, std::ios_base::ate};
ss << "/cluster_" << clusterDesc.GetId() << "_" << colInfo.fQualifiedName << "_page_" << pageIdx
<< "_elems_" << pageInfo.fNElements << "_comp_" << colRange.fCompressionSettings << ".page";
const auto outFileName = ss.str();
Expand Down
4 changes: 4 additions & 0 deletions tree/ntupleutil/v7/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ endif()
ROOT_ADD_GTEST(ntuple_importer ntuple_importer.cxx LIBRARIES ROOTNTupleUtil CustomStructUtil)
ROOT_ADD_GTEST(ntuple_exporter ntuple_exporter.cxx LIBRARIES ROOTNTupleUtil)
ROOT_ADD_GTEST(ntuple_inspector ntuple_inspector.cxx LIBRARIES ROOTNTupleUtil)

if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
target_link_libraries(ntuple_exporter stdc++fs)
endif()
9 changes: 5 additions & 4 deletions tree/ntupleutil/v7/test/ntuple_exporter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <ROOT/RNTupleModel.hxx>

#include "ntupleutil_test.hxx"
#include <filesystem>

using namespace ROOT::Experimental;

Expand Down Expand Up @@ -268,7 +269,7 @@ TEST(RNTupleExporter, ExportToFilesCustomPath)
}

// create tmp directory
static const std::filesystem::path kDirName = "rntuple_exporter_custom_path";
static const std::string kDirName = "rntuple_exporter_custom_path";
bool ok = std::filesystem::create_directory(kDirName);
if (!ok) {
FAIL() << "failed to create directory " << kDirName;
Expand All @@ -286,9 +287,9 @@ TEST(RNTupleExporter, ExportToFilesCustomPath)

EXPECT_EQ(res.fExportedFileNames.size(), 3);

FileRaii pageVecIdx(kDirName / "cluster_0_vec-0_page_0_elems_100_comp_505.page");
FileRaii pageVec(kDirName / "cluster_0_vec._0-0_page_0_elems_2000_comp_505.page");
FileRaii pageFlt(kDirName / "cluster_0_flt-0_page_0_elems_100_comp_505.page");
FileRaii pageVecIdx(kDirName + "/cluster_0_vec-0_page_0_elems_100_comp_505.page");
FileRaii pageVec(kDirName + "/cluster_0_vec._0-0_page_0_elems_2000_comp_505.page");
FileRaii pageFlt(kDirName + "/cluster_0_flt-0_page_0_elems_100_comp_505.page");

EXPECT_TRUE(std::find(res.fExportedFileNames.begin(), res.fExportedFileNames.end(), pageFlt.GetPath()) !=
res.fExportedFileNames.end());
Expand Down
3 changes: 1 addition & 2 deletions tree/ntupleutil/v7/test/ntupleutil_test.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <ROOT/RNTupleReader.hxx>
#include <ROOT/RNTupleWriteOptions.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <filesystem>

/**
* An RAII wrapper around an open temporary file on disk. It cleans up the
Expand All @@ -27,7 +26,7 @@ public:
~FileRaii()
{
if (!fPreserveFile)
std::filesystem::remove(fPath.c_str());
std::remove(fPath.c_str());
}
std::string GetPath() const { return fPath; }

Expand Down

0 comments on commit c01239c

Please sign in to comment.