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

Roman Khachatryan commented on FLINK-26799:
-------------------------------------------

Hi [~Feifan Wang] , thanks for looking into it,

> But the if condition is incorrect, stream.getPos() return the position of 
> underlying stream which is different from position of input.
Exactly, this is the underlying stream that needs to be positioned. Then 
"offset" bytes are skipped from the buffer. So I think this is correct.

> Actually, input is aways at position 0 at beginning, so I think we can seek 
> to the offset directly.

Are you proposing to seek on the underlying stream {*}before wrapping{*}?
I think that won't work, because the compression flag is written at the 
beginning.

Alternatively, seeking on the underlying stream *after wrapping* seem dangerous 
to me: there is no contract that no bytes are buffered by constructor AFAIK.

> StateChangeFormat#read not seek to offset correctly
> ---------------------------------------------------
>
>                 Key: FLINK-26799
>                 URL: https://issues.apache.org/jira/browse/FLINK-26799
>             Project: Flink
>          Issue Type: Bug
>          Components: Runtime / State Backends
>            Reporter: Feifan Wang
>            Priority: Major
>
> StateChangeFormat#read must seek to offset before read, current implement as 
> follows :
>  
> {code:java}
> FSDataInputStream stream = handle.openInputStream();
> DataInputViewStreamWrapper input = wrap(stream);
> if (stream.getPos() != offset) {
>     LOG.debug("seek from {} to {}", stream.getPos(), offset);
>     input.skipBytesToRead((int) offset);
> }{code}
> But the if condition is incorrect, stream.getPos() return the position of 
> underlying stream which is different from position of input.
> By the way, because of wrapped by BufferedInputStream, position of underlying 
> stream always at n*bufferSize or the end of file. 
> Actually, input is aways at position 0 at beginning, so I think we can seek 
> to the offset directly.
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to