read BLOB column on tail heap and loop over rows

Anton Kravchenko kravchenko.anton86 at gmail.com
Mon Nov 13 23:33:36 CET 2017


Ok, here is a workaround
[though I suspect that performance is going to degrade (with respect to
CHAR column for example[1]) because BUNtail is being called for each row...]

sql_column *col = mvc_bind_column(m, tbl, colname[icol]);
BAT *b = table_funcs.full_column(m->session->tr, col); //read the entire
column into continuous memory on the tail heap of the BAT b
BATiter *iterators = NULL;
blob *blob_record;
int ib;
iterators = GDKzalloc(sizeof(BATiter));
iterators[0] = bat_iterator(b); // blob column iterator
for (irow=0; irow < nrow; irow++) {
      blob_record = (blob*) BUNtail(iterators[0], irow);
      for (ib=0; ib < blob_record->nitems; ib++) {
           printf("blob data = %c, %02x\n", blob_record->data[ib],
blob_record->data[ib]);
      }
  }

p.s.
[1]
//For CHAR column it would look like this:
sql_column *col = mvc_bind_column(m, tbl, colname[icol]);
BAT *b = table_funcs.full_column(m->session->tr, col); //read the entire
column into continuous memory on the tail heap of the BAT b
char *tvbase, *cptr;
unsigned char *readucrows;
tvbase = (char *) b->T.vheap->base + GDK_VAROFFSET;
readucrows = (unsigned char *) b->T.heap.base;
for (irow=0; irow < nrow; irow++) {
    cptr = tvbase + *readucrows++;
}

Anton


On Fri, Nov 10, 2017 at 4:13 PM, Anton Kravchenko <
kravchenko.anton86 at gmail.com> wrote:

> I wonder how one would read BLOB column and loop over its rows?
>
> BAT *b = table_funcs.full_column(m->session->tr, blob_col_name);
> //blob *readblobrows = (blob*) b->T.heap.base;
> //unsigned char *readblobrows = (unsigned char*) b->T.heap.base;
>
> p.s.
> For INT column it would be go like this:
> int * readintrows = (int *) b->T.heap.base;
> for (irow=0; irow < nrow; irow++) {
>          intvalue = *readintrows++;
> }
>
> Thanks,
> Anton
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.monetdb.org/pipermail/developers-list/attachments/20171113/76c6e143/attachment-0001.html>


More information about the developers-list mailing list