9#ifndef INCLUDED_SDSL_CONSTRUCT_SA
10#define INCLUDED_SDSL_CONSTRUCT_SA
90template <
typename t_
int_vec>
91void calculate_sa(
unsigned char const * c,
typename t_int_vec::size_type len, t_int_vec & sa)
93 typedef typename t_int_vec::size_type size_type;
94 constexpr uint8_t t_width = t_int_vec::fixed_int_width;
103 bool small_file = (
sizeof(len) <= 4 or len < 0x7FFFFFFFULL);
106 uint8_t sa_width = sa.width();
107 if (32 == t_width or (0 == t_width and 32 >= sa_width))
111 divsufsort(c, (int32_t *)sa.data(), (int32_t)len);
115 for (size_type i = 0, p = 0; i < len; ++i, p += sa_width)
117 sa.set_int(p, sa.get_int(i << 5, 32), sa_width);
127 throw std::logic_error(
"width of int_vector is to small for the text!!!");
132 for (size_type i = 0; i < len; ++i)
140 uint8_t sa_width = sa.
width();
147 for (size_type i = 0, p = 0; i < len; ++i, p += sa_width)
149 sa.set_int(p, sa.get_int(i << 6, 64), sa_width);
175template <u
int8_t t_w
idth>
178 static_assert(t_width == 0 or t_width == 8,
179 "construct_sa: width must be `0` for integer alphabet and `8` for byte alphabet");
195 else if (t_width == 0)
204 std::cerr <<
"Unknown alphabet type" << std::endl;
bits.hpp contains the sdsl::bits class.
void push_back(const uint64_t value)
Appends the given element value to the end of the int_vector_buffer.
A generic vector class for integers of width .
uint64_t const * data() const noexcept
Pointer to the raw data of the int_vector.
uint8_t width() const noexcept
Returns the width of the integers which are accessed via the [] operator.
size_type size() const noexcept
The number of elements in the int_vector.
static int_vector_mapper< t_width > create(std::string const &key, cache_config &config)
int_vector.hpp contains the sdsl::int_vector class.
int_vector_buffer.hpp contains the sdsl::int_vector_buffer class.
io.hpp contains some methods for reading/writing sdsl structures.
void calculate_sa(unsigned char const *c, typename t_int_vec::size_type len, t_int_vec &sa)
Calculates the Suffix Array for a text.
constexpr char KEY_TEXT[]
void construct_sa(int_vector_type &sa, char const *file, uint8_t num_bytes)
Construct a suffix array for the sequence stored in a file.
Namespace for the succinct data structure library.
bool store_to_cache(T const &v, std::string const &key, cache_config &config, bool add_type_hash=false)
Stores the object v as a resource in the cache.
int_vector_mapper< t_width, std::ios_base::in > const read_only_mapper
int32_t divsufsort(uint8_t const *T, saidx_t *SA, saidx_t n)
std::string cache_file_name(std::string const &key, cache_config const &config)
Returns the file name of the resource.
void construct_sa_se(cache_config &config)
Constructs the Suffix Array (SA) from text over byte-alphabet.
bool load_from_file(T &v, std::string const &file)
Load sdsl-object v from a file.
void register_cache_file(std::string const &key, cache_config &config)
Register the existing resource specified by the key to the cache.
int32_t divsufsort64(uint8_t const *T, int64_t *SA, int64_t n)
void construct_sa(cache_config &config)
Constructs the Suffix Array (SA) from text over byte- or integer-alphabet.
construct_config_data & construct_config()
qsufsort.hpp contains the interface for the suffix array construction algorithm of Larsson.
static constexpr uint32_t hi(uint64_t x)
Position of the most significant set bit the 64-bit word x.
Helper class for construction process.
byte_sa_algo_type byte_algo_sa
Helper classes to transform width=0 and width=8 to corresponding text key.