viirya commented on a change in pull request #26935:
URL: https://github.com/apache/spark/pull/26935#discussion_r491747706



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala
##########
@@ -81,6 +74,42 @@ trait StateStore {
     iterator()
   }
 
+  /**
+   * Return an iterator containing all the key-value pairs in the StateStore. 
Implementations must
+   * ensure that updates (puts, removes) can be made while iterating over this 
iterator.
+   */
+  def iterator(): Iterator[UnsafeRowPair]
+
+  /**
+   * Clean up the resource.
+   *
+   * The method name is to respect backward compatibility on [[StateStore]].
+   */
+  def abort(): Unit
+}
+
+/**
+ * Base trait for a versioned key-value store. Each instance of a `StateStore` 
represents a specific
+ * version of state data, and such instances are created through a 
[[StateStoreProvider]].
+ *
+ * Unlike [[ReadOnlyStateStore]], `abort` method may not be called if the 
`commit` method succeeds
+ * to commit the change. (`hasCommitted` returns `true`.) Otherwise, `abort` 
method will be called.
+ * Implementation should deal with resource cleanup in both methods, but also 
need to guard with
+ * double resource cleanup.
+ */
+trait StateStore extends ReadOnlyStateStore {

Review comment:
       So if we need to check if an instance of state store is read-only, we 
can only check if it is `StateStore` but not `ReadOnlyStateStore`? I agree that 
enforcing read-only behavior at interface level sounds good. Just it looks a 
bit weird that an instance of `StateStore` is also `ReadOnlyStateStore`.
   
   Maybe `ReadStateStore` or `StateStoreForRead` instead of 
`ReadOnlyStateStore`? Just suggestion. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to