-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(storage): adding disabling option for bidi reads #13506
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
base: main
Are you sure you want to change the base?
Changes from 22 commits
2db4acb
351729c
72af919
91e8f36
e67803a
a24e32a
5c3c71a
dc264f8
6a02a24
4b3c67e
1c1e08e
14c148b
31f5144
4e03119
13e89cb
78f32bd
d1723f2
9d44e29
a44d597
04396b2
36140bf
409d83a
99082c9
fa820aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -151,7 +151,7 @@ private AccumulatingRead( | |||||
| super(rangeSpec, retryContext, onCloseCallback); | ||||||
| this.readId = readId; | ||||||
| this.hasher = | ||||||
| (rangeSpec.begin() == 0 && !(hasher instanceof Hasher.NoOpHasher)) | ||||||
| (rangeSpec.begin() == 0) | ||||||
| ? new CumulativeHasher(hasher, 0, rangeSpec.maxLength()) | ||||||
| : hasher; | ||||||
| this.complete = SettableApiFuture.create(); | ||||||
|
|
@@ -284,7 +284,7 @@ static class StreamingRead extends BaseObjectReadSessionStreamRead<ScatteringByt | |||||
| super(rangeSpec, retryContext, onCloseCallback); | ||||||
| this.readId = new AtomicLong(readId); | ||||||
| this.hasher = | ||||||
| (rangeSpec.begin() == 0 && !(hasher instanceof Hasher.NoOpHasher)) | ||||||
| (rangeSpec.begin() == 0) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By removing the
Suggested change
References
|
||||||
| ? new CumulativeHasher(hasher, 0, rangeSpec.maxLength()) | ||||||
| : hasher; | ||||||
| this.closed = false; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ | |
| @BetaApi | ||
| @Immutable | ||
| public final class ReadAsChannel extends BaseConfig<ScatteringByteChannel, StreamingRead> { | ||
| static final ReadAsChannel INSTANCE = new ReadAsChannel(RangeSpec.all(), Hasher.enabled()); | ||
| static final ReadAsChannel INSTANCE = new ReadAsChannel(RangeSpec.all(), Hasher.readHasher()); | ||
|
|
||
| private final RangeSpec range; | ||
| private final Hasher hasher; | ||
|
|
@@ -97,7 +97,7 @@ public ReadAsChannel withRangeSpec(RangeSpec range) { | |
| */ | ||
| @BetaApi | ||
| boolean getCrc32cValidationEnabled() { | ||
| return Hasher.enabled().equals(hasher); | ||
| return !Hasher.noop().equals(hasher); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -111,7 +111,7 @@ boolean getCrc32cValidationEnabled() { | |
| */ | ||
| @BetaApi | ||
| ReadAsChannel withCrc32cValidationEnabled(boolean enabled) { | ||
| if (enabled && Hasher.enabled().equals(hasher)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is did required? |
||
| if (enabled && !Hasher.noop().equals(hasher)) { | ||
| return this; | ||
| } else if (!enabled && Hasher.noop().equals(hasher)) { | ||
| return this; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By removing the
!(hasher instanceof Hasher.NoOpHasher)check, aCumulativeHasheris now always allocated and wrapped around the delegate hasher whenrangeSpec.begin() == 0, even if checksum validation is disabled (i.e., whenhasheris aNoOpHasher). Keeping this check avoids unnecessary object allocation and overhead when checksumming is disabled.References