diff --git a/CMakeLists.txt b/CMakeLists.txt index 02a82b2a..1f3b31a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,16 +4,11 @@ cmake_policy(SET CMP0074 NEW) project(PISA CXX C) if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD 20) endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -if(NOT CMAKE_CXX_STANDARD EQUAL 17) - add_compile_definitions(PISA_ENABLE_CONCEPTS=1) - add_compile_definitions(PISA_CXX20=1) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconcepts-diagnostics-depth=2") -endif() add_compile_definitions(BOOST_NO_CXX98_FUNCTION_BASE=1) option(PISA_BUILD_TOOLS "Build command line tools." ON) diff --git a/benchmarks/perftest_interpolative.cpp b/benchmarks/perftest_interpolative.cpp index 416adacd..ac1d84ab 100644 --- a/benchmarks/perftest_interpolative.cpp +++ b/benchmarks/perftest_interpolative.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "spdlog/spdlog.h" @@ -7,8 +7,7 @@ #include "util/do_not_optimize_away.hpp" #include "util/util.hpp" -int main() -{ +int main() { using namespace pisa; static const size_t size = interpolative_block::block_size; static const size_t runs = 1 << 20; diff --git a/include/pisa/accumulator/lazy_accumulator.hpp b/include/pisa/accumulator/lazy_accumulator.hpp index 1842041e..a948b999 100644 --- a/include/pisa/accumulator/lazy_accumulator.hpp +++ b/include/pisa/accumulator/lazy_accumulator.hpp @@ -5,7 +5,6 @@ #include #include -#include "concepts.hpp" #include "partial_score_accumulator.hpp" #include "topk_queue.hpp" @@ -58,7 +57,7 @@ class LazyAccumulator { public: explicit LazyAccumulator(std::size_t size) : m_size(size), m_accumulators((size + counters_in_descriptor - 1) / counters_in_descriptor) { - PISA_ASSERT_CONCEPT(PartialScoreAccumulator); + static_assert(PartialScoreAccumulator); } void reset() { diff --git a/include/pisa/accumulator/partial_score_accumulator.hpp b/include/pisa/accumulator/partial_score_accumulator.hpp index 1421e2c9..6a6a055d 100644 --- a/include/pisa/accumulator/partial_score_accumulator.hpp +++ b/include/pisa/accumulator/partial_score_accumulator.hpp @@ -16,12 +16,8 @@ #pragma once -#ifdef PISA_ENABLE_CONCEPTS - #include #include -#include -#include #include "topk_queue.hpp" @@ -56,5 +52,3 @@ concept PartialScoreAccumulator = requires(T a, std::uint32_t docid, float score }; // namespace pisa // clang-format on - -#endif diff --git a/include/pisa/accumulator/simple_accumulator.hpp b/include/pisa/accumulator/simple_accumulator.hpp index cd374d88..0eb66472 100644 --- a/include/pisa/accumulator/simple_accumulator.hpp +++ b/include/pisa/accumulator/simple_accumulator.hpp @@ -19,7 +19,6 @@ limitations under the License. */ #include #include -#include "concepts.hpp" #include "partial_score_accumulator.hpp" #include "topk_queue.hpp" @@ -33,7 +32,7 @@ namespace pisa { class SimpleAccumulator: public std::vector { public: explicit SimpleAccumulator(std::size_t size) : std::vector(size) { - PISA_ASSERT_CONCEPT(PartialScoreAccumulator); + static_assert(PartialScoreAccumulator); } void reset() { std::fill(begin(), end(), 0.0); } diff --git a/include/pisa/block_inverted_index.hpp b/include/pisa/block_inverted_index.hpp index f5a5147f..5d79f743 100644 --- a/include/pisa/block_inverted_index.hpp +++ b/include/pisa/block_inverted_index.hpp @@ -7,8 +7,7 @@ #include "bit_vector.hpp" #include "codec/block_codec.hpp" #include "codec/block_codecs.hpp" -#include "concepts.hpp" -#include "concepts/inverted_index.hpp" +#include "concepts/posting_cursor.hpp" #include "global_parameters.hpp" #include "mappable/mappable_vector.hpp" #include "mappable/mapper.hpp" @@ -50,7 +49,7 @@ class BlockInvertedIndexCursor { m_universe(universe), m_block_codec(block_codec), m_block_size(block_codec->block_size()) { - PISA_ASSERT_CONCEPT( + static_assert( (concepts::FrequencyPostingCursor && concepts::SortedPostingCursor) ); @@ -68,7 +67,7 @@ class BlockInvertedIndexCursor { void PISA_ALWAYSINLINE next() { ++m_pos_in_block; - if PISA_UNLIKELY (m_pos_in_block == m_cur_block_size) { + if (m_pos_in_block == m_cur_block_size) [[unlikely]] { if (m_cur_block + 1 == m_blocks) { m_cur_docid = m_universe; return; @@ -87,7 +86,7 @@ class BlockInvertedIndexCursor { * to the current document ID, the position will not change. */ void PISA_ALWAYSINLINE next_geq(uint64_t lower_bound) { - if PISA_UNLIKELY (lower_bound > m_cur_block_max) { + if (lower_bound > m_cur_block_max) [[unlikely]] { // binary search seems to perform worse here if (lower_bound > block_max(m_blocks - 1)) { m_cur_docid = m_universe; @@ -111,7 +110,7 @@ class BlockInvertedIndexCursor { void PISA_ALWAYSINLINE move(uint64_t pos) { assert(pos >= position()); uint64_t block = pos / m_block_size; - if PISA_UNLIKELY (block != m_cur_block) { + if (block != m_cur_block) [[unlikely]] { decode_docs_block(block); } while (position() < pos) { @@ -338,8 +337,8 @@ class ProfilingBlockInvertedIndex: public BlockInvertedIndex { ProfilingBlockInvertedIndex(MemorySource source, BlockCodecPtr block_codec); - [[nodiscard]] auto operator[](std::size_t term_id - ) const -> BlockInvertedIndexCursor; + [[nodiscard]] auto operator[](std::size_t term_id) const + -> BlockInvertedIndexCursor; }; namespace index::block { diff --git a/include/pisa/codec/VarIntG8IU.h b/include/pisa/codec/VarIntG8IU.h index 0ea3bedc..883689de 100644 --- a/include/pisa/codec/VarIntG8IU.h +++ b/include/pisa/codec/VarIntG8IU.h @@ -3,6 +3,13 @@ * This code is released under the * Apache License Version 2.0 http://www.apache.org/licenses/. */ + +#include +#include +#include +#include +#include + #if defined(_MSC_VER) #include #else diff --git a/include/pisa/codec/block_codecs.hpp b/include/pisa/codec/block_codecs.hpp index 9680fbbf..922e701b 100644 --- a/include/pisa/codec/block_codecs.hpp +++ b/include/pisa/codec/block_codecs.hpp @@ -2,13 +2,8 @@ #include -#include "FastPFor/headers/optpfor.h" -#include "FastPFor/headers/variablebyte.h" - -#include "VarIntG8IU.h" #include "interpolative_coding.hpp" #include "util/compiler_attribute.hpp" -#include "util/likely.hpp" #include "util/util.hpp" namespace pisa { diff --git a/include/pisa/codec/compact_elias_fano.hpp b/include/pisa/codec/compact_elias_fano.hpp index 43e3e180..0f56856b 100644 --- a/include/pisa/codec/compact_elias_fano.hpp +++ b/include/pisa/codec/compact_elias_fano.hpp @@ -7,7 +7,6 @@ #include "global_parameters.hpp" #include "util/compiler_attribute.hpp" -#include "util/likely.hpp" #include "util/util.hpp" namespace pisa { @@ -164,9 +163,9 @@ struct compact_elias_fano { uint64_t skip = position - m_position; // optimize small forward skips - if PISA_LIKELY (position > m_position && skip <= linear_scan_threshold) { + if (position > m_position && skip <= linear_scan_threshold) [[likely]] { m_position = position; - if PISA_UNLIKELY (m_position == size()) { + if (m_position == size()) [[unlikely]] { m_value = m_of.universe; } else { bit_vector::unary_enumerator he = m_high_enumerator; @@ -193,13 +192,13 @@ struct compact_elias_fano { uint64_t cur_high = m_value >> m_of.lower_bits; uint64_t high_diff = high_lower_bound - cur_high; - if PISA_LIKELY (lower_bound > m_value && high_diff <= linear_scan_threshold) { + if (lower_bound > m_value && high_diff <= linear_scan_threshold) [[likely]] { // optimize small skips next_reader next_value(*this, m_position + 1); uint64_t val; do { m_position += 1; - if PISA_LIKELY (m_position < size()) { + if (m_position < size()) [[likely]] { val = next_value(); } else { m_position = size(); @@ -220,7 +219,7 @@ struct compact_elias_fano { m_position += 1; assert(m_position <= size()); - if PISA_LIKELY (m_position < size()) { + if (m_position < size()) [[likely]] { m_value = read_next(); } else { m_value = m_of.universe; @@ -234,7 +233,7 @@ struct compact_elias_fano { } uint64_t prev_high = 0; - if PISA_LIKELY (m_position < size()) { + if (m_position < size()) [[likely]] { prev_high = m_bv->predecessor1(m_high_enumerator.position() - 1); } else { prev_high = m_bv->predecessor1(m_of.lower_bits_offset - 1); @@ -253,7 +252,7 @@ struct compact_elias_fano { private: value_type PISA_NOINLINE slow_move(uint64_t position) { - if PISA_UNLIKELY (position == size()) { + if (position == size()) [[unlikely]] { m_position = position; m_value = m_of.universe; return value(); @@ -279,7 +278,7 @@ struct compact_elias_fano { } value_type PISA_NOINLINE slow_next_geq(uint64_t lower_bound) { - if PISA_UNLIKELY (lower_bound >= m_of.universe) { + if (lower_bound >= m_of.universe) [[unlikely]] { return move(size()); } @@ -309,7 +308,7 @@ struct compact_elias_fano { next_reader read_value(*this, m_position); while (true) { - if PISA_UNLIKELY (m_position == size()) { + if (m_position == size()) [[unlikely]] { m_value = m_of.universe; return value(); } diff --git a/include/pisa/codec/compact_ranked_bitvector.hpp b/include/pisa/codec/compact_ranked_bitvector.hpp index 7900d67a..927397f1 100644 --- a/include/pisa/codec/compact_ranked_bitvector.hpp +++ b/include/pisa/codec/compact_ranked_bitvector.hpp @@ -7,7 +7,6 @@ #include "global_parameters.hpp" #include "util/compiler_attribute.hpp" -#include "util/likely.hpp" #include "util/util.hpp" namespace pisa { @@ -139,9 +138,9 @@ struct compact_ranked_bitvector { // optimize small forward skips uint64_t skip = position - m_position; - if PISA_LIKELY (position > m_position && skip <= linear_scan_threshold) { + if (position > m_position && skip <= linear_scan_threshold) [[likely]] { m_position = position; - if PISA_UNLIKELY (m_position == size()) { + if (m_position == size()) [[unlikely]] { m_value = m_of.universe; } else { bit_vector::unary_enumerator he = m_enumerator; @@ -164,13 +163,13 @@ struct compact_ranked_bitvector { } uint64_t diff = lower_bound - m_value; - if PISA_LIKELY (lower_bound > m_value && diff <= linear_scan_threshold) { + if (lower_bound > m_value && diff <= linear_scan_threshold) [[likely]] { // optimize small skips bit_vector::unary_enumerator he = m_enumerator; uint64_t val; do { m_position += 1; - if PISA_LIKELY (m_position < size()) { + if (m_position < size()) [[likely]] { val = he.next() - m_of.bits_offset; } else { m_position = size(); @@ -190,7 +189,7 @@ struct compact_ranked_bitvector { m_position += 1; assert(m_position <= size()); - if PISA_LIKELY (m_position < size()) { + if (m_position < size()) [[likely]] { m_value = read_next(); } else { m_value = m_of.universe; @@ -206,7 +205,7 @@ struct compact_ranked_bitvector { } uint64_t pos = 0; - if PISA_LIKELY (m_position < size()) { + if (m_position < size()) [[likely]] { pos = m_bv->predecessor1(m_enumerator.position() - 1); } else { pos = m_bv->predecessor1(m_of.end - 1); @@ -218,7 +217,7 @@ struct compact_ranked_bitvector { private: value_type PISA_NOINLINE slow_move(uint64_t position) { uint64_t skip = position - m_position; - if PISA_UNLIKELY (position == size()) { + if (position == size()) [[unlikely]] { m_position = position; m_value = m_of.universe; return value(); @@ -245,7 +244,7 @@ struct compact_ranked_bitvector { value_type PISA_NOINLINE slow_next_geq(uint64_t lower_bound) { using broadword::popcount; - if PISA_UNLIKELY (lower_bound >= m_of.universe) { + if (lower_bound >= m_of.universe) [[unlikely]] { return move(size()); } diff --git a/include/pisa/concepts.hpp b/include/pisa/concepts.hpp deleted file mode 100644 index ea0fc373..00000000 --- a/include/pisa/concepts.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2023 PISA developers - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -#pragma once - -#ifdef PISA_ENABLE_CONCEPTS - - #include - - #define PISA_REQUIRES(x) requires(x) - - #define PISA_ASSERT_CONCEPT(x) static_assert(x) - -#else - - #define PISA_REQUIRES(x) /**/ - - #define PISA_ASSERT_CONCEPT(x) /**/ - -#endif diff --git a/include/pisa/concepts/container.hpp b/include/pisa/concepts/container.hpp index e55907df..c59ff100 100644 --- a/include/pisa/concepts/container.hpp +++ b/include/pisa/concepts/container.hpp @@ -17,8 +17,6 @@ #pragma once -#ifdef PISA_ENABLE_CONCEPTS - #include namespace pisa::concepts { @@ -35,5 +33,3 @@ concept SizedContainer = requires(T const container) { }; // namespace pisa // clang-format on - -#endif diff --git a/include/pisa/concepts/inverted_index.hpp b/include/pisa/concepts/inverted_index.hpp index bb5d3bcb..d7e73b27 100644 --- a/include/pisa/concepts/inverted_index.hpp +++ b/include/pisa/concepts/inverted_index.hpp @@ -16,8 +16,6 @@ // clang-format off -#ifdef PISA_ENABLE_CONCEPTS - #include #include @@ -48,5 +46,3 @@ concept SortedInvertedIndex = InvertedIndex && SortedPostingCursor #include #include @@ -59,5 +57,3 @@ concept BidirectionalMapping = Mapping && ReverseMapping }; // namespace pisa // clang-format on - -#endif diff --git a/include/pisa/concepts/posting_cursor.hpp b/include/pisa/concepts/posting_cursor.hpp index 26dbb1e0..886ad1ac 100644 --- a/include/pisa/concepts/posting_cursor.hpp +++ b/include/pisa/concepts/posting_cursor.hpp @@ -16,8 +16,6 @@ #pragma once -#ifdef PISA_ENABLE_CONCEPTS - #include #include @@ -95,5 +93,3 @@ concept BlockMaxPostingCursor = MaxScorePostingCursor && SortedPostingCursor< }; // namespace pisa // clang-format on - -#endif diff --git a/include/pisa/cursor/block_max_scored_cursor.hpp b/include/pisa/cursor/block_max_scored_cursor.hpp index f2e82312..f86ed8dc 100644 --- a/include/pisa/cursor/block_max_scored_cursor.hpp +++ b/include/pisa/cursor/block_max_scored_cursor.hpp @@ -10,7 +10,7 @@ namespace pisa { template -PISA_REQUIRES((concepts::FrequencyPostingCursor && concepts::SortedPostingCursor)) + requires(concepts::FrequencyPostingCursor && concepts::SortedPostingCursor) class BlockMaxScoredCursor: public MaxScoredCursor { public: using base_cursor_type = Cursor; @@ -24,7 +24,7 @@ class BlockMaxScoredCursor: public MaxScoredCursor { ) : MaxScoredCursor(std::move(cursor), std::move(term_scorer), weight, max_score), m_wdata(std::move(wdata)) { - PISA_ASSERT_CONCEPT((concepts::BlockMaxPostingCursor)); + static_assert(concepts::BlockMaxPostingCursor); } BlockMaxScoredCursor(BlockMaxScoredCursor const&) = delete; BlockMaxScoredCursor(BlockMaxScoredCursor&&) = default; diff --git a/include/pisa/cursor/max_scored_cursor.hpp b/include/pisa/cursor/max_scored_cursor.hpp index 70b02dc9..cc95e066 100644 --- a/include/pisa/cursor/max_scored_cursor.hpp +++ b/include/pisa/cursor/max_scored_cursor.hpp @@ -9,7 +9,7 @@ namespace pisa { template -PISA_REQUIRES((concepts::FrequencyPostingCursor && concepts::SortedPostingCursor)) + requires(concepts::FrequencyPostingCursor && concepts::SortedPostingCursor) class MaxScoredCursor: public ScoredCursor { public: using base_cursor_type = Cursor; @@ -17,7 +17,7 @@ class MaxScoredCursor: public ScoredCursor { MaxScoredCursor(Cursor cursor, TermScorer term_scorer, float weight, float max_score) : ScoredCursor(std::move(cursor), std::move(term_scorer), weight), m_max_score(max_score) { - PISA_ASSERT_CONCEPT( + static_assert( (concepts::MaxScorePostingCursor && concepts::SortedPostingCursor) ); diff --git a/include/pisa/cursor/scored_cursor.hpp b/include/pisa/cursor/scored_cursor.hpp index 990a520a..e2e1ffb5 100644 --- a/include/pisa/cursor/scored_cursor.hpp +++ b/include/pisa/cursor/scored_cursor.hpp @@ -1,6 +1,5 @@ #pragma once -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "query.hpp" #include "scorer/index_scorer.hpp" @@ -18,7 +17,7 @@ auto resolve_term_scorer(Scorer scorer, float weight) -> TermScorer { } template -PISA_REQUIRES((concepts::FrequencyPostingCursor && concepts::SortedPostingCursor)) + requires(concepts::FrequencyPostingCursor && concepts::SortedPostingCursor) class ScoredCursor { public: using base_cursor_type = Cursor; @@ -27,7 +26,7 @@ class ScoredCursor { : m_base_cursor(std::move(cursor)), m_weight(weight), m_term_scorer(resolve_term_scorer(term_scorer, weight)) { - PISA_ASSERT_CONCEPT( + static_assert( (concepts::ScoredPostingCursor && concepts::SortedPostingCursor) ); diff --git a/include/pisa/forward_index.hpp b/include/pisa/forward_index.hpp index ac1b8629..21899d07 100644 --- a/include/pisa/forward_index.hpp +++ b/include/pisa/forward_index.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/include/pisa/freq_index.hpp b/include/pisa/freq_index.hpp index 9f69c0da..686ab408 100644 --- a/include/pisa/freq_index.hpp +++ b/include/pisa/freq_index.hpp @@ -6,7 +6,6 @@ #include "bitvector_collection.hpp" #include "codec/integer_codes.hpp" -#include "concepts.hpp" #include "concepts/inverted_index.hpp" #include "concepts/posting_cursor.hpp" #include "global_parameters.hpp" @@ -44,9 +43,7 @@ class freq_index { * any index operations may result in undefined behavior. */ explicit freq_index(MemorySource source) : m_source(std::move(source)) { - PISA_ASSERT_CONCEPT( - (concepts::SortedInvertedIndex) - ); + static_assert(concepts::SortedInvertedIndex); mapper::map(*this, m_source.data(), mapper::map_flags::warmup); } @@ -180,7 +177,7 @@ class freq_index { typename DocsSequence::enumerator docs_enum, typename FreqsSequence::enumerator freqs_enum ) : m_docs_enum(docs_enum), m_freqs_enum(freqs_enum) { - PISA_ASSERT_CONCEPT( + static_assert( (concepts::FrequencyPostingCursor && concepts::SortedPostingCursor) ); diff --git a/include/pisa/query/algorithm/and_query.hpp b/include/pisa/query/algorithm/and_query.hpp index 5c8b0bde..d35895a0 100644 --- a/include/pisa/query/algorithm/and_query.hpp +++ b/include/pisa/query/algorithm/and_query.hpp @@ -4,7 +4,6 @@ #include #include -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" namespace pisa { @@ -18,7 +17,7 @@ namespace pisa { */ struct and_query { template - PISA_REQUIRES((concepts::SortedPostingCursor)) + requires(concepts::SortedPostingCursor) auto operator()(CursorRange&& cursors, uint32_t max_docid) const { using Cursor = typename std::decay_t::value_type; diff --git a/include/pisa/query/algorithm/block_max_maxscore_query.hpp b/include/pisa/query/algorithm/block_max_maxscore_query.hpp index 7e2f9bc3..5285079b 100644 --- a/include/pisa/query/algorithm/block_max_maxscore_query.hpp +++ b/include/pisa/query/algorithm/block_max_maxscore_query.hpp @@ -2,7 +2,6 @@ #include -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "topk_queue.hpp" @@ -12,7 +11,7 @@ struct block_max_maxscore_query { explicit block_max_maxscore_query(topk_queue& topk) : m_topk(topk) {} template - PISA_REQUIRES((concepts::BlockMaxPostingCursor>)) + requires(concepts::BlockMaxPostingCursor>) void operator()(CursorRange&& cursors, uint64_t max_docid) { using Cursor = typename std::decay_t::value_type; if (cursors.empty()) { diff --git a/include/pisa/query/algorithm/block_max_ranked_and_query.hpp b/include/pisa/query/algorithm/block_max_ranked_and_query.hpp index d5a133c1..d7874f3a 100644 --- a/include/pisa/query/algorithm/block_max_ranked_and_query.hpp +++ b/include/pisa/query/algorithm/block_max_ranked_and_query.hpp @@ -2,7 +2,6 @@ #include -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "topk_queue.hpp" @@ -12,7 +11,7 @@ struct block_max_ranked_and_query { explicit block_max_ranked_and_query(topk_queue& topk) : m_topk(topk) {} template - PISA_REQUIRES(concepts::BlockMaxPostingCursor>) + requires(concepts::BlockMaxPostingCursor>) void operator()(CursorRange&& cursors, uint64_t max_docid) { using Cursor = typename std::decay_t::value_type; diff --git a/include/pisa/query/algorithm/block_max_wand_query.hpp b/include/pisa/query/algorithm/block_max_wand_query.hpp index a7b374f6..63c5d48d 100644 --- a/include/pisa/query/algorithm/block_max_wand_query.hpp +++ b/include/pisa/query/algorithm/block_max_wand_query.hpp @@ -2,7 +2,6 @@ #include -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "topk_queue.hpp" @@ -12,7 +11,7 @@ struct block_max_wand_query { explicit block_max_wand_query(topk_queue& topk) : m_topk(topk) {} template - PISA_REQUIRES(concepts::BlockMaxPostingCursor>) + requires(concepts::BlockMaxPostingCursor>) void operator()(CursorRange&& cursors, uint64_t max_docid) { using Cursor = typename std::decay_t::value_type; if (cursors.empty()) { diff --git a/include/pisa/query/algorithm/maxscore_query.hpp b/include/pisa/query/algorithm/maxscore_query.hpp index d18e7e5a..e36a1a14 100644 --- a/include/pisa/query/algorithm/maxscore_query.hpp +++ b/include/pisa/query/algorithm/maxscore_query.hpp @@ -5,7 +5,6 @@ #include #include -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "topk_queue.hpp" #include "util/compiler_attribute.hpp" @@ -16,10 +15,10 @@ struct maxscore_query { explicit maxscore_query(topk_queue& topk) : m_topk(topk) {} template - PISA_REQUIRES( - (concepts::MaxScorePostingCursor> - && concepts::SortedPostingCursor>) - ) + requires( + (concepts::MaxScorePostingCursor> + && concepts::SortedPostingCursor>) + ) [[nodiscard]] PISA_ALWAYSINLINE auto sorted(Cursors&& cursors) -> std::vector> { std::vector term_positions(cursors.size()); @@ -35,7 +34,7 @@ struct maxscore_query { } template - PISA_REQUIRES((concepts::MaxScorePostingCursor>)) + requires(concepts::MaxScorePostingCursor>) [[nodiscard]] PISA_ALWAYSINLINE auto calc_upper_bounds(Cursors&& cursors) -> std::vector { std::vector upper_bounds(cursors.size()); auto out = upper_bounds.rbegin(); @@ -48,7 +47,7 @@ struct maxscore_query { } template - PISA_REQUIRES((concepts::MaxScorePostingCursor>)) + requires(concepts::MaxScorePostingCursor>) [[nodiscard]] PISA_ALWAYSINLINE auto min_docid(Cursors&& cursors) -> std::uint32_t { return std::min_element( cursors.begin(), @@ -61,7 +60,7 @@ struct maxscore_query { enum class DocumentStatus : bool { Insert, Skip }; template - PISA_REQUIRES((concepts::MaxScorePostingCursor>)) + requires(concepts::MaxScorePostingCursor>) PISA_ALWAYSINLINE void run_sorted(Cursors&& cursors, uint64_t max_docid) { auto upper_bounds = calc_upper_bounds(cursors); auto above_threshold = [&](auto score) { return m_topk.would_enter(score); }; @@ -92,7 +91,7 @@ struct maxscore_query { while (current_docid < max_docid) { auto status = DocumentStatus::Skip; while (status == DocumentStatus::Skip) { - if PISA_UNLIKELY (next_docid >= max_docid) { + if (next_docid >= max_docid) [[unlikely]] { return; } @@ -131,7 +130,7 @@ struct maxscore_query { } template - PISA_REQUIRES((concepts::MaxScorePostingCursor>)) + requires(concepts::MaxScorePostingCursor>) void operator()(Cursors&& cursors_, uint64_t max_docid) { if (cursors_.empty()) { return; diff --git a/include/pisa/query/algorithm/or_query.hpp b/include/pisa/query/algorithm/or_query.hpp index d38213d7..2c4a4f2d 100644 --- a/include/pisa/query/algorithm/or_query.hpp +++ b/include/pisa/query/algorithm/or_query.hpp @@ -4,7 +4,6 @@ #include #include -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "util/do_not_optimize_away.hpp" @@ -13,7 +12,7 @@ namespace pisa { template struct or_query { template - PISA_REQUIRES((concepts::SortedPostingCursor)) + requires(concepts::SortedPostingCursor) uint64_t operator()(CursorRange&& cursors, uint64_t max_docid) const { using Cursor = typename std::decay_t::value_type; if (cursors.empty()) { diff --git a/include/pisa/query/algorithm/range_query.hpp b/include/pisa/query/algorithm/range_query.hpp index 70ddc48c..79031865 100644 --- a/include/pisa/query/algorithm/range_query.hpp +++ b/include/pisa/query/algorithm/range_query.hpp @@ -1,6 +1,5 @@ #pragma once -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "topk_queue.hpp" @@ -11,7 +10,7 @@ struct range_query { explicit range_query(topk_queue& topk) : m_topk(topk) {} template - PISA_REQUIRES((concepts::MaxScorePostingCursor::value_type>)) + requires(concepts::MaxScorePostingCursor::value_type>) void operator()(CursorRange&& cursors, uint64_t max_docid, size_t range_size) { m_topk.clear(); if (cursors.empty()) { @@ -27,7 +26,7 @@ struct range_query { std::vector const& topk() const { return m_topk.topk(); } template - PISA_REQUIRES((concepts::MaxScorePostingCursor::value_type>)) + requires(concepts::MaxScorePostingCursor::value_type>) void process_range(CursorRange&& cursors, size_t end) { QueryAlg query_alg(m_topk); query_alg(cursors, end); diff --git a/include/pisa/query/algorithm/range_taat_query.hpp b/include/pisa/query/algorithm/range_taat_query.hpp index 6fc08d3b..2b59b6d7 100644 --- a/include/pisa/query/algorithm/range_taat_query.hpp +++ b/include/pisa/query/algorithm/range_taat_query.hpp @@ -1,7 +1,6 @@ #pragma once #include "accumulator/partial_score_accumulator.hpp" -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "topk_queue.hpp" @@ -12,12 +11,11 @@ struct range_taat_query { explicit range_taat_query(topk_queue& topk) : m_topk(topk) {} template - PISA_REQUIRES( - (PartialScoreAccumulator - && pisa::concepts::MaxScorePostingCursor::value_type>) - ) - void - operator()(CursorRange&& cursors, uint64_t max_docid, size_t range_size, Acc&& accumulator) { + requires( + (PartialScoreAccumulator + && pisa::concepts::MaxScorePostingCursor::value_type>) + ) + void operator()(CursorRange&& cursors, uint64_t max_docid, size_t range_size, Acc&& accumulator) { if (cursors.empty()) { return; } diff --git a/include/pisa/query/algorithm/ranked_and_query.hpp b/include/pisa/query/algorithm/ranked_and_query.hpp index c79cffff..632b5acc 100644 --- a/include/pisa/query/algorithm/ranked_and_query.hpp +++ b/include/pisa/query/algorithm/ranked_and_query.hpp @@ -2,7 +2,6 @@ #include -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "topk_queue.hpp" @@ -12,12 +11,11 @@ struct ranked_and_query { explicit ranked_and_query(topk_queue& topk) : m_topk(topk) {} template - PISA_REQUIRES( - (concepts::ScoredPostingCursor> - && concepts::SortedPostingCursor>) - ) - void - operator()(CursorRange&& cursors, uint64_t max_docid) { + requires( + (concepts::ScoredPostingCursor> + && concepts::SortedPostingCursor>) + ) + void operator()(CursorRange&& cursors, uint64_t max_docid) { using Cursor = typename std::decay_t::value_type; if (cursors.empty()) { return; diff --git a/include/pisa/query/algorithm/ranked_or_query.hpp b/include/pisa/query/algorithm/ranked_or_query.hpp index 95c31db2..6a1a377a 100644 --- a/include/pisa/query/algorithm/ranked_or_query.hpp +++ b/include/pisa/query/algorithm/ranked_or_query.hpp @@ -2,7 +2,6 @@ #include -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "topk_queue.hpp" @@ -18,12 +17,11 @@ struct ranked_or_query { explicit ranked_or_query(topk_queue& topk) : m_topk(topk) {} template - PISA_REQUIRES( - (concepts::ScoredPostingCursor> - && concepts::SortedPostingCursor>) - ) - void - operator()(CursorRange&& cursors, uint64_t max_docid) { + requires( + (concepts::ScoredPostingCursor> + && concepts::SortedPostingCursor>) + ) + void operator()(CursorRange&& cursors, uint64_t max_docid) { using Cursor = typename std::decay_t::value_type; if (cursors.empty()) { return; diff --git a/include/pisa/query/algorithm/ranked_or_taat_query.hpp b/include/pisa/query/algorithm/ranked_or_taat_query.hpp index 9f70af53..fe8d0068 100644 --- a/include/pisa/query/algorithm/ranked_or_taat_query.hpp +++ b/include/pisa/query/algorithm/ranked_or_taat_query.hpp @@ -1,7 +1,6 @@ #pragma once #include "accumulator/partial_score_accumulator.hpp" -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "topk_queue.hpp" @@ -12,12 +11,11 @@ class ranked_or_taat_query { explicit ranked_or_taat_query(topk_queue& topk) : m_topk(topk) {} template - PISA_REQUIRES( - (PartialScoreAccumulator && concepts::ScoredPostingCursor> - && concepts::SortedPostingCursor>) - ) - void - operator()(CursorRange&& cursors, uint64_t max_docid, Acc&& accumulator) { + requires( + (PartialScoreAccumulator && concepts::ScoredPostingCursor> + && concepts::SortedPostingCursor>) + ) + void operator()(CursorRange&& cursors, uint64_t max_docid, Acc&& accumulator) { if (cursors.empty()) { return; } diff --git a/include/pisa/query/algorithm/wand_query.hpp b/include/pisa/query/algorithm/wand_query.hpp index fd42689e..db7f6c79 100644 --- a/include/pisa/query/algorithm/wand_query.hpp +++ b/include/pisa/query/algorithm/wand_query.hpp @@ -2,7 +2,6 @@ #include -#include "concepts.hpp" #include "concepts/posting_cursor.hpp" #include "topk_queue.hpp" @@ -12,12 +11,11 @@ struct wand_query { explicit wand_query(topk_queue& topk) : m_topk(topk) {} template - PISA_REQUIRES( - (concepts::MaxScorePostingCursor> - && concepts::SortedPostingCursor>) - ) - void - operator()(CursorRange&& cursors, uint64_t max_docid) { + requires( + (concepts::MaxScorePostingCursor> + && concepts::SortedPostingCursor>) + ) + void operator()(CursorRange&& cursors, uint64_t max_docid) { using Cursor = typename std::decay_t::value_type; if (cursors.empty()) { return; diff --git a/include/pisa/recursive_graph_bisection.hpp b/include/pisa/recursive_graph_bisection.hpp index 85f27646..7af02252 100644 --- a/include/pisa/recursive_graph_bisection.hpp +++ b/include/pisa/recursive_graph_bisection.hpp @@ -1,19 +1,15 @@ #pragma once #include -#include #include -#include #include #include "tbb/enumerable_thread_specific.h" +#include "tbb/parallel_invoke.h" #include "tbb/task_group.h" #include "algorithm.hpp" #include "forward_index.hpp" -#include "payload_vector.hpp" -#include "util/index_build_utils.hpp" -#include "util/inverted_index_utils.hpp" #include "util/log.hpp" #include "util/progress.hpp" #include "util/single_init_vector.hpp" @@ -180,7 +176,7 @@ void compute_move_gains_caching( auto terms = range.terms(d); for (const auto& t: terms) { if constexpr (isLikelyCached) { // NOLINT(readability-braces-around-statements) - if PISA_UNLIKELY (not gain_cache.has_value(t)) { + if (not gain_cache.has_value(t)) [[unlikely]] { const auto& from_deg = from_lex[t]; const auto& to_deg = to_lex[t]; const auto term_gain = bp::expb(logn1, logn2, from_deg, to_deg) @@ -188,7 +184,7 @@ void compute_move_gains_caching( gain_cache.set(t, term_gain); } } else { - if PISA_LIKELY (not gain_cache.has_value(t)) { + if (not gain_cache.has_value(t)) [[likely]] { const auto& from_deg = from_lex[t]; const auto& to_deg = to_lex[t]; const auto term_gain = bp::expb(logn1, logn2, from_deg, to_deg) @@ -223,7 +219,7 @@ void swap(document_partition& partition, degree_map_pair& degrees) { auto lit = left.begin(); auto rit = right.begin(); for (; lit != left.end() && rit != right.end(); ++lit, ++rit) { - if PISA_UNLIKELY (left.gain(*lit) + right.gain(*rit) <= 0) { + if (left.gain(*lit) + right.gain(*rit) <= 0) [[unlikely]] { break; } { diff --git a/include/pisa/reorder_docids.hpp b/include/pisa/reorder_docids.hpp index 55e0ae09..7416781e 100644 --- a/include/pisa/reorder_docids.hpp +++ b/include/pisa/reorder_docids.hpp @@ -11,8 +11,8 @@ #include #include "binary_freq_collection.hpp" +#include "payload_vector.hpp" #include "recursive_graph_bisection.hpp" -#include "util/index_build_utils.hpp" #include "util/inverted_index_utils.hpp" #include "util/progress.hpp" diff --git a/include/pisa/score_opt_partition.hpp b/include/pisa/score_opt_partition.hpp index bbe73857..a49445e0 100644 --- a/include/pisa/score_opt_partition.hpp +++ b/include/pisa/score_opt_partition.hpp @@ -1,14 +1,11 @@ #pragma once #include +#include #include -#include #include #include -#include "concepts.hpp" -#include "util/util.hpp" - namespace pisa { using posting_t = uint32_t; @@ -103,10 +100,11 @@ struct score_opt_partition { score_opt_partition( I begin, std::uint32_t base, std::uint64_t size, double eps1, double eps2, float fixed_cost ) - PISA_REQUIRES( + requires( std::forward_iterator && (std::convertible_to::value_type, std::pair>) - ) { + ) + { // compute cost of single block. float max = 0; float sum = 0; diff --git a/include/pisa/sequence/partitioned_sequence.hpp b/include/pisa/sequence/partitioned_sequence.hpp index e80c398f..2fc09d67 100644 --- a/include/pisa/sequence/partitioned_sequence.hpp +++ b/include/pisa/sequence/partitioned_sequence.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include @@ -186,7 +185,7 @@ struct partitioned_sequence { // note: this is instantiated oly if BaseSequence has next_geq template > value_type PISA_ALWAYSINLINE next_geq(uint64_t lower_bound) { - if PISA_LIKELY (lower_bound >= m_cur_base && lower_bound <= m_cur_upper_bound) { + if (lower_bound >= m_cur_base && lower_bound <= m_cur_upper_bound) [[likely]] { auto val = m_partition_enum.next_geq(lower_bound - m_cur_base); m_position = m_cur_begin + val.first; return value_type(m_position, m_cur_base + val.second); @@ -197,7 +196,7 @@ struct partitioned_sequence { value_type PISA_ALWAYSINLINE next() { ++m_position; - if PISA_LIKELY (m_position < m_cur_end) { + if (m_position < m_cur_end) [[likely]] { uint64_t val = m_cur_base + m_partition_enum.next().second; return value_type(m_position, val); } @@ -207,7 +206,7 @@ struct partitioned_sequence { uint64_t size() const { return m_size; } uint64_t prev_value() const { - if PISA_UNLIKELY (m_position == m_cur_begin) { + if (m_position == m_cur_begin) [[unlikely]] { return m_cur_partition != 0U ? m_cur_base - 1 : 0; } return m_cur_base + m_partition_enum.prev_value(); @@ -224,7 +223,7 @@ struct partitioned_sequence { // tight loops, on microbenchmarks this causes an improvement of // about 3ns on my i7 3Ghz value_type PISA_NOINLINE slow_next() { - if PISA_UNLIKELY (m_position == m_size) { + if (m_position == m_size) [[unlikely]] { assert(m_cur_partition == m_partitions - 1); auto val = m_partition_enum.next(); assert(val.first == m_partition_enum.size()); diff --git a/include/pisa/sequence/positive_sequence.hpp b/include/pisa/sequence/positive_sequence.hpp index 0e559bc9..4e617edf 100644 --- a/include/pisa/sequence/positive_sequence.hpp +++ b/include/pisa/sequence/positive_sequence.hpp @@ -48,7 +48,7 @@ struct positive_sequence { // the most common cases uint64_t prev = m_cur; if (position != m_position + 1) { - if PISA_UNLIKELY (position == 0) { + if (position == 0) [[unlikely]] { // we need to special-case position 0 m_cur = m_base_enum.move(0).second; m_position = 0; diff --git a/include/pisa/sequence/uniform_partitioned_sequence.hpp b/include/pisa/sequence/uniform_partitioned_sequence.hpp index 0f4b941c..327255ed 100644 --- a/include/pisa/sequence/uniform_partitioned_sequence.hpp +++ b/include/pisa/sequence/uniform_partitioned_sequence.hpp @@ -1,7 +1,5 @@ #pragma once -#include - #include "codec/compact_elias_fano.hpp" #include "codec/integer_codes.hpp" #include "global_parameters.hpp" @@ -171,7 +169,7 @@ struct uniform_partitioned_sequence { // note: this is instantiated oly if BaseSequence has next_geq template > value_type PISA_ALWAYSINLINE next_geq(uint64_t lower_bound) { - if PISA_LIKELY (lower_bound >= m_cur_base && lower_bound <= m_cur_upper_bound) { + if (lower_bound >= m_cur_base && lower_bound <= m_cur_upper_bound) [[likely]] { auto val = m_partition_enum.next_geq(lower_bound - m_cur_base); m_position = m_cur_begin + val.first; return value_type(m_position, m_cur_base + val.second); @@ -182,7 +180,7 @@ struct uniform_partitioned_sequence { value_type PISA_ALWAYSINLINE next() { ++m_position; - if PISA_LIKELY (m_position < m_cur_end) { + if (m_position < m_cur_end) [[likely]] { uint64_t val = m_cur_base + m_partition_enum.next().second; return value_type(m_position, val); } @@ -192,7 +190,7 @@ struct uniform_partitioned_sequence { uint64_t size() const { return m_size; } uint64_t prev_value() const { - if PISA_UNLIKELY (m_position == m_cur_begin) { + if (m_position == m_cur_begin) [[unlikely]] { return m_cur_partition != 0U ? m_cur_base - 1 : 0; } return m_cur_base + m_partition_enum.prev_value(); @@ -205,7 +203,7 @@ struct uniform_partitioned_sequence { // tight loops, on microbenchmarks this causes an improvement of // about 3ns on my i7 3Ghz value_type PISA_NOINLINE slow_next() { - if PISA_UNLIKELY (m_position == m_size) { + if (m_position == m_size) [[unlikely]] { assert(m_cur_partition == m_partitions - 1); auto val = m_partition_enum.next(); assert(val.first == m_partition_enum.size()); diff --git a/include/pisa/term_map.hpp b/include/pisa/term_map.hpp index f0e087c8..70fad231 100644 --- a/include/pisa/term_map.hpp +++ b/include/pisa/term_map.hpp @@ -4,7 +4,6 @@ #include #include -#include "concepts.hpp" #include "concepts/container.hpp" #include "concepts/mapping.hpp" #include "payload_vector.hpp" @@ -25,7 +24,7 @@ class TermMap { -> std::optional = 0; }; -PISA_ASSERT_CONCEPT((concepts::ReverseMapping)); +static_assert(concepts::ReverseMapping); /** * Maps string representations of numbers to their numeric representations. @@ -38,7 +37,7 @@ class IntMap final: public TermMap { -> std::optional override; }; -PISA_ASSERT_CONCEPT((concepts::ReverseMapping)); +static_assert(concepts::ReverseMapping); class LexiconMap final: public TermMap { std::optional m_buffer; @@ -57,7 +56,7 @@ class LexiconMap final: public TermMap { [[nodiscard]] auto size() const noexcept -> std::size_t; }; -PISA_ASSERT_CONCEPT((concepts::BidirectionalMapping)); -PISA_ASSERT_CONCEPT((concepts::SizedContainer)); +static_assert(concepts::BidirectionalMapping); +static_assert(concepts::SizedContainer); } // namespace pisa diff --git a/include/pisa/topk_queue.hpp b/include/pisa/topk_queue.hpp index 80795ffc..3cd0d340 100644 --- a/include/pisa/topk_queue.hpp +++ b/include/pisa/topk_queue.hpp @@ -1,10 +1,11 @@ #pragma once -#include "type_alias.hpp" -#include "util/likely.hpp" -#include "util/util.hpp" - #include +#include +#include +#include + +#include "type_alias.hpp" namespace pisa { @@ -43,13 +44,13 @@ struct topk_queue { /// If the heap is full, the entry with the lowest value will be removed, i.e., /// the heap will maintain its size. auto insert(Score score, DocId docid = 0) -> bool { - if PISA_UNLIKELY (not would_enter(score)) { + if (not would_enter(score)) [[unlikely]] { return false; } m_q.emplace_back(score, docid); - if PISA_UNLIKELY (m_q.size() <= m_k) { + if (m_q.size() <= m_k) [[unlikely]] { std::push_heap(m_q.begin(), m_q.end(), min_heap_order); - if PISA_UNLIKELY (m_q.size() == m_k) { + if (m_q.size() == m_k) [[unlikely]] { m_effective_threshold = m_q.front().first; } } else { diff --git a/include/pisa/util/likely.hpp b/include/pisa/util/likely.hpp deleted file mode 100644 index e224927e..00000000 --- a/include/pisa/util/likely.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -// Likeliness annotations -#if defined(PISA_CXX20) - #define PISA_LIKELY(x) (x) [[likely]] - #define PISA_UNLIKELY(x) (x) [[unlikely]] -#elif defined(__GNUC__) - #define PISA_LIKELY(x) (__builtin_expect(!!(x), 1)) - #define PISA_UNLIKELY(x) (__builtin_expect(!!(x), 0)) -#else - #define PISA_LIKELY(x) (x) - #define PISA_UNLIKELY(x) (x) -#endif diff --git a/include/pisa/util/util.hpp b/include/pisa/util/util.hpp index aa765888..aa2811f2 100644 --- a/include/pisa/util/util.hpp +++ b/include/pisa/util/util.hpp @@ -5,9 +5,7 @@ #include #include #include -#include #include -#include #include #include diff --git a/microbench/topk_queue_bench.cpp b/microbench/topk_queue_bench.cpp index 3ab3e2f4..55e5f42a 100644 --- a/microbench/topk_queue_bench.cpp +++ b/microbench/topk_queue_bench.cpp @@ -1,6 +1,7 @@ #include +#include #include -#include +#include #include @@ -14,8 +15,7 @@ enum Series : std::int64_t { RANDOM = 2, }; -auto generate_increasing_scores(std::size_t length) -{ +auto generate_increasing_scores(std::size_t length) { std::vector vals; std::generate_n(std::back_inserter(vals), length, [score = 100.0, docid = 0]() mutable { score += 0.1; @@ -24,8 +24,7 @@ auto generate_increasing_scores(std::size_t length) return vals; } -auto generate_decreasing_scores(std::size_t length) -{ +auto generate_decreasing_scores(std::size_t length) { std::vector vals; std::generate_n(std::back_inserter(vals), length, [score = 100.0, docid = 0]() mutable { score -= 0.1; @@ -34,8 +33,7 @@ auto generate_decreasing_scores(std::size_t length) return vals; } -auto generate_random_scores(std::size_t length) -{ +auto generate_random_scores(std::size_t length) { std::mt19937 gen(1902741074); std::uniform_real_distribution<> dis(0.0, 10.0); std::vector vals; @@ -45,8 +43,7 @@ auto generate_random_scores(std::size_t length) return vals; } -auto generate_entries(std::size_t length, Series series) -{ +auto generate_entries(std::size_t length, Series series) { switch (series) { case INCREASING: return generate_increasing_scores(length); case DECREASING: return generate_decreasing_scores(length); @@ -55,15 +52,13 @@ auto generate_entries(std::size_t length, Series series) throw std::logic_error("unreachable"); } -void insert_all(pisa::topk_queue& queue, std::vector const& entries) -{ +void insert_all(pisa::topk_queue& queue, std::vector const& entries) { for (auto const& [score, docid]: entries) { benchmark::DoNotOptimize(queue.insert(score, docid)); } } -static void bm_topk_queue(benchmark::State& state) -{ +static void bm_topk_queue(benchmark::State& state) { auto entries = generate_entries(state.range(0), Series{state.range(2)}); for (auto _: state) { pisa::topk_queue queue(state.range(1)); diff --git a/src/block_inverted_index.cpp b/src/block_inverted_index.cpp index 27203968..8c76b052 100644 --- a/src/block_inverted_index.cpp +++ b/src/block_inverted_index.cpp @@ -10,13 +10,13 @@ namespace pisa { BlockInvertedIndex::BlockInvertedIndex(MemorySource source, BlockCodecPtr block_codec) : m_source(std::move(source)), m_block_codec(std::move(block_codec)) { - PISA_ASSERT_CONCEPT((concepts::SortedInvertedIndex>)); + static_assert(concepts::SortedInvertedIndex>); mapper::map(*this, m_source.data(), mapper::map_flags::warmup); } BlockInvertedIndex::BlockInvertedIndex(BlockCodecPtr block_codec) : m_block_codec(std::move(block_codec)) { - PISA_ASSERT_CONCEPT((concepts::SortedInvertedIndex>)); + static_assert(concepts::SortedInvertedIndex>); } auto BlockInvertedIndex::operator[](std::size_t term_id) const -> BlockInvertedIndexCursor<> { @@ -73,7 +73,7 @@ auto BlockInvertedIndex::size_stats() -> SizeStats { ProfilingBlockInvertedIndex::ProfilingBlockInvertedIndex(MemorySource source, BlockCodecPtr block_codec) : BlockInvertedIndex(std::move(source), std::move(block_codec)) { - PISA_ASSERT_CONCEPT( + static_assert( (concepts::SortedInvertedIndex>) ); } diff --git a/src/codec/maskedvbyte.cpp b/src/codec/maskedvbyte.cpp index d1981da1..639b87f6 100644 --- a/src/codec/maskedvbyte.cpp +++ b/src/codec/maskedvbyte.cpp @@ -22,7 +22,7 @@ void MaskedVByteBlockCodec::encode( uint8_t const* MaskedVByteBlockCodec::decode(uint8_t const* in, uint32_t* out, uint32_t sum_of_values, size_t n) const { assert(n <= m_block_size); - if PISA_UNLIKELY (n < m_block_size) { + if (n < m_block_size) [[unlikely]] { return interpolative_block::decode(in, out, sum_of_values, n); } auto read = masked_vbyte_decode(in, out, n); diff --git a/src/codec/optpfor.cpp b/src/codec/optpfor.cpp index b56e17c1..d536dde7 100644 --- a/src/codec/optpfor.cpp +++ b/src/codec/optpfor.cpp @@ -60,7 +60,7 @@ OptPForBlockCodec::decode(uint8_t const* in, uint32_t* out, uint32_t sum_of_valu thread_local Codec optpfor_codec; // pfor decoding is *not* thread-safe assert(n <= m_block_size); - if PISA_UNLIKELY (n < m_block_size) { + if (n < m_block_size) [[unlikely]] { return interpolative_block::decode(in, out, sum_of_values, n); } diff --git a/src/codec/qmx.cpp b/src/codec/qmx.cpp index 26afb27a..a07c0b95 100644 --- a/src/codec/qmx.cpp +++ b/src/codec/qmx.cpp @@ -25,7 +25,7 @@ uint8_t const* QmxBlockCodec::decode(uint8_t const* in, uint32_t* out, uint32_t sum_of_values, size_t n) const { static QMX::compress_integer_qmx_improved qmx_codec; // decodeBlock is thread-safe assert(n <= m_block_size); - if PISA_UNLIKELY (n < m_block_size) { + if (n < m_block_size) [[unlikely]] { return interpolative_block::decode(in, out, sum_of_values, n); } uint32_t enc_len = 0; diff --git a/src/codec/simdbp.cpp b/src/codec/simdbp.cpp index 13723082..995fd787 100644 --- a/src/codec/simdbp.cpp +++ b/src/codec/simdbp.cpp @@ -27,7 +27,7 @@ void SimdBpBlockCodec::encode( uint8_t const* SimdBpBlockCodec::decode(uint8_t const* in, uint32_t* out, uint32_t sum_of_values, size_t n) const { assert(n <= m_block_size); - if PISA_UNLIKELY (n < m_block_size) { + if (n < m_block_size) [[unlikely]] { return interpolative_block::decode(in, out, sum_of_values, n); } uint32_t b = *in++; diff --git a/src/codec/varint_g8iu.cpp b/src/codec/varint_g8iu.cpp index 49fb2595..3868b73c 100644 --- a/src/codec/varint_g8iu.cpp +++ b/src/codec/varint_g8iu.cpp @@ -1,8 +1,8 @@ #include +#include "codec/VarIntG8IU.h" #include "codec/block_codecs.hpp" #include "codec/varint_g8iu.hpp" -#include "util/likely.hpp" namespace pisa { @@ -64,7 +64,7 @@ VarintG8IUBlockCodec::decode(uint8_t const* in, uint32_t* out, uint32_t sum_of_v static Codec varint_codec; // decodeBlock is thread-safe assert(n <= m_block_size); - if PISA_UNLIKELY (n < m_block_size) { + if (n < m_block_size) [[unlikely]] { return interpolative_block::decode(in, out, sum_of_values, n); } diff --git a/src/codec/varintgb.cpp b/src/codec/varintgb.cpp index 2e012848..7b4582fe 100644 --- a/src/codec/varintgb.cpp +++ b/src/codec/varintgb.cpp @@ -23,7 +23,7 @@ uint8_t const* VarintGbBlockCodec::decode(uint8_t const* in, uint32_t* out, uint32_t sum_of_values, size_t n) const { thread_local VarIntGB varintgb_codec; assert(n <= m_block_size); - if PISA_UNLIKELY (n < m_block_size) { + if (n < m_block_size) [[unlikely]] { return interpolative_block::decode(in, out, sum_of_values, n); } auto read = varintgb_codec.decodeArray(in, n, out); diff --git a/test/test_ranked_queries.cpp b/test/test_ranked_queries.cpp index b3ac556b..243fe195 100644 --- a/test/test_ranked_queries.cpp +++ b/test/test_ranked_queries.cpp @@ -96,7 +96,7 @@ class ranked_or_taat_query_acc: public ranked_or_taat_query { using ranked_or_taat_query::ranked_or_taat_query; template - PISA_REQUIRES((pisa::concepts::MaxScorePostingCursor::value_type>)) + requires(pisa::concepts::MaxScorePostingCursor::value_type>) void operator()(CursorRange&& cursors, uint64_t max_docid) { Acc accumulator(max_docid); ranked_or_taat_query::operator()(cursors, max_docid, accumulator); @@ -109,7 +109,7 @@ class range_query_128: public range_query { using range_query::range_query; template - PISA_REQUIRES((pisa::concepts::MaxScorePostingCursor::value_type>)) + requires(pisa::concepts::MaxScorePostingCursor::value_type>) void operator()(CursorRange&& cursors, uint64_t max_docid) { range_query::operator()(cursors, max_docid, 128); }