Skip to content

Commit

Permalink
edgo_io: not finish
Browse files Browse the repository at this point in the history
  • Loading branch information
voutcn committed Jun 8, 2019
1 parent e429268 commit e8e632e
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 184 deletions.
10 changes: 6 additions & 4 deletions src/cx1/cx1.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
* @tparam NBuckets number of buckets
*/
template <typename TGlobal, unsigned NBuckets>
struct CX1 {
class CX1 {
private:
typedef TGlobal global_data_t;
// other settings, don't change
static const int kLv1BytePerItem = 4; // 32-bit differatial offset
Expand Down Expand Up @@ -78,9 +79,10 @@ struct CX1 {
std::vector<int64_t> lv1_items_special_;

// === functions to specify a CX1 instance ===
int64_t (*encode_lv1_diff_base_func_)(int64_t, global_data_t &);
void (*prepare_func_)(global_data_t &); // num_items_, num_cpu_threads_ and num_output_threads_ must be set here
void *(*lv0_calc_bucket_size_func_)(void *);
public:
virtual int64_t encode_lv1_diff_base_func_(int64_t, global_data_t &) = 0;
virtual void prepare_func_(global_data_t &) = 0; // num_items_, num_cpu_threads_ and num_output_threads_ must be set here
virtual void *(*lv0_calc_bucket_size_func_)(void *);
void (*init_global_and_set_cx1_func_)(global_data_t &); // xxx set here
void *(*lv1_fill_offset_func_)(void *);
void (*lv1_sort_and_proc)(global_data_t &);
Expand Down
14 changes: 7 additions & 7 deletions src/cx1/cx1_kmer_count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ void init_global_and_set_cx1(count_global_t &globals) {
}

// --- initialize writer ---
globals.edge_writer.set_file_prefix(globals.output_prefix);
globals.edge_writer.set_num_threads(globals.num_output_threads);
globals.edge_writer.set_kmer_size(globals.kmer_k);
globals.edge_writer.set_num_buckets(kNumBuckets);
globals.edge_writer.init_files();
globals.edge_writer.SetFilePrefix(globals.output_prefix);
globals.edge_writer.SetNumThreads(globals.num_output_threads);
globals.edge_writer.SetKmerSize(globals.kmer_k);
globals.edge_writer.SetNumBuckets(kNumBuckets);
globals.edge_writer.InitFiles();
}

void *lv1_fill_offset(void *_data) {
Expand Down Expand Up @@ -523,7 +523,7 @@ void lv2_output_(int64_t start_index, int64_t end_index, int thread_id, count_gl

if (count >= globals.kmer_freq_threshold) {
PackEdge(packed_edge, first_item, count, globals);
globals.edge_writer.write(packed_edge, packed_edge[0] >> (32 - 2 * kBucketPrefixLength), thread_id, &snapshot);
globals.edge_writer.Write(packed_edge, packed_edge[0] >> (32 - 2 * kBucketPrefixLength), thread_id, &snapshot);
}
}

Expand Down Expand Up @@ -623,7 +623,7 @@ void post_proc(count_global_t &globals) {
fclose(counting_file);

// --- cleaning ---
globals.edge_writer.destroy();
globals.edge_writer.Finalize();
}

} // namespace cx1_kmer_count
6 changes: 3 additions & 3 deletions src/cx1/cx1_seq2sdbg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,16 @@ void read_seq_and_prepare(seq2sdbg_global_t &globals) {

if (globals.input_prefix != "") {
MegahitEdgeReader edge_reader;
edge_reader.set_file_prefix(globals.input_prefix);
edge_reader.read_info();
edge_reader.SetFilePrefix(globals.input_prefix);
edge_reader.ReadInfo();
int64_t num_edges = edge_reader.num_edges();
xinfo("Number edges: %lld\n", (long long)num_edges);

if (globals.need_mercy) {
num_edges *= 1.25; // it is rare that # mercy > 25%
}

bases_to_reserve += num_edges * (edge_reader.kmer_size() + 1);
bases_to_reserve += num_edges * (edge_reader.k() + 1);
num_multiplicities_to_reserve += num_edges;
}

Expand Down
12 changes: 6 additions & 6 deletions src/iterate/kmer_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class KmerCollector {
words_per_kmer_ = DivCeiling(k_ * 2 + kBitsPerMul, 32);
buffer_.resize(words_per_kmer_);

writer_.set_num_threads(1);
writer_.set_file_prefix(out_prefix);
writer_.set_unsorted();
writer_.set_kmer_size(k_ - 1);
writer_.init_files();
writer_.SetNumThreads(1);
writer_.SetFilePrefix(out_prefix);
writer_.SetUnsorted();
writer_.SetKmerSize(k_ - 1);
writer_.InitFiles();
}

void Insert(const KmerType &kmer, mul_t mul) { collection_.insert({kmer, mul}); }
Expand Down Expand Up @@ -62,7 +62,7 @@ class KmerCollector {
*ptr = (w << last_shift_);
assert((buffer_.back() & kMaxMul) == 0);
buffer_.back() |= mul;
writer_.write_unsorted(buffer_.data(), 0);
writer_.WriteUnsorted(buffer_.data(), 0);
}

private:
Expand Down
Loading

0 comments on commit e8e632e

Please sign in to comment.