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

Feature/plat 1613 webstream #58

Merged
merged 19 commits into from
Jun 24, 2022
Merged

Feature/plat 1613 webstream #58

merged 19 commits into from
Jun 24, 2022

Conversation

ivanovSPvirtru
Copy link
Contributor

No description provided.

@ivanovSPvirtru ivanovSPvirtru requested a review from a team as a code owner June 10, 2022 11:35
# Conflicts:
#	lib/facade/FileClient.ts
#	lib/tdf3/src/client/builders.js
#	lib/tdf3/src/crypto/node-crypto-service.ts
#	lib/tdf3/src/utils/chunkers.ts
@ivanovSPvirtru ivanovSPvirtru changed the title Feature/plat 1613 stream Feature/plat 1613 webstream Jun 24, 2022
@github-actions
Copy link

If these changes look good, signoff on them with:

git pull && git commit --amend --signoff && git push --force-with-lease origin

If they aren't any good, please remove them with:

git pull && git reset --hard HEAD~1 && git push --force-with-lease origin

Signed-off-by: sivanov <sivanov.ctr@virtru.com>
@ivanovSPvirtru ivanovSPvirtru force-pushed the feature/PLAT-1613-stream branch from 4e527ed to fdbce5d Compare June 24, 2022 09:53
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 18 Code Smells

No Coverage information No Coverage information
0.3% 0.3% Duplication

Copy link
Member

@dmihalcik-virtru dmihalcik-virtru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can take or leave my comment on the toBuffer method


while (!done) {
const result = await reader.read();
if (result.value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I'm rabbit holing on this. This is a O(n²) algorithm, so I'd rather not do this. An ideal algorithm is probably something like https://hg.openjdk.java.net/jdk8/jdk8/jdk/file/tip/src/share/classes/java/util/ArrayList.java#l237.

However, it roughly the same worst case space performance as just creating a list so I'm inclined to do that instead. This would then be two pass algorithm - first build a standard array of TypedArrays and count the bytes, then allocate memory and assign in a second loop

Alternatively if you want to save a bit of memory you can try some hybrid or space aware approach.

Also does it really need to be a Buffer buffer instead of something that implements the Buffer interface? An alternative is to just implement a 'fractured' buffer but I'm guessing that isn't something we can entertain at the moment

@ivanovSPvirtru ivanovSPvirtru merged commit b4581e9 into main Jun 24, 2022
@ivanovSPvirtru ivanovSPvirtru deleted the feature/PLAT-1613-stream branch June 24, 2022 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants