23 template<
typename coder_t,
typename decode_buffer_t>
29 auto text_len = decoder.template decode<len_t>(
len_r);
32 decode_buffer_t buffer(std::move(env), text_len);
35 Range text_r(text_len);
38 auto flen_min = decoder.template decode<len_t>(text_r);
39 auto flen_max = decoder.template decode<len_t>(text_r);
43 auto fdist_max = decoder.template decode<len_t>(text_r);
44 Range fdist_r(fdist_max);
47 while(!decoder.eof()) {
50 auto b = decoder.template decode<bool>(
bit_r);
51 if(b) num = decoder.template decode<len_t>(fdist_r);
56 auto c = decoder.template decode<uliteral_t>(
literal_r);
57 buffer.decode_literal(c);
62 auto src = decoder.template decode<len_t>(text_r);
63 auto len = decoder.template decode<len_t>(flen_r);
65 buffer.decode_factor(
src, len);
72 buffer.decode_eagerly();
82 template<
typename coder_t,
typename strategy_t,
typename dec_t,
typename text_t = TextDS<>>
86 Meta m(
"compressor",
"lcpcomp");
102 DCHECK(in.ends_with(uint8_t(0)));
105 return text_t(env().env_for_option(
"textds"), in, strategy_t::textds_flags());
109 const len_t threshold = env().option(
"threshold").as_integer();
114 strategy_t strategy(env().env_for_option(
"comp"));
115 strategy.factorize(text, threshold, factors);
124 if(env().option(
"flatten").as_integer()) {
131 typename coder_t::Encoder coder(
132 env().env_for_option(
"coder"),
142 typename coder_t::Decoder decoder(env().env_for_option(
"coder"), input);
149 lcpcomp::decode_text_internal<typename coder_t::Decoder, dec_t>(env().env_for_option(
"dec"), decoder, outs);
Represents a generic range of positive integers.
Contains the text compression and encoding framework.
constexpr auto bit_r
Global predefined range for bits (0 or 1).
Factorizes the input by finding redundant phrases in a re-ordered version of the LCP table...
Base for data compressors.
void encode_text(coder_t &coder, const text_t &text, const factor_t &factors)
Provides access to runtime and memory measurement in statistics phases.
Represents a range of positive integers that tend to be distributed towards the minimum.
virtual void compress(Input &input, Output &output) override
Compress the given input to the given output.
Runs a number of scans of the factors.
OutputStream as_stream() const
Creates a stream that allows for character-wise output.
Creates arrays instead of an LCP-heap Each array corresponds to one LCP value We do not eagerly invok...
void decode_text_internal(Env &&env, coder_t &decoder, std::ostream &outs)
constexpr auto literal_r
Global predefined reange for literals.
An abstraction layer for algorithm output.
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.
static void log(const char *key, const T &value)
Logs a user statistic for the current phase.
constexpr auto len_r
Global predefined range for len_t.
static auto wrap(const char *title, F func) -> typename std::result_of< F(StatPhase &)>::type
Executes a lambda as a single statistics phase.
LCPCompressor(Env &&env)
Construct the class with an environment.
virtual void decompress(Input &input, Output &output) override
Decompress the given input to the given output.
Local environment for a compression/encoding/decompression call.
Manages text related data structures.