dolphindb 2.0.510 → 2.0.511

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 CHANGED
@@ -60,10 +60,28 @@ export declare enum DdbFunctionType {
60
60
  JitFunc = 7,
61
61
  JitPartialFunc = 8
62
62
  }
63
+ export declare enum DdbDurationUnit {
64
+ ns = 0,
65
+ us = 1,
66
+ ms = 2,
67
+ s = 3,
68
+ m = 4,
69
+ H = 5,
70
+ d = 6,
71
+ w = 7,
72
+ M = 8,
73
+ y = 9,
74
+ B = 10
75
+ }
63
76
  export interface DdbFunctionDefValue {
64
77
  type: DdbFunctionType;
65
78
  name: string;
66
79
  }
80
+ export interface DdbDurationValue {
81
+ unit: DdbDurationUnit;
82
+ /** int32 */
83
+ data: number;
84
+ }
67
85
  export interface DdbSymbolExtendedValue {
68
86
  base_id: number;
69
87
  base: string[];
@@ -85,7 +103,7 @@ export declare type DdbScalarValue = null | boolean | number | bigint | string |
85
103
  number,
86
104
  number
87
105
  ] | // complex, point
88
- DdbFunctionDefValue;
106
+ DdbFunctionDefValue | DdbDurationValue;
89
107
  export declare type DdbVectorValue = Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | string[] | // string[]
90
108
  Uint8Array[] | // blob
91
109
  DdbObj[] | // any
package/browser.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ddb = exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.str2timestamp = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.DdbTable = exports.DdbSetString = exports.DdbSetDouble = exports.DdbSetInt = exports.DdbVectorSymbol = exports.DdbVectorAny = exports.DdbVectorString = exports.DdbVectorDouble = exports.DdbVectorInt = exports.DdbFunction = exports.DdbPair = exports.DdbNanoTimeStamp = exports.DdbTimeStamp = exports.DdbDateTime = exports.DdbDouble = exports.DdbLong = exports.DdbString = exports.DdbInt = exports.DdbChar = exports.DdbBool = exports.DdbVoid = exports.DdbObj = exports.timezone_offset = exports.nulls = exports.DdbFunctionType = exports.DdbType = exports.DdbForm = void 0;
3
+ exports.ddb = exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.str2timestamp = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.DdbTable = exports.DdbSetString = exports.DdbSetDouble = exports.DdbSetInt = exports.DdbVectorSymbol = exports.DdbVectorAny = exports.DdbVectorString = exports.DdbVectorDouble = exports.DdbVectorInt = exports.DdbFunction = exports.DdbPair = exports.DdbNanoTimeStamp = exports.DdbTimeStamp = exports.DdbDateTime = exports.DdbDouble = exports.DdbLong = exports.DdbString = exports.DdbInt = exports.DdbChar = exports.DdbBool = exports.DdbVoid = exports.DdbObj = exports.timezone_offset = exports.nulls = exports.DdbDurationUnit = exports.DdbFunctionType = exports.DdbType = exports.DdbForm = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
6
6
  const customParseFormat_js_1 = tslib_1.__importDefault(require("dayjs/plugin/customParseFormat.js"));
@@ -72,6 +72,20 @@ var DdbFunctionType;
72
72
  DdbFunctionType[DdbFunctionType["JitFunc"] = 7] = "JitFunc";
73
73
  DdbFunctionType[DdbFunctionType["JitPartialFunc"] = 8] = "JitPartialFunc";
74
74
  })(DdbFunctionType = exports.DdbFunctionType || (exports.DdbFunctionType = {}));
75
+ var DdbDurationUnit;
76
+ (function (DdbDurationUnit) {
77
+ DdbDurationUnit[DdbDurationUnit["ns"] = 0] = "ns";
78
+ DdbDurationUnit[DdbDurationUnit["us"] = 1] = "us";
79
+ DdbDurationUnit[DdbDurationUnit["ms"] = 2] = "ms";
80
+ DdbDurationUnit[DdbDurationUnit["s"] = 3] = "s";
81
+ DdbDurationUnit[DdbDurationUnit["m"] = 4] = "m";
82
+ DdbDurationUnit[DdbDurationUnit["H"] = 5] = "H";
83
+ DdbDurationUnit[DdbDurationUnit["d"] = 6] = "d";
84
+ DdbDurationUnit[DdbDurationUnit["w"] = 7] = "w";
85
+ DdbDurationUnit[DdbDurationUnit["M"] = 8] = "M";
86
+ DdbDurationUnit[DdbDurationUnit["y"] = 9] = "y";
87
+ DdbDurationUnit[DdbDurationUnit["B"] = 10] = "B";
88
+ })(DdbDurationUnit = exports.DdbDurationUnit || (exports.DdbDurationUnit = {}));
75
89
  exports.nulls = {
76
90
  int8: -0x80,
77
91
  int16: -32768,
@@ -369,6 +383,16 @@ class DdbObj {
369
383
  ]
370
384
  ];
371
385
  }
386
+ case DdbType.duration: {
387
+ const dv = new DataView(buf.buffer, buf.byteOffset);
388
+ return [
389
+ 8,
390
+ {
391
+ unit: dv.getUint32(4, le),
392
+ data: dv.getInt32(0, le)
393
+ }
394
+ ];
395
+ }
372
396
  default:
373
397
  return [0, buf];
374
398
  }
@@ -602,6 +626,13 @@ class DdbObj {
602
626
  values
603
627
  ];
604
628
  }
629
+ // case DdbType.duration: -> 实际会返回一个 any vector
630
+ // [2y, 1M, 3d, 7H, 11m, 12s, 15ms, 16us, 17ns]
631
+ // <Buffer 19 01 type = any, form = vector
632
+ // 09 00 00 00 01 00 00 00 rows = 9, cols = 1
633
+ // 24 00 type = DdbType.duration, form = scalar
634
+ // 02 00 00 00 09 00 00 00
635
+ // 24 00 01 00 00 00 08 00 00 00 24 00 03 00 00 00 06 00 00 00 24 00 07 00 00 00 05 00 00 00 ... 50 more bytes>
605
636
  default:
606
637
  return [0, buf];
607
638
  }
@@ -703,8 +734,10 @@ class DdbObj {
703
734
  case DdbType.complex:
704
735
  case DdbType.point:
705
736
  return [Float64Array.from(this.value)];
706
- case DdbType.duration:
707
- return [value];
737
+ case DdbType.duration: {
738
+ const { unit, data } = this.value;
739
+ return [Int32Array.of(data, unit)];
740
+ }
708
741
  case DdbType.handle:
709
742
  throw new Error('DolphinDB Server 不支持 handle 的反序列化');
710
743
  default:
@@ -887,6 +920,10 @@ class DdbObj {
887
920
  switch (this.type) {
888
921
  case DdbType.functiondef:
889
922
  return `'${this.value.name}'`;
923
+ case DdbType.duration: {
924
+ const { data, unit } = this.value;
925
+ return `${data}${DdbDurationUnit[unit]}`;
926
+ }
890
927
  case DdbType.string:
891
928
  return `'${this.value}'`;
892
929
  }