Skip to content

Commit

Permalink
int_vector_mapper: support loading from arbitrary position in file, a…
Browse files Browse the repository at this point in the history
…dded getter
  • Loading branch information
karasikov committed Jan 22, 2023
1 parent 905184e commit d11abfa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion include/sdsl/int_vector_mapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ class int_vector_mapper

int_vector_mapper(const std::string filename,
bool is_plain = false,
bool delete_on_close = false) :
bool delete_on_close = false,
uint64_t file_offset = 0) :
m_file_name(filename), m_delete_on_close(delete_on_close)
{
size_type size_in_bits = 0;
Expand All @@ -135,13 +136,15 @@ class int_vector_mapper
"int_vector_mapper: file does not exist.");
}
if (!is_plain) {
f.seekg(file_offset);
int_vector<t_width>::read_header(size_in_bits, int_width, f);
}
}
m_file_size_bytes = util::file_size(m_file_name);

if (!is_plain) {
m_data_offset = t_width ? 8 : 9;
m_data_offset += file_offset;
} else {
if (8 != t_width and 16 != t_width and 32 != t_width and 64 != t_width) {
throw std::runtime_error("int_vector_mapper: plain vector can "
Expand Down Expand Up @@ -183,6 +186,11 @@ class int_vector_mapper

}

const int_vector<t_width>& wrapper() const
{
return m_wrapper;
}

std::string file_name() const { return m_file_name; }
width_type width() const { return m_wrapper.width(); }
void width(const uint8_t new_int_width)
Expand Down

0 comments on commit d11abfa

Please sign in to comment.