From 7ee677bbef541862328ff9f9acf8e3fb2d7c4300 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 14 Nov 2018 18:59:56 +0100 Subject: Actually set configured fadvise options. --- .../vespa/searchlib/diskindex/bitvectordictionary.cpp | 6 ++++-- .../src/vespa/searchlib/diskindex/bitvectordictionary.h | 2 +- searchlib/src/vespa/searchlib/diskindex/diskindex.cpp | 4 ++-- searchlib/src/vespa/searchlib/diskindex/diskindex.h | 4 ++-- .../src/vespa/searchlib/diskindex/pagedict4randread.cpp | 11 +++++++---- searchlib/src/vespa/searchlib/diskindex/zcposting.cpp | 16 ++++++++-------- .../src/vespa/searchlib/diskindex/zcpostingiterators.cpp | 10 +++++----- 7 files changed, 29 insertions(+), 24 deletions(-) (limited to 'searchlib') diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp index 0e8538386a0..b898405be07 100644 --- a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp @@ -21,7 +21,7 @@ BitVectorDictionary::BitVectorDictionary() BitVectorDictionary::~BitVectorDictionary() { - if (_datFile.get() != nullptr) { + if (_datFile) { _datFile->Close(); } } @@ -62,7 +62,9 @@ BitVectorDictionary::open(const vespalib::string &pathPrefix, idxFile.Close(); _vectorSize = BitVector::getFileBytes(_docIdLimit); - _datFile.reset(new FastOS_File()); + _datFile = std::make_unique(); + _datFile->setFAdviseOptions(tuneFileRead.getAdvise()); + if (tuneFileRead.getWantMemoryMap()) { _datFile->enableMemoryMap(tuneFileRead.getMemoryMapFlags()); } else if (tuneFileRead.getWantDirectIO()) { diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.h b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.h index 32a30ba6361..79c892c6ed7 100644 --- a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.h +++ b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.h @@ -51,7 +51,7 @@ public: * bit vector if found. * * @param wordNum the word number to lookup a bit vector for. - * @return the loaded bit vector or NULL if not found. + * @return the loaded bit vector or nullptr if not found. **/ BitVector::UP lookup(uint64_t wordNum); diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp index 4b163ee07d2..9a6144e9635 100644 --- a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp @@ -299,7 +299,7 @@ DiskIndex::readPostingList(const LookupResult &lookupRes) const handle->_bitLength = lookupRes.counts._bitLength; SchemaUtil::IndexIterator it(_schema, lookupRes.indexId); handle->_file = _postingFiles[it.getIndex()].get(); - if (handle->_file == NULL) { + if (handle->_file == nullptr) { return PostingListHandle::UP(); } const uint32_t firstSegment = 0; @@ -317,7 +317,7 @@ DiskIndex::readBitVector(const LookupResult &lookupRes) const { SchemaUtil::IndexIterator it(_schema, lookupRes.indexId); BitVectorDictionary * dict = _bitVectorDicts[it.getIndex()].get(); - if (dict == NULL) { + if (dict == nullptr) { return BitVector::UP(); } return dict->lookup(lookupRes.wordNum); diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.h b/searchlib/src/vespa/searchlib/diskindex/diskindex.h index 382f04ffdbd..4bef53a3030 100644 --- a/searchlib/src/vespa/searchlib/diskindex/diskindex.h +++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.h @@ -106,7 +106,7 @@ public: * @param indexId the id of the field to * perform lookup for. * @param word the word to lookup. - * @return the lookup result or NULL if the word is not found. + * @return the lookup result or nullptr if the word is not found. **/ LookupResult::UP lookup(uint32_t indexId, vespalib::stringref word); LookupResultVector lookup(const std::vector & indexes, vespalib::stringref word); @@ -124,7 +124,7 @@ public: * Read the bit vector corresponding to the given lookup result. * * @param lookupRes the result of the previous dictionary lookup. - * @return the bit vector or NULL if no bit vector exists for the + * @return the bit vector or nullptr if no bit vector exists for the * word in the lookup result. **/ BitVector::UP readBitVector(const LookupResult &lookupRes) const; diff --git a/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp b/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp index 0ae141fd827..4ee37470e1d 100644 --- a/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp @@ -25,9 +25,9 @@ PageDict4RandRead::PageDict4RandRead() _ssReader(), _ssd(), _ssReadContext(_ssd), - _ssfile(new FastOS_File()), - _spfile(new FastOS_File()), - _pfile(new FastOS_File()), + _ssfile(std::make_unique()), + _spfile(std::make_unique()), + _pfile(std::make_unique()), _ssFileBitSize(0u), _spFileBitSize(0u), _pFileBitSize(0u), @@ -210,6 +210,10 @@ PageDict4RandRead::open(const vespalib::string &name, _spfile->enableMemoryMap(mmapFlags); _pfile->enableMemoryMap(mmapFlags); + int fadvise = tuneFileRead.getAdvise(); + _ssfile->setFAdviseOptions(fadvise); + _spfile->setFAdviseOptions(fadvise); + _pfile->setFAdviseOptions(fadvise); if (!_ssfile->OpenReadOnly(ssname.c_str())) { LOG(error, "could not open %s: %s", _ssfile->GetFileName(), getLastErrorString().c_str()); @@ -257,7 +261,6 @@ PageDict4RandRead::close() return true; } - uint64_t PageDict4RandRead::getNumWordIds() const { diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp b/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp index 688e3ef59e1..d51a592bf2b 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp @@ -78,7 +78,7 @@ Zc4PostingSeqRead(PostingListCountFileSeqRead *countFile) _wordStart(0), _residue(0) { - if (_countFile != NULL) { + if (_countFile != nullptr) { PostingListParams params; _countFile->getParams(params); params.get("docIdLimit", _docIdLimit); @@ -492,7 +492,7 @@ Zc4PostingSeqRead::close() { _readContext.dropComprBuf(); _file.Close(); - _readContext.setFile(NULL); + _readContext.setFile(nullptr); return true; } @@ -500,7 +500,7 @@ Zc4PostingSeqRead::close() void Zc4PostingSeqRead::getParams(PostingListParams ¶ms) { - if (_countFile != NULL) { + if (_countFile != nullptr) { PostingListParams countParams; _countFile->getParams(countParams); params = countParams; @@ -614,7 +614,7 @@ Zc4PostingSeqWrite(PostingListCountFileSeqWrite *countFile) _minSkipDocs(64), _docIdLimit(10000000), _docIds(), - _encodeFeatures(NULL), + _encodeFeatures(nullptr), _featureOffset(0), _featureWriteContext(sizeof(uint64_t)), _writePos(0), @@ -630,7 +630,7 @@ Zc4PostingSeqWrite(PostingListCountFileSeqWrite *countFile) { _encodeContext.setWriteContext(&_writeContext); - if (_countFile != NULL) { + if (_countFile != nullptr) { PostingListParams params; _countFile->getParams(params); params.get("docIdLimit", _docIdLimit); @@ -874,7 +874,7 @@ Zc4PostingSeqWrite::close() _writeContext.dropComprBuf(); _file.Sync(); _file.Close(); - _writeContext.setFile(NULL); + _writeContext.setFile(nullptr); updateHeader(); return true; } @@ -885,7 +885,7 @@ void Zc4PostingSeqWrite:: setParams(const PostingListParams ¶ms) { - if (_countFile != NULL) + if (_countFile != nullptr) _countFile->setParams(params); params.get("docIdLimit", _docIdLimit); params.get("minChunkDocs", _minChunkDocs); @@ -897,7 +897,7 @@ void Zc4PostingSeqWrite:: getParams(PostingListParams ¶ms) { - if (_countFile != NULL) { + if (_countFile != nullptr) { PostingListParams countParams; _countFile->getParams(countParams); params = countParams; diff --git a/searchlib/src/vespa/searchlib/diskindex/zcpostingiterators.cpp b/searchlib/src/vespa/searchlib/diskindex/zcpostingiterators.cpp index c3261878b45..513f39c47f8 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcpostingiterators.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/zcpostingiterators.cpp @@ -37,7 +37,7 @@ template Zc4RareWordPostingIterator:: Zc4RareWordPostingIterator(const TermFieldMatchDataArray &matchData, Position start, uint32_t docIdLimit) : ZcIteratorBase(matchData, start, docIdLimit), - _decodeContext(NULL), + _decodeContext(nullptr), _residue(0), _prevDocId(0), _numDocs(0) @@ -204,8 +204,8 @@ ZcRareWordPostingIterator::readWordStart(uint32_t docIdLimit) ZcPostingIteratorBase::ZcPostingIteratorBase(const TermFieldMatchDataArray &matchData, Position start, uint32_t docIdLimit) : ZcIteratorBase(matchData, start, docIdLimit), - _valI(NULL), - _valIBase(NULL), + _valI(nullptr), + _valIBase(nullptr), _featureSeekPos(0), _l1(), _l2(), @@ -226,12 +226,12 @@ ZcPostingIterator(uint32_t minChunkDocs, const search::fef::TermFieldMatchDataArray &matchData, Position start, uint32_t docIdLimit) : ZcPostingIteratorBase(matchData, start, docIdLimit), - _decodeContext(NULL), + _decodeContext(nullptr), _minChunkDocs(minChunkDocs), _docIdK(0), _dynamicK(dynamicK), _numDocs(0), - _featuresValI(NULL), + _featuresValI(nullptr), _featuresBitOffset(0), _counts(counts) { } -- cgit v1.2.3