aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-01-10 15:50:22 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2024-01-10 16:04:09 +0000
commite7b84c045e2f9a3c60c0681475b3643aea14d9b1 (patch)
tree7098383548e576c3cce0279dfc410c43548c5045
parent51f50dd170a80b33e0ddd06f83b2b53d7216bede (diff)
- Store entrySize in fileheader and use that as entry size if present. If not use legacy alignment and compute size.
- Make predefined tags for use in fileheaders to reduce string constants lying around.
-rw-r--r--searchlib/src/tests/common/bitvector/bitvector_test.cpp26
-rw-r--r--searchlib/src/vespa/searchlib/common/CMakeLists.txt1
-rw-r--r--searchlib/src/vespa/searchlib/common/bitvector.h4
-rw-r--r--searchlib/src/vespa/searchlib/common/fileheadercontext.cpp12
-rw-r--r--searchlib/src/vespa/searchlib/common/fileheadertags.cpp16
-rw-r--r--searchlib/src/vespa/searchlib/common/fileheadertags.h17
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp44
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp44
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp44
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.h2
10 files changed, 125 insertions, 85 deletions
diff --git a/searchlib/src/tests/common/bitvector/bitvector_test.cpp b/searchlib/src/tests/common/bitvector/bitvector_test.cpp
index 571ea80ef36..351890e94bf 100644
--- a/searchlib/src/tests/common/bitvector/bitvector_test.cpp
+++ b/searchlib/src/tests/common/bitvector/bitvector_test.cpp
@@ -645,45 +645,45 @@ TEST("requireThatGrowWorks")
EXPECT_EQUAL(4u, v.writer().countTrueBits());
EXPECT_EQUAL(200u, v.reader().size());
- EXPECT_EQUAL(1023u, v.writer().capacity());
+ EXPECT_EQUAL(2047u, v.writer().capacity());
EXPECT_TRUE(assertBV("[7,39,71,103]", v.reader()));
EXPECT_EQUAL(4u, v.writer().countTrueBits());
- EXPECT_TRUE(v.reserve(1024));
+ EXPECT_TRUE(v.reserve(2048u));
EXPECT_EQUAL(200u, v.reader().size());
- EXPECT_EQUAL(2047u, v.writer().capacity());
+ EXPECT_EQUAL(4095u, v.writer().capacity());
EXPECT_TRUE(assertBV("[7,39,71,103]", v.reader()));
EXPECT_EQUAL(4u, v.writer().countTrueBits());
EXPECT_FALSE(v.extend(202));
EXPECT_EQUAL(202u, v.reader().size());
- EXPECT_EQUAL(2047u, v.writer().capacity());
+ EXPECT_EQUAL(4095u, v.writer().capacity());
EXPECT_TRUE(assertBV("[7,39,71,103]", v.reader()));
EXPECT_EQUAL(4u, v.writer().countTrueBits());
EXPECT_FALSE(v.shrink(200));
EXPECT_EQUAL(200u, v.reader().size());
- EXPECT_EQUAL(2047u, v.writer().capacity());
+ EXPECT_EQUAL(4095u, v.writer().capacity());
EXPECT_TRUE(assertBV("[7,39,71,103]", v.reader()));
EXPECT_EQUAL(4u, v.writer().countTrueBits());
- EXPECT_FALSE(v.reserve(2047));
+ EXPECT_FALSE(v.reserve(4095u));
EXPECT_EQUAL(200u, v.reader().size());
- EXPECT_EQUAL(2047u, v.writer().capacity());
+ EXPECT_EQUAL(4095u, v.writer().capacity());
EXPECT_TRUE(assertBV("[7,39,71,103]", v.reader()));
EXPECT_EQUAL(4u, v.writer().countTrueBits());
EXPECT_FALSE(v.shrink(202));
EXPECT_EQUAL(202u, v.reader().size());
- EXPECT_EQUAL(2047u, v.writer().capacity());
+ EXPECT_EQUAL(4095u, v.writer().capacity());
EXPECT_TRUE(assertBV("[7,39,71,103]", v.reader()));
EXPECT_EQUAL(4u, v.writer().countTrueBits());
EXPECT_FALSE(v.shrink(100));
EXPECT_EQUAL(100u, v.reader().size());
- EXPECT_EQUAL(2047u, v.writer().capacity());
+ EXPECT_EQUAL(4095u, v.writer().capacity());
EXPECT_TRUE(assertBV("[7,39,71]", v.reader()));
EXPECT_EQUAL(3u, v.writer().countTrueBits());
v.writer().invalidateCachedCount();
- EXPECT_TRUE(v.reserve(3100));
+ EXPECT_TRUE(v.reserve(5100u));
EXPECT_EQUAL(100u, v.reader().size());
- EXPECT_EQUAL(4095u, v.writer().capacity());
+ EXPECT_EQUAL(6143u, v.writer().capacity());
EXPECT_EQUAL(3u, v.writer().countTrueBits());
g.assign_generation(1);
@@ -700,9 +700,9 @@ TEST("require that growable bit vectors keeps memory allocator")
EXPECT_EQUAL(AllocStats(1, 0), stats);
v.writer().resize(1); // DO NOT TRY THIS AT HOME
EXPECT_EQUAL(AllocStats(2, 1), stats);
- v.reserve(2000);
+ v.reserve(2048);
EXPECT_EQUAL(AllocStats(3, 1), stats);
- v.extend(4000);
+ v.extend(5000);
EXPECT_EQUAL(AllocStats(4, 1), stats);
v.shrink(200);
EXPECT_EQUAL(AllocStats(4, 1), stats);
diff --git a/searchlib/src/vespa/searchlib/common/CMakeLists.txt b/searchlib/src/vespa/searchlib/common/CMakeLists.txt
index 970937e18ec..3270c170327 100644
--- a/searchlib/src/vespa/searchlib/common/CMakeLists.txt
+++ b/searchlib/src/vespa/searchlib/common/CMakeLists.txt
@@ -10,6 +10,7 @@ vespa_add_library(searchlib_common OBJECT
documentlocations.cpp
documentsummary.cpp
fileheadercontext.cpp
+ fileheadertags.cpp
flush_token.cpp
geo_gcd.cpp
geo_location.cpp
diff --git a/searchlib/src/vespa/searchlib/common/bitvector.h b/searchlib/src/vespa/searchlib/common/bitvector.h
index 6e5d02f2872..d69f2ac845b 100644
--- a/searchlib/src/vespa/searchlib/common/bitvector.h
+++ b/searchlib/src/vespa/searchlib/common/bitvector.h
@@ -281,6 +281,8 @@ public:
static UP create(Index numberOfElements);
static UP create(const BitVector & rhs);
static void consider_enable_range_check();
+ static Index numWords(Index bits) noexcept { return wordNum(bits + 1 + (WordLen - 1)); }
+ static Index numBytes(Index bits) noexcept { return numWords(bits) * sizeof(Word); }
protected:
using Alloc = vespalib::alloc::Alloc;
VESPA_DLL_LOCAL BitVector(void * buf, Index start, Index end) noexcept;
@@ -292,8 +294,6 @@ protected:
VESPA_DLL_LOCAL void clearIntervalNoInvalidation(Range range);
bool isValidCount() const noexcept { return isValidCount(_numTrueBits.load(std::memory_order_relaxed)); }
static bool isValidCount(Index v) noexcept { return v != invalidCount(); }
- static Index numWords(Index bits) noexcept { return wordNum(bits + 1 + (WordLen - 1)); }
- static Index numBytes(Index bits) noexcept { return numWords(bits) * sizeof(Word); }
size_t numWords() const noexcept { return numWords(size()); }
static constexpr size_t getAlignment() noexcept { return 0x100u; }
static size_t numActiveBytes(Index start, Index end) noexcept { return numActiveWords(start, end) * sizeof(Word); }
diff --git a/searchlib/src/vespa/searchlib/common/fileheadercontext.cpp b/searchlib/src/vespa/searchlib/common/fileheadercontext.cpp
index 77246e2b202..067d7aeaae9 100644
--- a/searchlib/src/vespa/searchlib/common/fileheadercontext.cpp
+++ b/searchlib/src/vespa/searchlib/common/fileheadercontext.cpp
@@ -1,6 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "fileheadercontext.h"
+#include "fileheadertags.h"
#include <vespa/vespalib/data/fileheader.h>
#include <chrono>
@@ -9,6 +10,7 @@ using namespace std::chrono;
namespace search::common {
using vespalib::GenericHeader;
+using namespace tags;
FileHeaderContext::FileHeaderContext() = default;
@@ -18,17 +20,17 @@ void
FileHeaderContext::addCreateAndFreezeTime(GenericHeader &header)
{
using Tag = GenericHeader::Tag;
- header.putTag(Tag("createTime", duration_cast<microseconds>(system_clock::now().time_since_epoch()).count()));
- header.putTag(Tag("freezeTime", 0));
+ header.putTag(Tag(CREATE_TIME, duration_cast<microseconds>(system_clock::now().time_since_epoch()).count()));
+ header.putTag(Tag(FREEZE_TIME, 0));
}
void
FileHeaderContext::setFreezeTime(GenericHeader &header)
{
using Tag = GenericHeader::Tag;
- if (header.hasTag("freezeTime") &&
- header.getTag("freezeTime").getType() == Tag::TYPE_INTEGER) {
- header.putTag(Tag("freezeTime", duration_cast<microseconds>(system_clock::now().time_since_epoch()).count()));
+ if (header.hasTag(FREEZE_TIME) &&
+ header.getTag(FREEZE_TIME).getType() == Tag::TYPE_INTEGER) {
+ header.putTag(Tag(FREEZE_TIME, duration_cast<microseconds>(system_clock::now().time_since_epoch()).count()));
}
}
diff --git a/searchlib/src/vespa/searchlib/common/fileheadertags.cpp b/searchlib/src/vespa/searchlib/common/fileheadertags.cpp
new file mode 100644
index 00000000000..aaef218a98b
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/common/fileheadertags.cpp
@@ -0,0 +1,16 @@
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "fileheadertags.h"
+
+namespace search::tags {
+// Do not change these constants, they are persisted in many file headers.
+vespalib::string FREEZE_TIME("freezeTime");
+vespalib::string CREATE_TIME("createTime");
+vespalib::string FROZEN("frozen");
+vespalib::string DOCID_LIMIT("docidLimit");
+vespalib::string FILE_BIT_SIZE("fileBitSize");
+vespalib::string DESC("desc");
+vespalib::string ENTRY_SIZE("entrySize");
+vespalib::string NUM_KEYS("numKeys");
+
+}
diff --git a/searchlib/src/vespa/searchlib/common/fileheadertags.h b/searchlib/src/vespa/searchlib/common/fileheadertags.h
new file mode 100644
index 00000000000..c7e7385160e
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/common/fileheadertags.h
@@ -0,0 +1,17 @@
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+#include <vespa/vespalib/stllike/string.h>
+
+namespace search::tags {
+
+extern vespalib::string FREEZE_TIME;
+extern vespalib::string CREATE_TIME;
+extern vespalib::string FROZEN;
+extern vespalib::string DOCID_LIMIT;
+extern vespalib::string FILE_BIT_SIZE;
+extern vespalib::string DESC;
+extern vespalib::string ENTRY_SIZE;
+extern vespalib::string NUM_KEYS;
+
+}
diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp
index f2a7ec4d88b..b5c07dca923 100644
--- a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp
@@ -1,6 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "bitvectordictionary.h"
+#include <vespa/searchlib/common/fileheadertags.h>
#include <vespa/vespalib/data/fileheader.h>
#include <vespa/fastos/file.h>
#include <cassert>
@@ -10,10 +11,12 @@ LOG_SETUP(".diskindex.bitvectordictionary");
namespace search::diskindex {
+using namespace tags;
+
BitVectorDictionary::BitVectorDictionary()
- : _docIdLimit(),
+ : _docIdLimit(0u),
_entries(),
- _vectorSize(),
+ _vectorSize(0u),
_datFile(),
_datHeaderLen(0u)
{ }
@@ -27,27 +30,32 @@ BitVectorDictionary::open(const vespalib::string &pathPrefix,
const TuneFileRandRead &tuneFileRead,
BitVectorKeyScope scope)
{
- vespalib::string booloccIdxName = pathPrefix + "boolocc" +
- getBitVectorKeyScopeSuffix(scope);
+ vespalib::string booloccIdxName = pathPrefix + "boolocc" + getBitVectorKeyScopeSuffix(scope);
vespalib::string booloccDatName = pathPrefix + "boolocc.bdat";
{
FastOS_File idxFile;
idxFile.OpenReadOnly(booloccIdxName.c_str());
if (!idxFile.IsOpened()) {
- LOG(warning, "Could not open bitvector idx file '%s'",
- booloccIdxName.c_str());
+ LOG(warning, "Could not open bitvector idx file '%s'", booloccIdxName.c_str());
return false;
}
vespalib::FileHeader idxHeader;
uint32_t idxHeaderLen = idxHeader.readFile(idxFile);
idxFile.SetPosition(idxHeaderLen);
- assert(idxHeader.hasTag("frozen"));
- assert(idxHeader.hasTag("docIdLimit"));
- assert(idxHeader.hasTag("numKeys"));
- assert(idxHeader.getTag("frozen").asInteger() != 0);
- _docIdLimit = idxHeader.getTag("docIdLimit").asInteger();
- uint32_t numEntries = idxHeader.getTag("numKeys").asInteger();
+ assert(idxHeader.hasTag(FROZEN));
+ assert(idxHeader.hasTag(DOCID_LIMIT));
+ assert(idxHeader.hasTag(NUM_KEYS));
+ assert(idxHeader.getTag(FROZEN).asInteger() != 0);
+ _docIdLimit = idxHeader.getTag(DOCID_LIMIT).asInteger();
+ uint32_t numEntries = idxHeader.getTag(NUM_KEYS).asInteger();
+ if (idxHeader.hasTag(ENTRY_SIZE)) {
+ _vectorSize = idxHeader.getTag(ENTRY_SIZE).asInteger();
+ } else {
+ constexpr size_t LEGACY_ALIGNMENT = 0x40;
+ BitVector::Index bytes = BitVector::numBytes(_docIdLimit);
+ _vectorSize = bytes + (-bytes & (LEGACY_ALIGNMENT - 1));
+ }
_entries.resize(numEntries);
size_t bufSize = sizeof(WordSingleKey) * numEntries;
@@ -69,14 +77,12 @@ BitVectorDictionary::open(const vespalib::string &pathPrefix,
}
_datFile->OpenReadOnly(booloccDatName.c_str());
if (!_datFile->IsOpened()) {
- LOG(warning, "Could not open bitvector dat file '%s'",
- booloccDatName.c_str());
+ LOG(warning, "Could not open bitvector dat file '%s'", booloccDatName.c_str());
return false;
}
vespalib::FileHeader datHeader(64);
_datHeaderLen = datHeader.readFile(*_datFile);
- assert(_datFile->getSize() >=
- static_cast<int64_t>(_vectorSize * _entries.size() + _datHeaderLen));
+ assert(_datFile->getSize() >= static_cast<int64_t>(_vectorSize * _entries.size() + _datHeaderLen));
return true;
}
@@ -88,12 +94,10 @@ BitVectorDictionary::lookup(uint64_t wordNum)
key._wordNum = wordNum;
auto itr = std::lower_bound(_entries.begin(), _entries.end(), key);
if (itr == _entries.end() || key < *itr) {
- return BitVector::UP();
+ return {};
}
int64_t pos = &*itr - &_entries[0];
- return BitVector::create(_docIdLimit, *_datFile,
- ((int64_t) _vectorSize) * pos + _datHeaderLen,
- itr->_numDocs);
+ return BitVector::create(_docIdLimit, *_datFile, ((int64_t) _vectorSize) * pos + _datHeaderLen, itr->_numDocs);
}
}
diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp
index f5fcce845df..d2129ed81d5 100644
--- a/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp
@@ -3,6 +3,7 @@
#include "bitvectorfile.h"
#include <vespa/searchlib/common/bitvector.h>
#include <vespa/searchlib/common/fileheadercontext.h>
+#include <vespa/searchlib/common/fileheadertags.h>
#include <vespa/searchlib/index/bitvectorkeys.h>
#include <vespa/searchlib/util/file_settings.h>
#include <vespa/vespalib/data/fileheader.h>
@@ -14,6 +15,7 @@ namespace search::diskindex {
using search::index::BitVectorWordSingleKey;
using search::common::FileHeaderContext;
+using namespace tags;
namespace {
@@ -37,8 +39,7 @@ BitVectorFileWrite::BitVectorFileWrite(BitVectorKeyScope scope)
BitVectorFileWrite::~BitVectorFileWrite() = default;
void
-BitVectorFileWrite::open(const vespalib::string &name,
- uint32_t docIdLimit,
+BitVectorFileWrite::open(const vespalib::string &name, uint32_t docIdLimit,
const TuneFileSeqWrite &tuneFileWrite,
const FileHeaderContext &fileHeaderContext)
{
@@ -78,11 +79,12 @@ BitVectorFileWrite::makeDatHeader(const FileHeaderContext &fileHeaderContext)
vespalib::FileHeader h(FileSettings::DIRECTIO_ALIGNMENT);
using Tag = vespalib::GenericHeader::Tag;
fileHeaderContext.addTags(h, _datFile->GetFileName());
- h.putTag(Tag("docIdLimit", _docIdLimit));
- h.putTag(Tag("numKeys", _numKeys));
- h.putTag(Tag("frozen", 0));
- h.putTag(Tag("fileBitSize", 0));
- h.putTag(Tag("desc", "Bitvector data file"));
+ h.putTag(Tag(ENTRY_SIZE, BitVector::getFileBytes(_docIdLimit)));
+ h.putTag(Tag(DOCID_LIMIT, _docIdLimit));
+ h.putTag(Tag(NUM_KEYS, _numKeys));
+ h.putTag(Tag(FROZEN, 0));
+ h.putTag(Tag(FILE_BIT_SIZE, 0));
+ h.putTag(Tag(DESC, "Bitvector data file"));
_datFile->SetPosition(0);
_datHeaderLen = h.writeFile(*_datFile);
_datFile->Flush();
@@ -96,9 +98,9 @@ BitVectorFileWrite::updateDatHeader(uint64_t fileBitSize)
using Tag = vespalib::GenericHeader::Tag;
readHeader(h, _datFile->GetFileName());
FileHeaderContext::setFreezeTime(h);
- h.putTag(Tag("numKeys", _numKeys));
- h.putTag(Tag("frozen", 1));
- h.putTag(Tag("fileBitSize", fileBitSize));
+ h.putTag(Tag(NUM_KEYS, _numKeys));
+ h.putTag(Tag(FROZEN, 1));
+ h.putTag(Tag(FILE_BIT_SIZE, fileBitSize));
bool sync_ok = _datFile->Sync();
assert(sync_ok);
assert(h.getSize() == _datHeaderLen);
@@ -140,19 +142,17 @@ BitVectorFileWrite::sync()
void
BitVectorFileWrite::close()
{
- if (_datFile != nullptr) {
- if (_datFile->IsOpened()) {
- size_t bitmapbytes = BitVector::getFileBytes(_docIdLimit);
- uint64_t pos = _datFile->getPosition();
- assert(pos == static_cast<uint64_t>(_numKeys) * static_cast<uint64_t>(bitmapbytes) + _datHeaderLen);
- (void) bitmapbytes;
- _datFile->alignEndForDirectIO();
- updateDatHeader(pos * 8);
- bool close_ok = _datFile->Close();
- assert(close_ok);
- }
- _datFile.reset();
+ if (_datFile && _datFile->IsOpened()) {
+ size_t bitmapbytes = BitVector::getFileBytes(_docIdLimit);
+ uint64_t pos = _datFile->getPosition();
+ assert(pos == static_cast<uint64_t>(_numKeys) * static_cast<uint64_t>(bitmapbytes) + _datHeaderLen);
+ (void) bitmapbytes;
+ _datFile->alignEndForDirectIO();
+ updateDatHeader(pos * 8);
+ bool close_ok = _datFile->Close();
+ assert(close_ok);
}
+ _datFile.reset();
Parent::close();
}
diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp
index ec436205578..e4f70484fac 100644
--- a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp
@@ -2,6 +2,7 @@
#include "bitvectoridxfile.h"
#include <vespa/searchlib/common/fileheadercontext.h>
+#include <vespa/searchlib/common/fileheadertags.h>
#include <vespa/searchlib/index/bitvectorkeys.h>
#include <vespa/searchlib/util/file_settings.h>
#include <vespa/vespalib/data/fileheader.h>
@@ -13,6 +14,7 @@ namespace search::diskindex {
using search::index::BitVectorWordSingleKey;
using search::common::FileHeaderContext;
+using namespace tags;
namespace {
@@ -45,10 +47,9 @@ BitVectorIdxFileWrite::idxSize() const
}
void
-BitVectorIdxFileWrite::open(const vespalib::string &name,
- uint32_t docIdLimit,
- const TuneFileSeqWrite &tuneFileWrite,
- const FileHeaderContext &fileHeaderContext)
+BitVectorIdxFileWrite::open(const vespalib::string &name, uint32_t docIdLimit,
+ const TuneFileSeqWrite &tuneFileWrite,
+ const FileHeaderContext &fileHeaderContext)
{
if (_numKeys != 0) {
assert(docIdLimit == _docIdLimit);
@@ -90,13 +91,14 @@ BitVectorIdxFileWrite::makeIdxHeader(const FileHeaderContext &fileHeaderContext)
vespalib::FileHeader h(FileSettings::DIRECTIO_ALIGNMENT);
using Tag = vespalib::GenericHeader::Tag;
fileHeaderContext.addTags(h, _idxFile->GetFileName());
- h.putTag(Tag("docIdLimit", _docIdLimit));
- h.putTag(Tag("numKeys", _numKeys));
- h.putTag(Tag("frozen", 0));
+ h.putTag(Tag(ENTRY_SIZE, BitVector::getFileBytes(_docIdLimit)));
+ h.putTag(Tag(DOCID_LIMIT, _docIdLimit));
+ h.putTag(Tag(NUM_KEYS, _numKeys));
+ h.putTag(Tag(FROZEN, 0));
if (_scope != BitVectorKeyScope::SHARED_WORDS) {
- h.putTag(Tag("fileBitSize", 0));
+ h.putTag(Tag(FILE_BIT_SIZE, 0));
}
- h.putTag(Tag("desc", "Bitvector dictionary file, single words"));
+ h.putTag(Tag(DESC, "Bitvector dictionary file, single words"));
_idxFile->SetPosition(0);
_idxHeaderLen = h.writeFile(*_idxFile);
_idxFile->Flush();
@@ -109,10 +111,10 @@ BitVectorIdxFileWrite::updateIdxHeader(uint64_t fileBitSize)
using Tag = vespalib::GenericHeader::Tag;
readHeader(h, _idxFile->GetFileName());
FileHeaderContext::setFreezeTime(h);
- h.putTag(Tag("numKeys", _numKeys));
- h.putTag(Tag("frozen", 1));
+ h.putTag(Tag(NUM_KEYS, _numKeys));
+ h.putTag(Tag(FROZEN, 1));
if (_scope != BitVectorKeyScope::SHARED_WORDS) {
- h.putTag(Tag("fileBitSize", fileBitSize));
+ h.putTag(Tag(FILE_BIT_SIZE, fileBitSize));
}
bool sync_ok = _idxFile->Sync();
assert(sync_ok);
@@ -160,17 +162,15 @@ BitVectorIdxFileWrite::sync()
void
BitVectorIdxFileWrite::close()
{
- if (_idxFile) {
- if (_idxFile->IsOpened()) {
- uint64_t pos = _idxFile->getPosition();
- assert(pos == idxSize());
- _idxFile->alignEndForDirectIO();
- updateIdxHeader(pos * 8);
- bool close_ok = _idxFile->Close();
- assert(close_ok);
- }
- _idxFile.reset();
+ if (_idxFile && _idxFile->IsOpened()) {
+ uint64_t pos = _idxFile->getPosition();
+ assert(pos == idxSize());
+ _idxFile->alignEndForDirectIO();
+ updateIdxHeader(pos * 8);
+ bool close_ok = _idxFile->Close();
+ assert(close_ok);
}
+ _idxFile.reset();
}
}
diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.h b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.h
index 533f5620ea2..9f1e5ce0f80 100644
--- a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.h
+++ b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.h
@@ -2,10 +2,10 @@
#pragma once
+#include "bitvectorkeyscope.h"
#include <vespa/searchlib/common/bitvector.h>
#include <vespa/searchlib/common/tunefileinfo.h>
#include <vespa/vespalib/stllike/string.h>
-#include "bitvectorkeyscope.h"
class Fast_BufferedFile;