Esempio n. 1
0
			/**
			 * flush buffers
			 **/
			void flush()
			{
				for ( uint64_t i = 0; i < buffers.getN(); ++i )
					if ( buffers[i].get() )
					{
						std::cerr << "(" << (i+1) << "/" << buffers.getN();
						buffers[i]->flush();
						buffers[i].reset();
						std::cerr << ")";
					}
			}
Esempio n. 2
0
			static inline uint64_t minOk(
				::libmaus2::autoarray::AutoArray < bool > const & ok,
				::libmaus2::autoarray::AutoArray < ::libmaus2::graph::TripleEdge > const & triples
				)
			{
				assert ( anyTrue ( ok ) );
				
				bool foundok = false;
				uint64_t minidx = 0;
				
				while ( ! foundok )
					if ( ok[minidx] )
						foundok = true;
					else
						minidx++;
						
				assert ( ok[minidx] );
				::libmaus2::graph::TripleEdge mintrip = triples[minidx];
				
				for ( uint64_t i = 0; i < triples.getN(); ++i )
					if ( ok[i] && triples[i] < mintrip )
					{
						mintrip = triples[i];
						minidx = i;
					}
					
				return minidx;
			}
Esempio n. 3
0
			static inline bool anyTrue(::libmaus2::autoarray::AutoArray < bool > const & ok)
			{
				bool t = false;
				for ( uint64_t i = 0; i < ok.getN(); ++i )
					t = t || ok[i];
				return t;
			}
Esempio n. 4
0
			SocketOutputBufferTemplate(
				::libmaus2::network::SocketBase * rdst, 
				int const rtag,
				uint64_t const bufsize)
			: dst(rdst), tag(rtag), B(bufsize), pa(B.get()), pc(pa), pe(pa+B.getN())
			{
			}
                        /**
                         * constructor by output stream
                         *
                         * @param out output stream
                         * @param bufsize output buffer size
                         **/
                        SynchronousGenericOutput(std::ostream & out, uint64_t const bufsize)
                        : B(bufsize), pa(B.get()), pc(pa), pe(pa+B.getN()), 
                          W(out),
                          datawrittentofile(0)
                        {

                        }
			/**
			 * constructor by file name
			 *
			 * @param filename name of output file
			 * @param bufsize size of output buffer
			 * @param truncate true if file should be truncated false data should be appended
			 * @param offset write offset in bytes
			 **/
                        SynchronousGenericOutput(std::string const & filename, uint64_t const bufsize, bool const truncate = true, uint64_t const offset = 0, bool const /* metasync */ = true)
                        : B(bufsize,false), pa(B.get()), pc(pa), pe(pa+B.getN()), 
                          PW ( truncate ? new ofstream_type(filename) : 0),
                          PF ( truncate ? 0 : new std::fstream(filename.c_str(), std::ios::binary|std::ios::in|std::ios::out|std::ios::ate) ),
                          W  ( truncate ? (static_cast<std::ostream &>(*PW)) : (static_cast<std::ostream &>(*PF)) ),
                          datawrittentofile(0)
                        {
                        	W.seekp(offset,std::ios::beg);
                        }
			static void writeArray(::libmaus2::autoarray::AutoArray<data_type,atype> const & A, 
				std::string const & outputfilename)
			{
				this_type out(outputfilename,64*1024);
				
				for ( uint64_t i = 0; i < A.getN(); ++i )
					out.put(A[i]);
				
				out.flush();
			}
			/**
			  * put terminator num
			  *
			  * @param num terminator number
			  **/
			void putTerm(uint64_t num)
			{
				uint8_t * p = termbuf.get() + termbuf.getN();
				for ( unsigned int i = 0; i < expo; ++i )
				{
					*(--p) = (num % base) + 1;
					num /= base;
				}
				assert ( p == termbuf.get() );
				for ( unsigned int i = 0; i < expo; ++i )
					put( *(p++) );
			}
Esempio n. 9
0
			/**
			 * constructor
			 *
			 * @param filename output file name
			 * @param bufsize size of output buffer in elements
			 **/
			OutputBuffer(std::string const & filename, uint64_t const bufsize)
			: B(bufsize), pa(B.get()), pc(pa), pe(pa+B.getN()), W(filename,16)
			{
		
			}
Esempio n. 10
0
			FileBunchLRU ( std::vector < std::string > const & rfilenames, uint64_t rlrusize = 1024)
			: LRU(rlrusize), lrusize(rlrusize), filenames ( rfilenames ), mapping(filenames.size()), rmapping(lrusize), files(lrusize)
			{
				std::fill ( mapping.get(), mapping.get() + mapping.getN(), lrusize );
			}