gemini-code-assist[bot] commented on PR #37629: URL: https://github.com/apache/beam/pull/37629#issuecomment-3917477943
## Summary of Changes Hello @hnnsgstfssn, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Apache Beam Go SDK by introducing `OrderedListState`, a crucial state primitive that was previously available in Java and Python SDKs. This addition allows Go developers to manage timestamped, ordered collections of data per key within stateful DoFns, bringing the Go SDK closer to feature parity with other language SDKs and enabling more complex stateful processing patterns. ### Highlights * **OrderedListState support in Go SDK**: Added the `OrderedList[T]` state type to the Go SDK's stateful DoFn API, enabling operations like Add, Read, ReadRange, Clear, and ClearRange using `int64` sort keys. * **Plumbing and Integration**: Integrated `OrderedListState` through the `exec` package, `graphx` translation, and the harness state manager, including the `beam:coder:ordered_list_state:v1` URN. * **Examples and Tests**: Included a new example pipeline demonstrating `OrderedListState` usage, a snippet for documentation, and comprehensive unit and integration tests to validate the new functionality. 🧠**New Feature in Public Preview:** You can now enable **Memory** to help **Gemini Code Assist** learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. **Click [here](https://codeassist.google/code-review/login) to enable Memory in your admin console.** <details> <summary><b>Changelog</b></summary> * **CHANGES.md** * Added an entry for OrderedListState support in the Go SDK. * **sdks/go/examples/ordered_list_state/ordered_list_state.go** * Added a new example demonstrating the use of OrderedListState to accumulate and summarize timestamped events. * **sdks/go/examples/snippets/04transforms.go** * Added a new code snippet illustrating OrderedListState usage, including Add, ReadRange, and ClearRange operations. * **sdks/go/pkg/beam/core/graph/fn.go** * Updated the `validateState` function to recognize `state.TypeOrderedList` as a supported state type. * **sdks/go/pkg/beam/core/runtime/exec/data.go** * Extended the `StateReader` interface with methods for `OpenOrderedListUserStateReader`, `OpenOrderedListUserStateAppender`, and `OpenOrderedListUserStateClearer`. * **sdks/go/pkg/beam/core/runtime/exec/sideinput_test.go** * Added no-op implementations for the new OrderedListState reader, appender, and clearer methods in `testStateReader`. * **sdks/go/pkg/beam/core/runtime/exec/translate.go** * Modified the `makeLink` function to handle `OrderedListSpec` when translating state specifications. * **sdks/go/pkg/beam/core/runtime/exec/userstate.go** * Imported `math` and `protowire` packages. * Added `initialOrderedListByKey` to `stateProvider` to cache initial ordered list state values. * Implemented `ReadOrderedListState`, `WriteOrderedListState`, and `ClearOrderedListState` methods in `stateProvider`. * Added helper functions `getOrderedListReader`, `getOrderedListAppender`, and `getOrderedListClearer`. * Implemented `encodeOrderedListEntry` and `decodeOrderedListEntry` for serializing and deserializing ordered list entries. * Initialized `initialOrderedListByKey` in `userStateAdapter.NewStateProvider`. * **sdks/go/pkg/beam/core/runtime/exec/userstate_test.go** * Initialized `initialOrderedListByKey` in `buildStateProvider`. * **sdks/go/pkg/beam/core/runtime/graphx/translate.go** * Defined new URNs `URNOrderedListUserState` and `URNOrderedListStateProtocol`. * Added `URNOrderedListStateProtocol` to the list of Go capabilities. * Extended the `addMultiEdge` function to generate `StateSpec_OrderedListSpec` for `state.TypeOrderedList`. * **sdks/go/pkg/beam/core/runtime/harness/statemgr.go** * Implemented `OpenOrderedListUserStateReader`, `OpenOrderedListUserStateAppender`, and `OpenOrderedListUserStateClearer` in `ScopedStateReader`. * Added factory functions `newOrderedListUserStateReader`, `newOrderedListUserStateWriter`, and `newOrderedListUserStateClearer` for creating state key readers/writers. * **sdks/go/pkg/beam/core/state/state.go** * Imported `cmp`, `math`, and `slices` packages. * Defined `TypeOrderedList` as a new `TypeEnum`. * Introduced `OrderedListEntry` and `TimestampedValue` structs for ordered list elements. * Defined the `OrderedList[T]` struct with `Add`, `Read`, `ReadRange`, `Clear`, and `ClearRange` methods. * Implemented `StateKey`, `KeyCoderType`, `CoderType`, and `StateType` methods for `OrderedList[T]`. * Added `MakeOrderedListState` factory function. * **sdks/go/pkg/beam/core/state/state_test.go** * Imported the `math` package. * Added `initialOrderedListState` to `fakeProvider`. * Implemented `ReadOrderedListState`, `WriteOrderedListState`, and `ClearOrderedListState` methods in `fakeProvider`. * Added comprehensive unit tests for `OrderedListRead`, `OrderedListAdd`, `OrderedListClear`, and `OrderedListClearRange`. * **sdks/go/test/integration/primitives/state.go** * Registered `orderedListStateFn` for DoFn processing. * Added `orderedListStateFn` struct and its `ProcessElement` method to demonstrate ordered list state. * Added `OrderedListStateParDo` integration test function. * **sdks/go/test/integration/primitives/state_test.go** * Added `TestOrderedListState` to run the `OrderedListStateParDo` integration test. * **website/www/site/content/en/documentation/programming-guide.md** * Added a code sample for `ordered_list_state` to the programming guide documentation. </details> <details> <summary><b>Using Gemini Code Assist</b></summary> <br> The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips. <b>Invoking Gemini</b> You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page. Feature | Command | Description --- | --- | --- Code Review | `/gemini review` | Performs a code review for the current pull request in its current state. Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state. Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. Help | `/gemini help` | Displays a list of available commands. <b>Customization</b> 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 `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). <b>Limitations & Feedback</b> Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: 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](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG). <b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b> </details> [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
