dolphindb 2.0.901 → 2.0.903

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.js CHANGED
@@ -7,6 +7,7 @@ import 'xshell/prototype.browser.js';
7
7
  import { blue, cyan, green, grey, magenta } from 'xshell/chalk.browser.js';
8
8
  import { concat, assert } from 'xshell/utils.browser.js';
9
9
  import { connect_websocket } from 'xshell/net.browser.js';
10
+ import { t } from './i18n/index.js';
10
11
  export var DdbForm;
11
12
  (function (DdbForm) {
12
13
  DdbForm[DdbForm["scalar"] = 0] = "scalar";
@@ -17,14 +18,14 @@ export var DdbForm;
17
18
  DdbForm[DdbForm["dict"] = 5] = "dict";
18
19
  DdbForm[DdbForm["table"] = 6] = "table";
19
20
  DdbForm[DdbForm["chart"] = 7] = "chart";
20
- /** Node internal communication may be used, calling function execution script generally does not return this type */
21
+ /** 结点内部通信可能会使用,调用函数执行脚本一般不会返回这种类型 Node internal communication may be used, calling function execution script generally does not return this type */
21
22
  DdbForm[DdbForm["chunk"] = 8] = "chunk";
22
23
  /** sysobj */
23
24
  DdbForm[DdbForm["object"] = 9] = "object";
24
25
  })(DdbForm = DdbForm || (DdbForm = {}));
25
26
  /** DolphinDB DataType
26
- The corresponding array vector type is 64 + base type
27
- The corresponding extended type is 128 + base type
27
+ 对应的 array vector 类型为 64 + 基本类型 The corresponding array vector type is 64 + base type
28
+ 对应的 extended 类型为 128 + 基本类型 The corresponding extended type is 128 + base type
28
29
  */
29
30
  export var DdbType;
30
31
  (function (DdbType) {
@@ -472,7 +473,7 @@ export class DdbObj {
472
473
  return [12, { scale: dv.getInt32(0, le), data: data === nulls.int64 ? null : data }];
473
474
  }
474
475
  default:
475
- throw new Error(`${DdbType[type] || type} 暂时不支持解析`);
476
+ throw new Error(String(DdbType[type] || type) + t(' 暂时不支持解析'));
476
477
  }
477
478
  }
478
479
  /** parse: rows, cols, items
@@ -567,7 +568,7 @@ export class DdbObj {
567
568
  lengths = new Uint32Array(lengths_buf.buffer);
568
569
  break;
569
570
  default:
570
- throw new Error(`array vector 存在非法 unit = ${unit}`);
571
+ throw new Error(t('array vector 存在非法 unit: {{unit}}', { unit }));
571
572
  }
572
573
  let total_length = 0;
573
574
  for (const x of lengths)
@@ -892,7 +893,7 @@ export class DdbObj {
892
893
  return [Int32Array.of(scale), BigInt64Array.of(data === null ? nulls.int64 : data)];
893
894
  }
894
895
  default:
895
- throw new Error(`${DdbType[type] || type} 暂时不支持序列化`);
896
+ throw new Error(String(DdbType[type] || type) + t(' 暂时不支持序列化'));
896
897
  }
897
898
  case DdbForm.vector:
898
899
  case DdbForm.pair:
@@ -957,7 +958,7 @@ export class DdbObj {
957
958
  ];
958
959
  }
959
960
  default:
960
- throw new Error(`${DdbForm[form]} serialization is not currently supported`);
961
+ throw new Error(t('vector {{type}} 暂不支持序列化', { type: DdbType[type] || type }));
961
962
  }
962
963
  })();
963
964
  if (!body)
@@ -1049,7 +1050,7 @@ export class DdbObj {
1049
1050
  return [Int32Array.of(scale), data];
1050
1051
  }
1051
1052
  default:
1052
- throw new Error(`vector ${DdbType[type]} 暂不支持序列化`);
1053
+ throw new Error(t('vector {{type}} 暂不支持序列化', { type: String(DdbType[type] || type) }));
1053
1054
  }
1054
1055
  }
1055
1056
  toString(options = { nullstr: true, quote: true }) {
@@ -1201,7 +1202,7 @@ export class DdbObj {
1201
1202
  case 'boolean':
1202
1203
  return new DdbBool(value);
1203
1204
  default:
1204
- throw new Error(`Cannot automatically convert ${type} to DdbObj`);
1205
+ throw new Error(t('不能自动转换 {{type}} 至 DdbObj', { type }));
1205
1206
  }
1206
1207
  }
1207
1208
  /** 转换 js 数组为 DdbObj[] */
