ibessonov commented on code in PR #960:
URL: https://github.com/apache/ignite-3/pull/960#discussion_r935311285
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/MvPartitionStorage.java:
##########
@@ -31,6 +33,43 @@
* <p>Each MvPartitionStorage instance represents exactly one partition.
*/
public interface MvPartitionStorage extends AutoCloseable {
+ /**
+ * Closure for executing write operations on the storage.
+ *
+ * @param <E> Type of exception that could be thrown within a closure.
+ * @param <V> Type of the result returned from the closure.
+ */
+ @SuppressWarnings("PublicInnerClass")
+ @FunctionalInterface
+ interface DataAccessClosure<E extends Exception, V> {
+ V execute() throws E, StorageException;
+ }
+
+ /**
+ * Executes {@link DataAccessClosure} atomically, maening that partial
result of the incompleted closure will never be written to a
+ * physical device, thus guaranteeing data consistency after restart.
Simply runs the closure in case of a volatile storage.
+ *
+ * @param closure Data access closure to be executed.
+ * @param <E> Type of exception that could be thrown within a closure.
+ * @param <V> Type of the result returned from the closure.
+ * @return Closure result.
+ * @throws E If closure thrown exception.
+ * @throws StorageException If failed to write data to the storage.
+ */
+ default <E extends Exception, V> V runConsistently(DataAccessClosure<E, V>
closure) throws E, StorageException {
+ return closure.execute();
+ }
+
+ /**
+ * Flushes current state of the data or <i>the state from the nearest
future</i> to the storage. It means that the future can be
+ * completed with the data that has not been written yet. This feature
allows implementing a batch flush for several partitions at once.
+ *
+ * @return Future that's completed when flushing of the data is completed.
+ */
+ default CompletionStage<Void> flush() {
Review Comment:
Yes, that was generated y Idea I guess
--
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]