25 Meta m(
"lcpcomp_comp",
"arrays");
35 template<
typename text_t>
42 auto lcp = text.release_lcp();
47 auto& sa = text.require_sa();
48 auto& isa = text.require_isa();
50 if(lcp.max_lcp()+1 <= threshold)
return;
51 const size_t cand_length = lcp.max_lcp()+1-threshold;
52 std::vector<len_compact_t>* cand =
new std::vector<len_compact_t>[cand_length];
55 for(
size_t i = 1; i < sa.size(); ++i) {
56 if(lcp[i] < threshold)
continue;
57 cand[lcp[i]-threshold].push_back(i);
62 for(
size_t i = 0; i < cand_length; ++i) {
63 ret += cand[i].size();
69 StatPhase phase(std::string{
"Factors at max. LCP value "}
72 for(
size_t maxlcp = lcp.max_lcp(); maxlcp >= threshold; --maxlcp) {
75 if( ((maxlcpbits ^ (1UL<<(
bits_for(maxlcpbits)-1))) == 0) && (( (maxlcp-threshold) ^ (1UL<<(maxlcpbits-1))) == 0)) {
76 phase.
split(std::string{
"Factors at max. LCP value "}
81 std::vector<len_compact_t>& candcol = cand[maxlcp-threshold];
82 for(
size_t i = 0; i < candcol.size(); ++i) {
84 const auto& lcp_value = lcp[index];
85 if(lcp_value < maxlcp) {
86 if(lcp_value < threshold)
continue;
87 cand[lcp_value-threshold].push_back(index);
91 const len_t pos_target = sa[index];
93 const len_t pos_source = sa[index-1];
94 const len_t factor_length = lcp[index];
96 factors.
emplace_back(pos_target, pos_source, factor_length);
99 for(
size_t k = 0; k < factor_length; ++k) {
100 lcp[isa[pos_target + k]] = 0;
103 const len_t max_affect = std::min(factor_length, pos_target);
105 for(
len_t k = 0; k < max_affect; ++k) {
106 const len_t pos_suffix = pos_target - k - 1; DCHECK_GE(pos_target,k+1);
107 const len_t ind_suffix = isa[pos_suffix];
108 lcp[ind_suffix] = std::min<len_t>(k+1, lcp[ind_suffix]);
113 candcol.shrink_to_fit();
Contains the text compression and encoding framework.
constexpr uint_fast8_t bits_for(size_t n)
Computes the number of bits required to store the given integer value.
void factorize(text_t &text, size_t threshold, lzss::FactorBuffer &factors)
static ds::dsflags_t textds_flags()
std::string to_string(tdc::uint_impl_t< N > value)
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.
Algorithm(Algorithm const &)=default
Creates arrays instead of an LCP-heap Each array corresponds to one LCP value We do not eagerly invok...
uint32_t len_compact_t
Type to represent an bit-compact length value.
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 emplace_back(len_t fpos, len_t fsrc, len_t flen)
void log_stat(const char *key, const T &value)
Logs a user statistic for this phase.
static void log(const char *key, const T &value)
Logs a user statistic for the current phase.
static auto wrap(const char *title, F func) -> typename std::result_of< F(StatPhase &)>::type
Executes a lambda as a single statistics phase.
Interface for algorithms.