Serialization to fastlib/src
This commit is contained in:
@@ -68,8 +68,8 @@ add_executable( otrav_test otrav_test.cc )
|
||||
target_link_libraries( otrav_test fastlib )
|
||||
|
||||
# make sure header files are installed correctly
|
||||
install(FILES ${CMAKE_BINARY_DIR}/include/fastlib/
|
||||
DESTINATION include/fastlib)
|
||||
#install(FILES ${CMAKE_BINARY_DIR}/include/fastlib/
|
||||
# DESTINATION include/fastlib)
|
||||
|
||||
## installation
|
||||
install(TARGETS fastlib
|
||||
@@ -78,4 +78,4 @@ install(TARGETS fastlib
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
|
||||
install(FILES fastlib.h DESTINATION include/fastlib)
|
||||
#install(FILES fastlib.h DESTINATION include/fastlib)
|
||||
|
||||
@@ -53,6 +53,14 @@
|
||||
#include "cc.h"
|
||||
#include "ccmem.h"
|
||||
#include "otrav.h"
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <boost/archive/text_oarchive.hpp>
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
#include <boost/serialization/utility.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
//#include "cc.h"
|
||||
//#include "ccmem.h"
|
||||
//#include "otrav.h"
|
||||
|
||||
@@ -68,7 +68,16 @@ class String {
|
||||
OT_OBJ(c_str);
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & array_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implicit conversion constructor.
|
||||
*/
|
||||
|
||||
@@ -69,11 +69,18 @@ class MinHeap {
|
||||
|
||||
ArrayList<Entry> entries_;
|
||||
|
||||
OBJECT_TRAVERSAL(MinHeap) {
|
||||
/*OBJECT_TRAVERSAL(MinHeap) {
|
||||
OT_OBJ(entries_);
|
||||
}
|
||||
}*/
|
||||
|
||||
public:
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & entries_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes an empty priority queue.
|
||||
*/
|
||||
|
||||
@@ -53,13 +53,26 @@ class DenseIntMap {
|
||||
index_t size_;
|
||||
Value default_value_;
|
||||
|
||||
OT_DEF(DenseIntMap) {
|
||||
/*OT_DEF(DenseIntMap) {
|
||||
OT_MY_OBJECT(size_);
|
||||
OT_MY_OBJECT(default_value_);
|
||||
OT_MALLOC_ARRAY(ptr_, size_);
|
||||
}
|
||||
}*/
|
||||
|
||||
public:
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < size_; i++)
|
||||
{
|
||||
ar & ptr_[i];
|
||||
}
|
||||
ar & size_;
|
||||
ar & default_value_;
|
||||
}
|
||||
|
||||
/** Creates a blank mapping. */
|
||||
void Init() {
|
||||
ptr_ = NULL;
|
||||
|
||||
@@ -68,11 +68,19 @@ class RangeSet {
|
||||
private:
|
||||
ArrayList<Range> ranges_;
|
||||
|
||||
OT_DEF(RangeSet) {
|
||||
/*OT_DEF(RangeSet) {
|
||||
OT_MY_OBJECT(ranges_);
|
||||
}
|
||||
}*/
|
||||
|
||||
public:
|
||||
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & ranges_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty set of ranges.
|
||||
*/
|
||||
|
||||
@@ -666,6 +666,7 @@ void Dataset::SplitTrainTest(int folds, int fold_number,
|
||||
|
||||
success_t data::Load(const char *fname, Matrix *matrix) {
|
||||
Dataset dataset;
|
||||
printf("In Load:%s\n", fname);
|
||||
success_t result = dataset.InitFromFile(fname);
|
||||
matrix->Own(&dataset.matrix());
|
||||
return result;
|
||||
|
||||
@@ -78,7 +78,7 @@ class DatasetFeature {
|
||||
/** If nominal, the names of each numbered value. */
|
||||
ArrayList<String> value_names_;
|
||||
|
||||
OBJECT_TRAVERSAL(DatasetFeature) {
|
||||
/*OBJECT_TRAVERSAL(DatasetFeature) {
|
||||
OT_OBJ(name_);
|
||||
//OT_OBJ(reinterpret_cast<int &>(type_));
|
||||
OT_ENUM_EXPERT(type_, int,
|
||||
@@ -86,7 +86,7 @@ class DatasetFeature {
|
||||
OT_ENUM_VAL(INTEGER)
|
||||
OT_ENUM_VAL(NOMINAL));
|
||||
OT_OBJ(value_names_);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Initialization common to all features.
|
||||
@@ -99,6 +99,16 @@ class DatasetFeature {
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & name_;
|
||||
ar & type_;
|
||||
ar & value_names_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize to be a continuous feature.
|
||||
*
|
||||
|
||||
@@ -79,7 +79,16 @@ class GenVector {
|
||||
index_t length_;
|
||||
/** Whether this should be freed, i.e. it is not an alias. */
|
||||
bool should_free_;
|
||||
|
||||
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & ptr_;
|
||||
ar & length_;
|
||||
ar & should_free_;
|
||||
}
|
||||
|
||||
OBJECT_TRAVERSAL_ONLY(GenVector) {
|
||||
OT_OBJ(length_);
|
||||
OT_ALLOC(ptr_, length_);
|
||||
@@ -465,6 +474,16 @@ class GenMatrix {
|
||||
/** Whether I am a strong copy (not an alias). */
|
||||
bool should_free_;
|
||||
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & ptr_;
|
||||
ar & n_rows_;
|
||||
ar & n_cols_;
|
||||
ar & should_free_;
|
||||
}
|
||||
|
||||
OBJECT_TRAVERSAL_ONLY(GenMatrix) {
|
||||
OT_OBJ(n_rows_);
|
||||
OT_OBJ(n_cols_);
|
||||
|
||||
@@ -55,12 +55,22 @@ class GaussianKernel {
|
||||
double neg_inv_bandwidth_2sq_;
|
||||
double bandwidth_sq_;
|
||||
|
||||
OBJECT_TRAVERSAL(GaussianKernel) {
|
||||
/* OBJECT_TRAVERSAL(GaussianKernel) {
|
||||
OT_OBJ(neg_inv_bandwidth_2sq_);
|
||||
OT_OBJ(bandwidth_sq_);
|
||||
}
|
||||
*/
|
||||
|
||||
public:
|
||||
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & neg_inv_bandwidth_2sq_;
|
||||
ar & bandwidth_sq_;
|
||||
}
|
||||
|
||||
static const bool HAS_CUTOFF = false;
|
||||
|
||||
public:
|
||||
|
||||
@@ -194,11 +194,19 @@ class MinMaxVal {
|
||||
/** The underlying value. */
|
||||
Value val;
|
||||
|
||||
OBJECT_TRAVERSAL(MinMaxVal) {
|
||||
/*OBJECT_TRAVERSAL(MinMaxVal) {
|
||||
OT_OBJ(val);
|
||||
}
|
||||
}*/
|
||||
|
||||
public:
|
||||
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts implicitly to the value.
|
||||
*/
|
||||
|
||||
@@ -62,12 +62,26 @@ class DHrectBound {
|
||||
DRange *bounds_;
|
||||
index_t dim_;
|
||||
|
||||
OBJECT_TRAVERSAL(DHrectBound) {
|
||||
/*OBJECT_TRAVERSAL(DHrectBound) {
|
||||
OT_OBJ(dim_);
|
||||
OT_ALLOC(bounds_, dim_);
|
||||
};
|
||||
};*/
|
||||
|
||||
public:
|
||||
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < dim_; i++)
|
||||
{
|
||||
ar & bounds_[i];
|
||||
}
|
||||
ar & dim_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes to specified dimensionality with each dimension the empty
|
||||
* set.
|
||||
|
||||
@@ -72,16 +72,28 @@ class BinarySpaceTree {
|
||||
index_t count_;
|
||||
Statistic stat_;
|
||||
|
||||
OT_DEF(BinarySpaceTree) {
|
||||
/*OT_DEF(BinarySpaceTree) {
|
||||
OT_MY_OBJECT(bound_);
|
||||
OT_PTR_NULLABLE(left_);
|
||||
OT_PTR_NULLABLE(right_);
|
||||
OT_MY_OBJECT(begin_);
|
||||
OT_MY_OBJECT(count_);
|
||||
OT_MY_OBJECT(stat_);
|
||||
}
|
||||
}*/
|
||||
|
||||
public:
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & bound_;
|
||||
ar & left_;
|
||||
ar & right_;
|
||||
ar & begin_;
|
||||
ar & count_;
|
||||
ar & stat_;
|
||||
}
|
||||
|
||||
/*
|
||||
BinarySpaceTree() {
|
||||
DEBUG_ONLY(begin_ = BIG_BAD_NUMBER);
|
||||
|
||||
Reference in New Issue
Block a user