I also tried it the other way, iterating over the columns instead of rows. Now
there is a weird error. The array of uint32_t values is interleaved with 0's.
Here is a snippet of the output:
getColumnAsUInts(gene_id, buf) = 52
JSON[0,0]=50002
JSON[0,1]=0
JSON[0,2]=50003
JSON[0,3]=0
JSON[0,4]=50004
JSON[0,5]=0
JSON[0,6]=50010
JSON[0,7]=0
JSON[0,8]=50011
JSON[0,9]=0
The code is pasted below. I've never seen this before so it is probably
clashing with something in node.h or v8.h, right?
Andrew
Local<Array> toJson(const ibis::table &tbl)
{
tbl.dump(std::cout);
size_t nr = tbl.nRows();
ibis::table::stringList nms = tbl.columnNames();
ibis::table::typeList tps = tbl.columnTypes();
Local<Array> JSON = Array::New();
int ierr = 0;
for (int j = 0; j < (int)nms.size(); ++ j) {
Local<Array> column = Array::New();
switch (tps[j]) {
case ibis::UINT:
{
uint32_t *buf = new uint32_t[nr];
ierr = tbl.getColumnAsUInts(nms[j], buf);
printf("getColumnAsUInts(%s, buf) =
%d\n",nms[j],ierr);
for (size_t i = 0; i < nr; ++ i) {
printf("JSON[%d,%ld]=%d\n",j,i,buf[i]);
//
column->Set(Integer::New(i),NumberObject::New(buf[i]));
}
break;
}
default:
{
break;
}
}
// JSON->Set(j,column->Clone());
}
printf("done building JSON\n");
return JSON;
}
On Oct 23, 2012, at 3:58 PM, Olson, Andrew wrote:
> Hi John,
> I'm working on exposing some FastBit based code for use in node.js. For
> example, I'd like to be able to perform basic SQL queries on a single fastbit
> data table. I'm having trouble mapping the ibis::table into a 2D Javascript
> array. There are probably some additional problems with my use of node.h and
> v8.h functions, but I can't get past line 21 if (cur == 0). The code is
> pasted here: http://pastie.org/private/yyxqdhm7yeakxdzdig5ipw
>
> Any ideas on why the cursor is not defined?
>
> Andrew
> _______________________________________________
> FastBit-users mailing list
> [email protected]
> https://hpcrdm.lbl.gov/cgi-bin/mailman/listinfo/fastbit-users
_______________________________________________
FastBit-users mailing list
[email protected]
https://hpcrdm.lbl.gov/cgi-bin/mailman/listinfo/fastbit-users