PLearn 0.1
|
#include <LocallyPrecomputedVMatrix.h>
Public Member Functions | |
LocallyPrecomputedVMatrix () | |
Default constructor. | |
virtual void | build () |
Simply calls inherited::build() then build_(). | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
virtual | ~LocallyPrecomputedVMatrix () |
Destructor, used to remove the file. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual LocallyPrecomputedVMatrix * | deepCopy (CopiesMap &copies) const |
Static Public Member Functions | |
static string | _classname_ () |
Declares name and deepCopy methods. | |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Public Attributes | |
string | local_dir |
int | max_wait |
int | remove_when_done |
bool | sequential_access |
int | verbosity |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares this class' options. | |
Private Types | |
typedef PrecomputedVMatrix | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 51 of file LocallyPrecomputedVMatrix.h.
typedef PrecomputedVMatrix PLearn::LocallyPrecomputedVMatrix::inherited [private] |
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 56 of file LocallyPrecomputedVMatrix.h.
PLearn::LocallyPrecomputedVMatrix::LocallyPrecomputedVMatrix | ( | ) |
Default constructor.
Definition at line 54 of file LocallyPrecomputedVMatrix.cc.
References PLearn::PrecomputedVMatrix::precomp_type, and PLearn::PrecomputedVMatrix::temporary.
: local_dir("/tmp"), max_wait(30), remove_when_done(-1), sequential_access(true), verbosity(2) { precomp_type = "pmat"; temporary = true; }
PLearn::LocallyPrecomputedVMatrix::~LocallyPrecomputedVMatrix | ( | ) | [virtual] |
Destructor, used to remove the file.
Definition at line 168 of file LocallyPrecomputedVMatrix.cc.
References PLearn::PPath::absolute(), PLearn::force_rmdir(), PLearn::VMatrix::getMetaDataDir(), PLearn::VMatrix::hasMetaDataDir(), PLearn::noReferenceToFile(), PLearn::openString(), PLASSERT, PLearn::PStream::plearn_ascii, PLWARNING, PLearn::PrecomputedVMatrix::precomp_source, PLearn::PrecomputedVMatrix::precomp_type, PLearn::PrecomputedVMatrix::temporary, and verbosity.
{ if (temporary && hasMetaDataDir()) { string filename_option; // Get the name of the precomputed file. if (precomp_type == "pmat") { string source_filename = precomp_source->getOption("filename"); openString(source_filename, PStream::plearn_ascii) >> filename_option; } else { PLASSERT( precomp_type == "dmat" ); string source_dirname = precomp_source->getOption("dirname"); openString(source_dirname, PStream::plearn_ascii) >> filename_option; } PPath precomputed_file(filename_option); // First we delete the precomputed source, so that it does not try // to save more stuff in the metadatadir after it has been deleted. // This should also trigger the deletion of the underlying data. precomp_source = 0; // If there is nobody accessing the data file (i.e. it should have // been deleted by now), we can also remove the metadata directory // of this VMatrix (the one that contained the data file). if (noReferenceToFile(precomputed_file)) { PPath mdir = getMetaDataDir(); bool removed = force_rmdir(mdir); if (!removed && verbosity >= 1) PLWARNING( "In LocallyPrecomputedVMatrix::~LocallyPrecomputedVMatrix " "- The precomputed data (in '%s') could not be removed", mdir.absolute().c_str()); } } }
string PLearn::LocallyPrecomputedVMatrix::_classname_ | ( | ) | [static] |
Declares name and deepCopy methods.
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 78 of file LocallyPrecomputedVMatrix.cc.
OptionList & PLearn::LocallyPrecomputedVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 78 of file LocallyPrecomputedVMatrix.cc.
RemoteMethodMap & PLearn::LocallyPrecomputedVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 78 of file LocallyPrecomputedVMatrix.cc.
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 78 of file LocallyPrecomputedVMatrix.cc.
Object * PLearn::LocallyPrecomputedVMatrix::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 78 of file LocallyPrecomputedVMatrix.cc.
StaticInitializer LocallyPrecomputedVMatrix::_static_initializer_ & PLearn::LocallyPrecomputedVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 78 of file LocallyPrecomputedVMatrix.cc.
void PLearn::LocallyPrecomputedVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 112 of file LocallyPrecomputedVMatrix.cc.
References PLearn::PrecomputedVMatrix::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::LocallyPrecomputedVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 121 of file LocallyPrecomputedVMatrix.cc.
References PLearn::PrecomputedVMatrix::build(), PLearn::force_mkdir(), PLearn::VMatrix::hasMetaDataDir(), local_dir, max_wait, PLearn::VMatrix::metadatadir, PLearn::newFilename(), PLASSERT, PLDEPRECATED, PLERROR, PLWARNING, PLearn::PrecomputedVMatrix::precomp_source, remove_when_done, sequential_access, PLearn::SourceVMatrix::source, PLearn::PrecomputedVMatrix::temporary, PLearn::VMatrix::updateMtime(), and verbosity.
Referenced by build().
{ // Check for deprecated option. if (remove_when_done != -1) { PLDEPRECATED("In LocallyPrecomputedVMatrix::build_ - You should now be" " using the 'temporary' option instead of " "the 'remove_when_done' option, which is deprecated."); PLASSERT( remove_when_done == 0 || remove_when_done == 1 ); temporary = remove_when_done != 0; } if (!hasMetaDataDir()) { bool made_dir = force_mkdir(local_dir); if (!made_dir) { PLWARNING( "In LocallyPrecomputedVMatrix::build_ - Could not create dir: %s\n" "The program may crash if it needs to access an element of this VMatrix.", local_dir.c_str()); return; } metadatadir = newFilename(local_dir, "locally_precomputed_", true); if (sequential_access) { // If necessary, wait until we are allowed to start the precomputation. if (source->hasMetaDataDir()) source->lockMetaDataDir(max_wait * 60, verbosity >= 2); else PLERROR("In LocallyPrecomputedVMatrix::build_ - The source VMatrix must have a metadatadir"); } inherited::build(); if (sequential_access) source->unlockMetaDataDir(); } updateMtime(precomp_source); updateMtime(source); }
string PLearn::LocallyPrecomputedVMatrix::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 78 of file LocallyPrecomputedVMatrix.cc.
void PLearn::LocallyPrecomputedVMatrix::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares this class' options.
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 83 of file LocallyPrecomputedVMatrix.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::PrecomputedVMatrix::declareOptions(), PLearn::OptionBase::learntoption, local_dir, max_wait, PLearn::VMatrix::metadatadir, PLearn::OptionBase::nosave, PLearn::redeclareOption(), remove_when_done, sequential_access, and verbosity.
{ declareOption(ol, "local_dir", &LocallyPrecomputedVMatrix::local_dir, OptionBase::buildoption, "The local directory in which we want to save the precomputed data."); declareOption(ol, "remove_when_done", &LocallyPrecomputedVMatrix::remove_when_done, OptionBase::learntoption, "Deprecated! (use 'temporary' instead)."); declareOption(ol, "sequential_access", &LocallyPrecomputedVMatrix::sequential_access, OptionBase::buildoption, "If set to 1, ensures there are no multiple parallel precomputations (see class help)."); declareOption(ol, "max_wait", &LocallyPrecomputedVMatrix::max_wait, OptionBase::buildoption, "Maximum wait time in minutes when 'sequential access' is set to 1 (see class help)."); declareOption(ol, "verbosity", &LocallyPrecomputedVMatrix::verbosity, OptionBase::buildoption, "Controls the amount of displayed information."); // Now call the parent class' declareOptions inherited::declareOptions(ol); redeclareOption(ol, "metadatadir", &LocallyPrecomputedVMatrix::metadatadir, OptionBase::nosave, "The metadatadir will be defined by the 'local_dir' option."); }
static const PPath& PLearn::LocallyPrecomputedVMatrix::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 109 of file LocallyPrecomputedVMatrix.h.
LocallyPrecomputedVMatrix * PLearn::LocallyPrecomputedVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 78 of file LocallyPrecomputedVMatrix.cc.
OptionList & PLearn::LocallyPrecomputedVMatrix::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 78 of file LocallyPrecomputedVMatrix.cc.
OptionMap & PLearn::LocallyPrecomputedVMatrix::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 78 of file LocallyPrecomputedVMatrix.cc.
RemoteMethodMap & PLearn::LocallyPrecomputedVMatrix::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 78 of file LocallyPrecomputedVMatrix.cc.
void PLearn::LocallyPrecomputedVMatrix::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 160 of file LocallyPrecomputedVMatrix.cc.
References PLearn::PrecomputedVMatrix::makeDeepCopyFromShallowCopy().
{ inherited::makeDeepCopyFromShallowCopy(copies); }
Reimplemented from PLearn::PrecomputedVMatrix.
Definition at line 109 of file LocallyPrecomputedVMatrix.h.
Definition at line 70 of file LocallyPrecomputedVMatrix.h.
Referenced by build_(), and declareOptions().
Definition at line 71 of file LocallyPrecomputedVMatrix.h.
Referenced by build_(), and declareOptions().
Definition at line 72 of file LocallyPrecomputedVMatrix.h.
Referenced by build_(), and declareOptions().
Definition at line 73 of file LocallyPrecomputedVMatrix.h.
Referenced by build_(), and declareOptions().
Definition at line 74 of file LocallyPrecomputedVMatrix.h.
Referenced by build_(), declareOptions(), and ~LocallyPrecomputedVMatrix().