15 Meta m(
"lcpcomp_dec",
"MultimapListBuffer");
21 std::vector<uliteral_t> m_buffer;
22 std::unordered_multimap<len_compact_t, len_compact_t> m_fwd;
26 len_t m_longest_chain;
27 len_t m_current_chain;
30 std::vector<len_compact_t> m_target_pos;
31 std::vector<len_compact_t> m_source_pos;
32 std::vector<len_compact_t> m_length;
38 m_longest_chain = std::max(m_longest_chain, m_current_chain);
52 for(
auto it = m_fwd.find(pos); it != m_fwd.end(); it = m_fwd.find(pos)) {
53 decode_literal_at(it->second, c);
65 inline void decode_lazy_() {
66 const len_t factors = m_source_pos.size();
67 for(
len_t j = 0; j < factors; ++j) {
71 for(
len_t i = 0; i < factor_length; ++i) {
72 if(m_decoded[source_position+i]) {
73 m_buffer[target_position+i] = m_buffer[source_position+i];
74 m_decoded[target_position+i] = 1;
82 :
Algorithm(
std::move(
env)), m_cursor(0), m_longest_chain(0), m_current_chain(0), m_lazy(this->
env().option(
"lazy").as_integer())
84 m_fwd.max_load_factor(0.8);
85 m_buffer.resize(size, 0);
90 decode_literal_at(m_cursor++, c);
94 bool factor_stored =
false;
95 for(
len_t i = 0; i < factor_length; ++i) {
96 const len_t src_pos = source_position+i;
97 if(m_decoded[src_pos]) {
98 m_buffer[m_cursor] = m_buffer[src_pos];
99 m_decoded[m_cursor] = 1;
101 else if(factor_stored ==
false) {
102 factor_stored =
true;
104 m_source_pos.push_back(src_pos);
105 m_length.push_back(factor_length-i);
112 size_t lazy = m_lazy;
120 const len_t factors = m_source_pos.size();
126 for(
len_t j = 0; j < factors; ++j) {
130 for(
len_t i = 0; i < factor_length; ++i) {
131 if(m_decoded[source_position+i]) {
132 decode_literal_at(target_position+i, m_buffer[source_position+i]);
134 m_fwd.emplace(source_position+i, target_position+i);
138 max_size = std::max(max_size, m_fwd.bucket_count());
139 if((j+1) % ((factors+5)/5) == 0 ) {
140 phase.
log_stat(
"hash table size", m_fwd.bucket_count());
141 phase.
log_stat(
"hash table entries", m_fwd.size());
144 std::string(
"Decoding Factors at position ")
153 return m_longest_chain;
157 for(
auto c : m_buffer) out << c;
Contains the text compression and encoding framework.
len_t longest_chain() const
A vector over arbitrary unsigned integer types.
uint8_t uliteral_t
Type to represent signed single literals.
void push_back(const value_type &val)
IntVector< uint_t< 1 > > BitVector
Represents a bit vector, alias for IntVector with a fixed bit width of 1.
std::string to_string(tdc::uint_impl_t< N > value)
MultimapBuffer(Env &&env, len_t size)
Provides access to runtime and memory measurement in statistics phases.
void split(const char *new_title)
Starts a new phase as a sibling, reusing the same object.
Env & env()
Provides access to the environment that the algorithm works in.
uint32_t len_compact_t
Type to represent an bit-compact length value.
void decode_factor(const len_t source_position, const len_t factor_length)
fast_t< len_compact_t > len_t
Type to represent an length value.
#define IF_STATS(x)
x is compiled only when the STATS_DISABLED macro is undefined.
void decode_literal(uliteral_t c)
void log_stat(const char *key, const T &value)
Logs a user statistic for this phase.
void write_to(std::ostream &out)
Local environment for a compression/encoding/decompression call.
Interface for algorithms.