Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace hashing algorithm from sha256 to xxh128 #594

Merged
merged 1 commit into from
Oct 16, 2023
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
2 changes: 1 addition & 1 deletion src/core/etl/src/Flow/ETL/Cache/LocalFilesystemCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ public function read(string $id) : \Generator

private function cachePath(string $id) : string
{
return \rtrim($this->path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . \hash('sha256', $id);
return \rtrim($this->path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . \hash('xxh128', $id);
}
}
4 changes: 2 additions & 2 deletions src/core/etl/src/Flow/ETL/GroupBy.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ private function hash(array $values) : string
/** @var mixed $value */
foreach ($values as $value) {
if ($value === null) {
$stringValues[] =\hash('sha256', 'null');
$stringValues[] =\hash('xxh128', 'null');
} elseif (\is_scalar($value)) {
$stringValues[] = (string) $value;
}
}

return \hash('sha256', \implode('', $stringValues));
return \hash('xxh128', \implode('', $stringValues));
}
}
5 changes: 2 additions & 3 deletions src/core/etl/tests/Flow/ETL/Tests/Integration/FlowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Flow\ETL\Tests\Integration;

use function Flow\ETL\DSL\col;
use function Flow\ETL\DSL\ref;
use Flow\ETL\Cache\PSRSimpleCache;
use Flow\ETL\Config;
Expand All @@ -27,7 +26,7 @@ public function test_etl_cache() : void

$cacheContent = \array_values(\array_diff(\scandir($this->cacheDir), ['..', '.']));

$this->assertContains(\hash('sha256', 'test_etl_cache'), $cacheContent);
$this->assertContains(\hash('xxh128', 'test_etl_cache'), $cacheContent);
}

public function test_etl_psr_cache() : void
Expand Down Expand Up @@ -84,7 +83,7 @@ public function test_etl_sort_by_in_memory() : void
->id($id = 'test_etl_sort_by_in_memory')
->cache($cacheSpy = new CacheSpy(Config::default()->cache()))
)->extract(new AllRowTypesFakeExtractor($rowsets = 20, $rows = 2))
->sortBy(col('id'))
->sortBy(ref('id'))
->fetch();

$cache = \array_diff(\scandir($this->cacheDir), ['..', '.']);
Expand Down
Loading