Vince's CSV Parser
Loading...
Searching...
No Matches
csv::internals::MmapParser Class Reference

Parser for memory-mapped files. More...

#include <basic_csv_parser.hpp>

Inherits csv::internals::IBasicCSVParser.

Public Member Functions

 MmapParser (csv::string_view filename, const CSVFormat &format, const ColNamesPtr &col_names=nullptr)
 
std::string & get_csv_head () override
 
void next (size_t bytes) override
 Parse the next block of data.
 
- Public Member Functions inherited from csv::internals::IBasicCSVParser
 IBasicCSVParser (const CSVFormat &, const ColNamesPtr &)
 
 IBasicCSVParser (const ParseFlagMap &parse_flags, const WhitespaceMap &ws_flags)
 
bool eof ()
 Whether or not we have reached the end of source.
 
ResolvedFormat get_resolved_format ()
 
void end_feed ()
 Indicate the last block of data has been parsed.
 
CONSTEXPR_17 ParseFlags parse_flag (const char ch) const noexcept
 
CONSTEXPR_17 ParseFlags compound_parse_flag (const char ch) const noexcept
 
CONSTEXPR bool utf8_bom () const
 Whether or not this CSV has a UTF-8 byte order mark.
 
void set_output (RowCollection &rows)
 

Additional Inherited Members

- Protected Member Functions inherited from csv::internals::IBasicCSVParser
CONSTEXPR bool no_chunk () const
 Whether or not source needs to be read in chunks.
 
size_t parse ()
 Parse the current chunk of data and return the completed-row prefix length.
 
void reset_data_ptr ()
 Create a new RawCSVDataPtr for a new chunk of data.
 
void resolve_format_from_head (const CSVFormat &format)
 
- Protected Attributes inherited from csv::internals::IBasicCSVParser
CSVRow current_row_
 
RawCSVDataPtr data_ptr_ = nullptr
 
ColNamesPtr col_names_ = nullptr
 
RawCSVFieldListfields_ = nullptr
 
int field_start_ = UNINITIALIZED_FIELD
 
size_t field_length_ = 0
 
SentinelVecs simd_sentinels_
 Precomputed SIMD broadcast vectors for find_next_non_special.
 
ParseFlagMap parse_flags_
 An array where the (i + 128)th slot gives the ParseFlags for ASCII character i.
 
bool eof_ = false
 
ResolvedFormat format
 
size_t source_size_ = 0
 The size of the incoming CSV.
 

Detailed Description

Parser for memory-mapped files.

Implementation
This class constructs moving windows over a file to avoid creating massive memory maps which may require more RAM than the user has available. It contains logic to automatically re-align each memory map to the beginning of a CSV row.
Head buffer
CSVReader may prime a pre-read head buffer used for format guessing via prime_head_for_reuse(). When provided, the first next() call parses that buffer directly, then resumes mmap reads from the proper file offset while preserving chunk-boundary remainder semantics.

Definition at line 415 of file basic_csv_parser.hpp.

Constructor & Destructor Documentation

◆ MmapParser()

csv::internals::MmapParser::MmapParser ( csv::string_view  filename,
const CSVFormat format,
const ColNamesPtr &  col_names = nullptr 
)
inline

Definition at line 417 of file basic_csv_parser.hpp.

◆ ~MmapParser()

csv::internals::MmapParser::~MmapParser ( )
inline

Definition at line 428 of file basic_csv_parser.hpp.

Member Function Documentation

◆ get_csv_head()

std::string & csv::internals::MmapParser::get_csv_head ( )
inlineoverridevirtual

Implements csv::internals::IBasicCSVParser.

Definition at line 430 of file basic_csv_parser.hpp.

◆ next()

void csv::internals::MmapParser::next ( size_t  bytes)
overridevirtual

Parse the next block of data.

Implements csv::internals::IBasicCSVParser.

Definition at line 312 of file basic_csv_parser.cpp.


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