Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions
LightGBM::TextReader< INDEX_T > Class Template Reference

Read text data from file. More...

#include <text_reader.h>

Public Member Functions

 TextReader (const char *filename, bool is_skip_first_line)
 Constructor.
 
 ~TextReader ()
 Destructor.
 
void Clear ()
 Clear cached data.
 
std::string first_line ()
 return first line of data
 
std::vector< std::string > & Lines ()
 Get text data that read from file.
 
INDEX_T ReadAllAndProcess (const std::function< void(INDEX_T, const char *, size_t)> &process_fun)
 
INDEX_T ReadAllLines ()
 Read all text data from file in memory.
 
std::vector< char > ReadContent (size_t *out_len)
 
INDEX_T SampleFromFile (Random &random, INDEX_T sample_cnt, std::vector< std::string > *out_sampled_data)
 
INDEX_T ReadAndFilterLines (const std::function< bool(INDEX_T)> &filter_fun, std::vector< INDEX_T > *out_used_data_indices)
 Read part of text data from file in memory, use filter_fun to filter data.
 
INDEX_T SampleAndFilterFromFile (const std::function< bool(INDEX_T)> &filter_fun, std::vector< INDEX_T > *out_used_data_indices, Random &random, INDEX_T sample_cnt, std::vector< std::string > *out_sampled_data)
 
INDEX_T CountLine ()
 
INDEX_T ReadAllAndProcessParallelWithFilter (const std::function< void(INDEX_T, const std::vector< std::string > &)> &process_fun, const std::function< bool(INDEX_T, INDEX_T)> &filter_fun)
 
INDEX_T ReadAllAndProcessParallel (const std::function< void(INDEX_T, const std::vector< std::string > &)> &process_fun)
 
INDEX_T ReadPartAndProcessParallel (const std::vector< INDEX_T > &used_data_indices, const std::function< void(INDEX_T, const std::vector< std::string > &)> &process_fun)
 

Detailed Description

template<typename INDEX_T>
class LightGBM::TextReader< INDEX_T >

Read text data from file.

Constructor & Destructor Documentation

◆ TextReader()

template<typename INDEX_T >
LightGBM::TextReader< INDEX_T >::TextReader ( const char *  filename,
bool  is_skip_first_line 
)
inline

Constructor.

Parameters
filenameFilename of data
is_skip_first_lineTrue if need to skip header

Member Function Documentation

◆ Lines()

template<typename INDEX_T >
std::vector< std::string > & LightGBM::TextReader< INDEX_T >::Lines ( )
inline

Get text data that read from file.

Returns
Text data, store in std::vector by line

◆ ReadAllLines()

template<typename INDEX_T >
INDEX_T LightGBM::TextReader< INDEX_T >::ReadAllLines ( )
inline

Read all text data from file in memory.

Returns
number of lines of text data

◆ ReadAndFilterLines()

template<typename INDEX_T >
INDEX_T LightGBM::TextReader< INDEX_T >::ReadAndFilterLines ( const std::function< bool(INDEX_T)> &  filter_fun,
std::vector< INDEX_T > *  out_used_data_indices 
)
inline

Read part of text data from file in memory, use filter_fun to filter data.

Parameters
filter_funFunction that perform data filter
out_used_data_indicesStore line indices that read text data
Returns
The number of total data

The documentation for this class was generated from the following file: