
You can use the macro bunfastapp. See the code base for examples. It's probably only a little faster than using BUNappend, but it does require more code around it (setting properties and such). The problem with strings is that the string need to be added to the string heap which is a relatively expensive operation. On 02/11/2018 22.08, Anton Kravchenko wrote:
Though I wonder how to append an array of values to a BUN for TYPE_str column?
sql_table *tbl = mvc_bind_table(m, sch, "atable");
sql_column *col1 = mvc_bind_column(m, tbl, "acolumn"); //char(1)
BAT *tmp1 = NULL;
int nrows = 3;
tmp1 = COLnew(0, TYPE_str, (BUN)nrows, TRANSIENT);
char v_char[3][2] = {"Y\0","N\0","Y\0"}; //char(1)
for (irow=0; irow<nrows; irow++)
BUNappend(tmp1, &(v_char[irow]), FALSE);
mvc_append_column(m->session->tr, col1, tmp1);
mvc_commit(m, 0, tr->name);
bat_destroy(tmp1);
Anton
On Fri, Nov 2, 2018 at 1:12 PM Anton Kravchenko <kravchenko.anton86@gmail.com <mailto:kravchenko.anton86@gmail.com>> wrote:
Ok to make it work I had to replace
for (irow=0; irow<nrows; irow++)
BUNappend(tmp1, &v_long[irow], FALSE);
with
memcpy(Tloc(tmp1, BUNlast(tmp1)), v_long, nrows*sizeof(long long));
BATsetcount(tmp1, BATcount(tmp1) + nrows);
Anton
On Fri, Nov 2, 2018 at 9:39 AM Anton Kravchenko <kravchenko.anton86@gmail.com <mailto:kravchenko.anton86@gmail.com>> wrote:
Hi there,
Is there a way to append an array of values to a BUN, instead one value at a time?
sql_table*tbl = mvc_bind_table(m, sch, "atable");
sql_column *col = mvc_bind_column(m, tbl, "acolumn"); BAT*tmp1 = COLnew(0, TYPE_lng, (BUN)nrows, TRANSIENT); longlong v_long[3] = {100000000009,100000000010,100000000011};
for(irow=0; irow<nrows; irow++)
BUNappend(tmp1, &v_long[irow], FALSE);
mvc_append_column(m->session->tr, col1, tmp1);
mvc_commit(m, 0, tr->name);
bat_destroy(tmp1);
Thanks, Anton
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
-- Sjoerd Mullender