Skip to content

Fix variable name and change tests to use MemorySource #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/pisa/block_freq_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class block_freq_index {
block_freq_index() = default;
explicit block_freq_index(MemorySource source) : m_source(std::move(source))
{
mapper::map(*this, source.data(), mapper::map_flags::warmup);
mapper::map(*this, m_source.data(), mapper::map_flags::warmup);
}

class builder {
Expand Down
2 changes: 1 addition & 1 deletion include/pisa/freq_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class freq_index {

explicit freq_index(MemorySource source) : m_source(std::move(source))
{
mapper::map(*this, source.data(), mapper::map_flags::warmup);
mapper::map(*this, m_source.data(), mapper::map_flags::warmup);
}

class builder {
Expand Down
2 changes: 1 addition & 1 deletion include/pisa/wand_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class wand_data {
wand_data() = default;
explicit wand_data(MemorySource source) : m_source(std::move(source))
{
mapper::map(*this, source.data(), mapper::map_flags::warmup);
mapper::map(*this, m_source.data(), mapper::map_flags::warmup);
}

template <typename LengthsIterator>
Expand Down
7 changes: 2 additions & 5 deletions test/test_block_freq_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,15 @@ void test_block_freq_index()
}

Temporary_Directory tmpdir;
auto filename = tmpdir.path().string() + "temp.bin";
auto filename = (tmpdir.path() / "temp.bin").string();
{
collection_type coll;
b.build(coll);
pisa::mapper::freeze(coll, filename.c_str());
}

{
collection_type coll;
mio::mmap_source m(filename.c_str());
pisa::mapper::map(coll, m);

collection_type coll(pisa::MemorySource::mapped_file(filename));
for (size_t i = 0; i < posting_lists.size(); ++i) {
auto const& plist = posting_lists[i];
auto doc_enum = coll[i];
Expand Down
12 changes: 7 additions & 5 deletions test/test_freq_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@

#include "freq_index.hpp"
#include "mappable/mapper.hpp"
#include "memory_source.hpp"
#include "mio/mmap.hpp"
#include "sequence/indexed_sequence.hpp"
#include "sequence/partitioned_sequence.hpp"
#include "sequence/positive_sequence.hpp"
#include "sequence/uniform_partitioned_sequence.hpp"
#include "temporary_directory.hpp"

template <typename DocsSequence, typename FreqsSequence>
void test_freq_index()
{
Temporary_Directory tmpdir;
auto idx_path = (tmpdir.path() / "coll.bin").string();

pisa::global_parameters params;
uint64_t universe = 20000;
using collection_type = pisa::freq_index<DocsSequence, FreqsSequence>;
Expand All @@ -40,14 +45,11 @@ void test_freq_index()
{
collection_type coll;
b.build(coll);
pisa::mapper::freeze(coll, "temp.bin");
pisa::mapper::freeze(coll, idx_path.c_str());
}

{
collection_type coll;
mio::mmap_source m("temp.bin");
pisa::mapper::map(coll, m);

collection_type coll(pisa::MemorySource::mapped_file(idx_path));
for (size_t i = 0; i < posting_lists.size(); ++i) {
auto const& plist = posting_lists[i];
auto doc_enum = coll[i];
Expand Down