File: kb_storer.h

package info (click to toggle)
kmc 2.3%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,412 kB
  • sloc: cpp: 17,316; perl: 178; makefile: 90; sh: 16
file content (92 lines) | stat: -rw-r--r-- 2,122 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
  This file is a part of KMC software distributed under GNU GPL 3 licence.
  The homepage of the KMC project is http://sun.aei.polsl.pl/kmc
  
  Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
  
  Version: 2.3.0
  Date   : 2015-08-21
*/

#ifndef _KB_STORER_H
#define _KB_STORER_H

#include "defs.h"
#include "params.h"
#include "kmer.h"
#include "radix.h"
#include <string>
#include <algorithm>
#include <numeric>
#include <array>
#include <tuple>
#include <stdio.h>

using namespace std;

//************************************************************************************************************
// CKmerBinStorer - storer of bins of k-mers
//************************************************************************************************************
class CKmerBinStorer {
	CMemoryMonitor *mm;

	uint64 total_size; 
	CMemoryPool *pmm_bins;
	string working_directory;
	int n_bins;
	CBinPartQueue *q_part;
	CBinDesc *bd;
	uint64 buffer_size_bytes;
	uint64 max_mem_buffer;
	uint64 max_mem_single_package;

	CSignatureMapper *s_mapper;
	CDiskLogger *disk_logger;
	uchar* tmp_buff;
	CMemDiskFile** files;
	uint64 *buf_sizes;
	uint64 max_buf_size;
	uint32 max_buf_size_id;
	bool mem_mode;

	typedef list<tuple<uchar *, uint32, uint32>> elem_t; 
	elem_t** buffer;

	void Release();
	string GetName(int n);
	void CheckBuffer();
	void ReleaseBuffer();
	void PutBinToTmpFile(uint32 n);
	
public:
	void GetTotal(uint64& _total)
	{
		_total = total_size;
	}
	CKmerBinStorer(CKMCParams &Params, CKMCQueues &Queues);
	~CKmerBinStorer();

	bool OpenFiles();
	void ProcessQueue();
};

//************************************************************************************************************
// CWKmerBinStorer - wrapper for multithreading purposes
//************************************************************************************************************
class CWKmerBinStorer {
	CKmerBinStorer *kbs;

public:
	void GetTotal(uint64& _total)
	{
		kbs->GetTotal(_total);
	}
	CWKmerBinStorer(CKMCParams &Params, CKMCQueues &Queues);
	~CWKmerBinStorer();

	void operator()();
};

#endif

// ***** EOF