add tmp file
This commit is contained in:
parent
87cc53f0cd
commit
3a0be47b1c
@ -13,6 +13,14 @@
|
|||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
namespace io {
|
namespace io {
|
||||||
DataMatrix* LoadDataMatrix(const char *fname, bool silent, bool savebuffer) {
|
DataMatrix* LoadDataMatrix(const char *fname, bool silent, bool savebuffer) {
|
||||||
|
std::string tmp_fname;
|
||||||
|
const char *fname_ext = NULL;
|
||||||
|
if (strchr(fname, ';') != NULL) {
|
||||||
|
tmp_fname = fname;
|
||||||
|
char *ptr = strchr(&tmp_fname[0], ';');
|
||||||
|
ptr[0] = '\0'; fname = &tmp_fname[0];
|
||||||
|
fname_ext = ptr + 1;
|
||||||
|
}
|
||||||
int magic;
|
int magic;
|
||||||
utils::FileStream fs(utils::FopenCheck(fname, "rb"));
|
utils::FileStream fs(utils::FopenCheck(fname, "rb"));
|
||||||
utils::Check(fs.Read(&magic, sizeof(magic)) != 0, "invalid input file format");
|
utils::Check(fs.Read(&magic, sizeof(magic)) != 0, "invalid input file format");
|
||||||
@ -25,15 +33,23 @@ DataMatrix* LoadDataMatrix(const char *fname, bool silent, bool savebuffer) {
|
|||||||
return dmat;
|
return dmat;
|
||||||
}
|
}
|
||||||
if (magic == DMatrixPage::kMagic) {
|
if (magic == DMatrixPage::kMagic) {
|
||||||
DMatrixPage *dmat = new DMatrixPage();
|
if (fname_ext == NULL) {
|
||||||
dmat->Load(fs, silent, fname);
|
DMatrixPage *dmat = new DMatrixPage();
|
||||||
// the file pointer is hold in page matrix
|
dmat->Load(fs, silent, fname);
|
||||||
return dmat;
|
return dmat;
|
||||||
|
} else {
|
||||||
|
DMatrixColPage *dmat = new DMatrixColPage(fname_ext);
|
||||||
|
dmat->Load(fs, silent, fname, true);
|
||||||
|
return dmat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (magic == DMatrixColPage::kMagic) {
|
if (magic == DMatrixColPage::kMagic) {
|
||||||
DMatrixColPage *dmat = new DMatrixColPage(fname);
|
std::string sfname = fname;
|
||||||
|
if (fname_ext == NULL) {
|
||||||
|
sfname += ".col"; fname_ext = sfname.c_str();
|
||||||
|
}
|
||||||
|
DMatrixColPage *dmat = new DMatrixColPage(fname_ext);
|
||||||
dmat->Load(fs, silent, fname);
|
dmat->Load(fs, silent, fname);
|
||||||
// the file pointer is hold in page matrix
|
|
||||||
return dmat;
|
return dmat;
|
||||||
}
|
}
|
||||||
fs.Close();
|
fs.Close();
|
||||||
|
|||||||
@ -214,10 +214,13 @@ class DMatrixPageBase : public DataMatrix {
|
|||||||
/*! \brief load and initialize the iterator with fi */
|
/*! \brief load and initialize the iterator with fi */
|
||||||
inline void Load(utils::FileStream &fi,
|
inline void Load(utils::FileStream &fi,
|
||||||
bool silent = false,
|
bool silent = false,
|
||||||
const char *fname = NULL) {
|
const char *fname = NULL,
|
||||||
|
bool skip_magic_check = false) {
|
||||||
int tmagic;
|
int tmagic;
|
||||||
utils::Check(fi.Read(&tmagic, sizeof(tmagic)) != 0, "invalid input file format");
|
utils::Check(fi.Read(&tmagic, sizeof(tmagic)) != 0, "invalid input file format");
|
||||||
utils::Check(tmagic == magic, "invalid format,magic number mismatch");
|
if (!skip_magic_check) {
|
||||||
|
utils::Check(tmagic == magic, "invalid format,magic number mismatch");
|
||||||
|
}
|
||||||
this->info.LoadBinary(fi);
|
this->info.LoadBinary(fi);
|
||||||
iter_->Load(fi);
|
iter_->Load(fi);
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
|
|||||||
@ -355,9 +355,7 @@ class FMatrixPage : public IFMatrix {
|
|||||||
class DMatrixColPage : public DMatrixPageBase<0xffffab03> {
|
class DMatrixColPage : public DMatrixPageBase<0xffffab03> {
|
||||||
public:
|
public:
|
||||||
explicit DMatrixColPage(const char *fname) {
|
explicit DMatrixColPage(const char *fname) {
|
||||||
std::string fext = fname;
|
fmat_ = new FMatrixPage(iter_, fname);
|
||||||
fext += ".col";
|
|
||||||
fmat_ = new FMatrixPage(iter_, fext.c_str());
|
|
||||||
}
|
}
|
||||||
virtual ~DMatrixColPage(void) {
|
virtual ~DMatrixColPage(void) {
|
||||||
delete fmat_;
|
delete fmat_;
|
||||||
|
|||||||
@ -13,6 +13,8 @@ IUpdater* CreateUpdater(const char *name) {
|
|||||||
if (!strcmp(name, "prune")) return new TreePruner();
|
if (!strcmp(name, "prune")) return new TreePruner();
|
||||||
if (!strcmp(name, "refresh")) return new TreeRefresher<GradStats>();
|
if (!strcmp(name, "refresh")) return new TreeRefresher<GradStats>();
|
||||||
if (!strcmp(name, "grow_colmaker")) return new ColMaker<GradStats>();
|
if (!strcmp(name, "grow_colmaker")) return new ColMaker<GradStats>();
|
||||||
|
if (!strcmp(name, "grow_colmaker5")) return new ColMaker< CVGradStats<5> >();
|
||||||
|
if (!strcmp(name, "grow_colmaker3")) return new ColMaker< CVGradStats<3> >();
|
||||||
utils::Error("unknown updater:%s", name);
|
utils::Error("unknown updater:%s", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user