Skip to content

Commit

Permalink
Tiny performance improvement on Path::partitions (#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech authored Jan 18, 2024
1 parent c8274e7 commit b112494
Show file tree
Hide file tree
Showing 26 changed files with 168 additions and 162 deletions.
4 changes: 2 additions & 2 deletions bin/flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

if ('' !== \Phar::running(false)) {
if ('' !== Phar::running(false)) {
require 'phar://flow.phar/vendor/autoload.php';
} else {
require __DIR__ . '/../vendor/autoload.php';
Expand Down Expand Up @@ -57,7 +57,7 @@ public function execute(InputInterface $input, OutputInterface $output) : int
$dataFrame->run();
}

} catch (\Exception $exception) {
} catch (Exception $exception) {
$style = new SymfonyStyle($input, $output);
$style->error($exception->getMessage());

Expand Down
99 changes: 47 additions & 52 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/data/orders_flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
$orders = \array_map(
static fn (int $i) : array => [
'order_id' => $faker->uuid,
'created_at' => $faker->dateTimeThisYear->format(\DateTimeInterface::RFC3339),
'updated_at' => $faker->dateTimeThisMonth->format(\DateTimeInterface::RFC3339),
'cancelled_at' => $faker->optional(0.1)->dateTimeThisMonth?->format(\DateTimeInterface::RFC3339),
'created_at' => $faker->dateTimeThisYear->format(DateTimeInterface::RFC3339),
'updated_at' => $faker->dateTimeThisMonth->format(DateTimeInterface::RFC3339),
'cancelled_at' => $faker->optional(0.1)->dateTimeThisMonth?->format(DateTimeInterface::RFC3339),
'total_price' => $faker->randomFloat(2, 0, 500),
'discount' => $faker->randomFloat(2, 0, 50),
'customer' => [
Expand Down
2 changes: 1 addition & 1 deletion examples/run_examples.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

try {
include $file->getRealPath();
} catch (\Exception $e) {
} catch (Exception $e) {
print "Example failed: {$e->getMessage()}\n";
}
}
2 changes: 1 addition & 1 deletion examples/topics/dataframe/partition_by.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function (int $i) : array {
for ($d = 0; $d < $maxItems; $d++) {
$data[] = [
'id' => Uuid::uuid4()->toString(),
'created_at' => (new \DateTimeImmutable('2020-01-01'))->add(new \DateInterval('P' . $i . 'D'))->setTime(\random_int(0, 23), \random_int(0, 59), \random_int(0, 59)),
'created_at' => (new DateTimeImmutable('2020-01-01'))->add(new DateInterval('P' . $i . 'D'))->setTime(\random_int(0, 23), \random_int(0, 59), \random_int(0, 59)),
'value' => \random_int(1, 1000),
];
}
Expand Down
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@
<directory name="src/lib/rdsl/src/Flow/RDSL/" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<RiskyTruthyFalsyComparison errorLevel="suppress" />
</issueHandlers>
</psalm>
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private function convert(Definition $definition) : array

if ($type === ListEntry::class) {
/** @var ListType $listType */
$listType = $definition->metadata()->get(Schema\FlowMetadata::METADATA_LIST_ENTRY_TYPE);
$listType = $definition->metadata()->get(FlowMetadata::METADATA_LIST_ENTRY_TYPE);
$listElement = $listType->element();

if ($listElement->type() instanceof ScalarType) {
Expand All @@ -72,7 +72,7 @@ private function convert(Definition $definition) : array

if ($type === Entry\MapEntry::class) {
/** @var MapType $mapType */
$mapType = $definition->metadata()->get(Schema\FlowMetadata::METADATA_MAP_ENTRY_TYPE);
$mapType = $definition->metadata()->get(FlowMetadata::METADATA_MAP_ENTRY_TYPE);

return match ($mapType->value()->type()->toString()) {
ScalarType::STRING => ['name' => $definition->entry()->name(), 'type' => ['type' => 'map', 'values' => \AvroSchema::STRING_TYPE]],
Expand Down Expand Up @@ -126,7 +126,7 @@ private function convert(Definition $definition) : array
'type' => \AvroSchema::ENUM_SCHEMA,
'symbols' => \array_map(
fn (\UnitEnum $e) => $e->name,
$definition->metadata()->get(Schema\FlowMetadata::METADATA_ENUM_CASES)
$definition->metadata()->get(FlowMetadata::METADATA_ENUM_CASES)
),
],
],
Expand All @@ -135,7 +135,7 @@ private function convert(Definition $definition) : array
Entry\BooleanEntry::class => ['name' => $definition->entry()->name(), 'type' => \AvroSchema::BOOLEAN_TYPE],
Entry\ArrayEntry::class => throw new RuntimeException("ArrayEntry entry can't be saved in Avro file, try convert it to ListEntry"),
Entry\DateTimeEntry::class => ['name' => $definition->entry()->name(), 'type' => 'long', \AvroSchema::LOGICAL_TYPE_ATTR => 'timestamp-micros'],
Entry\NullEntry::class => ['name' => $definition->entry()->name(), 'type' => \AvroSchema::NULL_TYPE],
NullEntry::class => ['name' => $definition->entry()->name(), 'type' => \AvroSchema::NULL_TYPE],
default => throw new RuntimeException($type . ' is not yet supported.')
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(string ...$entryNames)

public function create(Row $row) : Entry
{
return new Row\Entry\StringEntry(
return new Entry\StringEntry(
'id',
\hash(
$this->hashName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function create(RequestInterface $request) : Row\Entries
if (!empty($requestBodyContent)) {
switch ($requestType) {
case 'json':
if (\class_exists(\Flow\ETL\Row\Entry\JsonEntry::class)) {
if (\class_exists(Row\Entry\JsonEntry::class)) {
$requestBodyEntry = new Row\Entry\JsonEntry('request_body', (array) \json_decode($requestBodyContent, true, 512, JSON_THROW_ON_ERROR));
} else {
$requestBodyEntry = new Row\Entry\StringEntry('request_body', $requestBodyContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function create(ResponseInterface $response) : Row\Entries

switch ($responseType) {
case 'json':
if (\class_exists(\Flow\ETL\Row\Entry\JsonEntry::class)) {
if (\class_exists(Row\Entry\JsonEntry::class)) {
$responseBodyEntry = new Row\Entry\JsonEntry('response_body', (array) \json_decode($responseBodyContent, true, 512, JSON_THROW_ON_ERROR));
} else {
$responseBodyEntry = new Row\Entry\StringEntry('response_body', $responseBodyContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function to_meilisearch_bulk_update(
*/
function meilisearch_hits_to_rows() : MeilisearchPHP\HitsIntoRowsTransformer
{
return new \Flow\ETL\Adapter\Meilisearch\MeilisearchPHP\HitsIntoRowsTransformer();
return new MeilisearchPHP\HitsIntoRowsTransformer();
}

/**
Expand Down
Loading

0 comments on commit b112494

Please sign in to comment.