-
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
Control the number of rows returned by SelectResult #9273
Changes from all commits
d8c5028
747ec82
d623c06
8fadaf7
7f49198
75498c0
4ccfa41
973b698
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 |
---|---|---|
|
@@ -13,12 +13,46 @@ | |
|
||
package chunk | ||
|
||
// UnspecifiedNumRows represents requiredRows is not specified. | ||
const UnspecifiedNumRows = 0 | ||
|
||
// RecordBatch is input parameter of Executor.Next` method. | ||
type RecordBatch struct { | ||
*Chunk | ||
|
||
// requiredRows indicates how many rows is required by the parent executor. | ||
// Child executor should stop populating rows immediately if there are at | ||
// least required rows in the Chunk. | ||
requiredRows int | ||
} | ||
|
||
// NewRecordBatch is used to construct a RecordBatch. | ||
func NewRecordBatch(chk *Chunk) *RecordBatch { | ||
return &RecordBatch{chk} | ||
return &RecordBatch{chk, UnspecifiedNumRows} | ||
} | ||
|
||
// SetRequiredRows sets the number of rows the parent executor want. | ||
func (rb *RecordBatch) SetRequiredRows(numRows int) *RecordBatch { | ||
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. If we allocate a 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.
|
||
if numRows <= 0 { | ||
numRows = UnspecifiedNumRows | ||
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. If |
||
} | ||
rb.requiredRows = numRows | ||
return rb | ||
} | ||
|
||
// RequiredRows returns how many rows the parent executor want. | ||
func (rb *RecordBatch) RequiredRows() int { | ||
return rb.requiredRows | ||
} | ||
|
||
// IsFull returns if this batch can be considered full. | ||
// IsFull only takes requiredRows into account, the caller of this method should | ||
// also consider maxChunkSize, then it should behave like: | ||
// if !batch.IsFull() && batch.NumRows() < maxChunkSize { ... } | ||
func (rb *RecordBatch) IsFull() bool { | ||
if rb.requiredRows == UnspecifiedNumRows { | ||
return false | ||
} | ||
|
||
return rb.NumRows() >= rb.requiredRows | ||
} |
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.
how about setting the required rows of that newly created batch to max chunk size?