simdjson 4.6.4
Ridiculously Fast JSON
Loading...
Searching...
No Matches
simdjson::SIMDJSON_IMPLEMENTATION::ondemand::document_stream Class Reference

A forward-only stream of documents. More...

#include <document_stream.h>

Classes

class  iterator
 

Public Types

using iterator = document_stream::iterator
 

Public Member Functions

simdjson_inline document_stream () noexcept
 Construct an uninitialized document_stream.
 
simdjson_inline document_stream (document_stream &&other) noexcept=default
 Move one document_stream to another.
 
simdjson_inline document_streamoperator= (document_stream &&other) noexcept=default
 Move one document_stream to another.
 
size_t size_in_bytes () const noexcept
 Returns the input size in bytes.
 
size_t truncated_bytes () const noexcept
 After iterating through the stream, this method returns the number of bytes that were not parsed at the end of the stream.
 
simdjson_inline iterator begin () noexcept
 Start iterating the documents in the stream.
 
simdjson_inline iterator end () noexcept
 The end of the stream, for iterator comparison purposes.
 

Detailed Description

A forward-only stream of documents.

Produced by parser::iterate_many.

Definition at line 79 of file document_stream.h.

Member Typedef Documentation

◆ iterator

Constructor & Destructor Documentation

◆ document_stream()

simdjson_inline simdjson::SIMDJSON_IMPLEMENTATION::ondemand::document_stream::document_stream ( )
noexcept

Construct an uninitialized document_stream.

auto error = parser.iterate_many(json).get(docs);
simdjson_result< document_stream > iterate_many(const uint8_t *buf, size_t len, size_t batch_size=DEFAULT_BATCH_SIZE, bool allow_comma_separated=false) noexcept
Parse a buffer containing many JSON documents.
Definition parser-inl.h:136

Definition at line 117 of file document_stream-inl.h.

◆ ~document_stream()

simdjson_inline simdjson::SIMDJSON_IMPLEMENTATION::ondemand::document_stream::~document_stream ( )
noexcept

Definition at line 130 of file document_stream-inl.h.

Member Function Documentation

◆ begin()

simdjson_inline document_stream::iterator simdjson::SIMDJSON_IMPLEMENTATION::ondemand::document_stream::begin ( )
noexcept

Start iterating the documents in the stream.

Definition at line 198 of file document_stream-inl.h.

◆ end()

simdjson_inline document_stream::iterator simdjson::SIMDJSON_IMPLEMENTATION::ondemand::document_stream::end ( )
noexcept

The end of the stream, for iterator comparison purposes.

Definition at line 204 of file document_stream-inl.h.

◆ size_in_bytes()

size_t simdjson::SIMDJSON_IMPLEMENTATION::ondemand::document_stream::size_in_bytes ( ) const
inlinenoexcept

Returns the input size in bytes.

Definition at line 137 of file document_stream-inl.h.

◆ truncated_bytes()

size_t simdjson::SIMDJSON_IMPLEMENTATION::ondemand::document_stream::truncated_bytes ( ) const
inlinenoexcept

After iterating through the stream, this method returns the number of bytes that were not parsed at the end of the stream.

If truncated_bytes() differs from zero, then the input was truncated maybe because incomplete JSON documents were found at the end of the stream. You may need to process the bytes in the interval [size_in_bytes()-truncated_bytes(), size_in_bytes()).

You should only call truncated_bytes() after streaming through all documents, like so:

document_stream stream = parser.iterate_many(json,window); for(auto & doc : stream) { // do something with doc } size_t truncated = stream.truncated_bytes();

Definition at line 141 of file document_stream-inl.h.


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