Changeset: c8960a75a41b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c8960a75a41b Modified Files: sql/backends/monet5/sql_bincopyfrom.c Branch: copybinary Log Message:
Avoid unnecessary heap reallocations diffs (15 lines): diff --git a/sql/backends/monet5/sql_bincopyfrom.c b/sql/backends/monet5/sql_bincopyfrom.c --- a/sql/backends/monet5/sql_bincopyfrom.c +++ b/sql/backends/monet5/sql_bincopyfrom.c @@ -36,7 +36,10 @@ BATattach_as_bytes(BAT *bat, stream *s, assert(chunk_size % asz == 0); size_t n; if (rows_estimate > 0) { - n = rows_estimate; + // Set n to estimate+1 so it will read once, get n - 1 and know it's at EOF. + // Otherwise, it will read n, get n, then enlarge the heap, read again, + // and only then know it's at eof. + n = rows_estimate + 1; rows_estimate = 0; } else { n = chunk_size / asz; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list