-
Notifications
You must be signed in to change notification settings - Fork 666
add support for experimental ids #7667
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?
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. |
📝 PRs merging into main branchOur main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released. |
7b60d7c to
86fa294
Compare
| while (buffer.hasRemaining()) { | ||
| int length = buffer.getInt(); // Read the "Header" first | ||
| byte[] row = new byte[length]; | ||
| buffer.get(row); // Read exactly that many bytes |
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.
Am I missing something? The docs say that get(int) will get you 1 byte at a given index https://developer.android.com/reference/java/nio/ByteBuffer#get(int)
|
|
||
| while (buffer.hasRemaining()) { | ||
| int length = buffer.getInt(); // Read the "Header" first | ||
| byte[] row = new byte[length]; |
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.
Check that the buffer has enough bytes left to read
| } | ||
| } | ||
|
|
||
| private List<byte[]> deFlattenBlob(byte[] flatBlob) { |
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.
We haven't being doing it consistently, but could you make this @NonNull ?
| return rows; | ||
| } | ||
|
|
||
| private byte[] flattenListBlob(List<byte[]> blob) { |
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.
We haven't being doing it consistently, but could you make this @NonNull ?
| if (blob == null) return null; | ||
|
|
||
| byte[][] input = blob.toArray(new byte[0][]); | ||
| int metadataSize = input.length * 4; |
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.
add a comment describing that this is for the "integer" header
| @SuppressWarnings("mutable") | ||
| @Nullable | ||
| public abstract byte[] getEncryptedBlob(); | ||
| public abstract List<String> getEncryptedBlob(); |
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.
is this breaking?
| if (eventInternal.getExperimentIdsEncryptedList() != null) { | ||
| List<String> encodedListByteData = | ||
| encodeListByteData(eventInternal.getExperimentIdsEncryptedList()); | ||
| if (eventInternal.getExperimentIdsEncrypted() != null) { | ||
| encodedListByteData.add( | ||
| Base64.encodeToString(eventInternal.getExperimentIdsEncrypted(), Base64.NO_WRAP)); | ||
| } | ||
| builder.setEncryptedBlob(encodedListByteData); | ||
| } else if (eventInternal.getExperimentIdsEncrypted() != null) { | ||
| builder.setEncryptedBlob( | ||
| encodeListByteData(List.of(eventInternal.getExperimentIdsEncrypted()))); |
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.
While this is correct, I'm thinking if there's a way to make it less complex to read. What about something like (pseudo-code)
List<encryptedExperimentId> experiments = new List<>()
if (encryptedList != null) experiments.addAll(encryptedList)
if (encrypted !=null) experiments.add(encrypted)
if (!experiments.empty()) builder.setEncryptedBlob(...)
| ExperimentIds.builder() | ||
| .setClearBlob("blob".getBytes(StandardCharsets.UTF_8)) | ||
| .setEncryptedBlob("encrypted blob".getBytes(StandardCharsets.UTF_8)) | ||
| .setEncryptedBlob( |
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.
do we have tests that don't use the list? for backward compatibility ?
| .setPseudonymousId(PSEUDONYMOUS_ID) | ||
| .setExperimentIdsClear(EXPERIMENT_IDS_CLEAR.toByteArray()) | ||
| .setExperimentIdsEncrypted(EXPERIMENT_IDS_ENCRYPTED.toByteArray()) | ||
| .setExperimentIdsEncryptedList( |
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.
do we have one without the list? for backwards compatibility ?
| new EncodedPayload(JSON_ENCODING, "Hello".getBytes(Charset.defaultCharset()))) | ||
| .addMetadata("key1", "value1") | ||
| .addMetadata("key2", "value2") | ||
| .setExperimentIdsEncryptedList(List.of("encrypted blob".getBytes(StandardCharsets.UTF_8))) |
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.
do we have one with a single element?
This PR does the following