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

Josh Elser commented on RATIS-477:
----------------------------------

{quote}how are you going to resolve read(3) call? You will need to iterate 
through *all* log entries again. Correct?
{quote}
I don't think I will have to. In the memory of LogStateMachine, I think I can 
keep an in-memory representation (an index) over the RaftLog of RaftLog's ID to 
the recordId (LogService ID). This will help me avoid the large penalty of not 
knowing where to seek. We can construct this memory when we are starting the 
state machine (if we have previous state) and we can maintain it for every 
operation we apply. At least, I think we can do this.
{quote}Read can return multiple entries if corresponding write was batch write 
for this particular *logId*
{quote}
I worry about this approach because it will make the read API less like a 
simple List. If you read one entry, sometimes you get one value, sometimes you 
get many values. I think we can hide this detail.

> Improve LogStateMachine.processReadRequest()
> --------------------------------------------
>
>                 Key: RATIS-477
>                 URL: https://issues.apache.org/jira/browse/RATIS-477
>             Project: Ratis
>          Issue Type: Improvement
>          Components: LogService
>            Reporter: Josh Elser
>            Assignee: Josh Elser
>            Priority: Major
>             Fix For: 0.4.0
>
>
> [~vrodionov] and [~rajeshbabu] were asking about this in RATIS-470. Can we 
> improve the logic that reads through the "head" of the RaftLog to find the 
> "LogService offset"?
> Vlad suggested:
> {quote}
> Josh, can we simplify this a little bit? Client gets Raft log ID one every 
> append, for multi-get calls we can use this LogID (RAFT) as our start log ID 
> to avoid iterating through all logs, then you can unwind log entries by using 
> new logic, see above:
>  int numRecordsInAppend = append.getDataCount();
> There is no need to iterate from the very beginning
> {quote}



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

Reply via email to