Sources¶
Namespace: dftracer::utils::utilities::fileio::lines::sources
-
class IndexedFileBytesIterator¶
Zero-copy iterator for reading lines within byte boundaries from indexed files.
Uses StreamType::LINE_BYTES to read lines one at a time within a byte range. The stream handles line boundaries automatically, so no complex buffering is needed.
Usage:
auto reader = ReaderFactory::create("file.gz", "file.gz.idx"); IndexedFileBytesIterator it(reader, 1000, 5000); // Bytes 1000-5000 while (it.has_next()) { Line line = it.next(); // Zero-copy string_view // Use line.content immediately }
Public Types
-
using Iterator = LineIterator<IndexedFileBytesIterator>¶
Public Functions
Construct iterator from existing Reader.
- Parameters:
reader – Shared pointer to Reader
start_byte – Starting byte offset (0-based, inclusive)
end_byte – Ending byte offset (0-based, exclusive)
buffer_size – Size of buffer for reading (default 1MB)
-
inline bool has_next() const¶
Check if more lines are available.
-
inline Line next()¶
Get the next line (zero-copy).
- Throws:
std::runtime_error – if no more lines available
- Returns:
Line object with string_view content (valid until next call)
-
inline std::size_t current_position() const¶
Get the current line number.
-
inline std::shared_ptr<dftracer::utils::utilities::reader::internal::Reader> get_reader() const¶
Get the underlying Reader.
-
using Iterator = LineIterator<IndexedFileBytesIterator>¶
-
class IndexedFileLineIterator¶
Unified zero-copy line iterator over indexed archive files.
This iterator returns one line at a time. It automatically selects the appropriate stream type based on the range:
LINE_RANGE: Uses StreamType::LINE (line-number based seeking)
BYTE_RANGE: Uses StreamType::LINE_BYTES (byte-offset based seeking)
Both stream types return one complete line per read(), so no complex buffering or newline splitting is needed.
Usage:
auto reader = dftracer::utils::utilities::reader::internal::ReaderFactory::create("file.gz", "file.gz.idx"); auto config = IndexedFileLineIteratorConfig() .with_reader(reader) .with_line_range(1, 100); IndexedFileLineIterator lines(config); // Iterate for (const auto& line : lines) { std::cout << line.content << "\n"; }
Public Types
-
using Iterator = LineIterator<IndexedFileLineIterator>¶
Public Functions
-
inline explicit IndexedFileLineIterator(const IndexedFileLineIteratorConfig &config)¶
Construct iterator from config object.
- Parameters:
config – Configuration object with builder pattern
-
inline bool has_next() const¶
Check if more lines are available.
-
inline Line next()¶
Get the next line (zero-copy).
- Throws:
std::runtime_error – if no more lines available
- Returns:
Line object with string_view content (valid until next call)
-
inline std::size_t current_position() const¶
Get the current position.
Interpretation depends on range_type:
LINE_RANGE: Current line number (1-based)
BYTE_RANGE: Current byte offset
-
inline std::size_t total_count() const¶
Get total count in this range.
Interpretation depends on range_type:
LINE_RANGE: Number of lines
BYTE_RANGE: Number of bytes
-
inline dftracer::utils::utilities::reader::internal::RangeType range_type() const¶
Get the range type being used.
-
inline std::shared_ptr<dftracer::utils::utilities::reader::internal::Reader> get_reader() const¶
Get the underlying Reader.
-
class IndexedFileLineIteratorConfig¶
Configuration for IndexedFileLineIterator.
The iterator automatically selects the appropriate stream type:
LINE_RANGE: Uses StreamType::LINE
BYTE_RANGE: Uses StreamType::LINE_BYTES
Usage:
// Option 1: From file path auto config = IndexedFileLineIteratorConfig() .with_file("file.gz", "file.gz.idx") .with_line_range(1, 100) .with_buffer_size(128 * 1024); // Option 2: From existing reader auto config = IndexedFileLineIteratorConfig() .with_reader(reader) .with_line_range(1, 100); IndexedFileLineIterator iter(config);
Public Functions
-
IndexedFileLineIteratorConfig() = default¶
-
inline IndexedFileLineIteratorConfig &with_file(const std::string &file_path, const std::string &index_path = "")¶
-
inline IndexedFileLineIteratorConfig &with_range_type(dftracer::utils::utilities::reader::internal::RangeType type)¶
-
inline IndexedFileLineIteratorConfig &with_line_range(std::size_t start_line, std::size_t end_line)¶
-
inline IndexedFileLineIteratorConfig &with_byte_range(std::size_t start_bytes, std::size_t end_bytes)¶
-
inline IndexedFileLineIteratorConfig &with_buffer_size(std::size_t size)¶
-
inline std::shared_ptr<dftracer::utils::utilities::reader::internal::Reader> reader() const¶
-
inline dftracer::utils::utilities::reader::internal::RangeType range_type() const¶
-
inline std::size_t start() const¶
-
inline std::size_t end() const¶
-
inline std::size_t buffer_size() const¶
-
class PlainFileBytesIterator¶
Public Types
-
using Iterator = LineIterator<PlainFileBytesIterator>¶
-
using Iterator = LineIterator<PlainFileBytesIterator>¶
-
class PlainFileLineIterator¶
Lazy, single‑buffer line‑by‑line iterator over plain text files.
Reads directly from std::ifstream without loading the whole file. Uses a single string buffer; the string_view returned by next() remains valid until the next call to next().
Usage:
PlainFileLineIterator it("data.txt"); while (it.has_next()) { Line line = it.next(); process(line.content); }
Public Types
-
using Iterator = LineIterator<PlainFileLineIterator>¶
Public Functions
-
inline explicit PlainFileLineIterator(std::string file_path)¶
-
inline PlainFileLineIterator(std::string file_path, std::size_t start_line, std::size_t end_line)¶
-
inline bool has_next() const¶
-
inline std::size_t current_position() const¶
-
inline const std::string &get_file_path() const¶
-
using Iterator = LineIterator<PlainFileLineIterator>¶