From 777329ae1ffb54506bba4e4b831b8a6d433ce8c9 Mon Sep 17 00:00:00 2001 From: Felix Meisen Date: Thu, 9 Jan 2025 20:35:52 +0100 Subject: [PATCH] Implemented the small changes requested. (Using ql::views and lowercase namespace) --- src/index/IndexImpl.Text.cpp | 20 ++++++++++---------- src/index/TextIndexReadWrite.cpp | 18 +++++++++--------- src/index/TextIndexReadWrite.h | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/index/IndexImpl.Text.cpp b/src/index/IndexImpl.Text.cpp index c9c48653a..d60373215 100644 --- a/src/index/IndexImpl.Text.cpp +++ b/src/index/IndexImpl.Text.cpp @@ -353,9 +353,9 @@ void IndexImpl::createTextIndex(const string& filename, if (std::get<0>(*reader) != currentBlockIndex) { AD_CONTRACT_CHECK(!classicPostings.empty()); - ContextListMetaData classic = TextIndexReadWrite::writePostings( + ContextListMetaData classic = textIndexReadWrite::writePostings( out, classicPostings, true, currenttOffset_); - ContextListMetaData entity = TextIndexReadWrite::writePostings( + ContextListMetaData entity = textIndexReadWrite::writePostings( out, entityPostings, false, currenttOffset_); textMeta_.addBlock(TextBlockMetaData( currentMinWordIndex, currentMaxWordIndex, classic, entity)); @@ -382,9 +382,9 @@ void IndexImpl::createTextIndex(const string& filename, } // Write the last block AD_CONTRACT_CHECK(!classicPostings.empty()); - ContextListMetaData classic = TextIndexReadWrite::writePostings( + ContextListMetaData classic = textIndexReadWrite::writePostings( out, classicPostings, true, currenttOffset_); - ContextListMetaData entity = TextIndexReadWrite::writePostings( + ContextListMetaData entity = textIndexReadWrite::writePostings( out, entityPostings, false, currenttOffset_); textMeta_.addBlock(TextBlockMetaData(currentMinWordIndex, currentMaxWordIndex, classic, entity)); @@ -575,7 +575,7 @@ IdTable IndexImpl::readWordCl( const ad_utility::AllocatorWithLimit& allocator) const { IdTable idTable{3, allocator}; vector cids = - TextIndexReadWrite::readGapComprList( + textIndexReadWrite::readGapComprList( tbmd._cl._nofElements, tbmd._cl._startContextlist, static_cast(tbmd._cl._startWordlist - tbmd._cl._startContextlist), @@ -584,7 +584,7 @@ IdTable IndexImpl::readWordCl( ql::ranges::transform(cids, idTable.getColumn(0).begin(), &Id::makeFromTextRecordIndex); ql::ranges::copy( - TextIndexReadWrite::readFreqComprList( + textIndexReadWrite::readFreqComprList( tbmd._cl._nofElements, tbmd._cl._startWordlist, static_cast(tbmd._cl._startScorelist - tbmd._cl._startWordlist), @@ -593,7 +593,7 @@ IdTable IndexImpl::readWordCl( return Id::makeFromWordVocabIndex(WordVocabIndex::make(id)); }), idTable.getColumn(1).begin()); - std::ranges::copy(TextIndexReadWrite::readFreqComprList( + std::ranges::copy(textIndexReadWrite::readFreqComprList( tbmd._cl._nofElements, tbmd._cl._startScorelist, static_cast(tbmd._cl._lastByte + 1 - tbmd._cl._startScorelist), @@ -608,7 +608,7 @@ IdTable IndexImpl::readWordEntityCl( const ad_utility::AllocatorWithLimit& allocator) const { IdTable idTable{3, allocator}; vector cids = - TextIndexReadWrite::readGapComprList( + textIndexReadWrite::readGapComprList( tbmd._entityCl._nofElements, tbmd._entityCl._startContextlist, static_cast(tbmd._entityCl._startWordlist - tbmd._entityCl._startContextlist), @@ -617,7 +617,7 @@ IdTable IndexImpl::readWordEntityCl( ql::ranges::transform(cids, idTable.getColumn(0).begin(), &Id::makeFromTextRecordIndex); ql::ranges::copy( - TextIndexReadWrite::readFreqComprList( + textIndexReadWrite::readFreqComprList( tbmd._entityCl._nofElements, tbmd._entityCl._startWordlist, static_cast(tbmd._entityCl._startScorelist - tbmd._entityCl._startWordlist), @@ -627,7 +627,7 @@ IdTable IndexImpl::readWordEntityCl( }), idTable.getColumn(1).begin()); ql::ranges::copy( - TextIndexReadWrite::readFreqComprList( + textIndexReadWrite::readFreqComprList( tbmd._entityCl._nofElements, tbmd._entityCl._startScorelist, static_cast(tbmd._entityCl._lastByte + 1 - tbmd._entityCl._startScorelist), diff --git a/src/index/TextIndexReadWrite.cpp b/src/index/TextIndexReadWrite.cpp index c63cec6b0..9a9f49533 100644 --- a/src/index/TextIndexReadWrite.cpp +++ b/src/index/TextIndexReadWrite.cpp @@ -6,7 +6,7 @@ #include "util/Simple8bCode.h" -namespace TextIndexReadWrite { +namespace textIndexReadWrite { // ____________________________________________________________________________ ContextListMetaData writePostings(ad_utility::File& out, @@ -24,17 +24,17 @@ ContextListMetaData writePostings(ad_utility::File& out, } auto firstElements = - postings | std::ranges::views::transform([](const Posting& posting) { + postings | ql::views::transform([](const Posting& posting) { return std::get<0>(posting).get(); }); auto secondElements = - postings | std::ranges::views::transform([](const Posting& posting) { + postings | ql::views::transform([](const Posting& posting) { return std::get<1>(posting); }); auto thirdElements = - postings | std::ranges::views::transform([](const Posting& posting) { + postings | ql::views::transform([](const Posting& posting) { return std::get<2>(posting); }); @@ -95,12 +95,12 @@ void writeVectorAndMoveOffset(const std::vector& vectorToWrite, off_t& currentOffset) { T* vectorAsList = new T[vectorToWrite.size()]; std::copy(vectorToWrite.begin(), vectorToWrite.end(), vectorAsList); - size_t bytes = TextIndexReadWrite::writeList(vectorAsList, nofElements, file); + size_t bytes = textIndexReadWrite::writeList(vectorAsList, nofElements, file); currentOffset += bytes; delete[] vectorAsList; } -} // namespace TextIndexReadWrite +} // namespace textIndexReadWrite // ____________________________________________________________________________ template @@ -152,8 +152,8 @@ FrequencyEncode::FrequencyEncode(const TypedVector& vectorToEncode) { template void FrequencyEncode::writeToFile(ad_utility::File& out, size_t nofElements, off_t& currentOffset) { - currentOffset += TextIndexReadWrite::writeCodebook(codeBook_, out); - TextIndexReadWrite::writeVectorAndMoveOffset(encodedVector_, nofElements, out, + currentOffset += textIndexReadWrite::writeCodebook(codeBook_, out); + textIndexReadWrite::writeVectorAndMoveOffset(encodedVector_, nofElements, out, currentOffset); } @@ -179,6 +179,6 @@ template requires std::is_arithmetic_v void GapEncode::writeToFile(ad_utility::File& out, size_t nofElements, off_t& currentOffset) { - TextIndexReadWrite::writeVectorAndMoveOffset(encodedVector_, nofElements, out, + textIndexReadWrite::writeVectorAndMoveOffset(encodedVector_, nofElements, out, currentOffset); } diff --git a/src/index/TextIndexReadWrite.h b/src/index/TextIndexReadWrite.h index 35e34d5f0..887378799 100644 --- a/src/index/TextIndexReadWrite.h +++ b/src/index/TextIndexReadWrite.h @@ -11,7 +11,7 @@ #include "util/HashMap.h" #include "util/Simple8bCode.h" -namespace TextIndexReadWrite { +namespace textIndexReadWrite { /// THIS METHOD HAS BEEN MODIFIED /// It basically tries to mimic the old function but with the new classes. ContextListMetaData writePostings(ad_utility::File& out, @@ -140,7 +140,7 @@ vector readGapComprList( return result; } -} // namespace TextIndexReadWrite +} // namespace textIndexReadWrite /// THIS IS A NEW CLASS WHICH MAINLY STEMS FROM ONE FUNCTION BEFORE /// The FrequencyEncode class basically does the olf createCodebook method