Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::CSVIterator Struct Reference
Collaboration diagram for duckdb::CSVIterator:

Public Member Functions

void Print () const
bool Next (CSVBufferManager &buffer_manager, const CSVReaderOptions &reader_options)
bool IsBoundarySet () const
 If boundary is set.
idx_t GetEndPos () const
 Getters.
idx_t GetBufferIdx () const
idx_t GetBoundaryIdx () const
void SetCurrentPositionToBoundary ()
void SetCurrentBoundaryToPosition (bool single_threaded, const CSVReaderOptions &reader_options)
void SetStart (idx_t pos)
void SetEnd (idx_t pos)
idx_t GetGlobalCurrentPos () const
void CheckIfDone ()
 Checks if we are done with this iterator.

Static Public Member Functions

static idx_t BytesPerThread (const CSVReaderOptions &reader_options)

Public Attributes

CSVPosition pos
bool done = false
bool first_one = true
idx_t buffer_size

Static Public Attributes

static constexpr idx_t ROWS_PER_THREAD = 4

Private Attributes

CSVBoundary boundary
 The original setting.
bool is_set

Constructor & Destructor Documentation

◆ CSVIterator()

duckdb::CSVIterator::CSVIterator ( )
168905 : buffer_size(0), is_set(false) {
168906}
bool is_set
Definition duckdb.cpp:166117

Member Function Documentation

◆ Print()

void duckdb::CSVIterator::Print ( ) const
168918 {
168919#ifndef DUCKDB_DISABLE_PRINT
168920 boundary.Print();
168921 std::cout << "Is set: " << is_set << '\n';
168922#endif
168923}
CSVBoundary boundary
The original setting.
Definition duckdb.cpp:166114

◆ Next()

bool duckdb::CSVIterator::Next ( CSVBufferManager & buffer_manager,
const CSVReaderOptions & reader_options )

Moves the boundary to the next one to be scanned, if there are no next boundaries, it returns False Otherwise, if there are boundaries, it returns True

168941 {
168942 if (!is_set) {
168943 return false;
168944 }
168945 const auto bytes_per_thread = BytesPerThread(reader_options);
168946
168947 // If we are calling next this is not the first one anymore
168948 first_one = false;
168949 boundary.boundary_idx++;
168950 // This is our start buffer
168951 auto buffer = buffer_manager.GetBuffer(boundary.buffer_idx);
168952 if (buffer->is_last_buffer && boundary.buffer_pos + bytes_per_thread > buffer->actual_size) {
168953 // 1) We are done with the current file
168954 return false;
168955 } else if (boundary.buffer_pos + bytes_per_thread >= buffer->actual_size) {
168956 // 2) We still have data to scan in this file, we set the iterator accordingly.
168957 // We must move the buffer
168958 boundary.buffer_idx++;
168959 boundary.buffer_pos = 0;
168960 // Verify this buffer really exists
168961 auto next_buffer = buffer_manager.GetBuffer(boundary.buffer_idx);
168962 if (!next_buffer) {
168963 return false;
168964 }
168965
168966 } else {
168967 // 3) We are not done with the current buffer, hence we just move where we start within the buffer
168968 boundary.buffer_pos += bytes_per_thread;
168969 }
168970 boundary.end_pos = boundary.buffer_pos + bytes_per_thread;
168971 SetCurrentPositionToBoundary();
168972 return true;
168973}
Here is the call graph for this function:

◆ IsBoundarySet()

bool duckdb::CSVIterator::IsBoundarySet ( ) const

If boundary is set.

168975 {
168976 return is_set;
168977}
Here is the caller graph for this function:

◆ GetEndPos()

idx_t duckdb::CSVIterator::GetEndPos ( ) const

Getters.

168978 {
168979 return boundary.end_pos;
168980}
Here is the caller graph for this function:

◆ GetBufferIdx()

idx_t duckdb::CSVIterator::GetBufferIdx ( ) const
168982 {
168983 return pos.buffer_idx;
168984}

◆ GetBoundaryIdx()

idx_t duckdb::CSVIterator::GetBoundaryIdx ( ) const
168986 {
168987 return boundary.boundary_idx;
168988}

◆ SetCurrentPositionToBoundary()

void duckdb::CSVIterator::SetCurrentPositionToBoundary ( )
168990 {
168991 pos.buffer_idx = boundary.buffer_idx;
168992 pos.buffer_pos = boundary.buffer_pos;
168993}

◆ SetCurrentBoundaryToPosition()

void duckdb::CSVIterator::SetCurrentBoundaryToPosition ( bool single_threaded,
const CSVReaderOptions & reader_options )
168995 {
168996 if (single_threaded) {
168997 is_set = false;
168998 return;
168999 }
169000 const auto bytes_per_thread = BytesPerThread(reader_options);
169001
169002 boundary.buffer_idx = pos.buffer_idx;
169003 if (pos.buffer_pos == 0) {
169004 boundary.end_pos = bytes_per_thread;
169005 } else {
169006 boundary.end_pos = ((pos.buffer_pos + bytes_per_thread - 1) / bytes_per_thread) * bytes_per_thread;
169007 }
169008
169009 boundary.buffer_pos = boundary.end_pos - bytes_per_thread;
169010 is_set = true;
169011}

◆ SetStart()

void duckdb::CSVIterator::SetStart ( idx_t pos)
169013 {
169014 boundary.buffer_pos = start;
169015}

◆ SetEnd()

void duckdb::CSVIterator::SetEnd ( idx_t pos)
169017 {
169018 boundary.end_pos = pos;
169019}

◆ GetGlobalCurrentPos()

idx_t duckdb::CSVIterator::GetGlobalCurrentPos ( ) const
169027 {
169028 return pos.buffer_pos + buffer_size * pos.buffer_idx;
169029}

◆ CheckIfDone()

void duckdb::CSVIterator::CheckIfDone ( )

Checks if we are done with this iterator.

169021 {
169022 if (IsBoundarySet() && (pos.buffer_idx > boundary.buffer_idx || pos.buffer_pos > boundary.buffer_pos)) {
169023 done = true;
169024 }
169025}
bool IsBoundarySet() const
If boundary is set.
Definition duckdb.cpp:168975
Here is the call graph for this function:

◆ BytesPerThread()

idx_t duckdb::CSVIterator::BytesPerThread ( const CSVReaderOptions & reader_options)
static
168925 {
168926 const idx_t buffer_size = reader_options.buffer_size_option.GetValue();
168927 const idx_t max_row_size = reader_options.maximum_line_size.GetValue();
168928 const idx_t bytes_per_thread = buffer_size / CSVBuffer::ROWS_PER_BUFFER * ROWS_PER_THREAD;
168929 if (bytes_per_thread < max_row_size) {
168930 // If we are setting up the buffer size directly, we must make sure each thread will read the full buffer.
168931 return max_row_size;
168932 }
168933 if (bytes_per_thread == 0) {
168934 // Bytes per thread can never be zero, but it might happen if max_row_size = 0
168935 // Not sure why a human being would do that...
168936 return 1;
168937 }
168938 return bytes_per_thread;
168939}
static constexpr idx_t ROWS_PER_BUFFER
By default, we use CSV_BUFFER_SIZE to allocate each buffer.
Definition duckdb.hpp:45985
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

Member Data Documentation

◆ is_set

bool duckdb::CSVIterator::is_set
private

Sometimes life knows no boundaries. The boundaries don't have to be set for single-threaded execution.


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