From f20483f3759769be8349020de23f5c890c5685e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=BDborn=C3=BD=20Adam?= Date: Thu, 24 Nov 2022 21:22:09 +0100 Subject: [PATCH] Fixed memory leak --- src/Export.php | 1 - src/Extractor.php | 3 +-- src/Parse.php | 2 +- src/Parser/Mapping.php | 6 +++--- src/Parser/ParserInterface.php | 2 +- src/Parser/Raw.php | 8 ++++++-- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Export.php b/src/Export.php index ef91928..9e8c976 100644 --- a/src/Export.php +++ b/src/Export.php @@ -6,7 +6,6 @@ use Generator; use Keboola\Component\UserException; -use Keboola\Utils\Exception\JsonDecodeException; use MongoExtractor\Config\ExportOptions; use Nette\Utils\Strings; use Retry\BackOff\ExponentialBackOffPolicy; diff --git a/src/Extractor.php b/src/Extractor.php index df5c0ed..162cdb6 100644 --- a/src/Extractor.php +++ b/src/Extractor.php @@ -13,7 +13,6 @@ use MongoDB\Driver\Manager; use MongoExtractor\Config\Config; use MongoExtractor\Config\ExportOptions; -use MongoExtractor\Config\OldConfigDefinition; use Retry\BackOff\ExponentialBackOffPolicy; use Retry\Policy\SimpleRetryPolicy; use Retry\RetryProxy; @@ -139,7 +138,7 @@ private function createSshTunnel(array $sshOptions): void } /** - * @param array|string|null}> $manifestsData + * @param array|string|null}> $manifestsData */ protected function generateManifests(array $manifestsData, ExportOptions $exportOptions): void { diff --git a/src/Parse.php b/src/Parse.php index 0351ace..87d9b35 100644 --- a/src/Parse.php +++ b/src/Parse.php @@ -30,7 +30,7 @@ public function __construct( /** * Parses exported json and creates .csv and .manifest files - * @return array|string}> + * @return array|string}> * @throws \Keboola\Csv\Exception * @throws \Keboola\Csv\InvalidArgumentException */ diff --git a/src/Parser/Mapping.php b/src/Parser/Mapping.php index e6474d5..a619ec7 100644 --- a/src/Parser/Mapping.php +++ b/src/Parser/Mapping.php @@ -25,7 +25,7 @@ class Mapping implements ParserInterface private string $path; private string $name; private Filesystem $filesystem; - /** @var array|string}> */ + /** @var array|string}> */ private array $manifestData = []; /** @@ -81,7 +81,7 @@ public function parse(array $data): void throw new Exception('Failed write to file "' . $outputCsv . '"'); } - $this->manifestData[] = [ + $this->manifestData[$outputCsv] = [ 'path' => $outputCsv . '.manifest', 'primaryKey' => $file->getPrimaryKey(true), ]; @@ -105,7 +105,7 @@ protected function prependHeader(Table $file, string &$content): void } /** - * @return array|string}> + * @return array|string}> */ public function getManifestData(): array { diff --git a/src/Parser/ParserInterface.php b/src/Parser/ParserInterface.php index 67a1775..56ed998 100644 --- a/src/Parser/ParserInterface.php +++ b/src/Parser/ParserInterface.php @@ -9,6 +9,6 @@ interface ParserInterface /** @param array $data */ public function parse(array $data): void; - /** @return array|string}> */ + /** @return array|string}> */ public function getManifestData(): array; } diff --git a/src/Parser/Raw.php b/src/Parser/Raw.php index 7e53068..282385b 100644 --- a/src/Parser/Raw.php +++ b/src/Parser/Raw.php @@ -72,10 +72,14 @@ private function writerRowToOutputFile(object $item): void } /** - * @return array|string}> + * @return array|string}> */ public function getManifestData(): array { - return [['path' => $this->filename . '.manifest', 'primaryKey' => $this->setIdAsPrimaryKey ? ['id']: []]]; + return [ + $this->filename => [ + 'path' => $this->filename . '.manifest', 'primaryKey' => $this->setIdAsPrimaryKey ? ['id']: [], + ], + ]; } }