sijie commented on a change in pull request #1587: [WIP] Add key/value 
operations in StateContext

 File path: 
 @@ -18,15 +18,61 @@
 package org.apache.pulsar.functions.instance.state;
+import java.nio.ByteBuffer;
 import java.util.concurrent.CompletableFuture;
  * A state context per function.
 public interface StateContext {
+    /**
+     * Increment the given <i>key</i> by the given <i>amount</i>.
+     *
+     * @param key key to increment
+     * @param amount the amount incremented
+     */
     void incr(String key, long amount);
+    /**
+     * Update the given <i>key</i> to the provide <i>value</i>.
+     *
+     * <p>NOTE: the put operation might or might not be applied directly to 
the global state until
+     * the state is flushed via {@link #flush()} at the completion of function 
+     *
+     * <p>The behavior of `PUT` is non-deterministic, if two function 
instances attempt to update
+     * same key around the same time, there is no guarantee which update will 
be the final result.
+     * That says, if you attempt to get amount via {@link #getAmount(String)}, 
increment the amount
+     * based on the function computation logic, and update the computed amount 
back. one update will
+     * overwrite the other update. For this case, you are encouraged to use 
{@link #incr(String, long)}
+     * instead.
+     *
+     * @param key key to update.
+     * @param value value to update
+     */
+    void put(String key, ByteBuffer value);
 Review comment:
   will make them consistent

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

Reply via email to