csa_wt<t_wt, t_dens, t_inv_dens, t_sa_sample_strat, t_isa, t_alphabet_strat>::csa_wt(cache_config& config) { if (!cache_file_exists(key_trait<alphabet_type::int_width>::KEY_BWT, config)) { return; } { auto event = memory_monitor::event("construct csa-alpbabet"); int_vector_buffer<alphabet_type::int_width> bwt_buf(cache_file_name(key_trait<alphabet_type::int_width>::KEY_BWT,config)); size_type n = bwt_buf.size(); alphabet_type tmp_alphabet(bwt_buf, n); m_alphabet.swap(tmp_alphabet); } { auto event = memory_monitor::event("construct wavelet tree"); int_vector_buffer<alphabet_type::int_width> bwt_buf(cache_file_name(key_trait<alphabet_type::int_width>::KEY_BWT,config)); size_type n = bwt_buf.size(); wavelet_tree_type tmp_wt(bwt_buf, n); m_wavelet_tree.swap(tmp_wt); } { auto event = memory_monitor::event("sample SA"); sa_sample_type tmp_sa_sample(config); m_sa_sample.swap(tmp_sa_sample); } { auto event = memory_monitor::event("sample ISA"); isa_sample_type isa_s(config, &m_sa_sample); util::swap_support(m_isa_sample, isa_s, &m_sa_sample, &m_sa_sample); } }
csa_sada<t_enc_vec, t_dens, t_inv_dens, t_sa_sample_strat, t_isa, t_alphabet_strat>::csa_sada(cache_config& config) { create_buffer(); if (!cache_file_exists(key_trait<alphabet_type::int_width>::KEY_BWT, config)) { return; } int_vector_buffer<alphabet_type::int_width> bwt_buf(cache_file_name(key_trait<alphabet_type::int_width>::KEY_BWT,config)); size_type n = bwt_buf.size(); { auto event = memory_monitor::event("construct csa-alpbabet"); alphabet_type tmp_alphabet(bwt_buf, n); m_alphabet.swap(tmp_alphabet); } int_vector<> cnt_chr(sigma, 0, bits::hi(n)+1); for (typename alphabet_type::sigma_type i=0; i < sigma; ++i) { cnt_chr[i] = C[i]; } // calculate psi { auto event = memory_monitor::event("construct PSI"); // TODO: move PSI construct into construct_PSI.hpp int_vector<> psi(n, 0, bits::hi(n)+1); for (size_type i=0; i < n; ++i) { psi[ cnt_chr[ char2comp[bwt_buf[i]] ]++ ] = i; } std::string psi_file = cache_file_name(conf::KEY_PSI, config); if (!store_to_cache(psi, conf::KEY_PSI, config)) { return; } } { auto event = memory_monitor::event("encode PSI"); int_vector_buffer<> psi_buf(cache_file_name(conf::KEY_PSI, config)); t_enc_vec tmp_psi(psi_buf); m_psi.swap(tmp_psi); } { auto event = memory_monitor::event("sample SA"); sa_sample_type tmp_sa_sample(config); m_sa_sample.swap(tmp_sa_sample); } { auto event = memory_monitor::event("sample ISA"); isa_sample_type isa_s(config, &m_sa_sample); util::swap_support(m_isa_sample, isa_s, &m_sa_sample, (const sa_sample_type*)nullptr); } }
//! Constructor csa_bitcompressed(cache_config& config) { std::string text_file = cache_file_name(key_trait<alphabet_type::int_width>::KEY_TEXT,config); int_vector_buffer<alphabet_type::int_width> text_buf(text_file); int_vector_buffer<> sa_buf(cache_file_name(conf::KEY_SA,config)); size_type n = text_buf.size(); { alphabet_type tmp_alphabet(text_buf, n); m_alphabet.swap(tmp_alphabet); } { sa_sample_type tmp_sample(config); m_sa.swap(tmp_sample); } set_isa_samples<csa_bitcompressed>(sa_buf, m_isa); if (!store_to_file(m_isa, cache_file_name(conf::KEY_ISA,config), true)) { throw std::ios_base::failure("#csa_bitcompressed: Cannot store ISA to file system!"); } else { register_cache_file(conf::KEY_ISA, config); } }