-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chunk: reduce chunk's iterator function call #7585
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,13 +105,15 @@ func NewIterator4Chunk(chk *Chunk) *Iterator4Chunk { | |
|
||
// Iterator4Chunk is used to iterate rows inside a chunk. | ||
type Iterator4Chunk struct { | ||
chk *Chunk | ||
cursor int | ||
chk *Chunk | ||
cursor int | ||
numRows int | ||
} | ||
|
||
// Begin implements the Iterator interface. | ||
func (it *Iterator4Chunk) Begin() Row { | ||
if it.chk.NumRows() == 0 { | ||
it.numRows = it.chk.NumRows() | ||
if it.numRows == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any use case that we are iterating the chunk while appending into it simultaneously? I guess this is not allowed, just to make sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, there isn't. |
||
return it.End() | ||
} | ||
it.cursor = 1 | ||
|
@@ -120,8 +122,8 @@ func (it *Iterator4Chunk) Begin() Row { | |
|
||
// Next implements the Iterator interface. | ||
func (it *Iterator4Chunk) Next() Row { | ||
if it.cursor >= it.chk.NumRows() { | ||
it.cursor = it.chk.NumRows() + 1 | ||
if it.cursor >= it.numRows { | ||
it.cursor = it.numRows + 1 | ||
return it.End() | ||
} | ||
row := it.chk.GetRow(it.cursor) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change the type from
int
toint32
to makeIterator4Chunk
only take 16 bytes in a 64-bit machine?