main_memory_storage_manager.h

Go to the documentation of this file.
00001 #include "storage_manager.h"
00002 #include "incremental_sgd.h"
00003 #include <map>
00004 #include <vector>
00005 
00006 struct main_memory_storage_spec : storage_spec {
00007   
00008 };
00009 
00013 template<class T>
00014 class STLMainMemory_Storage_Manager : public Storage_Manager<T> {
00015   
00017   std::map<key, T> _entity_table;
00019   std::map<key, bool>    _eager_external_table;
00020   
00021   hazy_model::strategy strategy;
00023   // TODO: Make Hazy LAZY use this table??
00024   struct internal_record {
00025     key k;
00026     float eps;
00027     T v;
00028   };
00029   
00031   std::vector<internal_record> _itable;
00033   typedef typename std::vector<struct STLMainMemory_Storage_Manager<T>::internal_record>::iterator internal_iterator;
00034   typedef typename std::map<key,T>::iterator key_iterator_type;
00035   
00036   internal_iterator low_water_it_cached, high_water_it_cached;
00037   
00038   static bool cluster_sort_predicate(const internal_record &x, const internal_record &y) {
00039     return x.eps < y.eps;
00040   }
00041   
00048   double
00049     classify(struct model& m, T &v) {
00050     double ret= IncrementalSGD<T>::classifyExample(m, v);
00051     
00052     VERBOSE_ONLY(std::cout << "classify " << ret << std::endl;);
00053     return ret;
00054   }
00055  public:
00060   STLMainMemory_Storage_Manager(struct main_memory_storage_spec *s);
00067   STLMainMemory_Storage_Manager(Hazy_Database *db_conn, struct main_memory_storage_spec *s, struct hazy_model &hm);
00072   void resort(struct hazy_model &hm);
00073   
00079   void incrementalUpdate(struct hazy_model &m, double &waste_time);
00086   void insertEntity(struct hazy_model &m, key e, T x);
00087   
00094   void getEntityClass(key e, sClass &c, struct hazy_model &m);
00102   void getNumInClass(sClass c, int &nClass, struct hazy_model &m, double &waste_time);      
00106   ~STLMainMemory_Storage_Manager() { } 
00107   
00108 };
00109 
00110 // This is apparently best practice to deal with some linker problems for templtes.
00111 // since templates are not code themselves (but allow one to define code)
00112 #include "main_memory_storage_manager.hxx"
00113 

Generated on Wed Dec 15 10:46:15 2010 for Hazy_System by  doxygen 1.4.7