Xmipp
v3.23.11-Nereus
|
#include <metadata_db.h>
Classes | |
struct | MDDbIdIterator |
struct | MDDbRowIterator |
Public Member Functions | |
void | readPlain (const FileName &inFile, const String &labelsString, const String &separator=" ") |
void | addPlain (const FileName &inFile, const String &labelsString, const String &separator=" ") |
iterator | begin () override |
iterator | end () override |
const_iterator | begin () const override |
const_iterator | end () const override |
id_iterator | id_begin () override |
id_iterator | id_end () override |
id_const_iterator | id_begin () const override |
id_const_iterator | id_end () const override |
void | fillExpand (MDLabel label) |
void | fillConstant (MDLabel label, const String &value) override |
void | fillRandom (MDLabel label, const String &mode, double op1, double op2, double op3=0.) override |
void | fillLinear (MDLabel label, double initial, double step) override |
void | copyColumn (MDLabel labelDest, MDLabel labelSrc) override |
void | copyColumnTo (MetaData &md, MDLabel labelDest, MDLabel labelSrc) override |
void | renameColumn (MDLabel oldLabel, MDLabel newLabel) override |
void | renameColumn (const std::vector< MDLabel > &oldLabel, const std::vector< MDLabel > &newLabel) override |
void | metadataToVec (std::vector< MDRowSql > &vd) |
void | vecToMetadata (const std::vector< MDRow > &rowMetadata) |
bool | operator== (const MetaDataDb &op) const |
Constructors | |
MetaDataDb () | |
MetaDataDb (const std::vector< MDLabel > &labelsVector) | |
MetaDataDb (const MetaData &md) | |
MetaDataDb (const FileName &fileName, const std::vector< MDLabel > &desiredLabels={}) | |
MetaDataDb (const MetaDataDb &md) | |
MetaDataDb & | operator= (const MetaDataDb &md) |
virtual | ~MetaDataDb () |
void | clear () override |
Getters and setters | |
MDSql * | getDatabase () |
void | writeXML (const FileName fn, const FileName blockname, WriteModeMetaData mode) const override |
void | writeDB (const FileName fn, const FileName blockname, WriteModeMetaData mode) const |
void | writeText (const FileName fn, const std::vector< MDLabel > *desiredLabels) const override |
int | getMaxStringLength (const MDLabel thisLabel) const override |
MetaData Manipulation | |
bool | setValueCol (const MDObject &mdValueIn) override |
template<class T > | |
bool | setValueCol (const MDLabel label, const T &valueIn) |
bool | setValue (const MDObject &mdValueIn, size_t id) override |
template<class T > | |
bool | setValue (const MDLabel label, const T &valueIn, size_t id) |
bool | getValue (MDObject &mdValueOut, size_t id) const override |
bool | getRowValues (size_t id, std::vector< MDObject > &values) const override |
template<class T > | |
bool | getValue (const MDLabel label, T &valueOut, size_t id) const |
void | getColumnValues (const MDLabel label, std::vector< MDObject > &valuesOut) const override |
template<class T > | |
std::vector< T > | getColumnValues (const MDLabel label) const |
template<class T > | |
void | getColumnValues (const MDLabel label, std::vector< T > &valuesOut) const |
template<typename T > | |
bool | getColumnValuesOpt (const MDLabel label, std::vector< T > &values) const |
void | setColumnValues (const std::vector< MDObject > &valuesIn) override |
template<class T > | |
void | setColumnValues (const MDLabel label, const std::vector< T > &valuesIn) |
bool | bindValue (size_t id) const |
bool | initGetRow (bool addWhereClause) const |
bool | execGetRow (MDRow &row) const |
void | finalizeGetRow (void) const |
std::unique_ptr< MDRow > | getRow (size_t id) override |
std::unique_ptr< const MDRow > | getRow (size_t id) const override |
MDRowSql | getRowSql (size_t id) |
const MDRowSql | getRowSql (size_t id) const |
bool | getRow (MDRowSql &row, size_t id) const |
bool | getAllRows (std::vector< MDRowSql > &rows) const |
bool | getRow2 (MDRow &row, size_t id) const |
bool | setRow (const MDRow &row, size_t id) |
bool | initAddRow (const MDRow &row) |
bool | execAddRow (const MDRow &row) |
void | finalizeAddRow (void) |
size_t | addRow (const MDRow &row) override |
void | addRowOpt (const MDRowSql &row) |
void | addRows (const std::vector< MDRowSql > &rows) |
void | addMissingLabels (const MDRow &row) |
size_t | addRow2 (const MDRow &row) |
size_t | size () const override |
bool | containsLabel (const MDLabel label) const override |
std::vector< MDLabel > | getActiveLabels () const override |
bool | addLabel (const MDLabel label, int pos=-1) override |
bool | removeLabel (const MDLabel label) override |
size_t | addObject () override |
void | importObject (const MetaData &md, const size_t id, bool doClear=true) override |
void | importObjects (const MetaData &md, const std::vector< size_t > &objectsToAdd, bool doClear=true) override |
void | importObjects (const MetaData &md, const MDQuery &query, bool doClear=true) override |
bool | removeObject (size_t id) override |
void | removeObjects (const std::vector< size_t > &toRemove) override |
int | removeObjects (const MDQuery &query) override |
int | removeObjects () override |
void | addIndex (MDLabel label) const |
void | addIndex (const std::vector< MDLabel > &desiredLabels) const |
void | removeIndex (MDLabel label) |
void | removeIndex (const std::vector< MDLabel > &desiredLabels) |
void | addItemId () |
void | removeItemId () |
Iteration functions | |
size_t | firstRowId () const override |
size_t | firstObject (const MDQuery &) const override |
size_t | lastRowId () const override |
Search operations | |
void | findObjects (std::vector< size_t > &objectsOut, const MDQuery &query) const override |
void | findObjects (std::vector< size_t > &objectsOut, int limit=-1) const override |
size_t | countObjects (const MDQuery &query) const override |
bool | containsObject (size_t objectId) const override |
bool | containsObject (const MDQuery &query) const override |
I/O functions | |
void | _writeRows (std::ostream &os) const override |
void | write (const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const override |
void | write (std::ostream &os, const String &blockName="", WriteModeMetaData mode=MD_OVERWRITE) const override |
bool | existsBlock (const FileName &_inFile) |
void | readXML (const FileName &inFile, const std::vector< MDLabel > *desiredLabels=NULL, const String &blockRegExp=DEFAULT_BLOCK_NAME, bool decomposeStack=true) |
void | readDB (const FileName &inFile, const std::vector< MDLabel > *desiredLabels=NULL, const String &blockRegExp=DEFAULT_BLOCK_NAME, bool decomposeStack=true) |
void | read (const FileName &inFile, const std::vector< MDLabel > *desiredLabels=NULL, bool decomposeStack=true) override |
Set Operations | |
void | aggregate (const MetaDataDb &mdIn, AggregateOperation op, MDLabel aggregateLabel, MDLabel operateLabel, MDLabel resultLabel) |
void | aggregate (const MetaDataDb &mdIn, const std::vector< AggregateOperation > &ops, const std::vector< MDLabel > &operateLabels, const std::vector< MDLabel > &resultLabels) |
void | aggregateGroupBy (const MetaDataDb &mdIn, AggregateOperation op, const std::vector< MDLabel > &groupByLabels, MDLabel operateLabel, MDLabel resultLabel) |
void | aggregateSingle (MDObject &mdValueOut, AggregateOperation op, MDLabel aggregateLabel) |
void | aggregateSingleInt (MDObject &mdValueOut, AggregateOperation op, MDLabel aggregateLabel) |
void | aggregateSingleSizeT (MDObject &mdValueOut, AggregateOperation op, MDLabel aggregateLabel) |
double | getColumnMax (MDLabel column) |
double | getColumnMin (MDLabel column) |
void | unionDistinct (const MetaDataDb &mdIn, const MDLabel label=MDL_OBJID) |
void | unionAll (const MetaDataDb &mdIn) |
void | merge (const MetaData &md2) |
void | intersection (const MetaDataDb &mdIn, const MDLabel label) |
void | subtraction (const MetaDataDb &mdIn, const MDLabel label) |
void | distinct (MetaDataDb &MDin, MDLabel label) |
void | join1 (const MetaDataDb &mdInLeft, const MetaDataDb &mdInRight, const MDLabel label, JoinType type=LEFT) |
void | join2 (const MetaDataDb &mdInLeft, const MetaDataDb &mdInRight, const MDLabel labelLeft, const MDLabel labelRight, JoinType type=LEFT) |
void | join1 (const MetaDataDb &mdInLeft, const MetaDataDb &mdInRight, const std::vector< MDLabel > &labels, JoinType type=LEFT) |
void | join2 (const MetaDataDb &mdInLeft, const MetaDataDb &mdInRight, const std::vector< MDLabel > &labelsLeft, const std::vector< MDLabel > &labelsRight, JoinType type=LEFT) |
void | joinNatural (const MetaDataDb &mdInLeft, const MetaDataDb &mdInRight) |
void | operate (const String &expression) |
void | replace (const MDLabel label, const String &oldStr, const String &newStr) |
void | randomize (const MetaDataDb &MDin) |
void | removeDuplicates (MetaDataDb &MDin, MDLabel label=MDL_UNDEFINED) |
void | sort (MetaDataDb &MDin, const MDLabel sortLabel, bool asc=true, int limit=-1, int offset=0) |
void | sort (MetaDataDb &MDin, const String &sortLabel, bool asc=true, int limit=-1, int offset=0) |
void | split (size_t n, std::vector< MetaDataDb > &results, const MDLabel sortLabel=MDL_OBJID) |
void | selectSplitPart (const MetaData &mdIn, size_t n, size_t part, const MDLabel sortLabel=MDL_OBJID) |
void | selectRandomSubset (const MetaData &mdIn, size_t numberOfObjects, const MDLabel sortLabel=MDL_OBJID) override |
void | selectPart (const MetaData &mdIn, size_t startPosition, size_t numberOfObjects, const MDLabel sortLabel=MDL_OBJID) override |
void | makeAbsPath (const MDLabel label=MDL_IMAGE) |
Public Member Functions inherited from MetaData | |
virtual bool | nextBlock (mdBuffer &buffer, mdBlock &block) |
MetaData ()=default | |
virtual | ~MetaData () |
virtual bool | isColumnFormat () const |
virtual void | setMaxRows (size_t maxRows=0) |
virtual size_t | getParsedLines () |
virtual void | setPrecission (int _precision) |
virtual void | setColumnFormat (bool column) |
virtual void | writeStar (const FileName &outFile, const String &blockName, WriteModeMetaData mode) const |
virtual String | getComment () const |
virtual void | setComment (const String &newComment="No comment") |
virtual FileName | getFilename () const |
virtual void | setFilename (const FileName &_filename) |
template<class T > | |
bool | setValueCol (const MDLabel label, const T &valueIn) |
template<class T > | |
bool | setValue (const MDLabel label, const T &valueIn, size_t id) |
MetaData & | operator= (const MetaData &md) |
template<class T > | |
T | getValue (const MDLabel label, size_t id) const |
template<class T > | |
bool | getValue (const MDLabel label, T &valueOut, size_t id) const |
template<class T > | |
const T & | getValueOrAbort (const MDLabel label, size_t id) const |
template<class T > | |
T & | getValueOrAbort (const MDLabel label, size_t id) |
template<class T > | |
void | getValueOrAbort (const MDLabel label, T &valueOut, size_t id) const |
template<typename T > | |
const T | getValueOrDefault (const MDLabel label, size_t id, const T &_default) const |
template<typename T > | |
T | getValueOrDefault (const MDLabel label, size_t id, T &_default) |
template<typename T , typename T1 > | |
void | getValueOrDefault (const MDLabel label, T &valueOut, size_t id, const T1 &_default) const |
template<class T > | |
std::vector< T > | getColumnValues (const MDLabel label) const |
template<class T > | |
void | getColumnValues (const MDLabel label, std::vector< T > &out) const |
template<class T > | |
void | setColumnValues (const MDLabel label, const std::vector< T > &valuesIn) |
virtual bool | setValueFromStr (const MDLabel label, const String &value, size_t id) |
virtual bool | getStrFromValue (const MDLabel label, String &strOut, size_t id) const |
virtual bool | isEmpty () const |
void | keepLabels (const std::vector< MDLabel > &labels) |
virtual void | print () const |
void | append (const FileName &outFile) const |
virtual void | removeDisabled () |
virtual IdIteratorProxy< false > | ids () |
virtual IdIteratorProxy< true > | ids () const |
Protected Member Functions | |
void | init (const std::vector< MDLabel > &labelsVector) |
void | copyMetadata (const MetaDataDb &md, bool copyObjects=true) |
void | _selectSplitPart (const MetaDataDb &mdIn, int n, int part, size_t mdSize, const MDLabel sortLabel) |
void | _selectSplitPart (const MetaDataDb &mdIn, size_t n, size_t part, const MDLabel sortLabel=MDL_OBJID) |
void | _selectRandomSubset (const MetaDataDb &mdIn, size_t numberOfObjects, const MDLabel sortLabel=MDL_OBJID) |
void | _selectPart (const MetaDataDb &mdIn, size_t startPosition, size_t numberOfObjects, const MDLabel sortLabel=MDL_OBJID) |
void | _setOperates (const MetaDataDb &mdIn, const MDLabel label, SetOperation operation) |
void | _setOperates (const MetaDataDb &mdIn, const std::vector< MDLabel > &labels, SetOperation operation) |
void | _setOperates (const MetaDataDb &mdInLeft, const MetaDataDb &mdInRight, const std::vector< MDLabel > &labelsLeft, const std::vector< MDLabel > &labelsRight, SetOperation operation) |
void | _setOperatesLabel (const MetaDataDb &mdIn, const MDLabel label, SetOperation operation) |
void | _clear (bool onlyData=false) |
void | _readRowsStar (mdBlock &block, std::vector< MDObject *> &columnValues, const std::vector< MDLabel > *desiredLabels) override |
void | _readRowFormat (std::istream &is) |
void | _parseObjects (std::istream &is, std::vector< MDObject *> &columnValues, const std::vector< MDLabel > *desiredLabels, bool firstTime) override |
std::vector< MDObject > | getObjectsForActiveLabels () const |
void | _importObjectsDb (const MetaDataDb &md, const MDQuery &query, bool doClear=true) |
void | _importObjectsGeneral (const MetaData &md, const MDQuery &query, bool doClear=true) |
Protected Member Functions inherited from MetaData | |
void | copyInfo (const MetaData &md) |
double | precision () const |
virtual void | readStar (const FileName &filename, const std::vector< MDLabel > *desiredLabels, const String &blockRegExp, bool decomposeStack) |
virtual void | _readColumns (std::istream &is, std::vector< MDObject *> &columnValues, const std::vector< MDLabel > *desiredLabels=nullptr) |
virtual void | _readColumnsStar (mdBlock &block, std::vector< MDObject *> &columnValues, const std::vector< MDLabel > *desiredLabels, bool addColumns=true, size_t id=BAD_OBJID) |
virtual void | _parseObject (std::istream &is, MDObject &object, size_t id=BAD_OBJID) |
virtual void | _readRows (std::istream &is, std::vector< MDObject *> &columnValues, bool useCommentAsImage) |
Protected Attributes | |
MDSql * | myMDSql |
std::vector< MDLabel > | _activeLabels |
Protected Attributes inherited from MetaData | |
std::map< String, size_t > | _fastStringSearch |
MDLabel | _fastStringSearchLabel |
String | _comment |
int | _precision = 1000 |
FileName | _inFile |
size_t | _maxRows = 0 |
size_t | _parsedLines = 0 |
Friends | |
class | MDSql |
Additional Inherited Members | |
Public Types inherited from MetaData | |
using | iterator = rowIterator< false > |
using | const_iterator = rowIterator< true > |
using | id_iterator = idIterator< false > |
using | id_const_iterator = idIterator< true > |
Public Attributes inherited from MetaData | |
bool | isMetadataFile |
Original database implementation of MetaData. MetaData are stored in SQL database. Some database-specific commands are available in this implementation only.
Definition at line 55 of file metadata_db.h.
MetaDataDb::MetaDataDb | ( | ) |
Empty Constructor.
The MetaDataDb is created with no data stored on it. You can fill in it programmatically or by a later reading from a MetaDataDb file or old Xmipp formatted type. if labels vectors is passed this labels are created on metadata
Definition at line 496 of file metadata_db.cpp.
MetaDataDb::MetaDataDb | ( | const std::vector< MDLabel > & | labelsVector | ) |
Definition at line 508 of file metadata_db.cpp.
MetaDataDb::MetaDataDb | ( | const MetaData & | md | ) |
Definition at line 502 of file metadata_db.cpp.
MetaDataDb::MetaDataDb | ( | const FileName & | fileName, |
const std::vector< MDLabel > & | desiredLabels = {} |
||
) |
From File Constructor.
The MetaData is created and data is read from provided FileName. Optionally, a vector of labels can be provided to read just those required labels
Definition at line 514 of file metadata_db.cpp.
MetaDataDb::MetaDataDb | ( | const MetaDataDb & | md | ) |
Copy constructor
Created a new metadata by copying all data from an existing MetaData object.
Definition at line 521 of file metadata_db.cpp.
|
virtual |
Destructor
Frees all used memory and destroys object.
Definition at line 533 of file metadata_db.cpp.
|
protected |
|
protected |
Definition at line 612 of file metadata_db.cpp.
|
protected |
|
overrideprotectedvirtual |
Implements MetaData.
Definition at line 853 of file metadata_db.cpp.
|
protected |
Some private reading functions
Definition at line 1096 of file metadata_db.cpp.
|
overrideprotectedvirtual |
This function will be used to parse the rows data in START format
[out] | columnValues | MDRow with values to fill in |
pchStart | pointer to the position of '_loop' in memory | |
pEnd | pointer to the position of the next '_data' in memory | |
maxRows | if this number if greater than 0, only this number of rows will be parsed. |
Reimplemented from MetaData.
Definition at line 1051 of file metadata_db.cpp.
|
protected |
Definition at line 1609 of file metadata_db.cpp.
|
protected |
Definition at line 1591 of file metadata_db.cpp.
|
protected |
This have the same logic of the public one, but doesn't perform any range(which implies do a size()) checks.
Definition at line 1555 of file metadata_db.cpp.
|
protected |
Definition at line 1573 of file metadata_db.cpp.
|
protected |
This function is for generalize the sets operations of unionDistinct, intersection, subtraction which can be expressed in terms of ADD, SUBSTRACT of intersection part
Definition at line 1293 of file metadata_db.cpp.
|
protected |
Definition at line 1302 of file metadata_db.cpp.
|
protected |
Definition at line 1332 of file metadata_db.cpp.
|
protected |
This function is for generalize the sets operations in which the output has a single label a vector of labels instead of a single label may be implemented in the future
Definition at line 1317 of file metadata_db.cpp.
|
overridevirtual |
Write rows data to disk.
Implements MetaData.
Definition at line 774 of file metadata_db.cpp.
void MetaDataDb::addIndex | ( | MDLabel | label | ) | const |
Add and remove indexes for fast search in other labels, but insert are more expensive
Definition at line 653 of file metadata_db.cpp.
void MetaDataDb::addIndex | ( | const std::vector< MDLabel > & | desiredLabels | ) | const |
Definition at line 659 of file metadata_db.cpp.
void MetaDataDb::addItemId | ( | ) |
Add item id. From 1 to last.
Definition at line 677 of file metadata_db.cpp.
|
overridevirtual |
Add a new label to the metadata. By default the label is added at the end, if the position is specified and is between 0 and n-1 the new label is inserted at that position.
Implements MetaData.
Definition at line 554 of file metadata_db.cpp.
void MetaDataDb::addMissingLabels | ( | const MDRow & | row | ) |
Definition at line 422 of file metadata_db.cpp.
|
overridevirtual |
Adds a new, empty object to the objects map. If objectId == -1 the new ID will be that for the last object inserted + 1, else the given objectId is used. If there is already an object whose objectId == input objectId, just removes it and creates an empty one
Implements MetaData.
Definition at line 578 of file metadata_db.cpp.
void MetaDataDb::addPlain | ( | const FileName & | inFile, |
const String & | labelsString, | ||
const String & | separator = " " |
||
) |
Same as readPlain, but instead of cleanning data, the readed values will be added. If there are common columns in metadata and the plain text, the lattest will be setted
Definition at line 975 of file metadata_db.cpp.
|
overridevirtual |
Implements MetaData.
Definition at line 394 of file metadata_db.cpp.
size_t MetaDataDb::addRow2 | ( | const MDRow & | row | ) |
Definition at line 475 of file metadata_db.cpp.
void MetaDataDb::addRowOpt | ( | const MDRowSql & | row | ) |
Definition at line 417 of file metadata_db.cpp.
void MetaDataDb::addRows | ( | const std::vector< MDRowSql > & | rows | ) |
Definition at line 440 of file metadata_db.cpp.
void MetaDataDb::aggregate | ( | const MetaDataDb & | mdIn, |
AggregateOperation | op, | ||
MDLabel | aggregateLabel, | ||
MDLabel | operateLabel, | ||
MDLabel | resultLabel | ||
) |
Aggregate metadata objects, result in calling metadata object (except for aggregateSingle) thisLabel label is used for aggregation, second. Valid operations are:
MDL_AVG: The avg function returns the average value of all operationLabel within a group. The result of avg is always a floating point value as long as at there is at least one non-NULL input even if all inputs are integers. The result of avg is NULL if and only if there are no non-NULL inputs.
AGGR_COUNT: The count function returns a count of the number of times that operationLabel is in a group.
AGGR_MAX The max aggregate function returns the maximum value of all values in the group.
AGGR_MIN The min aggregate function returns the minimum value of all values in the group.
AGGRL_SUM The total aggregate functions return sum of all values in the group. If there are no non-NULL input rows then returns 0.0.
Definition at line 1255 of file metadata_db.cpp.
void MetaDataDb::aggregate | ( | const MetaDataDb & | mdIn, |
const std::vector< AggregateOperation > & | ops, | ||
const std::vector< MDLabel > & | operateLabels, | ||
const std::vector< MDLabel > & | resultLabels | ||
) |
Definition at line 1269 of file metadata_db.cpp.
void MetaDataDb::aggregateGroupBy | ( | const MetaDataDb & | mdIn, |
AggregateOperation | op, | ||
const std::vector< MDLabel > & | groupByLabels, | ||
MDLabel | operateLabel, | ||
MDLabel | resultLabel | ||
) |
Definition at line 1279 of file metadata_db.cpp.
void MetaDataDb::aggregateSingle | ( | MDObject & | mdValueOut, |
AggregateOperation | op, | ||
MDLabel | aggregateLabel | ||
) |
This function performs aggregation operations. without grouping. (i.e. absolute maximum of a metadata column) for double
Definition at line 1216 of file metadata_db.cpp.
void MetaDataDb::aggregateSingleInt | ( | MDObject & | mdValueOut, |
AggregateOperation | op, | ||
MDLabel | aggregateLabel | ||
) |
This function performs aggregation operations. without grouping. (i.e. absolute maximum of a metadata column) for int
Definition at line 1246 of file metadata_db.cpp.
void MetaDataDb::aggregateSingleSizeT | ( | MDObject & | mdValueOut, |
AggregateOperation | op, | ||
MDLabel | aggregateLabel | ||
) |
This function performs aggregation operations. without grouping. (i.e. absolute maximum of a metadata column) for size_t
Definition at line 1223 of file metadata_db.cpp.
|
inlineoverridevirtual |
Implements MetaData.
Definition at line 746 of file metadata_db.h.
|
inlineoverridevirtual |
Implements MetaData.
Definition at line 753 of file metadata_db.h.
bool MetaDataDb::bindValue | ( | size_t | id | ) | const |
Get all values of an MetaData row of an specified objId
Definition at line 155 of file metadata_db.cpp.
|
overridevirtual |
|
inlineoverridevirtual |
Check whether a label is contained in metadata.
Implements MetaData.
Definition at line 305 of file metadata_db.h.
|
overridevirtual |
Implements MetaData.
Definition at line 729 of file metadata_db.cpp.
|
overridevirtual |
Implements MetaData.
Definition at line 734 of file metadata_db.cpp.
Copy all values from one column to another. Source column should exist
Implements MetaData.
Definition at line 1175 of file metadata_db.cpp.
|
overridevirtual |
Same as previous, but copy to another metadata
Implements MetaData.
Definition at line 1187 of file metadata_db.cpp.
|
protected |
|
overridevirtual |
Implements MetaData.
Definition at line 722 of file metadata_db.cpp.
void MetaDataDb::distinct | ( | MetaDataDb & | MDin, |
MDLabel | label | ||
) |
Return only distinct (different) values of column label. Result in "calling" metadata with a single column
Definition at line 1389 of file metadata_db.cpp.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
bool MetaDataDb::execAddRow | ( | const MDRow & | row | ) |
Definition at line 361 of file metadata_db.cpp.
bool MetaDataDb::execGetRow | ( | MDRow & | row | ) | const |
Definition at line 181 of file metadata_db.cpp.
bool MetaDataDb::existsBlock | ( | const FileName & | _inFile | ) |
Check if block exists in metadata file input full parh block return false if metadata block does not exits
Definition at line 982 of file metadata_db.cpp.
Fill column with constant value
Implements MetaData.
Definition at line 1157 of file metadata_db.cpp.
void MetaDataDb::fillExpand | ( | MDLabel | label | ) |
Expand Metadata with metadata pointed by label Given a metadata md1, with a column containing the name of another column metdata file mdxx add the columns in mdxx to md1
Definition at line 1131 of file metadata_db.cpp.
|
overridevirtual |
Fill lineal, starting at some value and with some step
Implements MetaData.
Definition at line 1169 of file metadata_db.cpp.
|
overridevirtual |
Fill column with random value mode should be: uniform, gaussian or student op1, op2 and op2 are interpreted for each mode: uniform: op1 and op2 are the limits of the interval gaussian: op1 and op2 are mean and std student: same as gaussian and use op3
Implements MetaData.
Definition at line 1163 of file metadata_db.cpp.
void MetaDataDb::finalizeAddRow | ( | void | ) |
Definition at line 389 of file metadata_db.cpp.
void MetaDataDb::finalizeGetRow | ( | void | ) | const |
Definition at line 196 of file metadata_db.cpp.
|
overridevirtual |
Find all objects that match a query. if called without query, all objects are returned if limit is provided only return a maximun of 'limit'
Implements MetaData.
Definition at line 709 of file metadata_db.cpp.
|
overridevirtual |
Implements MetaData.
Definition at line 715 of file metadata_db.cpp.
|
overridevirtual |
Implements MetaData.
Definition at line 695 of file metadata_db.cpp.
|
overridevirtual |
Return the object id of the first element in metadata.
Implements MetaData.
Definition at line 690 of file metadata_db.cpp.
|
inlineoverridevirtual |
Get safe access to active labels.
Implements MetaData.
Definition at line 309 of file metadata_db.h.
bool MetaDataDb::getAllRows | ( | std::vector< MDRowSql > & | rows | ) | const |
Definition at line 212 of file metadata_db.cpp.
double MetaDataDb::getColumnMax | ( | MDLabel | column | ) |
Returns Max and Min values from a column in metadata These functions can only be used for labels of type double
Definition at line 1231 of file metadata_db.cpp.
double MetaDataDb::getColumnMin | ( | MDLabel | column | ) |
Definition at line 1238 of file metadata_db.cpp.
|
overridevirtual |
Get all values of a column as a vector.
Implements MetaData.
Definition at line 120 of file metadata_db.cpp.
|
inline |
Definition at line 247 of file metadata_db.h.
|
inline |
Definition at line 252 of file metadata_db.h.
bool MetaDataDb::getColumnValuesOpt | ( | const MDLabel | label, |
std::vector< T > & | values | ||
) | const |
Get all values of a column as a vector.
Definition at line 845 of file metadata_db.h.
|
inline |
Definition at line 182 of file metadata_db.h.
|
overridevirtual |
Get maximum string length of column values.
Implements MetaData.
Definition at line 541 of file metadata_db.cpp.
|
protected |
Get a vector of (empty) objects for each active label
Definition at line 201 of file metadata_db.cpp.
|
overridevirtual |
Implements MetaData.
Definition at line 236 of file metadata_db.cpp.
|
overridevirtual |
Implements MetaData.
Definition at line 243 of file metadata_db.cpp.
bool MetaDataDb::getRow | ( | MDRowSql & | row, |
size_t | id | ||
) | const |
Definition at line 264 of file metadata_db.cpp.
bool MetaDataDb::getRow2 | ( | MDRow & | row, |
size_t | id | ||
) | const |
Definition at line 283 of file metadata_db.cpp.
MDRowSql MetaDataDb::getRowSql | ( | size_t | id | ) |
Definition at line 250 of file metadata_db.cpp.
const MDRowSql MetaDataDb::getRowSql | ( | size_t | id | ) | const |
Definition at line 257 of file metadata_db.cpp.
|
overridevirtual |
Implements MetaData.
Definition at line 404 of file metadata_db.cpp.
|
overridevirtual |
Implements MetaData.
Definition at line 109 of file metadata_db.cpp.
|
inline |
Definition at line 238 of file metadata_db.h.
|
inlineoverridevirtual |
Implements MetaData.
Definition at line 793 of file metadata_db.h.
|
inlineoverridevirtual |
Implements MetaData.
Definition at line 801 of file metadata_db.h.
|
inlineoverridevirtual |
Implements MetaData.
Definition at line 797 of file metadata_db.h.
|
inlineoverridevirtual |
Implements MetaData.
Definition at line 805 of file metadata_db.h.
|
overridevirtual |
Import objects from another metadata.
Implements MetaData.
Definition at line 583 of file metadata_db.cpp.
|
overridevirtual |
Implements MetaData.
Definition at line 593 of file metadata_db.cpp.
|
overridevirtual |
Implements MetaData.
Definition at line 603 of file metadata_db.cpp.
|
protected |
Init, do some initializations tasks, used in constructors
Definition at line 59 of file metadata_db.cpp.
bool MetaDataDb::initAddRow | ( | const MDRow & | row | ) |
Add a new Row and set values, return the objId of newly added object
Definition at line 331 of file metadata_db.cpp.
bool MetaDataDb::initGetRow | ( | bool | addWhereClause | ) | const |
Definition at line 168 of file metadata_db.cpp.
void MetaDataDb::intersection | ( | const MetaDataDb & | mdIn, |
const MDLabel | label | ||
) |
Intersects two Metadatas. Result in "calling" Metadata
Definition at line 1374 of file metadata_db.cpp.
void MetaDataDb::join1 | ( | const MetaDataDb & | mdInLeft, |
const MetaDataDb & | mdInRight, | ||
const MDLabel | label, | ||
JoinType | type = LEFT |
||
) |
Join two Metadatas Result in "calling" metadata
Definition at line 1403 of file metadata_db.cpp.
void MetaDataDb::join1 | ( | const MetaDataDb & | mdInLeft, |
const MetaDataDb & | mdInRight, | ||
const std::vector< MDLabel > & | labels, | ||
JoinType | type = LEFT |
||
) |
Join two Metadatas Result in "calling" metadata
Definition at line 1418 of file metadata_db.cpp.
void MetaDataDb::join2 | ( | const MetaDataDb & | mdInLeft, |
const MetaDataDb & | mdInRight, | ||
const MDLabel | labelLeft, | ||
const MDLabel | labelRight, | ||
JoinType | type = LEFT |
||
) |
Join two Metadatas Result in "calling" metadata. join may be done using different labels in each metadata
Definition at line 1408 of file metadata_db.cpp.
void MetaDataDb::join2 | ( | const MetaDataDb & | mdInLeft, |
const MetaDataDb & | mdInRight, | ||
const std::vector< MDLabel > & | labelsLeft, | ||
const std::vector< MDLabel > & | labelsRight, | ||
JoinType | type = LEFT |
||
) |
Join two Metadatas Result in "calling" metadata. join may be done using different labels in each metadata
Definition at line 1423 of file metadata_db.cpp.
void MetaDataDb::joinNatural | ( | const MetaDataDb & | mdInLeft, |
const MetaDataDb & | mdInRight | ||
) |
Join two Metadatas using all common labels (NATURAL_JOIN)
Definition at line 1430 of file metadata_db.cpp.
|
overridevirtual |
Makes filenames with absolute paths
Definition at line 1620 of file metadata_db.cpp.
void MetaDataDb::merge | ( | const MetaData & | md2 | ) |
Merge of two Metadata. This function reads another metadata and add all columns values. The size of the two Metadatas should be the same. If there are common columns, the values in md2 will be setted.
Definition at line 1120 of file metadata_db.cpp.
void MetaDataDb::metadataToVec | ( | std::vector< MDRowSql > & | vd | ) |
Definition at line 1707 of file metadata_db.cpp.
void MetaDataDb::operate | ( | const String & | expression | ) |
Basic operations on columns data. Mainly perform replacements on string values and basic algebraic operations on numerical ones.
Definition at line 1435 of file metadata_db.cpp.
MetaDataDb & MetaDataDb::operator= | ( | const MetaDataDb & | md | ) |
Assignment operator
Copies MetaDataDb from an existing MetaData object.
Definition at line 527 of file metadata_db.cpp.
bool MetaDataDb::operator== | ( | const MetaDataDb & | op | ) | const |
void MetaDataDb::randomize | ( | const MetaDataDb & | MDin | ) |
Randomize a metadata. MDin is input and the "randomized" result will be in the "calling" Metadata.
Definition at line 1450 of file metadata_db.cpp.
|
overridevirtual |
Read data from file. Guess the blockname from the filename
Implements MetaData.
Definition at line 912 of file metadata_db.cpp.
void MetaDataDb::readDB | ( | const FileName & | inFile, |
const std::vector< MDLabel > * | desiredLabels = NULL , |
||
const String & | blockRegExp = DEFAULT_BLOCK_NAME , |
||
bool | decomposeStack = true |
||
) |
void MetaDataDb::readPlain | ( | const FileName & | inFile, |
const String & | labelsString, | ||
const String & | separator = " " |
||
) |
Try to read a metadata from plain text with some columns. Labels for each columns should be provided in an string separated by spaces. Return false if couldn't read
Definition at line 939 of file metadata_db.cpp.
void MetaDataDb::readXML | ( | const FileName & | inFile, |
const std::vector< MDLabel > * | desiredLabels = NULL , |
||
const String & | blockRegExp = DEFAULT_BLOCK_NAME , |
||
bool | decomposeStack = true |
||
) |
void MetaDataDb::removeDuplicates | ( | MetaDataDb & | MDin, |
MDLabel | label = MDL_UNDEFINED |
||
) |
Remove duplicate entries for attribute in label
Definition at line 1382 of file metadata_db.cpp.
void MetaDataDb::removeIndex | ( | MDLabel | label | ) |
Definition at line 665 of file metadata_db.cpp.
void MetaDataDb::removeIndex | ( | const std::vector< MDLabel > & | desiredLabels | ) |
Definition at line 672 of file metadata_db.cpp.
void MetaDataDb::removeItemId | ( | ) |
Remove item id.
Definition at line 683 of file metadata_db.cpp.
|
overridevirtual |
Remove a label from the metadata. The data is still in the table. If you want to remove the data, make a copy of the MetaData.
Implements MetaData.
Definition at line 566 of file metadata_db.cpp.
|
overridevirtual |
Remove the object with this id. Returns true if the object was removed or false if the object did not exist
Implements MetaData.
Definition at line 629 of file metadata_db.cpp.
|
overridevirtual |
Removes the collection of objects of given vector id's NOTE: The iterator will point to the first object after any of these operations
Implements MetaData.
Definition at line 634 of file metadata_db.cpp.
|
overridevirtual |
Removes objects from metadata. return the number of deleted rows if not query, all objectes are removed Queries can be used in the same way as in the importObjects function
Implements MetaData.
Definition at line 641 of file metadata_db.cpp.
|
overridevirtual |
Rename column.
Implements MetaData.
Definition at line 1198 of file metadata_db.cpp.
|
overridevirtual |
Rename several columns. This is an expensive operations so if several columns need to be changed do it using this function instead one by one
Implements MetaData.
Definition at line 1210 of file metadata_db.cpp.
Replace an string in some column(label). The type of the column should be string. This function is a shortcut of the more genereal function operate
Definition at line 1441 of file metadata_db.cpp.
|
overridevirtual |
Select some part from Metadata. Select elements from input Metadata at some starting position if the numberOfObjects is -1, all objects will be returned from startPosition to the end.
Implements MetaData.
Definition at line 1601 of file metadata_db.cpp.
|
overridevirtual |
Select random subset
Implements MetaData.
Definition at line 1584 of file metadata_db.cpp.
void MetaDataDb::selectSplitPart | ( | const MetaData & | mdIn, |
size_t | n, | ||
size_t | part, | ||
const MDLabel | sortLabel = MDL_OBJID |
||
) |
Take a part from MetaData. This function is equivallent to divide the input MetaData in n parts and take one. The result will be in "calling" MetaData.
Definition at line 1566 of file metadata_db.cpp.
|
overridevirtual |
Get all values of a column as a vector.
Implements MetaData.
Definition at line 134 of file metadata_db.cpp.
|
inline |
Definition at line 266 of file metadata_db.h.
bool MetaDataDb::setRow | ( | const MDRow & | row, |
size_t | id | ||
) |
Copy all the values in the input row in the current metadata
Definition at line 306 of file metadata_db.cpp.
|
overridevirtual |
This functions are using MDObject for set real values there is an explicit function signature foreach type supported in Metadata. This is done for some type checking of Metadata labels and values
Implements MetaData.
Definition at line 90 of file metadata_db.cpp.
|
inline |
Definition at line 230 of file metadata_db.h.
|
overridevirtual |
Set the value of all objects in an specified column (both value and column are specified in mdValueIn)
Implements MetaData.
Definition at line 102 of file metadata_db.cpp.
|
inline |
Definition at line 215 of file metadata_db.h.
|
overridevirtual |
Number of objects contained in the metadata.
Implements MetaData.
Definition at line 549 of file metadata_db.cpp.
void MetaDataDb::sort | ( | MetaDataDb & | MDin, |
const MDLabel | sortLabel, | ||
bool | asc = true , |
||
int | limit = -1 , |
||
int | offset = 0 |
||
) |
Definition at line 1460 of file metadata_db.cpp.
void MetaDataDb::sort | ( | MetaDataDb & | MDin, |
const String & | sortLabel, | ||
bool | asc = true , |
||
int | limit = -1 , |
||
int | offset = 0 |
||
) |
Definition at line 1475 of file metadata_db.cpp.
void MetaDataDb::split | ( | size_t | n, |
std::vector< MetaDataDb > & | results, | ||
const MDLabel | sortLabel = MDL_OBJID |
||
) |
Split Metadata in several Metadatas. The Metadata will be divided in 'n' almost equally parts and the result will be a vector of Metadatas. The "calling" Metadata will no be modified.
Definition at line 1540 of file metadata_db.cpp.
void MetaDataDb::subtraction | ( | const MetaDataDb & | mdIn, |
const MDLabel | label | ||
) |
Subtract two Metadatas. Result in "calling" metadata
Definition at line 1396 of file metadata_db.cpp.
void MetaDataDb::unionAll | ( | const MetaDataDb & | mdIn | ) |
Union of all elements in two Metadata, duplicating common elements. Result in calling metadata object Repetition are allowed
Definition at line 1366 of file metadata_db.cpp.
void MetaDataDb::unionDistinct | ( | const MetaDataDb & | mdIn, |
const MDLabel | label = MDL_OBJID |
||
) |
Union of elements in two Metadatas, without duplicating. Result in calling metadata object union is a reserved word so I called this method unionDistinct
Definition at line 1359 of file metadata_db.cpp.
void MetaDataDb::vecToMetadata | ( | const std::vector< MDRow > & | rowMetadata | ) |
Definition at line 1713 of file metadata_db.cpp.
|
overridevirtual |
Write metadata to disk. Guess blockname from filename
Implements MetaData.
Definition at line 748 of file metadata_db.cpp.
|
overridevirtual |
Implements MetaData.
Definition at line 795 of file metadata_db.cpp.
void MetaDataDb::writeDB | ( | const FileName | fn, |
const FileName | blockname, | ||
WriteModeMetaData | mode | ||
) | const |
Write metadata in sqlite3 file.
Definition at line 1656 of file metadata_db.cpp.
|
overridevirtual |
Write metadata in text file as plain data without header.
Implements MetaData.
Definition at line 1692 of file metadata_db.cpp.
|
overridevirtual |
Export medatada to xml file.
Implements MetaData.
Definition at line 1663 of file metadata_db.cpp.
|
friend |
This variables should only be used by MDSql for handling db status of metadataThe table id to do db operations
Definition at line 61 of file metadata_db.h.
|
protected |
What labels have been read from a docfile/metadata file and/or will be stored on a new metadata file when "save" is called
Definition at line 68 of file metadata_db.h.
|
protected |
Definition at line 62 of file metadata_db.h.