From d11abfaa9f3d3ad539c74773c0ac904886627154 Mon Sep 17 00:00:00 2001 From: Mikhail Karasikov Date: Sun, 22 Jan 2023 14:56:48 +0100 Subject: [PATCH] int_vector_mapper: support loading from arbitrary position in file, added getter --- include/sdsl/int_vector_mapper.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/sdsl/int_vector_mapper.hpp b/include/sdsl/int_vector_mapper.hpp index 9f6c772ba..29ebeb64a 100644 --- a/include/sdsl/int_vector_mapper.hpp +++ b/include/sdsl/int_vector_mapper.hpp @@ -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; @@ -135,6 +136,7 @@ class int_vector_mapper "int_vector_mapper: file does not exist."); } if (!is_plain) { + f.seekg(file_offset); int_vector::read_header(size_in_bits, int_width, f); } } @@ -142,6 +144,7 @@ class int_vector_mapper 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 " @@ -183,6 +186,11 @@ class int_vector_mapper } + const int_vector& 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)