aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-02-08 20:38:08 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2024-02-09 10:37:01 +0000
commitffb88643646c0304850971a39c38f96b46b88217 (patch)
tree3a349004f34b357da989e0ff0ec38de4fd4b766b /searchlib
parent6e03787d79b327915dff98815db777d879986396 (diff)
Use smaller buffer for reading file headers. And GC some unused code.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/sourceselector.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/common/documentsummary.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/dictionarywordreader.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/diskindex.cpp40
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp9
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/indexbuilder.h1
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp2
10 files changed, 29 insertions, 41 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
index 4654cf435b1..dcf627b0ce2 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
@@ -328,7 +328,7 @@ bool
AttributeVector::isEnumeratedSaveFormat() const
{
vespalib::string datName(fmt("%s.dat", getBaseFileName().c_str()));
- Fast_BufferedFile datFile;
+ Fast_BufferedFile datFile(16_Ki);
vespalib::FileHeader datHeader(FileSettings::DIRECTIO_ALIGNMENT);
if ( ! datFile.OpenReadOnly(datName.c_str()) ) {
LOG(error, "could not open %s: %s", datFile.GetFileName(), getLastErrorString().c_str());
diff --git a/searchlib/src/vespa/searchlib/attribute/sourceselector.cpp b/searchlib/src/vespa/searchlib/attribute/sourceselector.cpp
index 907d54467c1..77c86e21b2a 100644
--- a/searchlib/src/vespa/searchlib/attribute/sourceselector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/sourceselector.cpp
@@ -81,7 +81,7 @@ void
SourceSelector::LoadInfo::load()
{
const vespalib::string fileName = _header._baseFileName + ".dat";
- Fast_BufferedFile file;
+ Fast_BufferedFile file(16_Ki);
// XXX no checking for success
file.ReadOpen(fileName.c_str());
diff --git a/searchlib/src/vespa/searchlib/common/documentsummary.cpp b/searchlib/src/vespa/searchlib/common/documentsummary.cpp
index f004e5cc4cf..9341cf92b89 100644
--- a/searchlib/src/vespa/searchlib/common/documentsummary.cpp
+++ b/searchlib/src/vespa/searchlib/common/documentsummary.cpp
@@ -40,7 +40,7 @@ bool
DocumentSummary::writeDocIdLimit(const vespalib::string &dir, uint32_t count)
{
vespalib::string qcntname = dir + "/docsum.qcnt";
- Fast_BufferedFile qcntfile(new FastOS_File);
+ Fast_BufferedFile qcntfile(4_Ki);
qcntfile.WriteOpen(qcntname.c_str());
if (!qcntfile.IsOpened()) {
diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp
index fc7fd9c2fb7..8c47e5c193e 100644
--- a/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp
@@ -49,7 +49,7 @@ BitVectorFileWrite::open(const vespalib::string &name, uint32_t docIdLimit,
Parent::open(name, docIdLimit, tuneFileWrite, fileHeaderContext);
- _datFile = std::make_unique<Fast_BufferedFile>(new FastOS_File);
+ _datFile = std::make_unique<Fast_BufferedFile>();
if (tuneFileWrite.getWantSyncWrites()) {
_datFile->EnableSyncWrites();
}
diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp
index 7e3f0f5f258..cec3db35d60 100644
--- a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp
@@ -59,7 +59,7 @@ BitVectorIdxFileWrite::open(const vespalib::string &name, uint32_t docIdLimit,
vespalib::string idxname = name + getBitVectorKeyScopeSuffix(_scope);
assert( !_idxFile);
- _idxFile = std::make_unique<Fast_BufferedFile>(new FastOS_File());
+ _idxFile = std::make_unique<Fast_BufferedFile>();
if (tuneFileWrite.getWantSyncWrites()) {
_idxFile->EnableSyncWrites();
}
diff --git a/searchlib/src/vespa/searchlib/diskindex/dictionarywordreader.cpp b/searchlib/src/vespa/searchlib/diskindex/dictionarywordreader.cpp
index 1392f47525e..19741b3b166 100644
--- a/searchlib/src/vespa/searchlib/diskindex/dictionarywordreader.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/dictionarywordreader.cpp
@@ -6,6 +6,8 @@
#include <vespa/fastlib/io/bufferedfile.h>
#include <vespa/log/log.h>
+
+#include <memory>
LOG_SETUP(".diskindex.dictionarywordreader");
namespace search::diskindex {
@@ -21,17 +23,15 @@ DictionaryWordReader::DictionaryWordReader()
{
}
-
DictionaryWordReader::~DictionaryWordReader() = default;
-
bool
DictionaryWordReader::open(const vespalib::string & dictionaryName,
const vespalib::string & wordMapName,
const TuneFileSeqRead &tuneFileRead)
{
- _old2newwordfile.reset(new Fast_BufferedFile(new FastOS_File));
- _dictFile.reset(new PageDict4FileSeqRead);
+ _old2newwordfile = std::make_unique<Fast_BufferedFile>();
+ _dictFile = std::make_unique<PageDict4FileSeqRead>();
if (!_dictFile->open(dictionaryName, tuneFileRead)) {
LOG(error, "Could not open dictionary %s: %s",
dictionaryName.c_str(), getLastErrorString().c_str());
diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
index bf295acec75..105151d8132 100644
--- a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
@@ -121,26 +121,20 @@ DiskIndex::openField(const vespalib::string &fieldDir,
DiskPostingFileReal::getSubIdentifier()) {
dynamicK = false;
} else {
- LOG(warning,
- "Could not detect format for posocc file read %s",
- postingName.c_str());
+ LOG(warning, "Could not detect format for posocc file read %s", postingName.c_str());
}
}
- pFile.reset(dynamicK ?
- new DiskPostingFileDynamicKReal() :
- new DiskPostingFileReal());
+ pFile.reset(dynamicK
+ ? new DiskPostingFileDynamicKReal()
+ : new DiskPostingFileReal());
if (!pFile->open(postingName, tuneFileSearch._read)) {
- LOG(warning,
- "Could not open posting list file '%s'",
- postingName.c_str());
+ LOG(warning, "Could not open posting list file '%s'", postingName.c_str());
return false;
}
bDict.reset(new BitVectorDictionary());
if (!bDict->open(fieldDir, tuneFileSearch._read, BitVectorKeyScope::PERFIELD_WORDS)) {
- LOG(warning,
- "Could not open bit vector dictionary in '%s'",
- fieldDir.c_str());
+ LOG(warning, "Could not open bit vector dictionary in '%s'", fieldDir.c_str());
return false;
}
_postingFiles.push_back(pFile);
@@ -158,8 +152,7 @@ DiskIndex::setup(const TuneFileSearch &tuneFileSearch)
return false;
}
for (SchemaUtil::IndexIterator itr(_schema); itr.isValid(); ++itr) {
- vespalib::string fieldDir =
- _indexDir + "/" + itr.getName() + "/";
+ vespalib::string fieldDir = _indexDir + "/" + itr.getName() + "/";
if (!openField(fieldDir, tuneFileSearch)) {
return false;
}
@@ -169,8 +162,7 @@ DiskIndex::setup(const TuneFileSearch &tuneFileSearch)
}
bool
-DiskIndex::setup(const TuneFileSearch &tuneFileSearch,
- const DiskIndex &old)
+DiskIndex::setup(const TuneFileSearch &tuneFileSearch, const DiskIndex &old)
{
if (tuneFileSearch != old._tuneFileSearch) {
return setup(tuneFileSearch);
@@ -180,8 +172,7 @@ DiskIndex::setup(const TuneFileSearch &tuneFileSearch,
}
const Schema &oldSchema = old._schema;
for (SchemaUtil::IndexIterator itr(_schema); itr.isValid(); ++itr) {
- vespalib::string fieldDir =
- _indexDir + "/" + itr.getName() + "/";
+ vespalib::string fieldDir = _indexDir + "/" + itr.getName() + "/";
SchemaUtil::IndexSettings settings = itr.getIndexSettings();
if (settings.hasError()) {
return false;
@@ -336,12 +327,11 @@ DiskIndex::LookupResult G_nothing;
class LookupCache {
public:
- LookupCache(DiskIndex & diskIndex, const std::vector<uint32_t> & fieldIds) :
- _diskIndex(diskIndex),
- _fieldIds(fieldIds),
- _cache()
- {
- }
+ LookupCache(DiskIndex & diskIndex, const std::vector<uint32_t> & fieldIds)
+ : _diskIndex(diskIndex),
+ _fieldIds(fieldIds),
+ _cache()
+ { }
const DiskIndex::LookupResult &
lookup(const vespalib::string & word, uint32_t fieldId) {
auto it = _cache.find(word);
@@ -473,7 +463,7 @@ DiskIndex::get_field_length_info(const vespalib::string& field_name) const
if (fieldId != Schema::UNKNOWN_FIELD_ID) {
return _postingFiles[fieldId]->get_field_length_info();
} else {
- return FieldLengthInfo();
+ return {};
}
}
diff --git a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp
index 5cf80d06c87..ae1e5594320 100644
--- a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp
@@ -180,10 +180,10 @@ FileHandle::close()
FieldHandle::FieldHandle(const Schema &schema, uint32_t fieldId, IndexBuilder &builder, uint32_t docIdLimit,
uint64_t numWordIds, const IFieldLengthInspector & field_length_inspector,
const TuneFileSeqWrite &tuneFileWrite, const FileHeaderContext &fileHeaderContext)
- : _schema(schema),
- _builder(builder),
- _file(),
- _fieldId(fieldId)
+ : _schema(schema),
+ _builder(builder),
+ _file(),
+ _fieldId(fieldId)
{
std::filesystem::create_directory(std::filesystem::path(getDir()));
_file.open(getDir(), SchemaUtil::IndexIterator(_schema, getIndexId()), docIdLimit, numWordIds,
@@ -251,7 +251,6 @@ IndexBuilder::IndexBuilder(const Schema &schema, vespalib::stringref prefix, uin
uint64_t numWordIds, const index::IFieldLengthInspector &field_length_inspector,
const TuneFileIndexing &tuneFileIndexing, const search::common::FileHeaderContext &fileHeaderContext)
: index::IndexBuilder(schema),
- _schema(schema),
_fields(extractFields(schema)),
_prefix(prefix),
_docIdLimit(docIdLimit),
diff --git a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.h b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.h
index 4ef6ab4a813..3417f595faa 100644
--- a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.h
+++ b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.h
@@ -30,7 +30,6 @@ public:
std::unique_ptr<index::FieldIndexBuilder> startField(uint32_t fieldId) override;
vespalib::string appendToPrefix(vespalib::stringref name) const;
private:
- const index::Schema &_schema;
std::vector<int> _fields;
const vespalib::string _prefix;
const uint32_t _docIdLimit;
diff --git a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp
index 83033b137f8..bda0a0594b7 100644
--- a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp
@@ -18,7 +18,7 @@ WordNumMapping::readMappingFile(const vespalib::string &name,
const TuneFileSeqRead &tuneFileRead)
{
// Open word mapping file
- Fast_BufferedFile old2newwordfile(new FastOS_File);
+ Fast_BufferedFile old2newwordfile;
if (tuneFileRead.getWantDirectIO()) {
old2newwordfile.EnableDirectIO();
}