dolphindb 2.0.1014 → 2.0.1016

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
@@ -338,6 +338,8 @@ export interface StreamingMessage extends StreamingParams {
338
338
  /** message id */
339
339
  id: bigint;
340
340
  colnames: string[];
341
+ /** 最新的 server 有可能先推一个 table schema 过来 */
342
+ schema?: DdbTableObj;
341
343
  /** 订阅主题,即一个订阅的名称。 Subscription topic, which is the name of a subscription.
342
344
  它是一个字符串,由订阅表所在节点的别名、流数据表名称和订阅任务名称(如果指定了 actionName)组合而成,使用 `/` 分隔
343
345
  It is a string consisting of the alias of the node where the subscription table is located, the stream data table name, and the subscription task name (if actionName is specified), separated by `/` */
package/browser.js CHANGED
@@ -2039,7 +2039,7 @@ export function nanotimestamp2str(nanotimestamp, format = 'YYYY.MM.DD HH:mm:ss.S
2039
2039
  assert(i_nanosecond_start !== -1, t('格式串必须包含纳秒的格式 (SSSSSSSSS)'));
2040
2040
  const remainder = nanotimestamp % 1000000000n;
2041
2041
  const borrow = remainder < 0n;
2042
- const ms = Number(nanotimestamp / 1000000n);
2042
+ const ms = Number((nanotimestamp - remainder + (borrow ? -1000000000n : 0n)) / 1000000n);
2043
2043
  return (dayjs(_datetime_formatter.format(new Date(ms))).format(format.slice(0, i_second_end)) +
2044
2044
  format.slice(i_second_end, i_nanosecond_start) +
2045
2045
  String(borrow ?
@@ -2658,14 +2658,19 @@ export class DDB {
2658
2658
  rows: 0,
2659
2659
  segments: [],
2660
2660
  };
2661
+ let schema;
2661
2662
  // 先准备好收到 websocket message 的 callback
2662
2663
  this.on_message = buffer => {
2663
2664
  try {
2664
2665
  const dv = new DataView(buffer);
2665
2666
  const buf = new Uint8Array(buffer);
2666
2667
  const i_topic_end = buf.indexOf(0, 17);
2667
- // 是 column 片段组成的 any vector
2668
+ // 首个 message 可能是 table schema, 后续消息是 column 片段组成的 any vector
2668
2669
  const data = DdbObj.parse(buf.subarray(i_topic_end + 1), this.le);
2670
+ if (data.form === DdbForm.table) {
2671
+ schema = data;
2672
+ return;
2673
+ }
2669
2674
  const { rows } = data.value[0];
2670
2675
  win.rows += rows;
2671
2676
  win.segments.push(data);
@@ -2686,6 +2691,7 @@ export class DDB {
2686
2691
  rows,
2687
2692
  topic: this.dec.decode(buf.subarray(17, i_topic_end)),
2688
2693
  colnames,
2694
+ schema,
2689
2695
  data,
2690
2696
  window: win,
2691
2697
  });