[jira] [Commented] (KAFKA-2903) FileMessageSet's read method maybe has problem when start is not zero
[ https://issues.apache.org/jira/browse/KAFKA-2903?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15048946#comment-15048946 ] Jun Rao commented on KAFKA-2903: Yes, I think that will be fine too. > FileMessageSet's read method maybe has problem when start is not zero > - > > Key: KAFKA-2903 > URL: https://issues.apache.org/jira/browse/KAFKA-2903 > Project: Kafka > Issue Type: Bug > Components: log >Affects Versions: 0.8.2.1, 0.9.0.0 >Reporter: Pengwei >Assignee: Jay Kreps > Fix For: 0.9.1.0 > > > now the code is : > def read(position: Int, size: Int): FileMessageSet = { >. > new FileMessageSet(file, >channel, >start = this.start + position, >end = math.min(this.start + position + size, > sizeInBytes())) > } > if this.start is not 0, the end is only the FileMessageSet's size, not the > actually position of end position. > the end parameter should be: > end = math.min(this.start + position + size, this.start+sizeInBytes()) -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (KAFKA-2903) FileMessageSet's read method maybe has problem when start is not zero
[ https://issues.apache.org/jira/browse/KAFKA-2903?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15046561#comment-15046561 ] Pengwei commented on KAFKA-2903: Yes we can also add comment on it. But if in the future version, someone need to use this read API will get error when using a slice FileMessageSet. so modify this code is better? Because it is only one line of code, and add comment will use much word on it > FileMessageSet's read method maybe has problem when start is not zero > - > > Key: KAFKA-2903 > URL: https://issues.apache.org/jira/browse/KAFKA-2903 > Project: Kafka > Issue Type: Bug > Components: log >Affects Versions: 0.8.2.1, 0.9.0.0 >Reporter: Pengwei >Assignee: Jay Kreps > Fix For: 0.9.1.0 > > > now the code is : > def read(position: Int, size: Int): FileMessageSet = { >. > new FileMessageSet(file, >channel, >start = this.start + position, >end = math.min(this.start + position + size, > sizeInBytes())) > } > if this.start is not 0, the end is only the FileMessageSet's size, not the > actually position of end position. > the end parameter should be: > end = math.min(this.start + position + size, this.start+sizeInBytes()) -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (KAFKA-2903) FileMessageSet's read method maybe has problem when start is not zero
[ https://issues.apache.org/jira/browse/KAFKA-2903?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15046379#comment-15046379 ] Jun Rao commented on KAFKA-2903: Yes, the current logic is a bit confusing, but is correct. We create a FileMessageSet in two cases. The first case is when we create a LogSegment. In this case, FileMessageSet.start is always 0. The second case is when we want to generate a response to the fetch request. In this case, we are getting a slice from the FileMessageSet created in case one, which always has FileMessageSet.start as 0. That's why the code works. We never had a case that we need to create a slice from a FileMessageSet created in case (2). To make the code easier to understand, perhaps we can just get rid of this.start all together when calculating end. It would also be good to add a comment above FileMessageSet to make this clear. Do you want to submit a patch? > FileMessageSet's read method maybe has problem when start is not zero > - > > Key: KAFKA-2903 > URL: https://issues.apache.org/jira/browse/KAFKA-2903 > Project: Kafka > Issue Type: Bug > Components: log >Affects Versions: 0.8.2.1, 0.9.0.0 >Reporter: Pengwei >Assignee: Jay Kreps > Fix For: 0.9.1.0 > > > now the code is : > def read(position: Int, size: Int): FileMessageSet = { >. > new FileMessageSet(file, >channel, >start = this.start + position, >end = math.min(this.start + position + size, > sizeInBytes())) > } > if this.start is not 0, the end is only the FileMessageSet's size, not the > actually position of end position. > the end parameter should be: > end = math.min(this.start + position + size, this.start+sizeInBytes()) -- This message was sent by Atlassian JIRA (v6.3.4#6332)