JsonFileReader implements SchemaSampler
The read of one listed file, for both the sample and the real read.
Interfaces
- SchemaSampler
Methods
- __construct() : mixed
- batches() : Generator<int, array<int, RawRowValues>>
- Abandoning the generator closes the source.
- chunks() : Generator<int, string>
- $first must be exactly $stream->read(self::CHUNK, 0) - the loop resumes at offset self::CHUNK.
- documentItems() : Generator<mixed, mixed>
- A 0-byte stream is no JSON text and yields nothing
- lineItems() : Generator<mixed, mixed>
- One line at a time, never re-split or re-joined, so a future byte-range unit stays alignable.
- sample() : Generator<int, RawRowValues>
- The pointer wrap and the empty-record skip live here and nowhere else, so the sample and the read see the same rows.
- samples() : Generator<int, Generator<int, RawRowValues>>
- $rowBudget is deliberately unused: sample() is lazy and SchemaInferrer stops advancing it.
Methods
__construct()
public
__construct(Filesystem $filesystem, JsonFormat $format, string|null $pointer, bool $pointerToEntryName, array<int, SourceFile> $sources) : mixed
Parameters
- $filesystem : Filesystem
- $format : JsonFormat
- $pointer : string|null
- $pointerToEntryName : bool
- $sources : array<int, SourceFile>
-
the extractor's materialised listing, already filtered, so filesToSniff counts filtered files; samples() and the extractor's own loop both walk it, which a Generator could not serve twice
batches()
Abandoning the generator closes the source.
public
batches(SourceFile $source, int<1, max> $batchSize) : Generator<int, array<int, RawRowValues>>
Parameters
- $source : SourceFile
- $batchSize : int<1, max>
Return values
Generator<int, array<int, RawRowValues>>chunks()
$first must be exactly $stream->read(self::CHUNK, 0) - the loop resumes at offset self::CHUNK.
public
chunks(SourceStream $stream, string $first) : Generator<int, string>
Parameters
- $stream : SourceStream
- $first : string
Return values
Generator<int, string>documentItems()
A 0-byte stream is no JSON text and yields nothing
public
documentItems(SourceStream $stream) : Generator<mixed, mixed>
A member is mixed, not an array: a document whose elements are scalars decodes to scalars, which reach
count() in sample() and raise a TypeError - bug b79.
Parameters
- $stream : SourceStream
Return values
Generator<mixed, mixed>lineItems()
One line at a time, never re-split or re-joined, so a future byte-range unit stays alignable.
public
lineItems(SourceStream $stream) : Generator<mixed, mixed>
Parameters
- $stream : SourceStream
Return values
Generator<mixed, mixed>sample()
The pointer wrap and the empty-record skip live here and nowhere else, so the sample and the read see the same rows.
public
sample(SourceFile $source) : Generator<int, RawRowValues>
Parameters
- $source : SourceFile
Return values
Generator<int, RawRowValues>samples()
$rowBudget is deliberately unused: sample() is lazy and SchemaInferrer stops advancing it.
public
samples(int $rowBudget) : Generator<int, Generator<int, RawRowValues>>
Parameters
- $rowBudget : int