Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public function extract(FlowContext $context): Generator
$enclosure = $this->enclosure ?? $option->enclosure;
$escape = $this->escape ?? $option->escape;
$uri = $stream->path()->uri();
$partitions = $stream->path()->partitions();

$headers = [];
$headersCount = 0;
$streamUri = $shouldPutInputIntoRows ? $uri : null;
$partitions = $stream->path()->partitions();

$csvLineReader = new CSVLineReader($enclosure, $this->charactersReadInLine, $this->removeBOM);
$rowNormalizer = new CSVRowNormalizer($this->emptyToNull);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,10 @@ public function extract(FlowContext $context): Generator
$offset = $this->offset ?? 1;

foreach ($context->streams()->list($this->path, $this->filter()) as $stream) {
$partitions = $stream->path()->partitions();

foreach ($this->extractRows($stream, $headers, $offset) as $row) {
$signal = yield array_to_rows(
$row,
$context->entryFactory(),
$stream->path()->partitions(),
schema: $this->schema,
);
$signal = yield array_to_rows($row, $context->entryFactory(), $partitions, $this->schema);

$this->incrementReturnedRows();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function extract(FlowContext $context): Generator

foreach ($context->streams()->list($this->path, $this->filter()) as $stream) {
$uri = $stream->path()->uri();
$partitions = $stream->path()->partitions();

/**
* @var array<string, mixed> $rowData
Expand All @@ -66,12 +67,7 @@ public function extract(FlowContext $context): Generator
continue;
}

$signal = yield array_to_rows(
[$row],
$context->entryFactory(),
$stream->path()->partitions(),
$this->schema,
);
$signal = yield array_to_rows([$row], $context->entryFactory(), $partitions, $this->schema);

$this->incrementReturnedRows();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function extract(FlowContext $context): Generator

foreach ($context->streams()->list($this->path, $this->filter()) as $stream) {
$uri = $stream->path()->uri();
$partitions = $stream->path()->partitions();

foreach ($stream->readLines() as $jsonLine) {
/**
Expand All @@ -81,12 +82,7 @@ public function extract(FlowContext $context): Generator
continue;
}

$signal = yield array_to_rows(
[$row],
$context->entryFactory(),
$stream->path()->partitions(),
$this->schema,
);
$signal = yield array_to_rows([$row], $context->entryFactory(), $partitions, $this->schema);

$this->incrementReturnedRows();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ public function extract(FlowContext $context): Generator

foreach ($this->readers($context) as $fileData) {
$fileRows = $fileData['file']->metadata()->rowsNumber();
$flowSchema = $this->schemaConverter->toFlow($fileData['file']->schema());
$uri = $fileData['stream']->path()->uri();

if (count($this->columns)) {
$flowSchema = $flowSchema->keep(...$this->columns);
}

if ($fileOffset > $fileRows) {
$fileData['stream']->close();
Expand All @@ -83,6 +77,14 @@ public function extract(FlowContext $context): Generator
continue;
}

$flowSchema = $this->schemaConverter->toFlow($fileData['file']->schema());

if (count($this->columns)) {
$flowSchema = $flowSchema->keep(...$this->columns);
}

$uri = $fileData['stream']->path()->uri();

foreach ($fileData['file']->values($this->columns, $this->limit(), $fileOffset) as $row) {
$entries = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function extract(FlowContext $context): Generator

foreach ($context->streams()->list($this->path, $this->filter()) as $stream) {
$uri = $stream->path()->uri();
$partitions = $stream->path()->partitions();

foreach ($stream->readLines() as $rowData) {
if ($shouldPutInputIntoRows) {
Expand All @@ -46,7 +47,7 @@ public function extract(FlowContext $context): Generator
$row = [['text' => rtrim($rowData)]];
}

$signal = yield array_to_rows($row, $context->entryFactory(), $stream->path()->partitions());
$signal = yield array_to_rows($row, $context->entryFactory(), $partitions);

$this->incrementReturnedRows();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public function extract(FlowContext $context): Generator

foreach ($context->streams()->list($this->path, $this->filter()) as $stream) {
$uri = $stream->path()->uri();
$partitions = $stream->path()->partitions();

foreach ($stream->iterate($this->bufferSize) as $chunk) {
if (!xml_parse($this->parser(), $chunk)) {
Expand All @@ -130,12 +131,7 @@ public function extract(FlowContext $context): Generator
$rowData['_input_file_uri'] = $uri;
}

$signal = yield array_to_rows(
$rowData,
$context->entryFactory(),
$stream->path()->partitions(),
$this->schema,
);
$signal = yield array_to_rows($rowData, $context->entryFactory(), $partitions, $this->schema);

$this->incrementReturnedRows();

Expand Down
Loading