dolphindb 3.1.0 → 3.1.2

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/index.d.ts CHANGED
@@ -174,7 +174,7 @@ export interface InspectOptions extends UtilInspectOptions {
174
174
  export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
175
175
  /** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
176
176
  export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
177
- export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | string[] | number[] | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbSymbolExtendedValue | DdbTensorValue | Uint8Array<ArrayBufferLike> | IotVectorItemValue | DdbDurationVectorValue | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | DdbArrayVectorValue | DdbDecimal128VectorValue | DdbMatrixValue | DdbChartValue;
177
+ export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | number[] | Uint8Array<ArrayBufferLike> | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | string[] | IotVectorItemValue | DdbSymbolExtendedValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDurationVectorValue | DdbTensorValue | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | DdbArrayVectorValue | DdbDecimal128VectorValue | DdbMatrixValue | DdbChartValue;
178
178
  /** 转换一个向量到 js 原生数组 */
179
179
  export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[] | Uint8Array;
180
180
  /** 构造 void 类型,默认为 `DdbVoidType.undefined` */
@@ -571,6 +571,8 @@ export declare class DDB {
571
571
  /** 定义函数并保存,避免下次重复执行定义,会自动提取脚本中的函数名,作为缓存 key,
572
572
  也同时作为返回值
573
573
  - definition: 函数完整定义
574
+ - options?:
575
+ - urgent?: 紧急 flag,确保提交的脚本使用 urgent worker 处理,防止被其它作业阻塞
574
576
  @example
575
577
  await ddb.invoke(
576
578
  await ddb.define(
@@ -578,7 +580,9 @@ export declare class DDB {
578
580
  ' print(bar)\n' +
579
581
  '}\n'),
580
582
  ['hello']) */
581
- define(definition: string): Promise<string>;
583
+ define(definition: string, { urgent }?: {
584
+ urgent?: boolean;
585
+ }): Promise<string>;
582
586
  }
583
587
  export interface DdbMessageListener {
584
588
  (message: DdbMessage, _this: DDB): any;
package/index.js CHANGED
@@ -2935,7 +2935,7 @@ export class DDB {
2935
2935
  }
2936
2936
  let result;
2937
2937
  if (function_definition_pattern.test(func))
2938
- func = await this.define(func);
2938
+ func = await this.define(func, { urgent: options?.urgent });
2939
2939
  if (convertable)
2940
2940
  result = await this.call(func, args, options);
2941
2941
  else {
@@ -3150,6 +3150,8 @@ export class DDB {
3150
3150
  /** 定义函数并保存,避免下次重复执行定义,会自动提取脚本中的函数名,作为缓存 key,
3151
3151
  也同时作为返回值
3152
3152
  - definition: 函数完整定义
3153
+ - options?:
3154
+ - urgent?: 紧急 flag,确保提交的脚本使用 urgent worker 处理,防止被其它作业阻塞
3153
3155
  @example
3154
3156
  await ddb.invoke(
3155
3157
  await ddb.define(
@@ -3157,7 +3159,7 @@ export class DDB {
3157
3159
  ' print(bar)\n' +
3158
3160
  '}\n'),
3159
3161
  ['hello']) */
3160
- async define(definition) {
3162
+ async define(definition, { urgent } = {}) {
3161
3163
  const matches = function_definition_pattern.exec(definition);
3162
3164
  if (!matches)
3163
3165
  throw new Error(t('DDB.define 方法传入的 definition 不符合函数定义格式 def xxx ()'));
@@ -3168,7 +3170,7 @@ export class DDB {
3168
3170
  // 防止并发调用 define 时多次重复定义
3169
3171
  let promise = this.pdefinitions.get(func_name);
3170
3172
  if (!promise)
3171
- this.pdefinitions.set(func_name, promise = this.execute(definition));
3173
+ this.pdefinitions.set(func_name, promise = this.execute(definition, { urgent }));
3172
3174
  await promise;
3173
3175
  this.definitions.set(func_name, definition);
3174
3176
  // 成功定义之后,definitions 中有了,就不需要通过 promise 来防止并发了,清理掉