dolphindb 3.0.122 → 3.0.124
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 +73 -64
- package/browser.js.map +1 -1
- package/i18n/dict.json +3 -0
- package/index.d.ts +3 -5
- package/index.js +73 -64
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/test.js.map +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
|
@@ -825,41 +825,20 @@ export class DdbObj {
|
|
|
825
825
|
];
|
|
826
826
|
}
|
|
827
827
|
case DdbType.iotany: {
|
|
828
|
-
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
const size =
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
for (let i =
|
|
835
|
-
const
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
i_value_start += 4;
|
|
839
|
-
indexes[i * 2] = type;
|
|
840
|
-
indexes[i * 2 + 1] = idx;
|
|
841
|
-
}
|
|
842
|
-
// 构造 sub vector
|
|
843
|
-
const type_size = dv.getUint32(i_value_start, le);
|
|
844
|
-
i_value_start += 4;
|
|
845
|
-
const sub_vec = new Map();
|
|
846
|
-
for (let i = 0; i < type_size; i++) {
|
|
847
|
-
const flag = dv.getUint16(i_value_start, le);
|
|
848
|
-
i_value_start += 2;
|
|
849
|
-
const form = flag >> 8;
|
|
850
|
-
const sub_type = flag & 0xff;
|
|
851
|
-
assert(form === DdbForm.vector, t('iotany sub vector 不支持非 vector 类型'));
|
|
852
|
-
const sub_size = dv.getUint32(i_value_start, le);
|
|
853
|
-
i_value_start += 8; // 同时跳过 sub_size 和 cols
|
|
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);
|
|
856
|
-
i_value_start += len;
|
|
857
|
-
sub_vec.set(sub_type, vector);
|
|
828
|
+
const [len, anys] = this.parse_vector_items(buf, le, DdbType.any, length);
|
|
829
|
+
const metas = anys[0].data();
|
|
830
|
+
assert(metas.length >= 2, t('iotany 的 meta vector 长度至少为 2'));
|
|
831
|
+
const size = metas[0];
|
|
832
|
+
// let sub_vec_count = meta_vec[1]
|
|
833
|
+
let sub_vecs = new Map();
|
|
834
|
+
for (let i = 1; i < length; i++) {
|
|
835
|
+
const sub_vector = anys[i];
|
|
836
|
+
const sub_type = sub_vector.type;
|
|
837
|
+
sub_vecs.set(sub_type, converts(sub_type, sub_vector.data(), sub_vector.length, le));
|
|
858
838
|
}
|
|
859
839
|
return [
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
seq(size, i => (sub_vec.get(indexes[i * 2]))[indexes[i * 2 + 1]])
|
|
840
|
+
len,
|
|
841
|
+
seq(size, i => (sub_vecs.get(metas[i + size + 2]))[metas[i + 2]])
|
|
863
842
|
];
|
|
864
843
|
}
|
|
865
844
|
// 25 01 type = decimal32, form = vector
|
|
@@ -2785,6 +2764,8 @@ export class DDB {
|
|
|
2785
2764
|
ppnode_run;
|
|
2786
2765
|
/** 首次定义 invoke 的 promise,保证并发调用 rpc 时只定义一次 invoke */
|
|
2787
2766
|
pinvoke;
|
|
2767
|
+
/** 首次定义 jsrpc 的 promise,保证并发调用 rpc 时只定义一次 jsrpc */
|
|
2768
|
+
pjsrpc;
|
|
2788
2769
|
get connected() {
|
|
2789
2770
|
return !this.error && this.lwebsocket.resource?.readyState === WebSocket.OPEN;
|
|
2790
2771
|
}
|
|
@@ -3173,8 +3154,6 @@ export class DDB {
|
|
|
3173
3154
|
When the node alias is set, it is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB)
|
|
3174
3155
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
3175
3156
|
When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
|
|
3176
|
-
- func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
|
|
3177
|
-
It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases
|
|
3178
3157
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
3179
3158
|
Select to pass when setting the nodes parameter, otherwise not pass
|
|
3180
3159
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage)
|
|
@@ -3188,18 +3167,41 @@ export class DDB {
|
|
|
3188
3167
|
将这个 flag 设为 true 跳过连接状态检查
|
|
3189
3168
|
(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.
|
|
3190
3169
|
Set this flag to true to skip connection status checks */
|
|
3191
|
-
async call(func, args = [], { urgent, node, nodes,
|
|
3170
|
+
async call(func, args = [], { urgent, node, nodes, add_node_alias, listener, parse_object, skip_connection_check, on_more_messages } = {}) {
|
|
3171
|
+
let func_ = func;
|
|
3172
|
+
let args_ = args;
|
|
3192
3173
|
if (node) {
|
|
3193
|
-
|
|
3194
|
-
|
|
3174
|
+
try {
|
|
3175
|
+
await (this.pjsrpc ??= this.eval(this.python ?
|
|
3176
|
+
'\n' +
|
|
3177
|
+
'def jsrpc (node, func_name, args):\n' +
|
|
3178
|
+
' args_ = args\n' +
|
|
3179
|
+
' if func_name == "invoke":\n' +
|
|
3180
|
+
' args_[0] = funcByName(args[0])\n' +
|
|
3181
|
+
' return rpc(node, unifiedCall, funcByName(func_name), args_)\n'
|
|
3182
|
+
:
|
|
3183
|
+
'\n' +
|
|
3184
|
+
'def jsrpc (node, func_name, args) {\n' +
|
|
3185
|
+
' args_ = args\n' +
|
|
3186
|
+
' if (func_name == "invoke")\n' +
|
|
3187
|
+
' args_[0] = funcByName(args[0])\n' +
|
|
3188
|
+
' return rpc(node, unifiedCall, funcByName(func_name), args_)\n' +
|
|
3189
|
+
'}\n', { urgent: true }));
|
|
3190
|
+
}
|
|
3191
|
+
catch (error) {
|
|
3192
|
+
this.pjsrpc = undefined;
|
|
3193
|
+
throw error;
|
|
3194
|
+
}
|
|
3195
|
+
func_ = 'jsrpc';
|
|
3196
|
+
args_ = [
|
|
3195
3197
|
node,
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
+
func,
|
|
3199
|
+
new DdbVectorAny(args)
|
|
3198
3200
|
];
|
|
3199
|
-
func = 'rpc';
|
|
3200
3201
|
}
|
|
3201
3202
|
if (nodes) {
|
|
3202
|
-
|
|
3203
|
+
func_ = 'pnode_run';
|
|
3204
|
+
args_ = [
|
|
3203
3205
|
new DdbVectorString(nodes),
|
|
3204
3206
|
func,
|
|
3205
3207
|
new DdbVectorAny(args),
|
|
@@ -3211,11 +3213,10 @@ export class DDB {
|
|
|
3211
3213
|
return [];
|
|
3212
3214
|
})()
|
|
3213
3215
|
];
|
|
3214
|
-
func = 'pnode_run';
|
|
3215
3216
|
}
|
|
3216
3217
|
return this.rpc('function', {
|
|
3217
|
-
func,
|
|
3218
|
-
args,
|
|
3218
|
+
func: func_,
|
|
3219
|
+
args: args_,
|
|
3219
3220
|
urgent,
|
|
3220
3221
|
listener,
|
|
3221
3222
|
parse_object,
|
|
@@ -3230,25 +3231,37 @@ export class DDB {
|
|
|
3230
3231
|
- urgent?: 紧急 flag。使用 urgent worker 执行,防止被其它作业阻塞
|
|
3231
3232
|
- node?: 设置结点 alias 时发送到集群中对应的结点执行 (使用 DolphinDB 中的 rpc 方法)
|
|
3232
3233
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
3233
|
-
- func_type?: 设置 node 参数且参数数组为空时必传,需指定函数类型,其它情况下不传
|
|
3234
3234
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
3235
3235
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
|
|
3236
3236
|
async invoke(func, args, options) {
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
'def invoke (func_name, args_json):\n' +
|
|
3240
|
-
' args = fromStdJson(args_json)\n' +
|
|
3241
|
-
' if type(args) != ANY:\n' +
|
|
3242
|
-
' args = cast(args, ANY)\n' +
|
|
3243
|
-
' return unifiedCall(funcByName(func_name), args)\n'
|
|
3244
|
-
:
|
|
3237
|
+
try {
|
|
3238
|
+
await (this.pinvoke ??= this.eval(this.python ?
|
|
3245
3239
|
'\n' +
|
|
3246
|
-
'def invoke (
|
|
3240
|
+
'def invoke (func, args_json):\n' +
|
|
3247
3241
|
' args = fromStdJson(args_json)\n' +
|
|
3248
|
-
'
|
|
3242
|
+
' func_ = func\n' +
|
|
3243
|
+
' if type(func) == STRING:\n' +
|
|
3244
|
+
' func_ = funcByName(func)\n' +
|
|
3245
|
+
' if type(args) != ANY:\n' +
|
|
3249
3246
|
' args = cast(args, ANY)\n' +
|
|
3250
|
-
' return unifiedCall(
|
|
3251
|
-
|
|
3247
|
+
' return unifiedCall(func_, args)\n'
|
|
3248
|
+
:
|
|
3249
|
+
'\n' +
|
|
3250
|
+
'def invoke (func, args_json) {\n' +
|
|
3251
|
+
' args = fromStdJson(args_json)\n' +
|
|
3252
|
+
' func_ = func\n' +
|
|
3253
|
+
' if (type(func) == STRING)\n' +
|
|
3254
|
+
' func_ = funcByName(func)\n' +
|
|
3255
|
+
' if (type(args) != ANY)\n' +
|
|
3256
|
+
' args = cast(args, ANY)\n' +
|
|
3257
|
+
' return unifiedCall(func_, args)\n' +
|
|
3258
|
+
'}\n', { urgent: true }));
|
|
3259
|
+
}
|
|
3260
|
+
catch (error) {
|
|
3261
|
+
// invoke 没有正确执行时,重新将 pinvoke 赋值为 undefined
|
|
3262
|
+
this.pinvoke = undefined;
|
|
3263
|
+
throw error;
|
|
3264
|
+
}
|
|
3252
3265
|
// 检查 args 是否全部为简单参数,是则直接调用 call,避免 invoke 间接调用
|
|
3253
3266
|
// 逻辑类似 DdbObj.to_ddbobjs, 需要同步修改
|
|
3254
3267
|
let simple = true;
|
|
@@ -3265,12 +3278,8 @@ export class DDB {
|
|
|
3265
3278
|
break;
|
|
3266
3279
|
}
|
|
3267
3280
|
}
|
|
3268
|
-
if (!simple)
|
|
3269
|
-
|
|
3270
|
-
throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
|
|
3271
|
-
if (options?.node)
|
|
3272
|
-
options.func_type = DdbFunctionType.UserDefinedFunc;
|
|
3273
|
-
}
|
|
3281
|
+
if (!simple && has_ddbobj)
|
|
3282
|
+
throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
|
|
3274
3283
|
const result = simple
|
|
3275
3284
|
? await this.call(func, args, options)
|
|
3276
3285
|
: await this.call('invoke', [func, JSON.stringify(args)], options);
|