1#ifndef LIGHTGBM_UTILS_PIPELINE_READER_H_
2#define LIGHTGBM_UTILS_PIPELINE_READER_H_
4#include <LightGBM/utils/log.h>
27 static size_t Read(
const char* filename,
int skip_bytes,
const std::function<
size_t(
const char*,
size_t)>& process_fun) {
29 if (!reader->Init()) {
33 const size_t buffer_size = 16 * 1024 * 1024;
35 auto buffer_process = std::vector<char>(buffer_size);
37 auto buffer_read = std::vector<char>(buffer_size);
41 read_cnt = reader->Read(buffer_process.data(), skip_bytes);
44 read_cnt = reader->Read(buffer_process.data(), buffer_size);
46 size_t last_read_cnt = 0;
47 while (read_cnt > 0) {
49 std::thread read_worker = std::thread(
51 last_read_cnt = reader->Read(buffer_read.data(), buffer_size);
54 cnt += process_fun(buffer_process.data(), read_cnt);
59 read_cnt = last_read_cnt;
A pipeline file reader, use 2 threads, one read block from file, the other process the block.
Definition pipeline_reader.h:20
static size_t Read(const char *filename, int skip_bytes, const std::function< size_t(const char *, size_t)> &process_fun)
Read data from a file, use pipeline methods.
Definition pipeline_reader.h:27
desc and descl2 fields must be written in reStructuredText format
Definition application.h:10
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.hpp:24418
static std::unique_ptr< VirtualFileReader > Make(const std::string &filename)
Create appropriate reader for filename.
Definition file_io.cpp:153