jeongyooneo commented on a change in pull request #5: [NEMO-27] Element Wise 
Block Write
URL: https://github.com/apache/incubator-nemo/pull/5#discussion_r188490297
 
 

 ##########
 File path: 
runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/data/block/Block.java
 ##########
 @@ -15,40 +15,62 @@
  */
 package edu.snu.nemo.runtime.executor.data.block;
 
+import edu.snu.nemo.common.exception.BlockFetchException;
+import edu.snu.nemo.common.exception.BlockWriteException;
 import edu.snu.nemo.runtime.common.data.KeyRange;
-import edu.snu.nemo.runtime.executor.data.NonSerializedPartition;
-import edu.snu.nemo.runtime.executor.data.SerializedPartition;
+import edu.snu.nemo.runtime.executor.data.partition.NonSerializedPartition;
+import edu.snu.nemo.runtime.executor.data.partition.SerializedPartition;
 
-import java.io.IOException;
 import java.io.Serializable;
-import java.util.List;
+import java.util.Map;
 import java.util.Optional;
 
 /**
  * This interface represents a block, which is the output of a specific task.
+ *
  * @param <K> the key type of its partitions.
  */
 public interface Block<K extends Serializable> {
 
+  /**
+   * Writes an element to non-committed block.
+   * Invariant: This should not be invoked after this block is committed.
+   * Invariant: This method may not support concurrent write.
+   *
+   * @param key     the key.
+   * @param element the element to write.
+   * @throws BlockWriteException for any error occurred while trying to write 
a block.
+   *                             (This exception will be thrown to the 
scheduler
+   *                             through {@link 
edu.snu.nemo.runtime.executor.Executor} and
+   *                             have to be handled by the scheduler with 
fault tolerance mechanism.)
+   */
+  void write(K key, Object element) throws BlockWriteException;
+
   /**
    * Stores {@link NonSerializedPartition}s to this block.
    * Invariant: This should not be invoked after this block is committed.
+   * Invariant: This method may not support concurrent write.
    *
    * @param partitions the {@link NonSerializedPartition}s to store.
-   * @return the size of the data per partition (only when the data is 
serialized in this method).
-   * @throws IOException if fail to store.
+   * @throws BlockWriteException for any error occurred while trying to write 
a block.
+   *                             (This exception will be thrown to the 
scheduler
+   *                             through {@link 
edu.snu.nemo.runtime.executor.Executor} and
+   *                             have to be handled by the scheduler with 
fault tolerance mechanism.)
    */
-  Optional<List<Long>> putPartitions(final Iterable<NonSerializedPartition<K>> 
partitions) throws IOException;
+  void writePartitions(Iterable<NonSerializedPartition<K>> partitions) throws 
BlockWriteException;
 
   /**
    * Stores {@link SerializedPartition}s to this block.
    * Invariant: This should not be invoked after this block is committed.
+   * Invariant: This method may not support concurrent write.
 
 Review comment:
   Ditto.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to