Skip to content

Commit 63ad025

Browse files
authored
Merge pull request #24 from taosdata/fix/xiaolei/nodejs-3.0-update-rawblock-structure
fix(driver):nodejs 3.0 update rawblock && fix [out of dnode]
2 parents 51dd73a + 9567c8d commit 63ad025

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

.github/workflows/native_3.0_pull_push.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ jobs:
4242
make -j8
4343
sudo make install
4444
45-
- name: start taosd
45+
- name: shell
4646
run: |
47-
nohup sudo taosd &
48-
taos -V
47+
cat >start.sh<<EOF
48+
ulimit -n 65535 && TAOS_SUPPORT_VNODES=256 taosd
49+
EOF
50+
- name: start taosd
51+
run: nohup sudo sh ./start.sh &
4952

5053
- name: checkout nodejs 3.0
5154
uses: actions/checkout@v3

nodejs/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
package-lock.json
2-
node_modules/
2+
node_modules/
3+
coverage/

nodejs/nodetaos/cinterface.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const TAOSFIELD = {
2626
function convertTimestamp(colHeadPtr, numOfRows, nBytes = 0, offset = 0, precision = 0) {
2727

2828
let res = [];
29-
let bitMapSize = Math.ceil(numOfRows / 8.0);
29+
let bitMapSize = (numOfRows + ((1 << 3) - 1)) >> 3;
3030
let bitMapBuf = ref.reinterpret(colHeadPtr, bitMapSize, 0);
3131

3232
offset = bitMapSize;
@@ -543,7 +543,7 @@ CTaosInterface.prototype.useResult = function useResult(result) {
543543
CTaosInterface.prototype.fetchRawBlock = function fetchRawBlock(taosRes) {
544544
var numOfRowPtr = ref.alloc('int *');
545545
var pDataPtr = ref.alloc('void **');
546-
546+
547547
let code = libtaos.taos_fetch_raw_block(taosRes, numOfRowPtr, pDataPtr);
548548

549549
if (code == 0) {
@@ -561,18 +561,16 @@ CTaosInterface.prototype.fetchRawBlock = function fetchRawBlock(taosRes) {
561561
blocks.fill(null);
562562

563563
// offset pData
564-
// pData + 12 + (4+2)*numOfFields;
565-
let offsetBeforeLengthArr = 12 + (4 + 2) * numOfFields;
564+
let offsetBeforeLengthArr = (4 * 5) + 8 + (4 + 1) * numOfFields;
566565
var lengthArraySize = 4 * numOfFields;
567566
let offsetForColData = offsetBeforeLengthArr + lengthArraySize;
568567
// read column after column
569-
if(numOfRows>0)
570-
{
568+
if (numOfRows > 0) {
571569
for (let i = 0; i < numOfFields; i++) {
572570

573571
let lengthPtr = ref.reinterpret(pData, ref.sizeof.int, offsetBeforeLengthArr + (i * 4));
574572
let length = lengthPtr.readInt32LE();
575-
573+
576574
if (!convertFunctions[fields[i]['type']]) {
577575
throw new errors.DatabaseError("Invalid data type returned from database");
578576
} else if (fields[i]['type'] == 8 || fields[i]['type'] == 10 || fields[i]['type'] == 15) {
@@ -586,7 +584,7 @@ CTaosInterface.prototype.fetchRawBlock = function fetchRawBlock(taosRes) {
586584
}
587585
}
588586
}
589-
587+
590588
return { blocks: blocks, num_of_rows: Math.abs(numOfRows) }
591589
} else {
592590
throw new OperationalError(`${libtaos.taos_errstr(taosRes)} ,${code}`);
@@ -634,9 +632,9 @@ CTaosInterface.prototype.query_a = function query_a(connection, sql, callback, p
634632
* function yourself using the libtaos.taos_fetch_raw_block_a function
635633
*/
636634

637-
CTaosInterface.prototype.fetch_raw_block_a = function fetch_raw_block_a(taosRes,callback,param=ref.ref(ref.NULL)){
635+
CTaosInterface.prototype.fetch_raw_block_a = function fetch_raw_block_a(taosRes, callback, param = ref.ref(ref.NULL)) {
638636
var cti = this;
639-
var fetchRawBlock_a_callback = function (param2,taosRes2,numOfRows2){
637+
var fetchRawBlock_a_callback = function (param2, taosRes2, numOfRows2) {
640638
let fields = cti.fetchFields_a(taosRes2);
641639
let precision = libtaos.taos_result_precision(taosRes2);
642640

@@ -650,21 +648,20 @@ CTaosInterface.prototype.fetch_raw_block_a = function fetch_raw_block_a(taosRes,
650648
fieldLengthArr.push(fieldLength);
651649
}
652650
}
653-
// =====logic same as fetch_raw_block
654-
// parse raw block from here.
651+
// =====logic same as fetch_raw_block
652+
// parse raw block from here.
655653
let pData = libtaos.taos_get_raw_block(taosRes2);
656654
let numOfRows = numOfRows2;
657655
let numOfFields = libtaos.taos_field_count(taosRes2);
658656

659-
let bitMapSize = Math.ceil(numOfRows / 8.0);
657+
let bitMapSize = (numOfRows + ((1 << 3) - 1)) >> 3;
660658
let offsetArrLength = ref.sizeof.int32 * numOfRows;
661659

662660
let blocks = new Array(numOfFields);
663661
blocks.fill(null);
664662

665663
// offset pData
666-
// pData + 12 + (4+2)*numOfFields;
667-
let offsetBeforeLengthArr = 12 + (4 + 2) * numOfFields;
664+
let offsetBeforeLengthArr = (4 * 5) + 8 + (4 + 1) * numOfFields;
668665
var lengthArraySize = 4 * numOfFields;
669666
let offsetForColData = offsetBeforeLengthArr + lengthArraySize;
670667
// read column after column
@@ -688,7 +685,7 @@ CTaosInterface.prototype.fetch_raw_block_a = function fetch_raw_block_a(taosRes,
688685
callback(param2, taosRes2, numOfRows2, blocks);
689686
}
690687
var fetchRawBlock_a_callback = ffi.Callback(ref.types.void, [ref.types.void_ptr, ref.types.void_ptr, ref.types.int], fetchRawBlock_a_callback);
691-
libtaos.taos_fetch_raw_block_a(taosRes,fetchRawBlock_a_callback,param)
688+
libtaos.taos_fetch_raw_block_a(taosRes, fetchRawBlock_a_callback, param)
692689
}
693690
// Used to parse the TAO_RES retrieved in taos_fetch_row_a()'s callback
694691
// block after block.

0 commit comments

Comments
 (0)