gcs: Standardize serialization on a single format. #1851
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the filters provide two different serialization formats per version. The first is the raw filter bytes without the number of items in its data set and is implemented by the
Bytes
andFromBytesV1
functions. The second includes that information and is implemented by theNBytes
andFromNBytesV1
functions.In practice, the ability to serialize the filter independently from the number of items in its data set is not very useful since that information is required to be able to query the filter and, unlike the other parameters which are fixed (e.g. false positive rate and key), the number of items varies per filter. For this reason, all usage in practice calls
NBytes
andFromNBytesV1
.Consequently, this simplifies the API for working with filters by standardizing on a single serialization format per filter version which includes the number of items in its data set.
In order to accomplish this, the current
Bytes
andFromBytesV1
functions are removed and theNBytes
andFromNBytesV1
functions are renamed to take their place.This also updates all tests and callers in the repo accordingly.