Conversation
Designed to minimize allocations and cgo calls.
API requires no allocations to INSERT or SELECT. (Apparently there is still one allocation, somewhere.) All cgo calls are amortized across rows.
bradfitz
left a comment
There was a problem hiding this comment.
I have more questions but probably best to just talk to you on a call.
| func NewBulkQuery(stmt *Stmt) (*BulkQuery, error) { | ||
| b := &BulkQuery{ | ||
| bulkStmt: newBulkStmt(stmt), | ||
| dataText: make([]byte, 1<<16), |
There was a problem hiding this comment.
only do shifts of 10 (KiB), 20 (MiB), etc.
so 64 << 10. (64 KiB)
| func (b *BulkQuery) resizeDataText() { | ||
| b.dataText = append(b.dataText, make([]byte, len(b.dataText))...) | ||
| } |
There was a problem hiding this comment.
rather than resizing this and generating garbage, my plan was for the C layer to signal to Go that the row won't fit and that it should be accessed using the C sqlite3 interface instead.
but because of where I was putting this, in Stmt, it wasn't extra work, because the C calls were already there.
There was a problem hiding this comment.
because of the way the iterator works, if a column doesn't fit, the row is punted to the next time the bulk query is run. so the only time dataText gets expanded is if someone tries to read a row more than 16kb, which generally shouldn't happen.
No description provided.