summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-07-23 10:53:10 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-07-25 07:57:52 +0000
commit59192dd1d07356497ea311b7f0d6a3b50f726f13 (patch)
tree5f9492d5ce9dd1e4b0125f7d6318127c30a964d6 /searchcore
parent78a211072a21ec5f368b99bce19c1b703d98152d (diff)
Prefer std::filesystem::exists over FastOS_StatInfo
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp12
-rw-r--r--searchcore/src/tests/proton/attribute/attributeflush_test.cpp15
-rw-r--r--searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp7
-rw-r--r--searchcore/src/vespa/searchcorespi/index/indexwriteutilities.cpp10
4 files changed, 22 insertions, 22 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp
index 140012624c2..2bf7aa85a0c 100644
--- a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp
@@ -39,7 +39,6 @@
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/config-attributes.h>
-#include <vespa/fastos/file.h>
#include <vespa/log/log.h>
LOG_SETUP("attribute_manager_test");
@@ -77,6 +76,8 @@ using AVConfig = search::attribute::Config;
using AttrSpecList = proton::AttributeCollectionSpec::AttributeList;
using AttrMgrSpec = proton::AttributeCollectionSpec;
+namespace fs = std::filesystem;
+
namespace {
const uint64_t createSerialNum = 42u;
@@ -567,10 +568,9 @@ TEST_F("require that removed fields can be pruned", Fixture)
SequentialAttributeManager sam(f._m, AttrMgrSpec(std::move(newSpec), 1, 11));
sam.mgr.pruneRemovedFields(11);
- FastOS_StatInfo si;
- EXPECT_TRUE(!FastOS_File::Stat(vespalib::string(test_dir + "/a1").c_str(), &si));
- EXPECT_TRUE(FastOS_File::Stat(vespalib::string(test_dir + "/a2").c_str(), &si));
- EXPECT_TRUE(!FastOS_File::Stat(vespalib::string(test_dir + "/a3").c_str(), &si));
+ EXPECT_FALSE(fs::exists(fs::path(test_dir + "/a1")));
+ EXPECT_TRUE(fs::exists(fs::path(test_dir + "/a2")));
+ EXPECT_FALSE(fs::exists(fs::path(test_dir + "/a3")));
}
TEST_F("require that lid space can be compacted", Fixture)
@@ -905,6 +905,6 @@ TEST_F("late create serial number is set on new attributes", Fixture)
TEST_MAIN()
{
- std::filesystem::remove_all(std::filesystem::path(test_dir));
+ fs::remove_all(fs::path(test_dir));
TEST_RUN_ALL();
}
diff --git a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
index dfcc8d1f08b..6b2c7a9e705 100644
--- a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
@@ -43,6 +43,8 @@ using namespace std::literals;
using GateSP = std::shared_ptr<Gate>;
+namespace fs = std::filesystem;
+
namespace proton {
namespace {
@@ -436,9 +438,9 @@ Test::requireThatCleanUpIsPerformedAfterFlush()
std::string base = "flush/a6";
std::string snap10 = "flush/a6/snapshot-10";
std::string snap20 = "flush/a6/snapshot-20";
- std::filesystem::create_directory(std::filesystem::path(base));
- std::filesystem::create_directory(std::filesystem::path(snap10));
- std::filesystem::create_directory(std::filesystem::path(snap20));
+ fs::create_directory(fs::path(base));
+ fs::create_directory(fs::path(snap10));
+ fs::create_directory(fs::path(snap20));
IndexMetaInfo info("flush/a6");
info.addSnapshot(IndexMetaInfo::Snapshot(true, 10, "snapshot-10"));
info.addSnapshot(IndexMetaInfo::Snapshot(false, 20, "snapshot-20"));
@@ -454,9 +456,8 @@ Test::requireThatCleanUpIsPerformedAfterFlush()
EXPECT_EQUAL(1u, info.snapshots().size()); // snapshots 10 & 20 removed
EXPECT_TRUE(info.snapshots()[0].valid);
EXPECT_EQUAL(30u, info.snapshots()[0].syncToken);
- FastOS_StatInfo statInfo;
- EXPECT_TRUE(!FastOS_File::Stat(snap10.c_str(), &statInfo));
- EXPECT_TRUE(!FastOS_File::Stat(snap20.c_str(), &statInfo));
+ EXPECT_FALSE(fs::exists(fs::path(snap10)));
+ EXPECT_FALSE(fs::exists(fs::path(snap20)));
}
@@ -662,7 +663,7 @@ Test::Main()
if (_argc > 0) {
DummyFileHeaderContext::setCreator(_argv[0]);
}
- std::filesystem::remove_all(std::filesystem::path(test_dir));
+ fs::remove_all(fs::path(test_dir));
TEST_DO(requireThatUpdaterAndFlusherCanRunConcurrently());
TEST_DO(requireThatFlushableAttributeReportsMemoryUsage());
TEST_DO(requireThatFlushableAttributeManagesSyncTokenInfo());
diff --git a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp
index c814377af06..f6b05f639ed 100644
--- a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp
+++ b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp
@@ -21,7 +21,6 @@
#include <vespa/vespalib/util/lambdatask.h>
#include <vespa/vespalib/util/destructor_callbacks.h>
#include <vespa/vespalib/util/time.h>
-#include <vespa/fastos/file.h>
#include <filesystem>
#include <sstream>
@@ -45,6 +44,7 @@ using vespalib::string;
using vespalib::Executor;
using vespalib::Runnable;
using vespalib::IDestructorCallback;
+namespace fs = std::filesystem;
namespace searchcorespi::index {
@@ -1081,11 +1081,10 @@ IndexMaintainer::runFusion(const FusionSpec &fusion_spec, std::shared_ptr<search
_activeFusionPrunedSchema.reset();
args._schema = _schema;
}
- FastOS_StatInfo statInfo;
string lastFlushDir(getFlushDir(fusion_spec.flush_ids.back()));
string lastSerialFile = IndexDiskLayout::getSerialNumFileName(lastFlushDir);
SerialNum serialNum = 0;
- if (FastOS_File::Stat(lastSerialFile.c_str(), &statInfo)) {
+ if (fs::exists(fs::path(lastSerialFile))) {
serialNum = IndexReadUtilities::readSerialNum(lastFlushDir);
}
IndexDiskDir fusion_index_disk_dir(fusion_spec.flush_ids.back(), true);
@@ -1104,7 +1103,7 @@ IndexMaintainer::runFusion(const FusionSpec &fusion_spec, std::shared_ptr<search
} else {
LOG(error, "Fusion failed, fusion dir \"%s\".", fail_dir.c_str());
}
- std::filesystem::remove_all(std::filesystem::path(fail_dir));
+ fs::remove_all(fs::path(fail_dir));
{
LockGuard slock(_state_lock);
LockGuard ilock(_index_update_lock);
diff --git a/searchcore/src/vespa/searchcorespi/index/indexwriteutilities.cpp b/searchcore/src/vespa/searchcorespi/index/indexwriteutilities.cpp
index a5f796cf48e..1e6265ec7c0 100644
--- a/searchcore/src/vespa/searchcorespi/index/indexwriteutilities.cpp
+++ b/searchcore/src/vespa/searchcorespi/index/indexwriteutilities.cpp
@@ -25,7 +25,7 @@ using search::index::SchemaUtil;
using search::SerialNum;
using vespalib::IllegalStateException;
using vespalib::FileHeader;
-using std::filesystem::path;
+namespace fs = std::filesystem;
namespace searchcorespi::index {
@@ -66,7 +66,7 @@ IndexWriteUtilities::writeSerialNum(SerialNum serialNum,
if (ok) {
std::error_code ec;
- std::filesystem::rename(path(tmpFileName), path(fileName), ec);
+ fs::rename(fs::path(tmpFileName), fs::path(fileName), ec);
ok = !ec;
}
if (!ok) {
@@ -86,14 +86,14 @@ IndexWriteUtilities::copySerialNumFile(const vespalib::string &sourceDir,
vespalib::string tmpDest = dest + ".tmp";
std::error_code ec;
- std::filesystem::copy_file(path(source), path(tmpDest), ec);
+ fs::copy_file(fs::path(source), fs::path(tmpDest), ec);
if (ec) {
LOG(error, "Unable to copy file '%s'", source.c_str());
return false;
}
vespalib::File::sync(tmpDest);
vespalib::File::sync(destDir);
- std::filesystem::rename(path(tmpDest), path(dest), ec);
+ fs::rename(fs::path(tmpDest), fs::path(dest), ec);
if (ec) {
LOG(error, "Unable to rename file '%s' to '%s'", tmpDest.c_str(), dest.c_str());
return false;
@@ -150,7 +150,7 @@ IndexWriteUtilities::updateDiskIndexSchema(const vespalib::string &indexDir,
}
vespalib::string schemaTmpName = schemaName + ".tmp";
vespalib::string schemaOrigName = schemaName + ".orig";
- std::filesystem::remove(path(schemaTmpName));
+ fs::remove(fs::path(schemaTmpName));
if (!newSchema->saveToFile(schemaTmpName)) {
LOG(error, "Could not save schema to '%s'",
schemaTmpName.c_str());