PLearn 0.1
|
Convert a date to fill 3 columns in the VMat: YYYY, MM, DD. More...
#include <SDBVMat.h>
Public Member Functions | |
SDBVMFieldDate (SDBVMSource source, real missing_values_mapping=MISSING_VALUE) | |
virtual void | convertField (const SDBWithStats &sdb, const Row &row, const Vec &output) const |
virtual int | fieldWidth () const |
Width that the field occupies in the VMat. | |
Private Types | |
typedef SDBVMFieldSource1 | inherited |
Convert a date to fill 3 columns in the VMat: YYYY, MM, DD.
typedef SDBVMFieldSource1 PLearn::SDBVMFieldDate::inherited [private] |
Reimplemented from PLearn::SDBVMFieldSource1.
PLearn::SDBVMFieldDate::SDBVMFieldDate | ( | SDBVMSource | source, |
real | missing_values_mapping = MISSING_VALUE |
||
) | [inline] |
Definition at line 508 of file SDBVMat.h.
: inherited(source,missing_values_mapping,VMField::Date) {}
void PLearn::SDBVMFieldDate::convertField | ( | const SDBWithStats & | sdb, |
const Row & | theRow, | ||
const Vec & | outputField | ||
) | const [virtual] |
Given a database row, convert the appropriate parts to a (preallocated) output vector of the correct width (given by fieldWidth). Replace MISSING_VALUEs by missing_values_mapping.
Implements PLearn::SDBVMField.
Definition at line 443 of file SDBVMat.cc.
References d, PLearn::PDate::day, PLearn::float_to_date(), PLearn::SDBVMSource::getValue(), PLearn::is_missing(), PLearn::SDBVMField::missing_values_mapping_, PLearn::PDate::month, PLearn::SDBVMFieldSource1::source_, and PLearn::PDate::year.
{ real realval = source_.getValue(sdb,row); if(is_missing(realval)) { output[0] = missing_values_mapping_; output[1] = missing_values_mapping_; output[2] = missing_values_mapping_; } else { PDate d = float_to_date(realval); output[0] = real(d.year); output[1] = real(d.month); output[2] = real(d.day); } }
int PLearn::SDBVMFieldDate::fieldWidth | ( | ) | const [virtual] |
Width that the field occupies in the VMat.
Implements PLearn::SDBVMField.
Definition at line 460 of file SDBVMat.cc.
{
return 3;
}