Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Public Member Functions | Protected Attributes | Private Types | List of all members
MSDataSqlConsumer Class Reference

A data consumer that inserts data into a SQL database. More...

#include <OpenMS/FORMAT/DATAACCESS/MSDataSqlConsumer.h>

Inheritance diagram for MSDataSqlConsumer:
IMSDataConsumer

Public Member Functions

 MSDataSqlConsumer (String filename, bool clearData=true, int buffer_size=500)
 Constructor. More...
 
 ~MSDataSqlConsumer ()
 Destructor. More...
 
void flush ()
 Flushes the data for good. More...
 
void consumeSpectrum (SpectrumType &s)
 Write a spectrum to the output file. More...
 
void consumeChromatogram (ChromatogramType &c)
 Write a chromatogram to the output file. More...
 
void setExpectedSize (Size, Size)
 Set expected size of spectra and chromatograms to be consumed. More...
 
void setExperimentalSettings (const ExperimentalSettings &)
 Set experimental settings (meta-data) of the data to be consumed. More...
 
- Public Member Functions inherited from IMSDataConsumer
virtual ~IMSDataConsumer ()
 

Protected Attributes

OpenMS::Internal::MzMLSqliteHandler sql_writer_
 
bool clearData_
 
size_t flush_after_
 
std::vector< SpectrumTypespectra_
 
std::vector< ChromatogramTypechromatograms_
 

Private Types

typedef MSExperiment MapType
 
typedef MapType::SpectrumType SpectrumType
 
typedef MapType::ChromatogramType ChromatogramType
 

Additional Inherited Members

- Public Types inherited from IMSDataConsumer
typedef MSSpectrum SpectrumType
 
typedef MSChromatogram ChromatogramType
 

Detailed Description

A data consumer that inserts data into a SQL database.

Consumes spectra and chromatograms and inserts them into an file-based SQL database using sqlite. As Sqlite is highly inefficient when inserting one spectrum/chromatogram at a time, the consumer collects the data in an internal buffer and then flushes them all together to disk.

Member Typedef Documentation

◆ ChromatogramType

◆ MapType

typedef MSExperiment MapType
private

◆ SpectrumType

Constructor & Destructor Documentation

◆ MSDataSqlConsumer()

MSDataSqlConsumer ( String  filename,
bool  clearData = true,
int  buffer_size = 500 
)

Constructor.

Opens the sqlite file and writes the tables.

Parameters
filenameThe filename of the Sqlite database
clearDataWhether to clear the data from memory after writing it
buffer_sizeHow large the internal buffer size should be (defaults to 500 spectra / chromatograms)

◆ ~MSDataSqlConsumer()

Destructor.

Flushes the data for good.

Member Function Documentation

◆ consumeChromatogram()

void consumeChromatogram ( ChromatogramType c)
virtual

Write a chromatogram to the output file.

Implements IMSDataConsumer.

◆ consumeSpectrum()

void consumeSpectrum ( SpectrumType s)
virtual

Write a spectrum to the output file.

Implements IMSDataConsumer.

◆ flush()

void flush ( )

Flushes the data for good.

After calling this function, no more data is held in the buffer but the class is still able to receive new data.

◆ setExpectedSize()

void setExpectedSize ( Size  expectedSpectra,
Size  expectedChromatograms 
)
virtual

Set expected size of spectra and chromatograms to be consumed.

Some implementations might care about the number of spectra and chromatograms to be consumed and need to be informed about this (usually before consuming starts).

Note
Calling this method is optional but good practice.
Parameters
expectedSpectraNumber of spectra expected
expectedChromatogramsNumber of chromatograms expected

Implements IMSDataConsumer.

◆ setExperimentalSettings()

void setExperimentalSettings ( const ExperimentalSettings exp)
virtual

Set experimental settings (meta-data) of the data to be consumed.

Some implementations might need to know about the meta-data (or the context) of the spectra and chromatograms to be consumed. This method allows them learn this.

Note
Calling this method is optional but good practice.
Parameters
expExperimental settings meta data for the data to be consumed

Implements IMSDataConsumer.

Member Data Documentation

◆ chromatograms_

std::vector<ChromatogramType> chromatograms_
protected

◆ clearData_

bool clearData_
protected

◆ flush_after_

size_t flush_after_
protected

◆ spectra_

std::vector<SpectrumType> spectra_
protected

◆ sql_writer_

OpenMS::Internal::MzMLSqliteHandler sql_writer_
protected

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:10 using doxygen 1.8.13