swamirishi commented on PR #8203:
URL: https://github.com/apache/ozone/pull/8203#issuecomment-2932119725

   > @sumitagrawl , @swamirishi ,
   > 
   > Below are the current API methods
   > 
   > ```java
   > //Table.java
   >   TableIterator<KEY, ? extends KeyValue<KEY, VALUE>> iterator() throws 
IOException;
   >   TableIterator<KEY, ? extends KeyValue<KEY, VALUE>> iterator(KEY prefix) 
throws IOException;
   > ```
   > 
   > The new API method should look like:
   > 
   > ```java
   > //Table.java
   >   TableIterator<KEY, ? extends KeyValue<KEY, VALUE>> iterator(KEY prefix,
   >       Executor executor, boolean ordered) throws IOException;
   > ```
   > 
   > See also [this 
comment](https://github.com/apache/ozone/pull/8203#discussion_r2049466909). The 
existing methods should just pass null for executor and true for ordered to the 
new method. When executor is non-null, the new implementation will use it for 
parallel execution. When it is null, it will use the existing (single-thread) 
implementation.
   > 
   > `SplitIterator` and reference count are all implementation detail in the 
new implementation. It should not be exposed to the API. (Just like that 
iterator can use `CodecBuffer` or `byte[]`, which are not in the API.)
   > 
   > If there is a need, we could add a new nextAsync() method to TableIterator 
for asynchronous execution at the caller side, i.e. the caller can process the 
elements in parallel.
   > 
   > ```java
   > //TableIterator
   >   CompletableFuture<T> nextAsync();
   > ```
   
   @szetszwo I don't like the idea of having a parallel iterator implementation 
which doesn't follow the already defined interface  java.util.Spliterator. Any 
implementation of Spliterator would give the downstream api users the 
flexibility to use the object in the way they deem fit may be wanting to submit 
the spliterator to a forkjoin pool to do a parallel iteration using multiple 
threads. If you look at this implementation of 
[trySplit](https://github.com/apache/ozone/blob/a6c25e73429d5911be0cca93bac15b000e9b2eef/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RawSpliterator.java#L168)
 in the follow up PR where we are splitting this iteration over multiple 
rocksdb iterators. The spliterator model really fits our usecase pretty well 
having an adhoc method within the TableIterator doesn't really make sense to 
me. I would be open to other people's opinions on this thread as well where we 
could finalize on an approach.
   cc: @kerneltime @sumitagrawl  


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


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

Reply via email to