@@ -1209,7 +1210,7 @@ export class DdbObj {
1209
1210
  return values.map(value => this.to_ddbobj(value));
1210
1211
  }
1211
1212
  to_cols() {
1212
- assert(this.form === DdbForm.table, 'form must be DdbForm.table, otherwise it cannot to_cols');
1213
+ assert(this.form === DdbForm.table, t('form 必须是 DdbForm.table, 否则不能 to_cols'));
1213
1214
  return this.value.map(col => ({
1214
1215
  title: col.name,
1215
1216
  dataIndex: col.name,
@@ -1217,7 +1218,7 @@ export class DdbObj {
1217
1218
  }));
1218
1219
  }
1219
1220
  to_rows() {
1220
- assert(this.form === DdbForm.table, 'form must be DdbForm.table, otherwise it cannot to_rows');
1221
+ assert(this.form === DdbForm.table, t('form 必须是 DdbForm.table, 否则不能 to_rows'));
1221
1222
  let rows = new Array(this.rows);
1222
1223
  for (let i = 0; i < this.rows; i++) {
1223
1224
  let row = {};
@@ -1249,10 +1250,10 @@ export class DdbObj {
1249
1250
  return rows;
1250
1251
  }
1251
1252
  to_dict({ strip, deep, } = {}) {
1252
- assert(this.form === DdbForm.dict, 'this.form must be DdbForm.dict, otherwise to_dict cannot be called to convert to js object');
1253
+ assert(this.form === DdbForm.dict, t('this.form 必须是 DdbForm.dict, 否则不能调用 to_dict 转换为 js object'));
1253
1254
  const [{ value: keys, type: key_type }, { value: values, type: value_type }] = this.value;
1254
- assert(key_type === DdbType.string && value_type === DdbType.any, 'Currently only supports automatic conversion of dict<string, any> to js object');
1255
- assert(!(deep && !strip), 'strip = true must be set when deep = true');
1255
+ assert(key_type === DdbType.string && value_type === DdbType.any, t('当前只支持自动转换 dict<string, any> 为 js object'));
1256
+ assert(!(deep && !strip), t('deep = true 时必须设置 strip = true'));
1256
1257
  let obj = {};
1257
1258
  for (let i = 0; i < this.rows; i++) {
1258
1259
  let value = values[i];
@@ -1264,12 +1265,12 @@ export class DdbObj {
1264
1265
  return obj;
1265
1266
  }
1266
1267
  }
1267
- /** Integer must use this number formatter, InspectOptions.decimals also use this if not passed */
1268
+ /** 整数一定用这个 number formatter, InspectOptions.decimals 不传也用这个 Integer must use this number formatter, InspectOptions.decimals also use this if not passed */
1268
1269
  let default_formatter = Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
1269
1270
  let _decimals = 20;
1270
- /** Cache, in order to optimize performance, usually options.decimals are unchanged */
1271
+ /** 缓存,为了优化性能,通常 options.decimals 都是不变的 Cache, in order to optimize performance, usually options.decimals are unchanged */
1271
1272
  let _formatter = Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
1272
- /** Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
1273
+ /** 根据 DdbType 格式化单个元素 (value) 为字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
1273
1274
  export function format(type, value, le, options = {}) {
1274
1275
  const { decimals, nullstr = false, colors = false, quote = false } = options;
1275
1276
  const formatter = (() => {
@@ -1479,7 +1480,7 @@ export function format(type, value, le, options = {}) {
1479
1480
  return String(value);
1480
1481
  }
1481
1482
  }
1482
- /** formatted vector, the index-th item in the collection is a string */
1483
+ /** 格式化向量、集合中的第 index 项为字符串 formatted vector, the index-th item in the collection is a string */
1483
1484
  export function formati(obj, index, options = {}) {
1484
1485
  assert(index < obj.rows, 'index < obj.rows');
1485
1486
  if (64 <= obj.type && obj.type < 128) { // array vector
@@ -1814,10 +1815,11 @@ export class DdbSetString extends DdbObj {
1814
1815
  });
1815
1816
  }
1816
1817
  }
1817
- /** Constructs a DdbDict object, which supports two usages:
1818
- - The incoming type is the keys of DdbObj<DdbVectorValue>, and the two parameters of values directly form the DdbDict of dict<keys.type, values.type>
1819
- - Pass in js object (type is Record<string, boolean | string | DdbObj>), automatically converted to DdbDict of dict<string, any>
1820
- */
1818
+ /** 构造 DdbDict 对象,支持两种用法: Constructs a DdbDict object, which supports two usages:
1819
+ - 传入类型是 DdbVectorObj 的 keys, values 两个参数直接组成 dict<keys.type, values.type> 的 DdbDict
1820
+ The incoming type is the keys of DdbObj<DdbVectorValue>, and the two parameters of values directly form the DdbDict of dict<keys.type, values.type>
1821
+ - 传入 js object (类型是 Record<string, boolean | string | DdbObj>), 自动转换为 dict<string, any> 的 DdbDict
1822
+ Pass in js object (type is Record<string, boolean | string | DdbObj>), automatically converted to DdbDict of dict<string, any> */
1821
1823
  export class DdbDict extends DdbObj {
1822
1824
  constructor(arg0, arg1) {
1823
1825
  if (arg1)
@@ -1947,7 +1949,7 @@ export function timestamp2ms(timestamp) {
1947
1949
  /** format timestamp (bigint) to string
1948
1950
  - timestamp: bigint value
1949
1951
  - format?:
1950
- format string, default to `YYYY.MM.DD HH:mm:ss.SSS`
1952
+ 格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS` format string, default to `YYYY.MM.DD HH:mm:ss.SSS`
1951
1953
  https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
1952
1954
  */
1953
1955
  export function timestamp2str(timestamp, format = 'YYYY.MM.DD HH:mm:ss.SSS') {
@@ -1971,15 +1973,16 @@ export function datehour2str(datehour, format = 'YYYY.MM.DDTHH') {
1971
1973
  dayjs(1000 * 60 * new Date(ms).getTimezoneOffset() + ms).format(format);
1972
1974
  }
1973
1975
  /** parse timestamp string to bigint value
1974
- - str: timestamp string, If it is an empty string or 'null', it will return the corresponding empty value (nulls.int64)
1976
+ - str: timestamp string, 如果为空字符串或 'null' 会返回对应的空值 (nulls.int64)
1977
+ timestamp string, If it is an empty string or 'null', it will return the corresponding empty value (nulls.int64)
1975
1978
  - format?:
1976
- The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSS`
1979
+ 对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS` The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSS`
1977
1980
  https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
1978
1981
  */
1979
1982
  export function str2timestamp(str, format = 'YYYY.MM.DD HH:mm:ss.SSS') {
1980
1983
  if (!str || str === 'null')
1981
1984
  return nulls.int64;
1982
- assert(str.length === format.length, 'The length of the timestamp string must be equal to the length of the format string');
1985
+ assert(str.length === format.length, t('timestamp 字符串长度必须等于格式串长度'));
1983
1986
  const ms = dayjs(str, format).valueOf();
1984
1987
  return BigInt(-(1000 * 60 * new Date(ms).getTimezoneOffset()) +
1985
1988
  ms);
@@ -1993,10 +1996,10 @@ export function nanotime2str(nanotime, format = 'HH:mm:ss.SSSSSSSSS') {
1993
1996
  if (nanotime < 0n)
1994
1997
  return String(nanotime);
1995
1998
  const i_second_start = format.indexOf('ss');
1996
- assert(i_second_start !== -1, 'The format string must contain the format for seconds (ss)');
1999
+ assert(i_second_start !== -1, t('格式串必须包含秒的格式 (ss)'));
1997
2000
  const i_second_end = i_second_start + 2;
1998
2001
  const i_nanosecond_start = format.indexOf('SSSSSSSSS', i_second_end);
1999
- assert(i_nanosecond_start !== -1, 'Format string must contain nanosecond format (SSSSSSSSS)');
2002
+ assert(i_nanosecond_start !== -1, t('格式串必须包含纳秒的格式 (SSSSSSSSS)'));
2000
2003
  const ms = Number(nanotime) / 1000000;
2001
2004
  return (dayjs(1000 * 60 * new Date(ms).getTimezoneOffset() + ms).format(format.slice(0, i_second_end)) +
2002
2005
  format.slice(i_second_end, i_nanosecond_start) +
@@ -2012,8 +2015,8 @@ export function nanotimestamp2ns(nanotimestamp) {
2012
2015
  /** format nanotimestamp value (bigint) to string
2013
2016
  - nanotimestamp: bigint value
2014
2017
  - format?:
2015
- format string, default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
2016
- Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included)
2018
+ 格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSSSSSSSS` format string, default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
2019
+ 秒的格式为 ss (必须包含); 纳秒的格式为 SSSSSSSSS (必须包含) Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included)
2017
2020
  https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
2018
2021
  */
2019
2022
  export function nanotimestamp2str(nanotimestamp, format = 'YYYY.MM.DD HH:mm:ss.SSSSSSSSS') {
@@ -2026,10 +2029,10 @@ export function nanotimestamp2str(nanotimestamp, format = 'YYYY.MM.DD HH:mm:ss.S
2026
2029
  if (nanotimestamp === null || nanotimestamp === nulls.int64)
2027
2030
  return 'null';
2028
2031
  const i_second_start = format.indexOf('ss');
2029
- assert(i_second_start !== -1, 'The format string must contain the format for seconds (ss)');
2032
+ assert(i_second_start !== -1, t('格式串必须包含秒的格式 (ss)'));
2030
2033
  const i_second_end = i_second_start + 2;
2031
2034
  const i_nanosecond_start = format.indexOf('SSSSSSSSS', i_second_end);
2032
- assert(i_nanosecond_start !== -1, 'Format string must contain nanosecond format (SSSSSSSSS)');
2035
+ assert(i_nanosecond_start !== -1, t('格式串必须包含纳秒的格式 (SSSSSSSSS)'));
2033
2036
  const remainder = nanotimestamp % 1000000000n;
2034
2037
  const borrow = remainder < 0n;
2035
2038
  const ms = Number(nanotimestamp / 1000000n);
@@ -2043,21 +2046,23 @@ export function nanotimestamp2str(nanotimestamp, format = 'YYYY.MM.DD HH:mm:ss.S
2043
2046
  remainder).padStart(9, '0'));
2044
2047
  }
2045
2048
  /** parse nano timestamp string to bigint value
2046
- - str: nano timestamp string, If it is an empty string or 'null', it will return the corresponding empty value (nulls.int64)
2049
+ - str: nano timestamp string, 如果为空字符串或 'null' 会返回对应的空值 (nulls.int64)
2050
+ nano timestamp string, If it is an empty string or 'null', it will return the corresponding empty value (nulls.int64)
2047
2051
  - format?:
2048
- The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
2049
- Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included)
2052
+ 对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
2053
+ 秒的格式为 ss (必须包含); 纳秒的格式为 SSSSSSSSS (必须包含)
2050
2054
  https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
2051
- */
2055
+ The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
2056
+ Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included) */
2052
2057
  export function str2nanotimestamp(str, format = 'YYYY.MM.DD HH:mm:ss.SSSSSSSSS') {
2053
2058
  if (!str || str === 'null')
2054
2059
  return nulls.int64;
2055
- assert(str.length === format.length, 'nanotimestamp string length must be equal to format string length');
2060
+ assert(str.length === format.length, t('nanotimestamp 字符串长度必须等于格式串长度'));
2056
2061
  const i_second_start = format.indexOf('ss');
2057
- assert(i_second_start !== -1, 'The format string must contain the format for seconds (ss)');
2062
+ assert(i_second_start !== -1, t('格式串必须包含秒的格式 (ss)'));
2058
2063
  const i_second_end = i_second_start + 2;
2059
2064
  const i_nanosecond_start = format.indexOf('SSSSSSSSS', i_second_end);
2060
- assert(i_nanosecond_start !== -1, 'Format string must contain nanosecond format (SSSSSSSSS)');
2065
+ assert(i_nanosecond_start !== -1, t('格式串必须包含纳秒的格式 (SSSSSSSSS)'));
2061
2066
  const ms = dayjs(str.slice(0, i_second_end), format.slice(0, i_second_end)).valueOf();
2062
2067
  return (BigInt(-(1000 * 60 * new Date(ms).getTimezoneOffset()) +
2063
2068
  ms) * 1000000n
@@ -2090,7 +2095,7 @@ export const winsize = 10_0000;
2090
2095
  export class ConnectionError extends Error {
2091
2096
  ddb;
2092
2097
  constructor(ddb) {
2093
- super(`websocket is disconnected: ${ddb.url}`);
2098
+ super(`${t('websocket 连接已断开')}: ${ddb.url}`);
2094
2099
  this.ddb = ddb;
2095
2100
  }
2096
2101
  }
@@ -2109,15 +2114,15 @@ export class DDB {
2109
2114
  le = true;
2110
2115
  /** little endian (client) */
2111
2116
  static le_client = Boolean(new Uint8Array(Uint32Array.of(1).buffer)[0]);
2112
- /** Whether to automatically log in after the connection is established, the default is true */
2117
+ /** 是否在建立连接后自动登录,默认 true Whether to automatically log in after the connection is established, the default is true */
2113
2118
  autologin = true;
2114
- /** DolphinDB username */
2119
+ /** DolphinDB 登录用户名 DolphinDB username */
2115
2120
  username = 'admin';
2116
- /** DolphinDB password */
2121
+ /** DolphinDB 登录密码 DolphinDB password */
2117
2122
  password = '123456';
2118
2123
  /** python session flag (2048) */
2119
2124
  python = false;
2120
- /** Whether it is a streaming data connection, this field is always null for non-streaming data */
2125
+ /** 是否为流数据连接,非流数据这个字段恒为 null Whether it is a streaming data connection, this field is always null for non-streaming data */
2121
2126
  streaming = null;
2122
2127
  // --- 内部选项, 状态
2123
2128
  print_message_buffer = false;
@@ -2134,20 +2139,21 @@ export class DDB {
2134
2139
  return this.websocket?.readyState === WebSocket.OPEN;
2135
2140
  }
2136
2141
  /**
2137
- Initialize an instance of DolphinDB Client using the WebSocket URL
2138
- (without establishing an actual network connection)
2139
- - url?: DolphinDB WebSocket URL. e.g.:`ws://127.0.0.1:8848`, Defaults to the current page URL
2142
+ 使用 WebSocket URL 初始化连接到 DolphinDB 的实例(不建立实际的网络连接)
2143
+ Initialize an instance of DolphinDB Client using the WebSocket URL (without establishing an actual network connection)
2144
+ - url?: DolphinDB WebSocket URL,如:`ws://127.0.0.1:8848`, 默认为当前页面 URL
2145
+ DolphinDB WebSocket URL. e.g.:`ws://127.0.0.1:8848`, Defaults to the current page URL
2140
2146
  - options?:
2141
- - autologin?: Whether to log in automatically after establishing a connection, default `true`
2142
- - username?: DolphinDB username, default `'admin'`
2143
- - password?: DolphinDB password, default `'123456'`
2144
- - python?: set python session flag, default `false`
2145
- - streaming?: When this option is set, the WebSocket connection is only used for streaming data
2147
+ - autologin?: 是否在建立连接后自动登录,默认 `true` Whether to log in automatically after establishing a connection, default `true`
2148
+ - username?: DolphinDB 登录用户名,默认 `'admin'` DolphinDB username, default `'admin'`
2149
+ - password?: DolphinDB 登录密码,默认 `'123456'` DolphinDB password, default `'123456'`
2150
+ - python?: 设置 python session flag,默认 `false` set python session flag, default `false`
2151
+ - streaming?: 设置该选项后,该 WebSocket 连接只用于流数据 When this option is set, the WebSocket connection is only used for streaming data
2146
2152
 
2147
2153
  @example
2148
2154
  let ddb = new DDB('ws://127.0.0.1:8848')
2149
2155
 
2150
- // Encrypt with HTTPS
2156
+ // 使用 HTTPS 加密 Encrypt with HTTPS
2151
2157
  let ddbsecure = new DDB('wss://dolphindb.com', {
2152
2158
  autologin: true,
2153
2159
  username: 'admin',
@@ -2178,9 +2184,9 @@ export class DDB {
2178
2184
  on_message(event) {
2179
2185
  // 这里的实现一定会被 connect 中的实现覆盖
2180
2186
  }
2181
- /** Establish a actual websocket connection to the DolphindB corresponding to the URL
2182
- After calling, it will ensure that it has been connected to the database (ensure that websocket.ReadyState is open), otherwise an error will be reported
2183
- this.autologin automatically log in when it is true */
2187
+ /** 建立实际的 WebSocket 连接到 URL 对应的 DolphinDB Establish a actual websocket connection to the DolphindB corresponding to the URL
2188
+ 是幂等的,调用后会确保已连接到数据库 (确保 websocket.readyState 为 open),否则报错 After calling, it will ensure that it has been connected to the database (ensure that websocket.ReadyState is open), otherwise an error will be reported
2189
+ this.autologin 为 true 时自动登录 this.autologin automatically log in when it is true */
2184
2190
  async connect() {
2185
2191
  if (this.connected)
2186
2192
  return;
@@ -2193,7 +2199,7 @@ export class DDB {
2193
2199
  try {
2194
2200
  if (!this.connected) {
2195
2201
  this.on_message = (event) => {
2196
- assert(false, 'This is the default on_message before calling this.rpc, and it should not be called. Unless the server pushed message first after the connection is established');
2202
+ assert(false, t('这是在调用 this.rpc 之前默认的 on_message, 不应该被调用到,除非建立连接后 server 先推送了 message'));
2197
2203
  };
2198
2204
  this.presult = Promise.resolve(null);
2199
2205
  this.pnode_run_defined = false;
@@ -2257,6 +2263,7 @@ export class DDB {
2257
2263
  this.websocket.close(1000);
2258
2264
  }
2259
2265
  /** rpc through websocket (function/script/variable command)
2266
+ 未连接到 DDB 时调用会自动连接,连接断开时调用会抛出 ConnectionError
2260
2267
  When the DDB is not connected, the call will be automatically connected. When the connection is disconnected, the call will throw the Connectionerror
2261
2268
  - type: API 类型: 'script' | 'function' | 'variable'
2262
2269
  - options:
@@ -2395,11 +2402,14 @@ export class DDB {
2395
2402
  return presult;
2396
2403
  }
2397
2404
  /** eval script through websocket (script command)
2398
- - script?: Script to execute
2399
- - options?: execution options
2400
- - urgent?: Urgent flag to ensure that submitted scripts are processed by urgent workers to prevent being blocked by other jobs
2401
- - listener?: Process messages during this rpc (DdbMessage)
2402
- - parse_object?: Set parse_object during this rpc, and restore the original after the end.
2405
+ - script?: 执行的脚本 Script to execute
2406
+ - options?: 执行选项 execution options
2407
+ - urgent?: 紧急 flag,确保提交的脚本使用 urgent worker 处理,防止被其它作业阻塞
2408
+ Urgent flag to ensure that submitted scripts are processed by urgent workers to prevent being blocked by other jobs
2409
+ - listener?: 处理本次 rpc 期间的消息 (DdbMessage) Process messages during this rpc (DdbMessage)
2410
+ - parse_object?: 在该次 rpc 期间设置 parse_object, 结束后恢复原有,为 false 时返回的 DdbObj 仅含有 buffer 和 le,
2411
+ 不做解析,以便后续转发、序列化
2412
+ Set parse_object during this rpc, and restore the original after the end.
2403
2413
  When it is false, the returned DdbObj only contains buffer and le without parsing,
2404
2414
  so as to facilitate subsequent forwarding and serialization
2405
2415
  */
@@ -2407,22 +2417,31 @@ export class DDB {
2407
2417
  return this.rpc('script', { script, urgent, listener, parse_object });
2408
2418
  }
2409
2419
  /** call function through websocket (function command)
2410
- - func: function name
2411
- - args?: `[ ]` Call parameters (the incoming native string and boolean will be automatically converted to DdbObj<string> and DdbObj<boolean>)
2412
- - options?: call options
2413
- - urgent?: Emergency flag. Use urgent worker execution to prevent being blocked by other jobs
2414
- - node?: When the node alias is set, it is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB)
2415
- - nodes?: When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
2416
- - func_type?: It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases
2417
- - add_node_alias?: Select to pass when setting the nodes parameter, otherwise not pass
2418
- - listener?: Process messages during this rpc (DdbMessage)
2419
- - parse_object?: Set parse_object during this rpc, and restore the original after the end.
2420
+ - func: 函数名 function name
2421
+ - args?: `[ ]` 调用参数 (传入的原生 string 和 boolean 会被自动转换为 DdbObj<string> 和 DdbObj<boolean>)
2422
+ Call parameters (the incoming native string and boolean will be automatically converted to DdbObj<string> and DdbObj<boolean>)
2423
+ - options?: 调用选项 call options
2424
+ - urgent?: 紧急 flag。使用 urgent worker 执行,防止被其它作业阻塞
2425
+ Emergency flag. Use urgent worker execution to prevent being blocked by other jobs
2426
+ - node?: 设置结点 alias 时发送到集群中对应的结点执行 (使用 DolphinDB 中的 rpc 方法)
2427
+ When the node alias is set, it is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB)
2428
+ - nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
2429
+ When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
2430
+ - func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
2431
+ It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases
2432
+ - add_node_alias?: 设置 nodes 参数时选传,其它情况不传
2433
+ Select to pass when setting the nodes parameter, otherwise not pass
2434
+ - listener?: 处理本次 rpc 期间的消息 (DdbMessage)
2435
+ Process messages during this rpc (DdbMessage)
2436
+ - parse_object?: 在该次 rpc 期间设置 parse_object, 结束后恢复原有,为 false 时返回的 DdbObj 仅含有 buffer 和 le,
2437
+ 不做解析,以便后续转发、序列化
2438
+ Set parse_object during this rpc, and restore the original after the end.
2420
2439
  When it is false, the returned DdbObj only contains buffer and le without parsing,
2421
2440
  so as to facilitate subsequent forwarding and serialization
2422
2441
  */
2423
2442
  async call(func, args = [], { urgent, node, nodes, func_type, add_node_alias, listener, parse_object, } = {}) {
2424
2443
  if (node) {
2425
- assert(func_type in DdbFunctionType, 'func_type must be set when specifying node');
2444
+ assert(func_type in DdbFunctionType, t('指定 node 时必须设置 func_type'));
2426
2445
  args = [
2427
2446
  node,
2428
2447
  new DdbFunction(func, func_type),
@@ -2455,14 +2474,14 @@ export class DDB {
2455
2474
  }
2456
2475
  /** upload variable through websocket (variable command) */
2457
2476
  async upload(
2458
- /** Uploaded variables' name */
2477
+ /** 上传的变量名 Uploaded variables' name */
2459
2478
  vars,
2460
- /** Uploaded variables' value */
2479
+ /** 上传的变量值 Uploaded variables' value */
2461
2480
  args, { listener, parse_object, } = {}) {
2462
- assert(args.length && args.length === vars.length, 'variable command parameter cannot be empty and parameter name cannot be empty, and the number should match');
2481
+ assert(args.length && args.length === vars.length, t('variable 指令参数不能为空且参数名不能为空,且数量应该匹配'));
2463
2482
  return this.rpc('variable', { vars, args, listener, parse_object });
2464
2483
  }
2465
- /** Cancel all console jobs corresponding to the current session id */
2484
+ /** 取消当前 session id 对应的所有 console jobs Cancel all console jobs corresponding to the current session id */
2466
2485
  async cancel() {
2467
2486
  let ddb = new DDB(this.url, this);
2468
2487
  try {
@@ -2494,7 +2513,7 @@ export class DDB {
2494
2513
  /** session id */
2495
2514
  const sid = parts[0];
2496
2515
  if (sid !== this.sid) {
2497
- console.log(`sid 从 ${this.sid} 变为 ${sid}`);
2516
+ console.log(t('session id 从 {{sid}} 变为 {{sid_}}', { sid: this.sid, sid_: sid }));
2498
2517
  this.sid = sid;
2499
2518
  }
2500
2519
  /** 返回对象的数量 */
@@ -2527,12 +2546,12 @@ export class DDB {
2527
2546
  })
2528
2547
  };
2529
2548
  }
2530
- /** Internal stream subscription method */
2549
+ /** 内部的流订阅方法 Internal stream subscription method */
2531
2550
  async subscribe() {
2532
2551
  await this.rpc('connect', {});
2533
2552
  if (this.autologin)
2534
2553
  await this.call('login', [this.username, this.password]);
2535
- console.log('Subscribed to streaming table, colnames:',
2554
+ console.log(t('订阅流表成功') + ', colnames:',
2536
2555
  // string[3](['time', 'stock', 'price'])
2537
2556
  this.streaming.colnames = (await this.call('publishTable', [
2538
2557
  'localhost',