diff --git a/include/pisa/mappable/mappable_vector.hpp b/include/pisa/mappable/mappable_vector.hpp index dd791bf9e..caf37021b 100644 --- a/include/pisa/mappable/mappable_vector.hpp +++ b/include/pisa/mappable/mappable_vector.hpp @@ -2,13 +2,9 @@ #include #include - -#include "boost/function.hpp" -#include "boost/lambda/bind.hpp" #include "boost/lambda/construct.hpp" #include "boost/range.hpp" #include "boost/utility.hpp" - #include "util/intrinsics.hpp" namespace pisa { namespace mapper { @@ -19,7 +15,7 @@ namespace pisa { namespace mapper { class sizeof_visitor; } // namespace detail - using deleter_t = boost::function; + using deleter_t = std::function; template // T must be a POD class mappable_vector { @@ -38,15 +34,16 @@ namespace pisa { namespace mapper { explicit mappable_vector(Range const& from) : m_data(0), m_size(0) { size_t size = boost::size(from); T* data = new T[size]; - m_deleter = boost::lambda::bind(boost::lambda::delete_array(), data); - + m_deleter = [&data]() { + delete[] data; + }; std::copy(boost::begin(from), boost::end(from), data); m_data = data; m_size = size; } ~mappable_vector() { - if (not m_deleter.empty()) { + if (m_deleter) { m_deleter(); } } @@ -66,7 +63,9 @@ namespace pisa { namespace mapper { if (m_size > 0) { auto* new_vec = new std::vector; new_vec->swap(vec); - m_deleter = boost::lambda::bind(boost::lambda::delete_ptr(), new_vec); + m_deleter = [&new_vec]() { + delete new_vec; + }; m_data = &(*new_vec)[0]; } } diff --git a/include/pisa/wand_data_raw.hpp b/include/pisa/wand_data_raw.hpp index a69b51a0f..ace50b6a4 100644 --- a/include/pisa/wand_data_raw.hpp +++ b/include/pisa/wand_data_raw.hpp @@ -55,7 +55,7 @@ class wand_data_raw { ); block_docid.insert(block_docid.end(), t.first.begin(), t.first.end()); max_term_weight.push_back(*(std::max_element(t.second.begin(), t.second.end()))); - blocks_start.push_back(t.first.size() + blocks_start.back()); + blocks_start.push_back(t.first.size()); total_elements += seq.docs.size(); total_blocks += t.first.size(); @@ -72,6 +72,7 @@ class wand_data_raw { void build(wand_data_raw& wdata) { wdata.m_block_max_term_weight.steal(block_max_term_weight); + std::partial_sum(blocks_start.cbegin(), blocks_start.cend(), blocks_start.begin()); wdata.m_blocks_start.steal(blocks_start); wdata.m_block_docid.steal(block_docid); spdlog::info( diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1bfa15d58..749c3f9cf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,7 +7,51 @@ include(Catch) add_library(testlib in_memory_index.cpp) target_link_libraries(testlib pisa) -file(GLOB TEST_SOURCES test_*.cpp) +#file(GLOB TEST_SOURCES test_*.cpp) +file(GLOB TEST_SOURCES +test_algorithm.cpp +test_bit_vector.cpp +test_block_codecs.cpp +test_block_freq_index.cpp +test_block_posting_list.cpp +test_bmw_queries.cpp +test_compact_elias_fano.cpp +test_compact_ranked_bitvector.cpp +test_compress.cpp +test_cow_string.cpp +test_cursors.cpp +test_forward_index.cpp +test_forward_index_builder.cpp +test_freq_index.cpp +test_html.cpp +test_indexed_sequence.cpp +test_intersection.cpp +test_invert.cpp +test_linear_quantizer.cpp +test_mapper.cpp +test_memory.cpp +test_memory_source.cpp +test_partition_fwd_index.cpp +test_partitioned_sequence.cpp +test_payload_vector.cpp +test_positive_sequence.cpp +test_ranked_queries.cpp +test_recursive_graph_bisection.cpp +test_sample_inverted_index.cpp +test_scorer.cpp +test_sequence_collection.cpp +test_stream_builder.cpp +test_strict_elias_fano.cpp +test_taily_stats.cpp +test_text_analyzer.cpp +test_token_filter.cpp +test_token_stream.cpp +test_tokenizer.cpp +test_topk_queue.cpp +test_trec_topic_reader.cpp +test_uniform_partitioned_sequence.cpp +test_wand_data.cpp + ) foreach(TEST_SRC ${TEST_SOURCES}) get_filename_component (TEST_SRC_NAME ${TEST_SRC} NAME_WE) add_executable(${TEST_SRC_NAME} ${TEST_SRC}) diff --git a/test/test_linear_quantizer.cpp b/test/test_linear_quantizer.cpp index 1bb1d6f89..d72e32ac0 100644 --- a/test/test_linear_quantizer.cpp +++ b/test/test_linear_quantizer.cpp @@ -26,6 +26,6 @@ TEST_CASE("LinearQuantizer", "[scoring][unit]") { CAPTURE(max); pisa::LinearQuantizer quantizer(max, bits); REQUIRE(quantizer(0) == 1); - REQUIRE(quantizer(max) == (1 << bits) - 1); + REQUIRE(quantizer(max) == (1ULL << bits) - 1); } }