dolphindb 3.0.119 → 3.0.121

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/i18n/dict.json CHANGED
@@ -100,5 +100,8 @@
100
100
  },
101
101
  "iife 执行的脚本行数应该至少为 2 行": {
102
102
  "en": "The number of script lines executed by iife should be at least 2"
103
+ },
104
+ "iotany sub vector 不支持非 vector 类型": {
105
+ "en": "iotany sub vector does not support non-vector types"
103
106
  }
104
107
  }
package/index.d.ts CHANGED
@@ -69,7 +69,7 @@ export declare enum DdbType {
69
69
  decimal64 = 38,
70
70
  decimal128 = 39,
71
71
  object = 40,
72
- pynone = 41,
72
+ iotany = 41,
73
73
  symbol_extended = 145
74
74
  }
75
75
  export declare enum DdbFunctionType {
@@ -235,7 +235,7 @@ DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value |
235
235
  export type DdbVectorValue = null | Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | BigInt128Array | string[] | // string[]
236
236
  Uint8Array[] | // blob
237
237
  DdbObj[] | // any
238
- DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue;
238
+ IotVectorItemValue | DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue;
239
239
  export type DdbValue = DdbScalarValue | DdbVectorValue | DdbMatrixValue | DdbDictValue | DdbChartValue | DdbTensorValue;
240
240
  export type DdbStringObj = DdbObj<string>;
241
241
  export type DdbVectorObj<TValue extends DdbVectorValue = DdbVectorValue> = DdbObj<TValue>;
@@ -277,6 +277,8 @@ export interface DdbMatrixData {
277
277
  /** 数据, data[0][1] 为第 0 行第 1 列数据 */
278
278
  data: any[][];
279
279
  }
280
+ export type IotVectorItemValue = [number | string | bigint | boolean][];
281
+ export type DdbIotAnyVector = DdbObj<IotVectorItemValue>;
280
282
  /** 可以表示所有 DolphinDB 数据库中的数据类型 Can represent data types in all DolphinDB databases */
281
283
  export declare class DdbObj<TValue extends DdbValue = DdbValue> {
282
284
  static dec: TextDecoder;
@@ -400,7 +402,7 @@ export interface ConvertOptions {
400
402
  /** timestamp 类型转换为字符串表示时显示到秒还是毫秒 */
401
403
  timestamp?: 's' | 'ms';
402
404
  }
403
- export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, timestamp }?: ConvertOptions): string | number | bigint | boolean | Uint8Array | number[] | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | string[] | Uint8Array[] | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | BigInt128Array | DdbObj<DdbValue>[] | DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue | DdbTensorValue;
405
+ export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, timestamp }?: ConvertOptions): string | number | bigint | boolean | Uint8Array | number[] | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | string[] | Uint8Array[] | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | BigInt128Array | DdbObj<DdbValue>[] | IotVectorItemValue | DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue | DdbTensorValue;
404
406
  /** 转换一个向量到 js 原生数组 */
405
407
  export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[];
406
408
  export declare class DdbVoid extends DdbObj<undefined> {
package/index.js CHANGED
@@ -76,7 +76,7 @@ export var DdbType;
76
76
  DdbType[DdbType["decimal64"] = 38] = "decimal64";
77
77
  DdbType[DdbType["decimal128"] = 39] = "decimal128";
78
78
  DdbType[DdbType["object"] = 40] = "object";
79
- DdbType[DdbType["pynone"] = 41] = "pynone";
79
+ DdbType[DdbType["iotany"] = 41] = "iotany";
80
80
  DdbType[DdbType["symbol_extended"] = 145] = "symbol_extended";
81
81
  })(DdbType || (DdbType = {}));
82
82
  export var DdbFunctionType;
@@ -557,6 +557,7 @@ export class DdbObj {
557
557
  cols: 1,
558
558
  rows,
559
559
  value,
560
+ ...type === DdbType.iotany ? { buffer: buf } : {}
560
561
  });
561
562
  }
562
563
  else { // array vector
@@ -820,6 +821,43 @@ export class DdbObj {
820
821
  values
821
822
  ];
822
823
  }
