Skip to content

Commit 9f62d6d

Browse files
authored
Fix variable name and change tests to use MemorySource (#420)
1 parent dde6095 commit 9f62d6d

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

Diff for: include/pisa/block_freq_index.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class block_freq_index {
2121
block_freq_index() = default;
2222
explicit block_freq_index(MemorySource source) : m_source(std::move(source))
2323
{
24-
mapper::map(*this, source.data(), mapper::map_flags::warmup);
24+
mapper::map(*this, m_source.data(), mapper::map_flags::warmup);
2525
}
2626

2727
class builder {

Diff for: include/pisa/freq_index.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class freq_index {
2222

2323
explicit freq_index(MemorySource source) : m_source(std::move(source))
2424
{
25-
mapper::map(*this, source.data(), mapper::map_flags::warmup);
25+
mapper::map(*this, m_source.data(), mapper::map_flags::warmup);
2626
}
2727

2828
class builder {

Diff for: include/pisa/wand_data.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class wand_data {
3232
wand_data() = default;
3333
explicit wand_data(MemorySource source) : m_source(std::move(source))
3434
{
35-
mapper::map(*this, source.data(), mapper::map_flags::warmup);
35+
mapper::map(*this, m_source.data(), mapper::map_flags::warmup);
3636
}
3737

3838
template <typename LengthsIterator>

Diff for: test/test_block_freq_index.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,15 @@ void test_block_freq_index()
4242
}
4343

4444
Temporary_Directory tmpdir;
45-
auto filename = tmpdir.path().string() + "temp.bin";
45+
auto filename = (tmpdir.path() / "temp.bin").string();
4646
{
4747
collection_type coll;
4848
b.build(coll);
4949
pisa::mapper::freeze(coll, filename.c_str());
5050
}
5151

5252
{
53-
collection_type coll;
54-
mio::mmap_source m(filename.c_str());
55-
pisa::mapper::map(coll, m);
56-
53+
collection_type coll(pisa::MemorySource::mapped_file(filename));
5754
for (size_t i = 0; i < posting_lists.size(); ++i) {
5855
auto const& plist = posting_lists[i];
5956
auto doc_enum = coll[i];

Diff for: test/test_freq_index.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@
1010

1111
#include "freq_index.hpp"
1212
#include "mappable/mapper.hpp"
13+
#include "memory_source.hpp"
1314
#include "mio/mmap.hpp"
1415
#include "sequence/indexed_sequence.hpp"
1516
#include "sequence/partitioned_sequence.hpp"
1617
#include "sequence/positive_sequence.hpp"
1718
#include "sequence/uniform_partitioned_sequence.hpp"
19+
#include "temporary_directory.hpp"
1820

1921
template <typename DocsSequence, typename FreqsSequence>
2022
void test_freq_index()
2123
{
24+
Temporary_Directory tmpdir;
25+
auto idx_path = (tmpdir.path() / "coll.bin").string();
26+
2227
pisa::global_parameters params;
2328
uint64_t universe = 20000;
2429
using collection_type = pisa::freq_index<DocsSequence, FreqsSequence>;
@@ -40,14 +45,11 @@ void test_freq_index()
4045
{
4146
collection_type coll;
4247
b.build(coll);
43-
pisa::mapper::freeze(coll, "temp.bin");
48+
pisa::mapper::freeze(coll, idx_path.c_str());
4449
}
4550

4651
{
47-
collection_type coll;
48-
mio::mmap_source m("temp.bin");
49-
pisa::mapper::map(coll, m);
50-
52+
collection_type coll(pisa::MemorySource::mapped_file(idx_path));
5153
for (size_t i = 0; i < posting_lists.size(); ++i) {
5254
auto const& plist = posting_lists[i];
5355
auto doc_enum = coll[i];

0 commit comments

Comments
 (0)