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/index.d.ts
CHANGED
|
@@ -631,7 +631,6 @@ export interface DdbOptions {
|
|
|
631
631
|
export interface DdbCallOptions extends DdbEvalOptions {
|
|
632
632
|
node?: string;
|
|
633
633
|
nodes?: string[];
|
|
634
|
-
func_type?: DdbFunctionType;
|
|
635
634
|
add_node_alias?: boolean;
|
|
636
635
|
skip_connection_check?: boolean;
|
|
637
636
|
on_more_messages?: DdbRpcOptions['on_more_messages'];
|
|
@@ -686,6 +685,8 @@ export declare class DDB {
|
|
|
686
685
|
ppnode_run: Promise<DdbVoid>;
|
|
687
686
|
/** 首次定义 invoke 的 promise,保证并发调用 rpc 时只定义一次 invoke */
|
|
688
687
|
pinvoke: Promise<DdbVoid>;
|
|
688
|
+
/** 首次定义 jsrpc 的 promise,保证并发调用 rpc 时只定义一次 jsrpc */
|
|
689
|
+
pjsrpc: Promise<DdbVoid>;
|
|
689
690
|
get connected(): boolean;
|
|
690
691
|
/**
|
|
691
692
|
使用 WebSocket URL 初始化连接到 DolphinDB 的实例(不建立实际的网络连接)
|
|
@@ -790,8 +791,6 @@ export declare class DDB {
|
|
|
790
791
|
When the node alias is set, it is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB)
|
|
791
792
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
792
793
|
When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
|
|
793
|
-
- func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
|
|
794
|
-
It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases
|
|
795
794
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
796
795
|
Select to pass when setting the nodes parameter, otherwise not pass
|
|
797
796
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage)
|
|
@@ -805,7 +804,7 @@ export declare class DDB {
|
|
|
805
804
|
将这个 flag 设为 true 跳过连接状态检查
|
|
806
805
|
(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.
|
|
807
806
|
Set this flag to true to skip connection status checks */
|
|
808
|
-
call<TResult extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes,
|
|
807
|
+
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>;
|
|
809
808
|
/** 调用 dolphindb 函数,传入 js 原生数组作为参数,返回 js 原生对象或值(调用 DdbObj.data() 后的结果)
|
|
810
809
|
- func: 函数名
|
|
811
810
|
- args?: `[ ]` 调用参数,可以是 js 原生数组,参数在中间且想用 server 函数的默认参数值时可以传 null 占位
|
|
@@ -813,7 +812,6 @@ export declare class DDB {
|
|
|
813
812
|
- urgent?: 紧急 flag。使用 urgent worker 执行,防止被其它作业阻塞
|
|
814
813
|
- node?: 设置结点 alias 时发送到集群中对应的结点执行 (使用 DolphinDB 中的 rpc 方法)
|
|
815
814
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
816
|
-
- func_type?: 设置 node 参数且参数数组为空时必传,需指定函数类型,其它情况下不传
|
|
817
815
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
818
816
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
|
|
819
817
|
invoke<TResult = any>(func: string, args?: any[], options?: DdbInvokeOptions): Promise<TResult>;
|
package/index.js
CHANGED
|
@@ -848,7 +848,8 @@ export class DdbObj {
|
|
|
848
848
|
assert(form === DdbForm.vector, t('iotany sub vector 不支持非 vector 类型'));
|
|
849
849
|
const sub_size = dv.getUint32(i_value_start, le);
|
|
850
850
|
i_value_start += 8; // 同时跳过 sub_size 和 cols
|
|
851
|
-
|
|
851
|
+
let [len, vector] = this.parse_vector_items(buf.subarray(i_value_start), le, sub_type, sub_size);
|
|
852
|
+
vector = converts(sub_type, vector, sub_size, le);
|
|
852
853
|
i_value_start += len;
|
|
853
854
|
sub_vec.set(sub_type, vector);
|
|
854
855
|
}
|
|
@@ -2760,6 +2761,8 @@ export class DDB {
|
|
|
2760
2761
|
ppnode_run;
|
|
2761
2762
|
/** 首次定义 invoke 的 promise,保证并发调用 rpc 时只定义一次 invoke */
|
|
2762
2763
|
pinvoke;
|
|
2764
|
+
/** 首次定义 jsrpc 的 promise,保证并发调用 rpc 时只定义一次 jsrpc */
|
|
2765
|
+
pjsrpc;
|
|
2763
2766
|
get connected() {
|
|
2764
2767
|
return !this.error && this.lwebsocket.resource?.readyState === WebSocketOpen;
|
|
2765
2768
|
}
|
|
@@ -3150,8 +3153,6 @@ export class DDB {
|
|
|
3150
3153
|
When the node alias is set, it is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB)
|
|
3151
3154
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
3152
3155
|
When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
|
|
3153
|
-
- func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
|
|
3154
|
-
It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases
|
|
3155
3156
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
3156
3157
|
Select to pass when setting the nodes parameter, otherwise not pass
|
|
3157
3158
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage)
|
|
@@ -3165,18 +3166,41 @@ export class DDB {
|
|
|
3165
3166
|
将这个 flag 设为 true 跳过连接状态检查
|
|
3166
3167
|
(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.
|
|
3167
3168
|
Set this flag to true to skip connection status checks */
|
|
3168
|
-
async call(func, args = [], { urgent, node, nodes,
|
|
3169
|
+
async call(func, args = [], { urgent, node, nodes, add_node_alias, listener, parse_object, skip_connection_check, on_more_messages } = {}) {
|
|
3170
|
+
let func_ = func;
|
|
3171
|
+
let args_ = args;
|
|
3169
3172
|
if (node) {
|
|
3170
|
-
|
|
3171
|
-
|
|
3173
|
+
try {
|
|
3174
|
+
await (this.pjsrpc ??= this.eval(this.python ?
|
|
3175
|
+
'\n' +
|
|
3176
|
+
'def jsrpc (node, func_name, args):\n' +
|
|
3177
|
+
' args_ = args\n' +
|
|
3178
|
+
' if func_name == "invoke":\n' +
|
|
3179
|
+
' args_[0] = funcByName(args[0])\n' +
|
|
3180
|
+
' return rpc(node, unifiedCall, funcByName(func_name), args_)\n'
|
|
3181
|
+
:
|
|
3182
|
+
'\n' +
|
|
3183
|
+
'def jsrpc (node, func_name, args) {\n' +
|
|
3184
|
+
' args_ = args\n' +
|
|
3185
|
+
' if (func_name == "invoke")\n' +
|
|
3186
|
+
' args_[0] = funcByName(args[0])\n' +
|
|
3187
|
+
' return rpc(node, unifiedCall, funcByName(func_name), args_)\n' +
|
|
3188
|
+
'}\n', { urgent: true }));
|
|
3189
|
+
}
|
|
3190
|
+
catch (error) {
|
|
3191
|
+
this.pjsrpc = undefined;
|
|
3192
|
+
throw error;
|
|
3193
|
+
}
|
|
3194
|
+
func_ = 'jsrpc';
|
|
3195
|
+
args_ = [
|
|
3172
3196
|
node,
|
|
3173
|
-
|
|
3174
|
-
|
|
3197
|
+
func,
|
|
3198
|
+
new DdbVectorAny(args)
|
|
3175
3199
|
];
|
|
3176
|
-
func = 'rpc';
|
|
3177
3200
|
}
|
|
3178
3201
|
if (nodes) {
|
|
3179
|
-
|
|
3202
|
+
func_ = 'pnode_run';
|
|
3203
|
+
args_ = [
|
|
3180
3204
|
new DdbVectorString(nodes),
|
|
3181
3205
|
func,
|
|
3182
3206
|
new DdbVectorAny(args),
|
|
@@ -3188,11 +3212,10 @@ export class DDB {
|
|
|
3188
3212
|
return [];
|
|
3189
3213
|
})()
|
|
3190
3214
|
];
|
|
3191
|
-
func = 'pnode_run';
|
|
3192
3215
|
}
|
|
3193
3216
|
return this.rpc('function', {
|
|
3194
|
-
func,
|
|
3195
|
-
args,
|
|
3217
|
+
func: func_,
|
|
3218
|
+
args: args_,
|
|
3196
3219
|
urgent,
|
|
3197
3220
|
listener,
|
|
3198
3221
|
parse_object,
|
|
@@ -3207,25 +3230,37 @@ export class DDB {
|
|
|
3207
3230
|
- urgent?: 紧急 flag。使用 urgent worker 执行,防止被其它作业阻塞
|
|
3208
3231
|
- node?: 设置结点 alias 时发送到集群中对应的结点执行 (使用 DolphinDB 中的 rpc 方法)
|
|
3209
3232
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
3210
|
-
- func_type?: 设置 node 参数且参数数组为空时必传,需指定函数类型,其它情况下不传
|
|
3211
3233
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
3212
3234
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
|
|
3213
3235
|
async invoke(func, args, options) {
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
'def invoke (func_name, args_json):\n' +
|
|
3217
|
-
' args = fromStdJson(args_json)\n' +
|
|
3218
|
-
' if type(args) != ANY:\n' +
|
|
3219
|
-
' args = cast(args, ANY)\n' +
|
|
3220
|
-
' return unifiedCall(funcByName(func_name), args)\n'
|
|
3221
|
-
:
|
|
3236
|
+
try {
|
|
3237
|
+
await (this.pinvoke ??= this.eval(this.python ?
|
|
3222
3238
|
'\n' +
|
|
3223
|
-
'def invoke (
|
|
3239
|
+
'def invoke (func, args_json):\n' +
|
|
3224
3240
|
' args = fromStdJson(args_json)\n' +
|
|
3225
|
-
'
|
|
3241
|
+
' func_ = func\n' +
|
|
3242
|
+
' if type(func) == STRING:\n' +
|
|
3243
|
+
' func_ = funcByName(func)\n' +
|
|
3244
|
+
' if type(args) != ANY:\n' +
|
|
3226
3245
|
' args = cast(args, ANY)\n' +
|
|
3227
|
-
' return unifiedCall(
|
|
3228
|
-
|
|
3246
|
+
' return unifiedCall(func_, args)\n'
|
|
3247
|
+
:
|
|
3248
|
+
'\n' +
|
|
3249
|
+
'def invoke (func, args_json) {\n' +
|
|
3250
|
+
' args = fromStdJson(args_json)\n' +
|
|
3251
|
+
' func_ = func\n' +
|
|
3252
|
+
' if (type(func) == STRING)\n' +
|
|
3253
|
+
' func_ = funcByName(func)\n' +
|
|
3254
|
+
' if (type(args) != ANY)\n' +
|
|
3255
|
+
' args = cast(args, ANY)\n' +
|
|
3256
|
+
' return unifiedCall(func_, args)\n' +
|
|
3257
|
+
'}\n', { urgent: true }));
|
|
3258
|
+
}
|
|
3259
|
+
catch (error) {
|
|
3260
|
+
// invoke 没有正确执行时,重新将 pinvoke 赋值为 undefined
|
|
3261
|
+
this.pinvoke = undefined;
|
|
3262
|
+
throw error;
|
|
3263
|
+
}
|
|
3229
3264
|
// 检查 args 是否全部为简单参数,是则直接调用 call,避免 invoke 间接调用
|
|
3230
3265
|
// 逻辑类似 DdbObj.to_ddbobjs, 需要同步修改
|
|
3231
3266
|
let simple = true;
|
|
@@ -3242,12 +3277,8 @@ export class DDB {
|
|
|
3242
3277
|
break;
|
|
3243
3278
|
}
|
|
3244
3279
|
}
|
|
3245
|
-
if (!simple)
|
|
3246
|
-
|
|
3247
|
-
throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
|
|
3248
|
-
if (options?.node)
|
|
3249
|
-
options.func_type = DdbFunctionType.UserDefinedFunc;
|
|
3250
|
-
}
|
|
3280
|
+
if (!simple && has_ddbobj)
|
|
3281
|
+
throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
|
|
3251
3282
|
const result = simple
|
|
3252
3283
|
? await this.call(func, args, options)
|
|
3253
3284
|
: await this.call('invoke', [func, JSON.stringify(args)], options);
|