Skip to content

Commit ddb7e53

Browse files
committed
OK
1 parent 22abf4e commit ddb7e53

File tree

6 files changed

+11
-50
lines changed

6 files changed

+11
-50
lines changed

R-package/src/xgboost_R.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,6 @@ extern "C" {
7676
_WrapperEnd();
7777
return ret;
7878
}
79-
SEXP XGDMatrixCreateCache_R(SEXP fname, SEXP cache_file, SEXP silent) {
80-
_WrapperBegin();
81-
void *handle = XGDMatrixCreateCache(CHAR(asChar(fname)),
82-
CHAR(asChar(cache_file)),
83-
asInteger(silent));
84-
SEXP ret = PROTECT(R_MakeExternalPtr(handle, R_NilValue, R_NilValue));
85-
R_RegisterCFinalizerEx(ret, _DMatrixFinalizer, TRUE);
86-
UNPROTECT(1);
87-
_WrapperEnd();
88-
return ret;
89-
}
9079
SEXP XGDMatrixCreateFromMat_R(SEXP mat,
9180
SEXP missing) {
9281
_WrapperBegin();

R-package/src/xgboost_R.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ extern "C" {
2424
* \return a loaded data matrix
2525
*/
2626
SEXP XGDMatrixCreateFromFile_R(SEXP fname, SEXP silent);
27-
/*!
28-
* \brief load a cached DMatrix, this is backed by several cache_files
29-
* and usually cost less memory
30-
* \param fname the name of the file, can be a cached buffer or text
31-
* \param cache_file the name of cached file
32-
* \param silent whether print messages during loading
33-
* \return a loaded data matrix
34-
*/
35-
SEXP XGDMatrixCreateCache_R(SEXP fname, SEXP cache_file, SEXP silent);
3627
/*!
3728
* \brief create matrix content from dense matrix
3829
* This assumes the matrix is stored in column major format

src/io/io.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ DataMatrix* LoadDataMatrix(const char *fname,
1616
bool loadsplit,
1717
const char *cache_file) {
1818
std::string fname_ = fname;
19+
1920
const char *dlm = strchr(fname, '#');
2021
if (dlm != NULL) {
2122
utils::Check(strchr(dlm + 1, '#') == NULL,
@@ -26,7 +27,7 @@ DataMatrix* LoadDataMatrix(const char *fname,
2627
fname = fname_.c_str();
2728
cache_file = dlm +1;
2829
}
29-
30+
3031
if (cache_file == NULL) {
3132
if (!std::strcmp(fname, "stdin") ||
3233
!std::strncmp(fname, "s3://", 5) ||
@@ -51,6 +52,13 @@ DataMatrix* LoadDataMatrix(const char *fname,
5152
dmat->CacheLoad(fname, silent, savebuffer);
5253
return dmat;
5354
} else {
55+
std::string cache_fname = cache_file;
56+
if (loadsplit) {
57+
std::ostringstream os;
58+
os << cache_file << ".r" << rabit::GetRank();
59+
cache_fname = os.str();
60+
cache_file = cache_fname.c_str();
61+
}
5462
FILE *fi = fopen64(cache_file, "rb");
5563
if (fi != NULL) {
5664
DMatrixPage *dmat = new DMatrixPage();

wrapper/xgboost.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def c_array(ctype, values):
8787

8888

8989
class DMatrix(object):
90-
def __init__(self, data, label=None, missing=0.0, weight=None, cache_file=None):
90+
def __init__(self, data, label=None, missing=0.0, weight=None):
9191
"""
9292
Data matrix used in XGBoost.
9393
@@ -102,24 +102,13 @@ def __init__(self, data, label=None, missing=0.0, weight=None, cache_file=None):
102102
Value in the data which needs to be present as a missing value.
103103
weight : list or numpy 1-D array (optional)
104104
Weight for each instance.
105-
cache_file: string
106-
Path to the binary cache of input data, when this is enabled,
107-
several binary cache files with the prefix cache_file will be created,
108-
xgboost will try to use external memory as much as possible,
109-
thus save memory during computation in general
110105
"""
111106

112107
# force into void_p, mac need to pass things in as void_p
113108
if data is None:
114109
self.handle = None
115110
return
116-
if cache_file is not None:
117-
if not isinstance(data, string_types):
118-
raise Exception('cache_file must be used together with input file name')
119-
if not isinstance(cache_file, string_types):
120-
raise Exception('cache_file must be string')
121-
self.handle = ctypes.c_void_p(xglib.XGDMatrixCreateCache(c_str(data), c_str(cache_file), 0))
122-
elif isinstance(data, string_types):
111+
if isinstance(data, string_types):
123112
self.handle = ctypes.c_void_p(xglib.XGDMatrixCreateFromFile(c_str(data), 0))
124113
elif isinstance(data, scipy.sparse.csr_matrix):
125114
self._init_from_csr(data)

wrapper/xgboost_wrapper.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ extern "C"{
114114
void* XGDMatrixCreateFromFile(const char *fname, int silent) {
115115
return LoadDataMatrix(fname, silent != 0, false, false);
116116
}
117-
void* XGDMatrixCreateCache(const char *fname,
118-
const char *cache_file,
119-
int silent) {
120-
return LoadDataMatrix(fname, silent != 0, false, false, cache_file);
121-
}
122117
void* XGDMatrixCreateFromCSR(const bst_ulong *indptr,
123118
const unsigned *indices,
124119
const float *data,

wrapper/xgboost_wrapper.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,6 @@ extern "C" {
2424
* \return a loaded data matrix
2525
*/
2626
XGB_DLL void* XGDMatrixCreateFromFile(const char *fname, int silent);
27-
/*!
28-
* \brief load a cached DMatrix, this is backed by several cache_files
29-
* and usually cost less memory
30-
* \param fname the name of the file, can be a cached buffer or text
31-
* \param cache_file the name of cached file
32-
* \param silent whether print messages during loading
33-
* \return a loaded data matrix
34-
*/
35-
XGB_DLL void* XGDMatrixCreateCache(const char *fname,
36-
const char *cache_file,
37-
int silent);
3827
/*!
3928
* \brief create a matrix content from csr format
4029
* \param indptr pointer to row headers

0 commit comments

Comments
 (0)