Genius-pig edited a comment on issue #458: [IOTDB-165][Documents][TsFile] Fix a 
example and update tsfile documents.
URL: https://github.com/apache/incubator-iotdb/pull/458#issuecomment-544153656
 
 
   ## why I delete `position()` method?
   1. This was requested change came from @jt2594838. @qiaojialin and I talked 
personally, then we decided to delete it.
   2. This was literally because every time when you new a 
`TsFileSequenceReader` object and its constructor would call 
`loadMetadataSize()` method, `loadMetadataSize()` would call `position()` 
method. In local mode, it actually called `FileChannel.position()` method. As 
we know, it was a method would move the position pointer. So questions were 
**Why to move the position pointer? It is really necessary to move the position 
pointer when I new a `TsFileSequenceReader` object?**
   ## why to move the position pointer?
   Let's firstly check out TsFile structure. 
   <img width="694" alt="Screen Shot 2019-10-19 at 10 10 39 PM" 
src="https://user-images.githubusercontent.com/26118649/67146402-72c89700-f2bd-11e9-8f09-112a8456799b.png";>
   You can find `MetaMarker.CHUNK_HEADER=0x1` after Magic String. There is a 
method called `readMarker()` to read `MetaMarker.CHUNK_HEADER=0x1`.
   ```
     /**
      * read one byte from the input. <br> this method is not thread safe
      */
     public byte readMarker() throws IOException {
       markerBuffer.clear();
       if (ReadWriteIOUtils.readAsPossible(tsFileInput, markerBuffer) == 0) {
         throw new IOException("reach the end of the file.");
       }
       markerBuffer.flip();
       return markerBuffer.get();
     }
   ```
   There is no `position()` method in `readMarker()`. So it used to use 
`position()` in `loadMetadataSize()` to move the position pointer. But there 
are many tests and examples use `readMarker()`. After you remove `position()` 
in `loadMetadataSize()`, you have to use `position()` before `readMarker()`. 
@qiaojialin suggested me do that and I just done it. 
   
   ## It is really necessary to move the position pointer when I new a 
`TsFileSequenceReader` object?
   No. Move the position pointer when you really need it.
   
   ## What other jobs does this pr have?
   I want to update some TsFile documents in this pr.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to