[ 
https://issues.apache.org/jira/browse/RATIS-272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16597743#comment-16597743
 ] 

ASF GitHub Bot commented on RATIS-272:
--------------------------------------

Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/incubator-ratis/pull/4#discussion_r214132445
  
    --- Diff: 
ratis-logservice/src/main/java/org/apache/ratis/logservice/api/LogReader.java 
---
    @@ -0,0 +1,82 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.ratis.logservice.api;
    +
    +import java.io.IOException;
    +import java.nio.ByteBuffer;
    +import java.util.List;
    +
    +/**
    + * Synchronous client interface to read from a LogStream.
    + */
    +public interface LogReader extends AutoCloseable {
    +
    +  /**
    +   * Seeks to the position before the record at the provided {@code 
recordId} in the LogStream.
    +   *
    +   * @param offset A non-negative, offset in the LogStream
    +   * @return A future for when the operation is completed.
    +   */
    +  void seek(long recordId) throws IOException;
    +
    +  /**
    +   * Reads the next record from the LogStream at the current position and 
advances the current position
    +   * to after the record which was just returned.
    +   *
    +   * @return The data for the next record.
    +   */
    +  ByteBuffer readNext() throws IOException;
    +
    +  /**
    +   * Reads the next record from the LogStream at the current position into 
the provided {@link buffer} and
    +   * advances the current position to the point after the record just read.
    +   *
    +   * @param buffer A buffer to read the record into
    +   */
    +  void readNext(ByteBuffer buffer) throws IOException;
    --- End diff --
    
    @VladRodionov one concern I just realized is: what if the buffer's size is 
less than the size of the record we need to read? As written now, we would have 
to throw an Exception. I don't know if we have flexibility within ByteBuffer to 
fix this.
    
    One way around it would be to build in some kind of ByteBufferPool to Ratis 
itself that would reuse buffers and reduce the work a client would have to do. 
WDYT?


> Design ideal API
> ----------------
>
>                 Key: RATIS-272
>                 URL: https://issues.apache.org/jira/browse/RATIS-272
>             Project: Ratis
>          Issue Type: Sub-task
>          Components: LogService
>            Reporter: Josh Elser
>            Priority: Major
>
> With influence from Apache DistributedLog, Kafka, and BookKeeper, design an 
> API that balances the ideal notion of what a distribute log system should 
> look like, but also considers the needs of HBase to replace a WAL.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to