shunping commented on code in PR #30317:
URL: https://github.com/apache/beam/pull/30317#discussion_r1638715584
##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/FnApiStateAccessor.java:
##########
@@ -600,8 +603,73 @@ public <KeyT, ValueT> MultimapState<KeyT, ValueT>
bindMultimap(
@Override
public <T> OrderedListState<T> bindOrderedList(
String id, StateSpec<OrderedListState<T>> spec, Coder<T> elemCoder) {
- throw new UnsupportedOperationException(
- "TODO: Add support for a sorted-list state to the Fn API.");
+ return (OrderedListState<T>)
+ stateKeyObjectCache.computeIfAbsent(
+ createOrderedListUserStateKey(id),
+ new Function<StateKey, Object>() {
+ @Override
+ public Object apply(StateKey key) {
+ return new OrderedListState<T>() {
+ private final OrderedListUserState<T> impl =
+ createOrderedListUserState(key, elemCoder);
+
+ @Override
+ public void clear() {
+ impl.clear();
+ }
+
+ @Override
+ public void add(TimestampedValue<T> value) {
Review Comment:
That's a good point. I think the same problem occurred in
https://github.com/apache/beam/blob/fd5b1de4f1daaa1c3fb930593f9b27062412d38b/runners/core-java/src/main/java/org/apache/beam/runners/core/InMemoryStateInternals.java#L653
Let me open a bug to fix both implementations after this PR.
--
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]