summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-07-18 14:13:53 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-07-18 14:13:53 +0000
commit570ab08f83b98783b9a18338df29f78ecaeb729a (patch)
tree859a2a5c8fbda6aba6e7a527bb1ed9dea8c15159
parent1d980cc63e8dc30dbd4ce4b4faaf04e420a90882 (diff)
Drop non ancient non const GetSize/GetPosition
-rw-r--r--searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp2
-rw-r--r--searchlib/src/apps/docstore/documentstoreinspect.cpp2
-rw-r--r--searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp2
-rw-r--r--searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp8
-rw-r--r--searchlib/src/tests/transactionlog/translogclient_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/fileheader.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/zcposting.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/docstore/filechunk.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/docstore/logdatastore.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/docstore/randread.h4
-rw-r--r--searchlib/src/vespa/searchlib/docstore/randreaders.cpp17
-rw-r--r--searchlib/src/vespa/searchlib/docstore/randreaders.h8
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp32
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp54
-rw-r--r--searchlib/src/vespa/searchlib/util/comprfile.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/util/file_with_header.cpp2
-rw-r--r--searchsummary/src/tests/juniper/auxTest.cpp49
-rw-r--r--vespalib/src/tests/fastos/file_test.cpp26
-rw-r--r--vespalib/src/vespa/fastlib/io/bufferedfile.cpp14
-rw-r--r--vespalib/src/vespa/fastlib/io/bufferedfile.h5
-rw-r--r--vespalib/src/vespa/fastos/file.h14
-rw-r--r--vespalib/src/vespa/fastos/linux_file.cpp8
-rw-r--r--vespalib/src/vespa/fastos/linux_file.h2
-rw-r--r--vespalib/src/vespa/fastos/unix_file.cpp6
-rw-r--r--vespalib/src/vespa/fastos/unix_file.h4
-rw-r--r--vespalib/src/vespa/vespalib/data/fileheader.cpp4
33 files changed, 146 insertions, 171 deletions
diff --git a/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp b/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp
index 3a7e2a706cb..2290b1e131c 100644
--- a/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp
+++ b/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp
@@ -85,7 +85,7 @@ shafile(const string &baseDir, const string &file)
LOG(error, "Could not open %s for sha256 checksum", fullFile.c_str());
LOG_ABORT("should not be reached");
}
- int64_t flen = f.GetSize();
+ int64_t flen = f.getSize();
int64_t remainder = flen;
EvpMdCtxPtr md_ctx(EVP_MD_CTX_new());
const EVP_MD* md = EVP_get_digestbyname("SHA256");
diff --git a/searchlib/src/apps/docstore/documentstoreinspect.cpp b/searchlib/src/apps/docstore/documentstoreinspect.cpp
index f19a128535f..f0ae2c67998 100644
--- a/searchlib/src/apps/docstore/documentstoreinspect.cpp
+++ b/searchlib/src/apps/docstore/documentstoreinspect.cpp
@@ -35,7 +35,7 @@ int DocumentStoreInspectApp::dumpIdxFile(const vespalib::string & file)
idxFile.enableMemoryMap(0);
if (idxFile.OpenReadOnly()) {
if (idxFile.IsMemoryMapped()) {
- int64_t fileSize = idxFile.GetSize();
+ int64_t fileSize = idxFile.getSize();
uint32_t docIdLimit = std::numeric_limits<uint32_t>::max();
uint64_t idxHeaderLen = FileChunk::readIdxHeader(idxFile, docIdLimit);
vespalib::nbostream is(static_cast<const char *>
diff --git a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp
index b0abfee4ab8..4391cfe6525 100644
--- a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp
+++ b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp
@@ -318,7 +318,7 @@ FileChecksum::FileChecksum(const vespalib::string &file_name)
LOG(error, "Could not open %s for sha256 checksum", full_file_name.c_str());
LOG_ABORT("should not be reached");
}
- int64_t flen = f.GetSize();
+ int64_t flen = f.getSize();
int64_t remainder = flen;
EvpMdCtxPtr md_ctx(EVP_MD_CTX_new());
const EVP_MD* md = EVP_get_digestbyname("SHA256");
diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
index 1d7bd9b8504..3b023ed3bc8 100644
--- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
+++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
@@ -184,15 +184,15 @@ TEST("test that DirectIOPadding works accordng to spec") {
EXPECT_FALSE(file.DirectIOPadding(FILE_SIZE-1, 4_Ki, padBefore, padAfter));
EXPECT_EQUAL(0u, padBefore);
EXPECT_EQUAL(0u, padAfter);
- EXPECT_EQUAL(FILE_SIZE, file.GetSize());
+ EXPECT_EQUAL(FILE_SIZE, file.getSize());
FastOS_File file2("directio.test");
file2.EnableDirectIO();
EXPECT_TRUE(file2.OpenWriteOnlyExisting(true));
- EXPECT_TRUE(file2.SetPosition(file2.GetSize()));
- EXPECT_EQUAL(FILE_SIZE, file2.GetSize());
+ EXPECT_TRUE(file2.SetPosition(file2.getSize()));
+ EXPECT_EQUAL(FILE_SIZE, file2.getSize());
EXPECT_EQUAL(FILE_SIZE, file2.Write2(buf.get(), FILE_SIZE));
- EXPECT_EQUAL(FILE_SIZE*2, file2.GetSize());
+ EXPECT_EQUAL(FILE_SIZE*2, file2.getSize());
EXPECT_TRUE(file2.Close());
EXPECT_TRUE(file.DirectIOPadding(4097, 4_Ki, padBefore, padAfter));
diff --git a/searchlib/src/tests/transactionlog/translogclient_test.cpp b/searchlib/src/tests/transactionlog/translogclient_test.cpp
index af277ecbc68..0f19a0b233b 100644
--- a/searchlib/src/tests/transactionlog/translogclient_test.cpp
+++ b/searchlib/src/tests/transactionlog/translogclient_test.cpp
@@ -935,7 +935,7 @@ TEST("test truncate on version mismatch") {
}
FastOS_File f((testDir.getDir() + "/sync/sync-0000000000000000").c_str());
EXPECT_TRUE(f.OpenWriteOnlyExisting());
- EXPECT_TRUE(f.SetPosition(f.GetSize()));
+ EXPECT_TRUE(f.SetPosition(f.getSize()));
char tmp[100];
memset(tmp, 0, sizeof(tmp));
diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp
index efdbedd0941..700bd82da78 100644
--- a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp
@@ -51,7 +51,7 @@ BitVectorDictionary::open(const vespalib::string &pathPrefix,
_entries.resize(numEntries);
size_t bufSize = sizeof(WordSingleKey) * numEntries;
- assert(idxFile.GetSize() >= static_cast<int64_t>(idxHeaderLen + bufSize));
+ assert(idxFile.getSize() >= static_cast<int64_t>(idxHeaderLen + bufSize));
if (bufSize > 0) {
ssize_t has_read = idxFile.Read(&_entries[0], bufSize);
assert(has_read == ssize_t(bufSize));
@@ -75,7 +75,7 @@ BitVectorDictionary::open(const vespalib::string &pathPrefix,
}
vespalib::FileHeader datHeader(64);
_datHeaderLen = datHeader.readFile(*_datFile);
- assert(_datFile->GetSize() >=
+ assert(_datFile->getSize() >=
static_cast<int64_t>(_vectorSize * _entries.size() + _datHeaderLen));
return true;
}
diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp
index f4d129bfc58..bcde4a17ea7 100644
--- a/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp
@@ -73,13 +73,13 @@ BitVectorFileWrite::open(const vespalib::string &name,
pos = static_cast<int64_t>(_numKeys) *
static_cast<int64_t>(bitmapbytes) + _datHeaderLen;
- int64_t olddatsize = _datFile->GetSize();
+ int64_t olddatsize = _datFile->getSize();
assert(olddatsize >= pos);
(void) olddatsize;
_datFile->SetSize(pos);
- assert(pos == _datFile->GetPosition());
+ assert(pos == _datFile->getPosition());
}
@@ -157,7 +157,7 @@ BitVectorFileWrite::close()
if (_datFile != nullptr) {
if (_datFile->IsOpened()) {
- uint64_t pos = _datFile->GetPosition();
+ uint64_t pos = _datFile->getPosition();
assert(pos == static_cast<uint64_t>(_numKeys) *
static_cast<uint64_t>(bitmapbytes) + _datHeaderLen);
(void) bitmapbytes;
diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp
index 0caf89a0730..ba7f19b4b0b 100644
--- a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp
@@ -75,13 +75,13 @@ BitVectorIdxFileWrite::open(const vespalib::string &name,
int64_t pos = idxSize();
- int64_t oldidxsize = _idxFile->GetSize();
+ int64_t oldidxsize = _idxFile->getSize();
assert(oldidxsize >= pos);
(void) oldidxsize;
_idxFile->SetSize(pos);
- assert(pos == _idxFile->GetPosition());
+ assert(pos == _idxFile->getPosition());
}
void
@@ -138,7 +138,7 @@ BitVectorIdxFileWrite::flush()
{
_idxFile->Flush();
- uint64_t pos = _idxFile->GetPosition();
+ uint64_t pos = _idxFile->getPosition();
assert(pos == idxSize());
(void) pos;
}
@@ -162,7 +162,7 @@ BitVectorIdxFileWrite::close()
{
if (_idxFile) {
if (_idxFile->IsOpened()) {
- uint64_t pos = _idxFile->GetPosition();
+ uint64_t pos = _idxFile->getPosition();
assert(pos == idxSize());
_idxFile->alignEndForDirectIO();
updateIdxHeader(pos * 8);
diff --git a/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp b/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp
index 432651278e0..02ae7b714bc 100644
--- a/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp
@@ -47,7 +47,7 @@ FileHeader::taste(const vespalib::string &name,
return false;
}
- fileSize = file.GetSize();
+ fileSize = file.getSize();
try {
headerLen = header.readFile(file);
assert(headerLen >= header.getSize());
diff --git a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp
index b90fdbe329f..0e2b4032689 100644
--- a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp
@@ -83,7 +83,7 @@ PageDict4FileSeqRead::DictFileReadContext::DictFileReadContext(vespalib::stringr
LOG(error, "could not open %s: %s", _file.GetFileName(), getLastErrorString().c_str());
return;
}
- uint64_t fileSize = _file.GetSize();
+ uint64_t fileSize = _file.getSize();
_readContext.setFile(&_file);
_readContext.setFileSize(fileSize);
if (read_all_upfront) {
@@ -257,11 +257,11 @@ PageDict4FileSeqWrite::DictFileContext::DictFileContext(bool extended, vespalib:
assertOpenWriteOnly(ok, name);
_writeContext.setFile(&_file);
_writeContext.allocComprBuf(64_Ki, 32_Ki);
- uint64_t fileSize = _file.GetSize();
+ uint64_t fileSize = _file.getSize();
uint64_t bufferStartFilePos = _writeContext.getBufferStartFilePos();
assert(fileSize >= bufferStartFilePos);
_file.SetSize(bufferStartFilePos);
- assert(bufferStartFilePos == static_cast<uint64_t>(_file.GetPosition()));
+ assert(bufferStartFilePos == static_cast<uint64_t>(_file.getPosition()));
_ec.setupWrite(_writeContext);
assert(_ec.getWriteOffset() == 0);
diff --git a/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp b/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp
index c8374610dea..c3192f303b6 100644
--- a/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp
@@ -84,7 +84,7 @@ PageDict4RandRead::readSPHeader()
d.setReadContext(&rc);
rc.setFile(_spfile.get());
- rc.setFileSize(_spfile->GetSize());
+ rc.setFileSize(_spfile->getSize());
rc.allocComprBuf(512, 32768u);
d.emptyBuffer(0);
rc.readComprBuffer();
@@ -117,7 +117,7 @@ PageDict4RandRead::readPHeader()
d.setReadContext(&rc);
rc.setFile(_pfile.get());
- rc.setFileSize(_pfile->GetSize());
+ rc.setFileSize(_pfile->getSize());
rc.allocComprBuf(512, 32768u);
d.emptyBuffer(0);
rc.readComprBuffer();
@@ -228,7 +228,7 @@ PageDict4RandRead::open(const vespalib::string &name,
return false;
}
- uint64_t fileSize = _ssfile->GetSize();
+ uint64_t fileSize = _ssfile->getSize();
_ssReadContext.setFile(_ssfile.get());
_ssReadContext.setFileSize(fileSize);
_ssReadContext.allocComprBuf((fileSize + sizeof(uint64_t) - 1) / sizeof(uint64_t), 32768u);
diff --git a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp
index 3c74ab5ff07..7b21349b6c3 100644
--- a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp
@@ -24,7 +24,7 @@ WordNumMapping::readMappingFile(const vespalib::string &name,
}
// XXX no checking for success
old2newwordfile.ReadOpen(name.c_str());
- int64_t tempfilesize = old2newwordfile.GetSize();
+ int64_t tempfilesize = old2newwordfile.getSize();
uint64_t tempfileentries = static_cast<uint64_t>(tempfilesize /
sizeof(uint64_t));
Array &map = _old2newwords;
diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.cpp b/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.cpp
index 8a987c49544..5d4f1e2f785 100644
--- a/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.cpp
@@ -165,7 +165,7 @@ open(const vespalib::string &name, const TuneFileRandRead &tuneFileRead)
LOG(error, "could not open %s: %s", _file->GetFileName(), getLastErrorString().c_str());
return false;
}
- _fileSize = _file->GetSize();
+ _fileSize = _file->getSize();
readHeader();
return true;
@@ -187,7 +187,7 @@ ZcPosOccRandRead::readHeader(const vespalib::string &identifier)
ComprFileReadContext drc(d);
drc.setFile(_file.get());
- drc.setFileSize(_file->GetSize());
+ drc.setFileSize(_file->getSize());
drc.allocComprBuf(512, 32768u);
d.emptyBuffer(0);
drc.readComprBuffer();
diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp b/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp
index c9a1563a8e3..ad262fef794 100644
--- a/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp
@@ -74,7 +74,7 @@ Zc4PostingSeqRead::open(const vespalib::string &name,
if (res) {
auto &readContext = _reader.get_read_context();
readContext.setFile(&_file);
- readContext.setFileSize(_file.GetSize());
+ readContext.setFileSize(_file.getSize());
auto &d = _reader.get_decode_features();
readContext.allocComprBuf(65536u, 32768u);
d.emptyBuffer(0);
diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
index 98541dba646..71dfed86fdb 100644
--- a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
@@ -92,13 +92,13 @@ FileChunk::FileChunk(FileId fileId, NameId nameId, const vespalib::string & base
if (!dataFile.Sync()) {
throw SummaryException("Failed syncing dat file", dataFile, VESPA_STRLOC);
}
- _diskFootprint.fetch_add(dataFile.GetSize(), std::memory_order_relaxed);
+ _diskFootprint.fetch_add(dataFile.getSize(), std::memory_order_relaxed);
FastOS_File idxFile(_idxFileName.c_str());
if (idxFile.OpenReadOnly()) {
if (!idxFile.Sync()) {
throw SummaryException("Failed syncing idx file", idxFile, VESPA_STRLOC);
}
- _diskFootprint.fetch_add(idxFile.GetSize(), std::memory_order_relaxed);
+ _diskFootprint.fetch_add(idxFile.getSize(), std::memory_order_relaxed);
_modificationTime = FileKit::getModificationTime(_idxFileName);
} else {
throw SummaryException("Failed opening idx file", idxFile, VESPA_STRLOC);
@@ -162,7 +162,7 @@ FileChunk::updateLidMap(const unique_lock &guard, ISetLid &ds, uint64_t serialNu
idxFile.enableMemoryMap(0);
if (idxFile.OpenReadOnly()) {
if (idxFile.IsMemoryMapped()) {
- const int64_t fileSize = idxFile.GetSize();
+ const int64_t fileSize = idxFile.getSize();
if (_idxHeaderLen == 0) {
_idxHeaderLen = readIdxHeader(idxFile, _docIdLimit);
}
@@ -436,7 +436,7 @@ FileChunk::readDataHeader(FileRandRead &datFile)
uint64_t
FileChunk::readIdxHeader(FastOS_FileInterface &idxFile, uint32_t &docIdLimit)
{
- int64_t fileSize = idxFile.GetSize();
+ int64_t fileSize = idxFile.getSize();
uint32_t hl = GenericHeader::getMinSize();
uint64_t idxHeaderLen = 0;
if (fileSize >= hl) {
diff --git a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp
index 7f63cb4c2d4..05f3413cdd8 100644
--- a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp
@@ -694,7 +694,7 @@ hasNonHeaderData(const vespalib::string &name)
FastOS_File file(name.c_str());
if (!file.OpenReadOnly())
return false;
- int64_t fSize(file.GetSize());
+ int64_t fSize(file.getSize());
uint32_t headerLen = 0;
uint32_t minHeaderLen = vespalib::GenericHeader::getMinSize();
if (fSize < minHeaderLen)
diff --git a/searchlib/src/vespa/searchlib/docstore/randread.h b/searchlib/src/vespa/searchlib/docstore/randread.h
index 63e615e2b23..6f47e625e48 100644
--- a/searchlib/src/vespa/searchlib/docstore/randread.h
+++ b/searchlib/src/vespa/searchlib/docstore/randread.h
@@ -16,9 +16,9 @@ class FileRandRead
{
public:
using FSP = std::shared_ptr<FastOS_FileInterface>;
- virtual ~FileRandRead() { }
+ virtual ~FileRandRead() = default;
virtual FSP read(size_t offset, vespalib::DataBuffer & buffer, size_t sz) = 0;
- virtual int64_t getSize() = 0;
+ virtual int64_t getSize() const = 0;
};
}
diff --git a/searchlib/src/vespa/searchlib/docstore/randreaders.cpp b/searchlib/src/vespa/searchlib/docstore/randreaders.cpp
index 0d1485891d6..337ae1f95d1 100644
--- a/searchlib/src/vespa/searchlib/docstore/randreaders.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/randreaders.cpp
@@ -49,9 +49,8 @@ DirectIORandRead::read(size_t offset, vespalib::DataBuffer & buffer, size_t sz)
int64_t
-DirectIORandRead::getSize()
-{
- return _file->GetSize();
+DirectIORandRead::getSize() const {
+ return _file->getSize();
}
@@ -85,8 +84,8 @@ MMapRandRead::read(size_t offset, vespalib::DataBuffer & buffer, size_t sz)
}
int64_t
-MMapRandRead::getSize() {
- return _file->GetSize();
+MMapRandRead::getSize() const {
+ return _file->getSize();
}
const void *
@@ -147,8 +146,8 @@ MMapRandReadDynamic::contains(const FastOS_FileInterface & file, size_t sz) {
int64_t
-MMapRandReadDynamic::getSize() {
- return _holder.get()->GetSize();
+MMapRandReadDynamic::getSize() const {
+ return _holder.get()->getSize();
}
FileRandRead::FSP
@@ -162,9 +161,9 @@ NormalRandRead::read(size_t offset, vespalib::DataBuffer & buffer, size_t sz)
}
int64_t
-NormalRandRead::getSize()
+NormalRandRead::getSize() const
{
- return _file->GetSize();
+ return _file->getSize();
}
}
diff --git a/searchlib/src/vespa/searchlib/docstore/randreaders.h b/searchlib/src/vespa/searchlib/docstore/randreaders.h
index b672116ca6d..d7fe655dc7a 100644
--- a/searchlib/src/vespa/searchlib/docstore/randreaders.h
+++ b/searchlib/src/vespa/searchlib/docstore/randreaders.h
@@ -15,7 +15,7 @@ class DirectIORandRead : public FileRandRead
public:
DirectIORandRead(const vespalib::string & fileName);
FSP read(size_t offset, vespalib::DataBuffer & buffer, size_t sz) override;
- int64_t getSize() override;
+ int64_t getSize() const override;
private:
std::unique_ptr<FastOS_FileInterface> _file;
size_t _alignment;
@@ -28,7 +28,7 @@ class MMapRandRead : public FileRandRead
public:
MMapRandRead(const vespalib::string & fileName, int mmapFlags, int fadviseOptions);
FSP read(size_t offset, vespalib::DataBuffer & buffer, size_t sz) override;
- int64_t getSize() override;
+ int64_t getSize() const override;
const void * getMapping();
private:
std::unique_ptr<FastOS_FileInterface> _file;
@@ -39,7 +39,7 @@ class MMapRandReadDynamic : public FileRandRead
public:
MMapRandReadDynamic(const vespalib::string & fileName, int mmapFlags, int fadviseOptions);
FSP read(size_t offset, vespalib::DataBuffer & buffer, size_t sz) override;
- int64_t getSize() override;
+ int64_t getSize() const override;
private:
static bool contains(const FastOS_FileInterface & file, size_t sz);
void remap(size_t end);
@@ -55,7 +55,7 @@ class NormalRandRead : public FileRandRead
public:
NormalRandRead(const vespalib::string & fileName);
FSP read(size_t offset, vespalib::DataBuffer & buffer, size_t sz) override;
- int64_t getSize() override;
+ int64_t getSize() const override;
private:
std::unique_ptr<FastOS_FileInterface> _file;
};
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
index 84bad6b65ac..7102b80d7d0 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
@@ -122,7 +122,7 @@ WriteableFileChunk(vespalib::Executor &executor,
if (_dataHeaderLen == 0) {
writeDataHeader(fileHeaderContext);
}
- _dataFile.SetPosition(_dataFile.GetSize());
+ _dataFile.SetPosition(_dataFile.getSize());
if (tune._write.getWantDirectIO()) {
if (!_dataFile.GetDirectIORestrictions(_alignment, _granularity, _maxChunkSize)) {
LOG(debug, "Direct IO setup failed for file %s due to %s",
@@ -134,7 +134,7 @@ WriteableFileChunk(vespalib::Executor &executor,
if (_idxHeaderLen == 0) {
_idxHeaderLen = writeIdxHeader(fileHeaderContext, _docIdLimit, *idxFile);
}
- _idxFileSize.store(idxFile->GetSize(), std::memory_order_relaxed);
+ _idxFileSize.store(idxFile->getSize(), std::memory_order_relaxed);
if ( ! idxFile->Sync()) {
throw SummaryException("Failed syncing idx file", *idxFile, VESPA_STRLOC);
}
@@ -335,8 +335,8 @@ const std::vector<char> Padding(Alignment, '\0');
size_t
getAlignedStartPos(FastOS_File & file)
{
- ssize_t startPos(file.GetPosition());
- assert(startPos == file.GetSize());
+ ssize_t startPos(file.getPosition());
+ assert(startPos == file.getSize());
if (startPos & (Alignment-1)) {
FastOS_File align(file.GetFileName());
if (align.OpenWriteOnly()) {
@@ -345,8 +345,8 @@ getAlignedStartPos(FastOS_File & file)
ssize_t written = align.Write2(&Padding[0], toWrite);
if (written == toWrite) {
if ( align.Sync() ) {
- file.SetPosition(align.GetSize());
- startPos = file.GetPosition();
+ file.SetPosition(align.getSize());
+ startPos = file.getPosition();
} else {
throw SummaryException(
make_string("Failed syncing dat file."),
@@ -744,7 +744,7 @@ WriteableFileChunk::append(uint64_t serialNum, uint32_t lid, const void * buffer
void
WriteableFileChunk::readDataHeader()
{
- int64_t fSize(_dataFile.GetSize());
+ int64_t fSize(_dataFile.getSize());
try {
FileHeader h;
_dataHeaderLen = h.readFile(_dataFile);
@@ -763,8 +763,8 @@ WriteableFileChunk::readDataHeader()
// header length, or if header has been truncated.
_dataFile.SetPosition(0);
_dataFile.SetSize(0);
- assert(_dataFile.GetSize() == 0);
- assert(_dataFile.GetPosition() == 0);
+ assert(_dataFile.getSize() == 0);
+ assert(_dataFile.getPosition() == 0);
LOG(warning,
"Truncated file chunk data %s due to truncated file header",
_dataFile.GetFileName());
@@ -776,7 +776,7 @@ WriteableFileChunk::readDataHeader()
void
WriteableFileChunk::readIdxHeader(FastOS_FileInterface & idxFile)
{
- int64_t fSize(idxFile.GetSize());
+ int64_t fSize(idxFile.getSize());
try {
FileHeader h;
_idxHeaderLen = h.readFile(idxFile);
@@ -797,8 +797,8 @@ WriteableFileChunk::readIdxHeader(FastOS_FileInterface & idxFile)
// header length, or if header has been truncated.
idxFile.SetPosition(0);
idxFile.SetSize(0);
- assert(idxFile.GetSize() == 0);
- assert(idxFile.GetPosition() == 0);
+ assert(idxFile.getSize() == 0);
+ assert(idxFile.getPosition() == 0);
LOG(warning, "Truncated file chunk index %s due to truncated file header", idxFile.GetFileName());
}
}
@@ -812,7 +812,7 @@ WriteableFileChunk::writeDataHeader(const FileHeaderContext &fileHeaderContext)
FileHeader h(FileSettings::DIRECTIO_ALIGNMENT);
assert(_dataFile.IsOpened());
assert(_dataFile.IsWriteMode());
- assert(_dataFile.GetPosition() == 0);
+ assert(_dataFile.getPosition() == 0);
fileHeaderContext.addTags(h, _dataFile.GetFileName());
h.putTag(Tag("desc", "Log data store chunk data"));
_dataHeaderLen = h.writeFile(_dataFile);
@@ -826,7 +826,7 @@ WriteableFileChunk::writeIdxHeader(const FileHeaderContext &fileHeaderContext, u
FileHeader h;
assert(file.IsOpened());
assert(file.IsWriteMode());
- assert(file.GetPosition() == 0);
+ assert(file.getPosition() == 0);
fileHeaderContext.addTags(h, file.GetFileName());
h.putTag(Tag("desc", "Log data store chunk index"));
writeDocIdLimit(h, docIdLimit);
@@ -911,7 +911,7 @@ WriteableFileChunk::unconditionallyFlushPendingChunks(const unique_lock &flushGu
}
vespalib::system_time timeStamp(vespalib::system_clock::now());
auto idxFile = openIdx();
- idxFile->SetPosition(idxFile->GetSize());
+ idxFile->SetPosition(idxFile->getSize());
ssize_t wlen = idxFile->Write2(os.data(), os.size());
updateCurrentDiskFootprint();
@@ -921,7 +921,7 @@ WriteableFileChunk::unconditionallyFlushPendingChunks(const unique_lock &flushGu
if ( ! idxFile->Sync()) {
throw SummaryException("Failed fsync of idx file", *idxFile, VESPA_STRLOC);
}
- _idxFileSize.store(idxFile->GetSize(), std::memory_order_relaxed);
+ _idxFileSize.store(idxFile->getSize(), std::memory_order_relaxed);
if (_lastPersistedSerialNum.load(std::memory_order_relaxed) < lastSerial) {
_lastPersistedSerialNum.store(lastSerial, std::memory_order_relaxed);
}
diff --git a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp
index aaf361b65ca..97ca6ad613e 100644
--- a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp
+++ b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp
@@ -55,7 +55,7 @@ handleSync(FastOS_FileInterface &file)
int osError = errno;
throw runtime_error(fmt("Failed to synchronize file '%s' of size %" PRId64 " due to '%s'. "
"Does not know how to handle this so throwing an exception.",
- file.GetFileName(), file.GetSize(), FastOS_File::getErrorString(osError).c_str()));
+ file.GetFileName(), file.getSize(), FastOS_File::getErrorString(osError).c_str()));
}
}
@@ -66,13 +66,13 @@ handleWriteError(const char *text, FastOS_FileInterface &file, int64_t lastKnown
string last(FastOS_File::getLastErrorString());
string e(fmt("%s. File '%s' at position %" PRId64 " for entries [%" PRIu64 ", %" PRIu64 "] of length %u. "
"OS says '%s'. Rewind to last known good position %" PRId64 ".",
- text, file.GetFileName(), file.GetPosition(), range.from(), range.to(), bufLen,
+ text, file.GetFileName(), file.getPosition(), range.from(), range.to(), bufLen,
last.c_str(), lastKnownGoodPos));
LOG(error, "%s", e.c_str());
if ( ! file.SetPosition(lastKnownGoodPos) ) {
last = FastOS_File::getLastErrorString();
throw runtime_error(fmt("Failed setting position %" PRId64 " of file '%s' of size %" PRId64 " : OS says '%s'",
- lastKnownGoodPos, file.GetFileName(), file.GetSize(), last.c_str()));
+ lastKnownGoodPos, file.GetFileName(), file.getSize(), last.c_str()));
}
handleSync(file);
return e;
@@ -82,13 +82,13 @@ string
getError(FastOS_FileInterface & f)
{
return fmt("File '%s' of size %" PRId64 " has last error of '%s'.",
- f.GetFileName(), f.GetSize(), FastOS_File::getLastErrorString().c_str());
+ f.GetFileName(), f.getSize(), FastOS_File::getLastErrorString().c_str());
}
bool
tailOfFileIsZero(FastOS_FileInterface &file, int64_t lastKnownGoodPos)
{
- ssize_t rest(file.GetSize() - lastKnownGoodPos);
+ ssize_t rest(file.getSize() - lastKnownGoodPos);
if (rest < 0 || rest > 0x100000) {
return false;
}
@@ -111,10 +111,10 @@ handleReadError(const char *text, FastOS_FileInterface &file, ssize_t len, ssize
string e;
if (len == rlen) {
e = fmt("Error in data read of size %zd bytes at pos %" PRId64 " trying to read %s. ",
- len, file.GetPosition() - rlen, text);
+ len, file.getPosition() - rlen, text);
} else {
e = fmt("Short Read. Got only %zd of %zd bytes at pos %" PRId64 " trying to read %s. ",
- rlen, len, file.GetPosition() - rlen, text);
+ rlen, len, file.getPosition() - rlen, text);
}
e += getError(file);
if (!allowTruncate) {
@@ -154,7 +154,7 @@ handleReadError(const char *text, FastOS_FileInterface &file, ssize_t len, ssize
string errString = FastOS_File::getLastErrorString();
throw runtime_error(fmt("IO error when reading %zd bytes at pos %" PRId64 "trying to read %s."
" Last known good position is %" PRId64 ": %s",
- len, file.GetPosition(), text, lastKnownGoodPos, getError(file).c_str()));
+ len, file.getPosition(), text, lastKnownGoodPos, getError(file).c_str()));
}
return retval;
}
@@ -165,8 +165,8 @@ Packet
DomainPart::readPacket(FastOS_FileInterface & transLog, SerialNumRange wanted, size_t targetSize, bool allowTruncate) {
Alloc buf;
Packet packet(targetSize);
- int64_t fSize(transLog.GetSize());
- int64_t currPos(transLog.GetPosition());
+ int64_t fSize(transLog.getSize());
+ int64_t currPos(transLog.getPosition());
while ((packet.sizeBytes() < targetSize) && (currPos < fSize) && (packet.range().to() < wanted.to())) {
IChunk::UP chunk;
if (read(transLog, chunk, buf, allowTruncate)) {
@@ -179,21 +179,21 @@ DomainPart::readPacket(FastOS_FileInterface & transLog, SerialNumRange wanted, s
}
} catch (const std::exception & ex) {
throw runtime_error(fmt("%s : Failed creating packet for list %s(%" PRIu64 ") at pos(%" PRIu64 ", %" PRIu64 ")",
- ex.what(), transLog.GetFileName(), fSize, currPos, transLog.GetPosition()));
+ ex.what(), transLog.GetFileName(), fSize, currPos, transLog.getPosition()));
}
} else {
throw runtime_error(fmt("Invalid entry reading file %s(%" PRIu64 ") at pos(%" PRIu64 ", %" PRIu64 ")",
- transLog.GetFileName(), fSize, currPos, transLog.GetPosition()));
+ transLog.GetFileName(), fSize, currPos, transLog.getPosition()));
}
} else {
- if (transLog.GetSize() != fSize) {
- fSize = transLog.GetSize();
+ if (transLog.getSize() != fSize) {
+ fSize = transLog.getSize();
} else {
throw runtime_error(fmt("Failed reading file %s(%" PRIu64 ") at pos(%" PRIu64 ", %" PRIu64 ")",
- transLog.GetFileName(), fSize, currPos, transLog.GetPosition()));
+ transLog.GetFileName(), fSize, currPos, transLog.getPosition()));
}
}
- currPos = transLog.GetPosition();
+ currPos = transLog.getPosition();
}
return packet;
}
@@ -206,7 +206,7 @@ DomainPart::buildPacketMapping(bool allowTruncate)
if ( ! transLog.OpenReadOnly(_transLog->GetFileName())) {
throw runtime_error(fmt("Failed opening '%s' for buffered readinf with direct io.", transLog.GetFileName()));
}
- int64_t fSize(transLog.GetSize());
+ int64_t fSize(transLog.getSize());
int64_t currPos(0);
try {
FileHeader header;
@@ -242,9 +242,9 @@ DomainPart::buildPacketMapping(bool allowTruncate)
// Called only from constructor so no need to hold lock
_skipList.emplace_back(firstSerial, firstPos);
} else {
- fSize = transLog.GetSize();
+ fSize = transLog.getSize();
}
- currPos = transLog.GetPosition();
+ currPos = transLog.getPosition();
}
return currPos;
}
@@ -292,15 +292,15 @@ DomainPart::DomainPart(const string & name, const string & baseDir, SerialNum s,
writeHeader(fileHeaderContext);
_byteSize = _headerLen;
}
- if ( ! _transLog->SetPosition(_transLog->GetSize()) ) {
+ if ( ! _transLog->SetPosition(_transLog->getSize()) ) {
throw runtime_error(fmt("Failed moving write pointer to the end of the file %s(%" PRIu64 ").",
- _transLog->GetFileName(), _transLog->GetSize()));
+ _transLog->GetFileName(), _transLog->getSize()));
}
handleSync(*_transLog);
_writtenSerial = get_range_to();
_syncedSerial = _writtenSerial;
- assert(int64_t(byteSize()) == _transLog->GetSize());
- assert(int64_t(byteSize()) == _transLog->GetPosition());
+ assert(int64_t(byteSize()) == _transLog->getSize());
+ assert(int64_t(byteSize()) == _transLog->getPosition());
}
DomainPart::~DomainPart()
@@ -315,7 +315,7 @@ DomainPart::writeHeader(const FileHeaderContext &fileHeaderContext)
FileHeader header;
assert(_transLog->IsOpened());
assert(_transLog->IsWriteMode());
- assert(_transLog->GetPosition() == 0);
+ assert(_transLog->getPosition() == 0);
fileHeaderContext.addTags(header, _transLog->GetFileName());
header.putTag(Tag("desc", "Transaction log domain part file"));
_headerLen = header.writeFile(*_transLog);
@@ -340,7 +340,7 @@ DomainPart::close()
}
if ( ! retval ) {
throw runtime_error(fmt("Failed closing file '%s' of size %" PRId64 ".",
- _transLog->GetFileName(), _transLog->GetSize()));
+ _transLog->GetFileName(), _transLog->getSize()));
}
return retval;
}
@@ -448,7 +448,7 @@ bool
DomainPart::read(FastOS_FileInterface &file, IChunk::UP & chunk, Alloc & buf, bool allowTruncate)
{
char tmp[5];
- int64_t lastKnownGoodPos(file.GetPosition());
+ int64_t lastKnownGoodPos(file.getPosition());
size_t rlen = file.Read(tmp, sizeof(tmp));
nbostream his(tmp, sizeof(tmp));
uint8_t encoding(-1);
@@ -484,7 +484,7 @@ DomainPart::read(FastOS_FileInterface &file, IChunk::UP & chunk, Alloc & buf, bo
chunk->decode(is);
} catch (const std::exception & e) {
throw runtime_error(fmt("Got exception during decoding of packet '%s' from file '%s' (pos=%" PRId64 ", len=%d)",
- e.what(), file.GetFileName(), file.GetPosition() - len - sizeof(len), static_cast<int>(len)));
+ e.what(), file.GetFileName(), file.getPosition() - len - sizeof(len), static_cast<int>(len)));
}
return true;
}
diff --git a/searchlib/src/vespa/searchlib/util/comprfile.cpp b/searchlib/src/vespa/searchlib/util/comprfile.cpp
index bde246a1239..f284e562b3d 100644
--- a/searchlib/src/vespa/searchlib/util/comprfile.cpp
+++ b/searchlib/src/vespa/searchlib/util/comprfile.cpp
@@ -222,7 +222,7 @@ ComprFileReadBase::SetPosition(uint64_t newPosition,
assert(pos <= static_cast<int64_t>(fileSize));
file->SetPosition(pos);
- assert(pos == file->GetPosition());
+ assert(pos == file->getPosition());
decodeContext.emptyBuffer(newPosition);
assert(decodeContext.getBitPos(bitOffset,
diff --git a/searchlib/src/vespa/searchlib/util/file_with_header.cpp b/searchlib/src/vespa/searchlib/util/file_with_header.cpp
index 569babab6fa..d3aa435b0eb 100644
--- a/searchlib/src/vespa/searchlib/util/file_with_header.cpp
+++ b/searchlib/src/vespa/searchlib/util/file_with_header.cpp
@@ -15,7 +15,7 @@ bool
extract_file_size(const vespalib::GenericHeader& header,
FastOS_FileInterface& file, uint64_t& file_size)
{
- file_size = file.GetSize();
+ file_size = file.getSize();
return FileSizeCalculator::extractFileSize(header, header.getSize(),file.GetFileName(), file_size);
}
diff --git a/searchsummary/src/tests/juniper/auxTest.cpp b/searchsummary/src/tests/juniper/auxTest.cpp
index a43294e709f..f4c5254cc1b 100644
--- a/searchsummary/src/tests/juniper/auxTest.cpp
+++ b/searchsummary/src/tests/juniper/auxTest.cpp
@@ -32,36 +32,21 @@ AuxTest::~AuxTest()
void AuxTest::init()
{
- test_methods_["TestExample"] =
- &AuxTest::TestExample;
- test_methods_["TestPropertyMap"] =
- &AuxTest::TestPropertyMap;
- test_methods_["TestRerase"] =
- &AuxTest::TestRerase;
- test_methods_["TestUTF811"] =
- &AuxTest::TestUTF811;
- test_methods_["TestUTF812"] =
- &AuxTest::TestUTF812;
- test_methods_["TestDoubleWidth"] =
- &AuxTest::TestDoubleWidth;
- test_methods_["TestPartialUTF8"] =
- &AuxTest::TestPartialUTF8;
- test_methods_["TestLargeBlockChinese"] =
- &AuxTest::TestLargeBlockChinese;
- test_methods_["TestUTF8context"] =
- &AuxTest::TestUTF8context;
- test_methods_["TestJapanese"] =
- &AuxTest::TestJapanese;
- test_methods_["TestStartHits"] =
- &AuxTest::TestStartHits;
- test_methods_["TestEndHit"] =
- &AuxTest::TestEndHit;
- test_methods_["TestJuniperStack"] =
- &AuxTest::TestJuniperStack;
- test_methods_["TestSpecialTokenRegistry"] =
- &AuxTest::TestSpecialTokenRegistry;
- test_methods_["TestWhiteSpacePreserved"] =
- &AuxTest::TestWhiteSpacePreserved;
+ test_methods_["TestExample"] = &AuxTest::TestExample;
+ test_methods_["TestPropertyMap"] = &AuxTest::TestPropertyMap;
+ test_methods_["TestRerase"] = &AuxTest::TestRerase;
+ test_methods_["TestUTF811"] = &AuxTest::TestUTF811;
+ test_methods_["TestUTF812"] = &AuxTest::TestUTF812;
+ test_methods_["TestDoubleWidth"] = &AuxTest::TestDoubleWidth;
+ test_methods_["TestPartialUTF8"] = &AuxTest::TestPartialUTF8;
+ test_methods_["TestLargeBlockChinese"] = &AuxTest::TestLargeBlockChinese;
+ test_methods_["TestUTF8context"] = &AuxTest::TestUTF8context;
+ test_methods_["TestJapanese"] = &AuxTest::TestJapanese;
+ test_methods_["TestStartHits"] = &AuxTest::TestStartHits;
+ test_methods_["TestEndHit"] = &AuxTest::TestEndHit;
+ test_methods_["TestJuniperStack"] = &AuxTest::TestJuniperStack;
+ test_methods_["TestSpecialTokenRegistry"] = &AuxTest::TestSpecialTokenRegistry;
+ test_methods_["TestWhiteSpacePreserved"] = &AuxTest::TestWhiteSpacePreserved;
}
@@ -155,7 +140,7 @@ AuxTest::TestPartialUTF8()
{
FastOS_File file((GetSourceDirectory() + "partialutf8.input.utf8").c_str());
_test(file.OpenReadOnly());
- _test(file.GetSize() == inputSize);
+ _test(file.getSize() == inputSize);
_test(file.Read(input, inputSize));
_test(countBrokenUTF8(input, inputSize) == 0);
}
@@ -191,7 +176,7 @@ void AuxTest::TestLargeBlockChinese()
{
FastOS_File file((GetSourceDirectory() + "largeblockchinese.input.utf8").c_str());
_test(file.OpenReadOnly());
- _test(file.GetSize() == inputSize);
+ _test(file.getSize() == inputSize);
_test(file.Read(input, inputSize));
_test(countBrokenUTF8(input, inputSize) == 0);
}
diff --git a/vespalib/src/tests/fastos/file_test.cpp b/vespalib/src/tests/fastos/file_test.cpp
index f0a859f0bfb..464861f5784 100644
--- a/vespalib/src/tests/fastos/file_test.cpp
+++ b/vespalib/src/tests/fastos/file_test.cpp
@@ -144,25 +144,25 @@ TEST(FileTest, DirectIOTest) {
TEST(FileTest, ReadOnlyTest) {
auto myFile = std::make_unique<FastOS_File>(roFilename.c_str());
ASSERT_TRUE(myFile->OpenReadOnly());
- EXPECT_EQ(myFile->GetSize(), 27);
+ EXPECT_EQ(myFile->getSize(), 27);
char dummyData[6] = "Dummy";
ASSERT_FALSE(myFile->CheckedWrite(dummyData, 6));
char dummyData2[28];
ASSERT_TRUE(myFile->SetPosition(1));
EXPECT_EQ(myFile->Read(dummyData2, 28), 26);
- EXPECT_EQ(myFile->GetPosition(), 27);
+ EXPECT_EQ(myFile->getPosition(), 27);
}
TEST(FileTest, WriteOnlyTest) {
Generated guard;
auto myFile = std::make_unique<FastOS_File>(woFilename.c_str());
ASSERT_TRUE(myFile->OpenWriteOnly());
- EXPECT_EQ(myFile->GetSize(), 0);
+ EXPECT_EQ(myFile->getSize(), 0);
char dummyData[6] = "Dummy";
ASSERT_TRUE(myFile->CheckedWrite(dummyData, 6));
- ASSERT_EQ(myFile->GetPosition(), 6);
+ ASSERT_EQ(myFile->getPosition(), 6);
ASSERT_TRUE(myFile->SetPosition(0));
- ASSERT_EQ(myFile->GetPosition(), 0);
+ ASSERT_EQ(myFile->getPosition(), 0);
EXPECT_LT(myFile->Read(dummyData, 6), 0);
EXPECT_TRUE(myFile->Close());
EXPECT_TRUE(std::filesystem::remove(std::filesystem::path(woFilename)));
@@ -173,20 +173,20 @@ TEST(FileTest, ReadWriteTest) {
auto myFile = std::make_unique<FastOS_File>(rwFilename.c_str());
ASSERT_FALSE(myFile->OpenReadOnlyExisting());
ASSERT_TRUE(myFile->OpenReadWrite());
- ASSERT_EQ(myFile->GetSize(), 0);
+ ASSERT_EQ(myFile->getSize(), 0);
char dummyData[6] = "Dummy";
ASSERT_TRUE(myFile->CheckedWrite(dummyData, 6));
- ASSERT_EQ(myFile->GetPosition(), 6);
+ ASSERT_EQ(myFile->getPosition(), 6);
ASSERT_TRUE(myFile->SetPosition(0));
- ASSERT_EQ(myFile->GetPosition(), 0);
+ ASSERT_EQ(myFile->getPosition(), 0);
char dummyData2[7];
ASSERT_EQ(myFile->Read(dummyData2, 6), 6);
EXPECT_EQ(memcmp(dummyData, dummyData2, 6), 0);
ASSERT_TRUE(myFile->SetPosition(1));
EXPECT_EQ(myFile->Read(dummyData2, 7), 5);
- EXPECT_EQ(myFile->GetPosition(), 6);
+ EXPECT_EQ(myFile->getPosition(), 6);
EXPECT_EQ(myFile->Read(dummyData2, 6), 0);
- EXPECT_EQ(myFile->GetPosition(), 6);
+ EXPECT_EQ(myFile->getPosition(), 6);
EXPECT_TRUE(myFile->Close());
EXPECT_TRUE(std::filesystem::remove(std::filesystem::path(rwFilename)));
}
@@ -205,14 +205,14 @@ TEST(FileTest, ReadBufTest) {
FastOS_File file(roFilename.c_str());
char buffer[20];
ASSERT_TRUE(file.OpenReadOnly());
- EXPECT_EQ(file.GetPosition(), 0);
+ EXPECT_EQ(file.getPosition(), 0);
EXPECT_EQ(file.Read(buffer, 4), 4);
buffer[4] = '\0';
- EXPECT_EQ(file.GetPosition(), 4);
+ EXPECT_EQ(file.getPosition(), 4);
EXPECT_EQ(strcmp(buffer, "This"), 0);
file.ReadBuf(buffer, 6, 8);
buffer[6] = '\0';
- EXPECT_EQ(file.GetPosition(), 4);
+ EXPECT_EQ(file.getPosition(), 4);
EXPECT_EQ(strcmp(buffer, "a test"), 0);
}
diff --git a/vespalib/src/vespa/fastlib/io/bufferedfile.cpp b/vespalib/src/vespa/fastlib/io/bufferedfile.cpp
index 60c8a4a40ef..5144b4f0c87 100644
--- a/vespalib/src/vespa/fastlib/io/bufferedfile.cpp
+++ b/vespalib/src/vespa/fastlib/io/bufferedfile.cpp
@@ -78,9 +78,9 @@ Fast_BufferedFile::Eof() const
}
int64_t
-Fast_BufferedFile::GetSize()
+Fast_BufferedFile::getSize() const
{
- return _file->GetSize();
+ return _file->getSize();
}
bool
@@ -122,10 +122,10 @@ Fast_BufferedFile::EnableSyncWrites()
}
int64_t
-Fast_BufferedFile::GetPosition()
+Fast_BufferedFile::getPosition() const
{
if (_file->IsWriteMode()) {
- int64_t filePosition = _file->GetPosition();
+ int64_t filePosition = _file->getPosition();
return (filePosition == -1) ? -1 : filePosition + (_bufi - buf());
} else {
return _filepos - (_bufe - _bufi);
@@ -293,7 +293,7 @@ Fast_BufferedFile::ReadOpenExisting(const char *name)
}
_openFlags = FASTOS_FILE_OPEN_READ;
//CASTWARN
- _fileleft = static_cast<uint64_t>(GetSize());
+ _fileleft = static_cast<uint64_t>(getSize());
_filepos = 0;
ResetBuf();
}
@@ -310,7 +310,7 @@ Fast_BufferedFile::ReadOpen(const char *name)
}
if (_file->IsOpened()) {
//CASTWARN
- _fileleft = static_cast<uint64_t>(GetSize());
+ _fileleft = static_cast<uint64_t>(getSize());
_openFlags = FASTOS_FILE_OPEN_READ;
} else
_fileleft = 0;
@@ -413,7 +413,7 @@ bool Fast_BufferedFile::Open(unsigned int openFlags, const char * name)
if (ok) {
_openFlags = openFlags;
//CASTWARN
- _fileleft = static_cast<uint64_t>(GetSize());
+ _fileleft = static_cast<uint64_t>(getSize());
} else {
// caller will have to check return value
}
diff --git a/vespalib/src/vespa/fastlib/io/bufferedfile.h b/vespalib/src/vespa/fastlib/io/bufferedfile.h
index 8faada61f9d..f6975c375d4 100644
--- a/vespalib/src/vespa/fastlib/io/bufferedfile.h
+++ b/vespalib/src/vespa/fastlib/io/bufferedfile.h
@@ -27,6 +27,7 @@ private:
bool _directIOEnabled;
char * buf() { return static_cast<char *>(_buf.get()); }
+ const char * buf() const { return static_cast<const char *>(_buf.get()); }
protected:
/** The file instance used for low-level file access. */
std::unique_ptr<FastOS_FileInterface> _file;
@@ -154,7 +155,7 @@ public:
*
* @return int64_t The size of the file.
*/
- int64_t GetSize () override;
+ int64_t getSize () const override;
/**
* Truncate or extend the file to a new size. Required write
* access.
@@ -196,7 +197,7 @@ public:
*
* @return int64_t The file position.
*/
- int64_t GetPosition () override;
+ int64_t getPosition () const override;
/**
* Set the position in the file. The next read or write
* will continue from this position.
diff --git a/vespalib/src/vespa/fastos/file.h b/vespalib/src/vespa/fastos/file.h
index 4e49951277f..079a2b610f1 100644
--- a/vespalib/src/vespa/fastos/file.h
+++ b/vespalib/src/vespa/fastos/file.h
@@ -288,12 +288,7 @@ public:
* Get the filepointer. -1 is returned if the operation fails.
* @return current position of file pointer (in bytes)
*/
- virtual int64_t GetPosition() = 0;
-
- /**
- * const version of @link GetPosition
- */
- int64_t getPosition() const { return const_cast<FastOS_FileInterface *>(this)->GetPosition(); }
+ virtual int64_t getPosition() const = 0;
/**
* Return the file size. This method requires that the file is
@@ -302,12 +297,7 @@ public:
* If an error occurs, the returned value is -1.
* @return file size (in bytes)
*/
- virtual int64_t GetSize() = 0;
-
- /**
- * const version of @link GetSize
- */
- int64_t getSize() const { return const_cast<FastOS_FileInterface *>(this)->GetSize(); }
+ virtual int64_t getSize() const = 0;
/**
* Force completion of pending disk writes (flush cache).
diff --git a/vespalib/src/vespa/fastos/linux_file.cpp b/vespalib/src/vespa/fastos/linux_file.cpp
index dabe84a8f30..b8ee005517a 100644
--- a/vespalib/src/vespa/fastos/linux_file.cpp
+++ b/vespalib/src/vespa/fastos/linux_file.cpp
@@ -264,9 +264,9 @@ FastOS_Linux_File::SetPosition(int64_t desiredPosition)
int64_t
-FastOS_Linux_File::GetPosition()
+FastOS_Linux_File::getPosition() const
{
- return _directIOEnabled ? _filePointer : FastOS_UNIX_File::GetPosition();
+ return _directIOEnabled ? _filePointer : FastOS_UNIX_File::getPosition();
}
@@ -336,7 +336,7 @@ FastOS_Linux_File::DirectIOPadding (int64_t offset, size_t length, size_t &padBe
if (int64_t(offset+length+padAfter) > _cachedSize) {
// _cachedSize is not really trustworthy, so if we suspect it is not correct, we correct it.
// The main reason is that it will not reflect the file being extended by another filedescriptor.
- _cachedSize = GetSize();
+ _cachedSize = getSize();
}
if ((padAfter != 0) &&
(static_cast<int64_t>(offset + length + padAfter) > _cachedSize) &&
@@ -393,7 +393,7 @@ FastOS_Linux_File::Open(unsigned int openFlags, const char *filename)
if (rc) {
bool sync_ok = Sync();
assert(sync_ok);
- _cachedSize = GetSize();
+ _cachedSize = getSize();
_filePointer = 0;
}
} else {
diff --git a/vespalib/src/vespa/fastos/linux_file.h b/vespalib/src/vespa/fastos/linux_file.h
index 2481b163210..51bf2a170c7 100644
--- a/vespalib/src/vespa/fastos/linux_file.h
+++ b/vespalib/src/vespa/fastos/linux_file.h
@@ -30,7 +30,7 @@ public:
bool DirectIOPadding(int64_t offset, size_t length, size_t &padBefore, size_t &padAfter) override;
void EnableDirectIO() override;
bool SetPosition(int64_t desiredPosition) override;
- int64_t GetPosition() override;
+ int64_t getPosition() const override;
bool SetSize(int64_t newSize) override;
void ReadBuf(void *buffer, size_t length, int64_t readOffset) override;
void *AllocateDirectIOBuffer(size_t byteSize, void *&realPtr) override;
diff --git a/vespalib/src/vespa/fastos/unix_file.cpp b/vespalib/src/vespa/fastos/unix_file.cpp
index 4d0245cd079..9f61f6d517f 100644
--- a/vespalib/src/vespa/fastos/unix_file.cpp
+++ b/vespalib/src/vespa/fastos/unix_file.cpp
@@ -60,7 +60,7 @@ FastOS_UNIX_File::SetPosition(int64_t desiredPosition)
int64_t
-FastOS_UNIX_File::GetPosition()
+FastOS_UNIX_File::getPosition() const
{
return lseek(_filedes, 0, SEEK_CUR);
}
@@ -219,7 +219,7 @@ FastOS_UNIX_File::Open(unsigned int openFlags, const char *filename)
if (rc) {
_openFlags = openFlags;
if (_mmapEnabled) {
- int64_t filesize = GetSize();
+ int64_t filesize = getSize();
auto mlen = static_cast<size_t>(filesize);
if ((static_cast<int64_t>(mlen) == filesize) && (mlen > 0)) {
void *mbase = mmap(nullptr, mlen, PROT_READ, MAP_SHARED | _mmapFlags, _filedes, 0);
@@ -291,7 +291,7 @@ FastOS_UNIX_File::Close()
int64_t
-FastOS_UNIX_File::GetSize()
+FastOS_UNIX_File::getSize() const
{
int64_t fileSize=-1;
struct stat stbuf{};
diff --git a/vespalib/src/vespa/fastos/unix_file.h b/vespalib/src/vespa/fastos/unix_file.h
index 120b1d35add..fc8d1ced69b 100644
--- a/vespalib/src/vespa/fastos/unix_file.h
+++ b/vespalib/src/vespa/fastos/unix_file.h
@@ -74,8 +74,8 @@ public:
bool IsMemoryMapped() const override { return _mmapbase != nullptr; }
bool SetPosition(int64_t desiredPosition) override;
- int64_t GetPosition() override;
- int64_t GetSize() override;
+ int64_t getPosition() const override;
+ int64_t getSize() const override;
[[nodiscard]] bool Sync() override;
bool SetSize(int64_t newSize) override;
void dropFromCache() const override;
diff --git a/vespalib/src/vespa/vespalib/data/fileheader.cpp b/vespalib/src/vespa/vespalib/data/fileheader.cpp
index 0cb5fa14ff4..317f483520d 100644
--- a/vespalib/src/vespa/vespalib/data/fileheader.cpp
+++ b/vespalib/src/vespa/vespalib/data/fileheader.cpp
@@ -537,7 +537,7 @@ FileHeader::rewriteFile(FastOS_FileInterface &file)
LOG_ASSERT(file.IsWriteMode());
// Store current position in file.
- int64_t pos = file.GetPosition();
+ int64_t pos = file.getPosition();
if (pos != 0) {
file.SetPosition(0);
}
@@ -566,7 +566,7 @@ FileHeader::rewriteFile(FastOS_FileInterface &file)
// Write new header and reset file position.
file.SetPosition(0);
size_t ret = writeFile(file);
- if (file.GetPosition() != pos) {
+ if (file.getPosition() != pos) {
file.SetPosition(pos);
}
return ret;