dolphindb 3.0.121 → 3.0.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser.d.ts +3 -5
- package/browser.js +63 -32
- package/browser.js.map +1 -1
- package/index.d.ts +3 -5
- package/index.js +63 -32
- package/index.js.map +1 -1
- package/package.json +1 -1
package/browser.d.ts
CHANGED
|
@@ -642,7 +642,6 @@ export interface DdbOptions {
|
|
|
642
642
|
export interface DdbCallOptions extends DdbEvalOptions {
|
|
643
643
|
node?: string;
|
|
644
644
|
nodes?: string[];
|
|
645
|
-
func_type?: DdbFunctionType;
|
|
646
645
|
add_node_alias?: boolean;
|
|
647
646
|
skip_connection_check?: boolean;
|
|
648
647
|
on_more_messages?: DdbRpcOptions['on_more_messages'];
|
|
@@ -695,6 +694,8 @@ export declare class DDB {
|
|
|
695
694
|
ppnode_run: Promise<DdbVoid>;
|
|
696
695
|
/** 首次定义 invoke 的 promise,保证并发调用 rpc 时只定义一次 invoke */
|
|
697
696
|
pinvoke: Promise<DdbVoid>;
|
|
697
|
+
/** 首次定义 jsrpc 的 promise,保证并发调用 rpc 时只定义一次 jsrpc */
|
|
698
|
+
pjsrpc: Promise<DdbVoid>;
|
|
698
699
|
get connected(): boolean;
|
|
699
700
|
/**
|
|
700
701
|
使用 WebSocket URL 初始化连接到 DolphinDB 的实例(不建立实际的网络连接)
|
|
@@ -800,8 +801,6 @@ export declare class DDB {
|
|
|
800
801
|
When the node alias is set, it is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB)
|
|
801
802
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
802
803
|
When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
|
|
803
|
-
- func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
|
|
804
|
-
It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases
|
|
805
804
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
806
805
|
Select to pass when setting the nodes parameter, otherwise not pass
|
|
807
806
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage)
|
|
@@ -815,7 +814,7 @@ export declare class DDB {
|
|
|
815
814
|
将这个 flag 设为 true 跳过连接状态检查
|
|
816
815
|
(internal use) When await ddb.connect() establishes a connection for the first time, you cannot call await this.connect() again to ensure the connection status, which will lead to circular dependencies.
|
|
817
816
|
Set this flag to true to skip connection status checks */
|
|
818
|
-
call<TResult extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes,
|
|
817
|
+
call<TResult extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, add_node_alias, listener, parse_object, skip_connection_check, on_more_messages }?: DdbCallOptions): Promise<TResult>;
|
|
819
818
|
/** 调用 dolphindb 函数,传入 js 原生数组作为参数,返回 js 原生对象或值(调用 DdbObj.data() 后的结果)
|
|
820
819
|
- func: 函数名
|
|
821
820
|
- args?: `[ ]` 调用参数,可以是 js 原生数组,参数在中间且想用 server 函数的默认参数值时可以传 null 占位
|
|
@@ -823,7 +822,6 @@ export declare class DDB {
|
|
|
823
822
|
- urgent?: 紧急 flag。使用 urgent worker 执行,防止被其它作业阻塞
|
|
824
823
|
- node?: 设置结点 alias 时发送到集群中对应的结点执行 (使用 DolphinDB 中的 rpc 方法)
|
|
825
824
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
826
|
-
- func_type?: 设置 node 参数且参数数组为空时必传,需指定函数类型,其它情况下不传
|
|
827
825
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
828
826
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
|
|
829
827
|
invoke<TResult = any>(func: string, args?: any[], options?: DdbInvokeOptions): Promise<TResult>;
|
package/browser.js
CHANGED
|
@@ -851,7 +851,8 @@ export class DdbObj {
|
|
|
851
851
|
assert(form === DdbForm.vector, t('iotany sub vector 不支持非 vector 类型'));
|
|
852
852
|
const sub_size = dv.getUint32(i_value_start, le);
|
|
853
853
|
i_value_start += 8; // 同时跳过 sub_size 和 cols
|
|
854
|
-
|
|
854
|
+
let [len, vector] = this.parse_vector_items(buf.subarray(i_value_start), le, sub_type, sub_size);
|
|
855
|
+
vector = converts(sub_type, vector, sub_size, le);
|
|
855
856
|
i_value_start += len;
|
|
856
857
|
sub_vec.set(sub_type, vector);
|
|
857
858
|
}
|
|
@@ -2784,6 +2785,8 @@ export class DDB {
|
|
|
2784
2785
|
ppnode_run;
|
|
2785
2786
|
/** 首次定义 invoke 的 promise,保证并发调用 rpc 时只定义一次 invoke */
|
|
2786
2787
|
pinvoke;
|
|
2788
|
+
/** 首次定义 jsrpc 的 promise,保证并发调用 rpc 时只定义一次 jsrpc */
|
|
2789
|
+
pjsrpc;
|
|
2787
2790
|
get connected() {
|
|
2788
2791
|
return !this.error && this.lwebsocket.resource?.readyState === WebSocket.OPEN;
|
|
2789
2792
|
}
|
|
@@ -3172,8 +3175,6 @@ export class DDB {
|
|
|
3172
3175
|
When the node alias is set, it is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB)
|
|
3173
3176
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
3174
3177
|
When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
|
|
3175
|
-
- func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
|
|
3176
|
-
It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases
|
|
3177
3178
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
3178
3179
|
Select to pass when setting the nodes parameter, otherwise not pass
|
|
3179
3180
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage)
|
|
@@ -3187,18 +3188,41 @@ export class DDB {
|
|
|
3187
3188
|
将这个 flag 设为 true 跳过连接状态检查
|
|
3188
3189
|
(internal use) When await ddb.connect() establishes a connection for the first time, you cannot call await this.connect() again to ensure the connection status, which will lead to circular dependencies.
|
|
3189
3190
|
Set this flag to true to skip connection status checks */
|
|
3190
|
-
async call(func, args = [], { urgent, node, nodes,
|
|
3191
|
+
async call(func, args = [], { urgent, node, nodes, add_node_alias, listener, parse_object, skip_connection_check, on_more_messages } = {}) {
|
|
3192
|
+
let func_ = func;
|
|
3193
|
+
let args_ = args;
|
|
3191
3194
|
if (node) {
|
|
3192
|
-
|
|
3193
|
-
|
|
3195
|
+
try {
|
|
3196
|
+
await (this.pjsrpc ??= this.eval(this.python ?
|
|
3197
|
+
'\n' +
|
|
3198
|
+
'def jsrpc (node, func_name, args):\n' +
|
|
3199
|
+
' args_ = args\n' +
|
|
3200
|
+
' if func_name == "invoke":\n' +
|
|
3201
|
+
' args_[0] = funcByName(args[0])\n' +
|
|
3202
|
+
' return rpc(node, unifiedCall, funcByName(func_name), args_)\n'
|
|
3203
|
+
:
|
|
3204
|
+
'\n' +
|
|
3205
|
+
'def jsrpc (node, func_name, args) {\n' +
|
|
3206
|
+
' args_ = args\n' +
|
|
3207
|
+
' if (func_name == "invoke")\n' +
|
|
3208
|
+
' args_[0] = funcByName(args[0])\n' +
|
|
3209
|
+
' return rpc(node, unifiedCall, funcByName(func_name), args_)\n' +
|
|
3210
|
+
'}\n', { urgent: true }));
|
|
3211
|
+
}
|
|
3212
|
+
catch (error) {
|
|
3213
|
+
this.pjsrpc = undefined;
|
|
3214
|
+
throw error;
|
|
3215
|
+
}
|
|
3216
|
+
func_ = 'jsrpc';
|
|
3217
|
+
args_ = [
|
|
3194
3218
|
node,
|
|
3195
|
-
|
|
3196
|
-
|
|
3219
|
+
func,
|
|
3220
|
+
new DdbVectorAny(args)
|
|
3197
3221
|
];
|
|
3198
|
-
func = 'rpc';
|
|
3199
3222
|
}
|
|
3200
3223
|
if (nodes) {
|
|
3201
|
-
|
|
3224
|
+
func_ = 'pnode_run';
|
|
3225
|
+
args_ = [
|
|
3202
3226
|
new DdbVectorString(nodes),
|
|
3203
3227
|
func,
|
|
3204
3228
|
new DdbVectorAny(args),
|
|
@@ -3210,11 +3234,10 @@ export class DDB {
|
|
|
3210
3234
|
return [];
|
|
3211
3235
|
})()
|
|
3212
3236
|
];
|
|
3213
|
-
func = 'pnode_run';
|
|
3214
3237
|
}
|
|
3215
3238
|
return this.rpc('function', {
|
|
3216
|
-
func,
|
|
3217
|
-
args,
|
|
3239
|
+
func: func_,
|
|
3240
|
+
args: args_,
|
|
3218
3241
|
urgent,
|
|
3219
3242
|
listener,
|
|
3220
3243
|
parse_object,
|
|
@@ -3229,25 +3252,37 @@ export class DDB {
|
|
|
3229
3252
|
- urgent?: 紧急 flag。使用 urgent worker 执行,防止被其它作业阻塞
|
|
3230
3253
|
- node?: 设置结点 alias 时发送到集群中对应的结点执行 (使用 DolphinDB 中的 rpc 方法)
|
|
3231
3254
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
3232
|
-
- func_type?: 设置 node 参数且参数数组为空时必传,需指定函数类型,其它情况下不传
|
|
3233
3255
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
3234
3256
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
|
|
3235
3257
|
async invoke(func, args, options) {
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
'def invoke (func_name, args_json):\n' +
|
|
3239
|
-
' args = fromStdJson(args_json)\n' +
|
|
3240
|
-
' if type(args) != ANY:\n' +
|
|
3241
|
-
' args = cast(args, ANY)\n' +
|
|
3242
|
-
' return unifiedCall(funcByName(func_name), args)\n'
|
|
3243
|
-
:
|
|
3258
|
+
try {
|
|
3259
|
+
await (this.pinvoke ??= this.eval(this.python ?
|
|
3244
3260
|
'\n' +
|
|
3245
|
-
'def invoke (
|
|
3261
|
+
'def invoke (func, args_json):\n' +
|
|
3246
3262
|
' args = fromStdJson(args_json)\n' +
|
|
3247
|
-
'
|
|
3263
|
+
' func_ = func\n' +
|
|
3264
|
+
' if type(func) == STRING:\n' +
|
|
3265
|
+
' func_ = funcByName(func)\n' +
|
|
3266
|
+
' if type(args) != ANY:\n' +
|
|
3248
3267
|
' args = cast(args, ANY)\n' +
|
|
3249
|
-
' return unifiedCall(
|
|
3250
|
-
|
|
3268
|
+
' return unifiedCall(func_, args)\n'
|
|
3269
|
+
:
|
|
3270
|
+
'\n' +
|
|
3271
|
+
'def invoke (func, args_json) {\n' +
|
|
3272
|
+
' args = fromStdJson(args_json)\n' +
|
|
3273
|
+
' func_ = func\n' +
|
|
3274
|
+
' if (type(func) == STRING)\n' +
|
|
3275
|
+
' func_ = funcByName(func)\n' +
|
|
3276
|
+
' if (type(args) != ANY)\n' +
|
|
3277
|
+
' args = cast(args, ANY)\n' +
|
|
3278
|
+
' return unifiedCall(func_, args)\n' +
|
|
3279
|
+
'}\n', { urgent: true }));
|
|
3280
|
+
}
|
|
3281
|
+
catch (error) {
|
|
3282
|
+
// invoke 没有正确执行时,重新将 pinvoke 赋值为 undefined
|
|
3283
|
+
this.pinvoke = undefined;
|
|
3284
|
+
throw error;
|
|
3285
|
+
}
|
|
3251
3286
|
// 检查 args 是否全部为简单参数,是则直接调用 call,避免 invoke 间接调用
|
|
3252
3287
|
// 逻辑类似 DdbObj.to_ddbobjs, 需要同步修改
|
|
3253
3288
|
let simple = true;
|
|
@@ -3264,12 +3299,8 @@ export class DDB {
|
|
|
3264
3299
|
break;
|
|
3265
3300
|
}
|
|
3266
3301
|
}
|
|
3267
|
-
if (!simple)
|
|
3268
|
-
|
|
3269
|
-
throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
|
|
3270
|
-
if (options?.node)
|
|
3271
|
-
options.func_type = DdbFunctionType.UserDefinedFunc;
|
|
3272
|
-
}
|
|
3302
|
+
if (!simple && has_ddbobj)
|
|
3303
|
+
throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
|
|
3273
3304
|
const result = simple
|
|
3274
3305
|
? await this.call(func, args, options)
|
|
3275
3306
|
: await this.call('invoke', [func, JSON.stringify(args)], options);
|