824
+ case DdbType.iotany: {
825
+ // 构造 indexes
826
+ const dv = new DataView(buf.buffer, buf.byteOffset);
827
+ let i_value_start = 0;
828
+ const size = Number(dv.getUint32(i_value_start, le));
829
+ i_value_start += 4;
830
+ const indexes = new Array(size * 2);
831
+ for (let i = 0; i < size; i++) {
832
+ const type = dv.getUint32(i_value_start, le);
833
+ i_value_start += 4;
834
+ const idx = dv.getUint32(i_value_start, le);
835
+ i_value_start += 4;
836
+ indexes[i * 2] = type;
837
+ indexes[i * 2 + 1] = idx;
838
+ }
839
+ // 构造 sub vector
840
+ const type_size = dv.getUint32(i_value_start, le);
841
+ i_value_start += 4;
842
+ const sub_vec = new Map();
843
+ for (let i = 0; i < type_size; i++) {
844
+ const flag = dv.getUint16(i_value_start, le);
845
+ i_value_start += 2;
846
+ const form = flag >> 8;
847
+ const sub_type = flag & 0xff;
848
+ assert(form === DdbForm.vector, t('iotany sub vector 不支持非 vector 类型'));
849
+ const sub_size = dv.getUint32(i_value_start, le);
850
+ i_value_start += 8; // 同时跳过 sub_size 和 cols
851
+ const [len, vector] = this.parse_vector_items(buf.subarray(i_value_start), le, sub_type, sub_size);
852
+ i_value_start += len;
853
+ sub_vec.set(sub_type, vector);
854
+ }
855
+ return [
856
+ i_value_start,
857
+ // 根据 indexes 数组构建最终的 value 数组
858
+ seq(size, i => (sub_vec.get(indexes[i * 2]))[indexes[i * 2 + 1]])
859
+ ];
860
+ }
823
861
  // 25 01 type = decimal32, form = vector
824
862
  // 02 00 00 00 01 00 00 00
825
863
  // 00 00 00 00 scale = 0
@@ -1021,6 +1059,8 @@ export class DdbObj {
1021
1059
  block.data
1022
1060
  ])).flat()
1023
1061
  ];
1062
+ if (form === DdbForm.vector && type === DdbType.iotany)
1063
+ return [this.buffer];
1024
1064
  return [
1025
1065
  Uint32Array.of(this.rows, 1),
1026
1066
  ...DdbObj.pack_vector_body(value, type, this.rows)
@@ -2058,6 +2098,8 @@ export function converts(type, value, rows, le, options) {
2058
2098
  }
2059
2099
  case DdbType.any:
2060
2100
  return value.map(x => x.data(options));
2101
+ case DdbType.iotany:
2102
+ return value;
2061
2103
  default:
2062
2104
  throw new Error(String(DdbType[type] || type) + '[]' + t(' 暂时不支持转换为 js 对象'));
2063
2105
  }
@@ -3189,7 +3231,7 @@ export class DDB {
3189
3231
  let simple = true;
3190
3232
  let has_ddbobj = false;
3191
3233
  if (args)
3192
- for (const arg of args) {
3234
+ for (const arg of args)
3193
3235
  if (arg && arg instanceof DdbObj)
3194
3236
  has_ddbobj = true;
3195
3237
  else {
@@ -3200,7 +3242,6 @@ export class DDB {
3200
3242
  break;
3201
3243
  }
3202
3244
  }
3203
- }
3204
3245
  if (!simple) {
3205
3246
  if (has_ddbobj)
3206
3247
  throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
@@ -3361,7 +3402,7 @@ export class DDB {
3361
3402
  data: seq(rows, i => zip_object(columns, seq(columns.length, j => _data[j][i])))
3362
3403
  };
3363
3404
  }
3364
- data.data.forEach(row => { win.data.push(row); });
3405
+ win.data.push(...data.data);
3365
3406
  win.objs.push(obj);
3366
3407
  if (win.data.length >= winsize * 2 && win.objs.length >= 2) {
3367
3408
  let winsize_ = 0;