[PLUGIN] Add plugin system

This commit is contained in:
tqchen
2016-01-12 11:56:22 -08:00
parent 36c389ac46
commit 96f4542a67
14 changed files with 457 additions and 13 deletions

View File

@@ -255,5 +255,8 @@ std::string SparsePage::Format::DecideFormat(const std::string& cache_prefix) {
return "raw";
}
}
// List of files that will be force linked in static links.
DMLC_REGISTRY_LINK_TAG(sparse_page_raw_format);
} // namespace data
} // namespace xgboost

View File

@@ -155,7 +155,7 @@ class SparsePage::Format {
* \brief save the data to fo, when a page was written.
* \param fo output stream
*/
virtual void Write(const SparsePage& page, dmlc::Stream* fo) const = 0;
virtual void Write(const SparsePage& page, dmlc::Stream* fo) = 0;
/*!
* \brief Create sparse page of format.
* \return The created format functors.

View File

@@ -71,7 +71,7 @@ class SparsePageDMatrix : public DMatrix {
/*! \brief page size 256 MB */
static const size_t kPageSize = 256UL << 20UL;
/*! \brief Maximum number of rows per batch. */
static const size_t kMaxRowPerBatch = 32UL << 10UL;
static const size_t kMaxRowPerBatch = 64UL << 10UL;
private:
// declare the column batch iter.

View File

@@ -4,11 +4,14 @@
* Raw binary format of sparse page.
*/
#include <xgboost/data.h>
#include <dmlc/registry.h>
#include "./sparse_batch_page.h"
namespace xgboost {
namespace data {
DMLC_REGISTRY_FILE_TAG(sparse_page_raw_format);
class SparsePageRawFormat : public SparsePage::Format {
public:
bool Read(SparsePage* page, dmlc::SeekStream* fi) override {
@@ -73,7 +76,7 @@ class SparsePageRawFormat : public SparsePage::Format {
return true;
}
void Write(const SparsePage& page, dmlc::Stream* fo) const override {
void Write(const SparsePage& page, dmlc::Stream* fo) override {
CHECK(page.offset.size() != 0 && page.offset[0] == 0);
CHECK_EQ(page.offset.back(), page.data.size());
fo->Write(page.offset);