未验证 提交 ea3406d7 编写于 作者: H huolibo 提交者: GitHub

[TD-14055]<fix>: adjust the method of obtaining values (#10958)

上级 f71ff7d7
...@@ -573,8 +573,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI ...@@ -573,8 +573,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI
return code; return code;
} }
TAOS_RES *tres = (TAOS_RES *)res; TAOS_RES *tres = (TAOS_RES *)res;
TAOS_FIELD *fields = taos_fetch_fields(tres);
int32_t numOfFields = taos_num_fields(tres); int32_t numOfFields = taos_num_fields(tres);
assert(numOfFields > 0); assert(numOfFields > 0);
...@@ -596,14 +595,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI ...@@ -596,14 +595,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI
(*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfRowsFp, (jint)numOfRows); (*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfRowsFp, (jint)numOfRows);
(*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfColsFp, (jint)numOfFields); (*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfColsFp, (jint)numOfFields);
int32_t *field = taos_fetch_lengths(tres);
for (int i = 0; i < numOfFields; i++) { for (int i = 0; i < numOfFields; i++) {
int bytes = fields[i].bytes; (*env)->CallVoidMethod(env, rowobj, g_blockdataSetByteArrayFp, i, field[i] * numOfRows,
jniFromNCharToByteArray(env, (char *)row[i], field[i] * numOfRows));
if (fields[i].type == TSDB_DATA_TYPE_BINARY || fields[i].type == TSDB_DATA_TYPE_NCHAR) {
bytes += 2;
}
(*env)->CallVoidMethod(env, rowobj, g_blockdataSetByteArrayFp, i, bytes * numOfRows,
jniFromNCharToByteArray(env, (char *)row[i], bytes * numOfRows));
} }
return JNI_SUCCESS; return JNI_SUCCESS;
......
...@@ -408,7 +408,8 @@ public class TSDBResultSetBlockData { ...@@ -408,7 +408,8 @@ public class TSDBResultSetBlockData {
case TSDBConstants.TSDB_DATA_TYPE_NCHAR: { case TSDBConstants.TSDB_DATA_TYPE_NCHAR: {
ByteBuffer bb = (ByteBuffer) this.colData.get(col); ByteBuffer bb = (ByteBuffer) this.colData.get(col);
bb.position((fieldSize + BINARY_LENGTH_OFFSET) * this.rowIndex); // bb.position((fieldSize * 4 + 2 + 1) * this.rowIndex);
bb.position(bb.capacity() / numOfRows * this.rowIndex);
int length = bb.getShort(); int length = bb.getShort();
byte[] dest = new byte[length]; byte[] dest = new byte[length];
bb.get(dest, 0, length); bb.get(dest, 0, length);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册