@deephaven-enterprise/query-utils 2026.1.48 → 2026.1.49

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.
@@ -16,12 +16,14 @@ export interface DefaultDraftQuery extends Omit<DraftQuery, 'id' | 'defaults'> {
16
16
  export type IDraftQuery = PlainEditableQueryInfo & {
17
17
  isClientSide: boolean;
18
18
  draftOwner: string;
19
+ /** @deprecated Thread counts are stored directly in jvmArguments. */
19
20
  initializationThreads?: string;
21
+ /** @deprecated Thread counts are stored directly in jvmArguments. */
20
22
  updateThreads?: string;
21
23
  defaults?: DefaultDraftQuery;
22
24
  isModified: boolean;
23
25
  };
24
- export type DraftQueryConstructorObject = Partial<IDraftQuery> & Pick<IDraftQuery, 'name' | 'owner' | 'draftOwner' | 'dbServerName' | 'initializationThreads' | 'updateThreads'>;
26
+ export type DraftQueryConstructorObject = Partial<IDraftQuery> & Pick<IDraftQuery, 'name' | 'owner' | 'draftOwner' | 'dbServerName'>;
25
27
  /**
26
28
  * A Draft Query is a client side object that contains mutable data for a Peristent Query along with some metadata.
27
29
  */
@@ -69,8 +71,6 @@ export declare class DraftQuery implements IDraftQuery {
69
71
  readonly SPARE_COUNT: "spareCount";
70
72
  readonly ASSIGNMENT_POLICY: "assignmentPolicy";
71
73
  readonly ASSIGNMENT_POLICY_PARAMS: "assignmentPolicyParams";
72
- readonly INITIALIZATION_THREADS: "initializationThreads";
73
- readonly UPDATE_THREADS: "updateThreads";
74
74
  readonly DEFAULTS: "defaults";
75
75
  readonly ENV_VAR_ENTRIES: "envVarEntries";
76
76
  readonly JVM_ARGUMENTS: "jvmArguments";
@@ -146,14 +146,6 @@ export declare class DraftQuery implements IDraftQuery {
146
146
  spareCount: number;
147
147
  assignmentPolicy: string | null;
148
148
  assignmentPolicyParams: string | null;
149
- /**
150
- * initialiZationThreads and updateThreads are thread counts only used for Core workers.
151
- * Additionally, they are not part of a Query object. These values are in Extra JVM Args.
152
- * When a draft is created, they will be parsed and removed from JVM args.
153
- * When the query is saved, they will be written to JVM args.
154
- */
155
- initializationThreads: string;
156
- updateThreads: string;
157
149
  defaults?: DefaultDraftQuery;
158
150
  updateSchedule(): void;
159
151
  /**
@@ -169,14 +161,6 @@ export declare class DraftQuery implements IDraftQuery {
169
161
  * @param editableQuery the Editable Query from the Server
170
162
  */
171
163
  saveDraftToQuery<T extends PlainEditableQueryInfo>(editableQuery: Partial<T> & Pick<T, 'serial'>): T;
172
- /**
173
- * Updates the JVM args to include the thread count for initialization and update threads.
174
- * It is safe to call from saveDraftToQuery because the the thead counts will be set to
175
- * system defaults for Legacy workers, which will not affect the JVM args.
176
- * However, saving a new draft does not call saveDraftToQuery, so this method should be called
177
- * manually in that case.
178
- */
179
- addThreadCountToJVMArgs(): void;
180
164
  /**
181
165
  * Get a PlainEditableQueryInfo object populated from this DraftQuery
182
166
  */
@@ -105,15 +105,15 @@ export class DraftQuery {
105
105
  this.spareCount = spareCount;
106
106
  this.assignmentPolicy = assignmentPolicy;
107
107
  this.assignmentPolicyParams = assignmentPolicyParams;
108
- // If the thread counts are not provided, they are read from the JVM args
109
- // And they need to be removed from the JVM args
108
+ // Thread counts live in jvmArguments. If old persisted data supplied them as
109
+ // separate fields, migrate them in so they are not lost.
110
110
  const jvmArgsArray = jvmArguments !== null && jvmArguments !== void 0 ? jvmArguments : tokenizeArgs(jvmArgs);
111
- this.initializationThreads =
112
- initializationThreads !== null && initializationThreads !== void 0 ? initializationThreads : WorkerThreadUtils.getDisplayStringFromJvmArgs(jvmArgsArray, WorkerThreadUtils.INITIALIZATION_THREADS_ARG);
113
- this.updateThreads =
114
- updateThreads !== null && updateThreads !== void 0 ? updateThreads : WorkerThreadUtils.getDisplayStringFromJvmArgs(jvmArgsArray, WorkerThreadUtils.UPDATE_THREADS_ARG);
115
- // The thread count args should always be removed from the JVM args as they are stored in the DraftQuery
116
- this.jvmArguments = WorkerThreadUtils.removeArgs(jvmArgsArray);
111
+ if (initializationThreads !== undefined || updateThreads !== undefined) {
112
+ this.jvmArguments = WorkerThreadUtils.migrateThreadArgs(jvmArgsArray, initializationThreads, updateThreads);
113
+ }
114
+ else {
115
+ this.jvmArguments = jvmArgsArray;
116
+ }
117
117
  // The scheduling array is parsed into a scheduler object
118
118
  this.scheduling = [];
119
119
  this.scheduler = new QueryScheduler(scheduling);
@@ -175,7 +175,6 @@ export class DraftQuery {
175
175
  * @param editableQuery the Editable Query from the Server
176
176
  */
177
177
  saveDraftToQuery(editableQuery) {
178
- this.addThreadCountToJVMArgs();
179
178
  // Type check to make sure none of the required fields are missing
180
179
  const completeQuery = {
181
180
  serial: editableQuery.serial,
@@ -213,17 +212,6 @@ export class DraftQuery {
213
212
  Object.assign(editableQuery, completeQuery);
214
213
  return editableQuery;
215
214
  }
216
- /**
217
- * Updates the JVM args to include the thread count for initialization and update threads.
218
- * It is safe to call from saveDraftToQuery because the the thead counts will be set to
219
- * system defaults for Legacy workers, which will not affect the JVM args.
220
- * However, saving a new draft does not call saveDraftToQuery, so this method should be called
221
- * manually in that case.
222
- */
223
- addThreadCountToJVMArgs() {
224
- const { initializationThreads, updateThreads } = this;
225
- this.jvmArguments = WorkerThreadUtils.addArgs(this.jvmArguments, initializationThreads, updateThreads);
226
- }
227
215
  /**
228
216
  * Get a PlainEditableQueryInfo object populated from this DraftQuery
229
217
  */
@@ -304,8 +292,6 @@ DraftQuery.FIELDS = Object.freeze({
304
292
  SPARE_COUNT: 'spareCount',
305
293
  ASSIGNMENT_POLICY: `assignmentPolicy`,
306
294
  ASSIGNMENT_POLICY_PARAMS: `assignmentPolicyParams`,
307
- INITIALIZATION_THREADS: 'initializationThreads',
308
- UPDATE_THREADS: 'updateThreads',
309
295
  DEFAULTS: 'defaults',
310
296
  ENV_VAR_ENTRIES: 'envVarEntries',
311
297
  JVM_ARGUMENTS: 'jvmArguments',
@@ -88,12 +88,10 @@ export declare function createQueryConfigViewportSubscription({ columnNames, cor
88
88
  * @param config.heapSize JVM heap size multiplier (default: 0.5)
89
89
  * @param config.isClientSide Whether this is a client-side query (default: true)
90
90
  * @param config.isCommunityWorker Whether this is a Community (Core+) worker (default: false)
91
- * @param config.initializationThreads Number of threads for initialization (Core+ only)
92
- * @param config.updateThreads Number of threads for updates (Core+ only)
93
91
  * @param config.timeout Timeout in milliseconds before auto-deletion (default: 60000)
94
92
  * @returns A configured DraftQuery instance ready to be created
95
93
  */
96
- export declare function createTemporaryDraftQuery({ additionalMemory, engine, heapSize, isClientSide, isCommunityWorker, initializationThreads, updateThreads, timeout, ...config }: TemporaryDraftQueryConfig): DraftQuery;
94
+ export declare function createTemporaryDraftQuery({ additionalMemory, engine, heapSize, isClientSide, isCommunityWorker, timeout, ...config }: TemporaryDraftQueryConfig): DraftQuery;
97
95
  /**
98
96
  * Fetch the WebClientData QueryInfo table from the WebClientTableFactory widget.
99
97
  * @param corePlusManager CorePlus manager for worker connections
@@ -131,13 +131,11 @@ export async function createQueryConfigViewportSubscription({ columnNames, coreP
131
131
  * @param config.heapSize JVM heap size multiplier (default: 0.5)
132
132
  * @param config.isClientSide Whether this is a client-side query (default: true)
133
133
  * @param config.isCommunityWorker Whether this is a Community (Core+) worker (default: false)
134
- * @param config.initializationThreads Number of threads for initialization (Core+ only)
135
- * @param config.updateThreads Number of threads for updates (Core+ only)
136
134
  * @param config.timeout Timeout in milliseconds before auto-deletion (default: 60000)
137
135
  * @returns A configured DraftQuery instance ready to be created
138
136
  */
139
137
  export function createTemporaryDraftQuery(_a) {
140
- var { additionalMemory = 0, engine, heapSize = 0.5, isClientSide = true, isCommunityWorker = false, initializationThreads, updateThreads, timeout = DEFAULT_TEMPORARY_QUERY_TIMEOUT_MS } = _a, config = __rest(_a, ["additionalMemory", "engine", "heapSize", "isClientSide", "isCommunityWorker", "initializationThreads", "updateThreads", "timeout"]);
138
+ var { additionalMemory = 0, engine, heapSize = 0.5, isClientSide = true, isCommunityWorker = false, timeout = DEFAULT_TEMPORARY_QUERY_TIMEOUT_MS } = _a, config = __rest(_a, ["additionalMemory", "engine", "heapSize", "isClientSide", "isCommunityWorker", "timeout"]);
141
139
  const scheduling = QueryScheduler.makeTemporaryScheduling({
142
140
  autoDelete: true,
143
141
  queueName: INTERACTIVE_CONSOLE_TEMPORARY_QUEUE_NAME,
@@ -146,10 +144,7 @@ export function createTemporaryDraftQuery(_a) {
146
144
  heapSize,
147
145
  isClientSide,
148
146
  scheduling,
149
- timeout, workerKind: engine, initializationThreads: isCommunityWorker
150
- ? initializationThreads
151
- : undefined, updateThreads: isCommunityWorker ? updateThreads : undefined }));
152
- draftQuery.addThreadCountToJVMArgs();
147
+ timeout, workerKind: engine }));
153
148
  draftQuery.updateSchedule();
154
149
  return draftQuery;
155
150
  }
@@ -34,14 +34,31 @@ export declare abstract class WorkerThreadUtils {
34
34
  */
35
35
  static removeArgs(jvmArgs: string[]): string[];
36
36
  /**
37
- * Adds the thread count arguments to the provided jvmArgs array.
37
+ * Sets a single thread-count argument in the provided jvmArgs array.
38
+ * If `displayValue` is `SYSTEM_DEFAULT_STRING`, any existing entry for
39
+ * `argName` is removed. Otherwise the entry is replaced if it already exists
40
+ * or appended if it does not.
38
41
  *
39
42
  * @param jvmArgs the array of JVM arguments
40
- * @param initializationThreads the display string for the initialization threads
41
- * @param updateThreads the display string for the update threads
42
- * @returns a new array with the thread count arguments added
43
+ * @param argName the argument name (without the leading `-D` or `=value`)
44
+ * @param displayValue the display string for the thread count
45
+ * @returns a new array with the argument set or removed
43
46
  */
44
- static addArgs(jvmArgs: string[], initializationThreads: string, updateThreads: string): string[];
47
+ static setArg(jvmArgs: string[], argName: string, displayValue: string): string[];
48
+ /**
49
+ * Migrates separately-stored thread-count fields into the jvmArguments array.
50
+ * Used for backward compat when loading old persisted data that stored
51
+ * `initializationThreads` / `updateThreads` as independent fields instead of
52
+ * inside `jvmArguments`.
53
+ *
54
+ * Pass `undefined` for either count to leave that arg unchanged.
55
+ *
56
+ * @param jvmArgs the current JVM arguments array
57
+ * @param initializationThreads the old initializationThreads display string, or undefined
58
+ * @param updateThreads the old updateThreads display string, or undefined
59
+ * @returns a new array with the thread counts set (or cleared when undefined)
60
+ */
61
+ static migrateThreadArgs(jvmArgs: string[], initializationThreads: string | undefined, updateThreads: string | undefined): string[];
45
62
  /**
46
63
  * Gets the display string for the provided value.
47
64
  *
@@ -22,7 +22,9 @@ export class WorkerThreadUtils {
22
22
  * @returns the display string or the system default string if not found
23
23
  */
24
24
  static getDisplayStringFromJvmArgs(jvmArgs, argName) {
25
- for (let i = 0; i < jvmArgs.length; i += 1) {
25
+ // Iterate in reverse — when duplicate -D args are present the JVM uses the
26
+ // last one, so the UI should reflect the same winning value.
27
+ for (let i = jvmArgs.length - 1; i >= 0; i -= 1) {
26
28
  if (jvmArgs[i].startsWith(`-D${argName}=`)) {
27
29
  return WorkerThreadUtils.getDisplayString(jvmArgs[i].split('=')[1]);
28
30
  }
@@ -40,23 +42,48 @@ export class WorkerThreadUtils {
40
42
  return jvmArgs.filter(arg => !WorkerThreadUtils.ALL_ARGS.some(argName => arg.startsWith(`-D${argName}=`)));
41
43
  }
42
44
  /**
43
- * Adds the thread count arguments to the provided jvmArgs array.
45
+ * Sets a single thread-count argument in the provided jvmArgs array.
46
+ * If `displayValue` is `SYSTEM_DEFAULT_STRING`, any existing entry for
47
+ * `argName` is removed. Otherwise the entry is replaced if it already exists
48
+ * or appended if it does not.
44
49
  *
45
50
  * @param jvmArgs the array of JVM arguments
46
- * @param initializationThreads the display string for the initialization threads
47
- * @param updateThreads the display string for the update threads
48
- * @returns a new array with the thread count arguments added
51
+ * @param argName the argument name (without the leading `-D` or `=value`)
52
+ * @param displayValue the display string for the thread count
53
+ * @returns a new array with the argument set or removed
49
54
  */
50
- static addArgs(jvmArgs, initializationThreads, updateThreads) {
51
- const result = [...jvmArgs];
52
- // The default value means "do not set an extra JVM arg"
53
- if (WorkerThreadUtils.isValidThreadCount(initializationThreads) &&
54
- initializationThreads !== WorkerThreadUtils.SYSTEM_DEFAULT_STRING) {
55
- result.push(`-D${WorkerThreadUtils.INITIALIZATION_THREADS_ARG}=${WorkerThreadUtils.getValue(initializationThreads)}`);
55
+ static setArg(jvmArgs, argName, displayValue) {
56
+ const prefix = `-D${argName}=`;
57
+ const filtered = jvmArgs.filter(arg => !arg.startsWith(prefix));
58
+ if (displayValue === WorkerThreadUtils.SYSTEM_DEFAULT_STRING ||
59
+ !WorkerThreadUtils.isValidThreadCount(displayValue)) {
60
+ return filtered;
56
61
  }
57
- if (WorkerThreadUtils.isValidThreadCount(updateThreads) &&
58
- updateThreads !== WorkerThreadUtils.SYSTEM_DEFAULT_STRING) {
59
- result.push(`-D${WorkerThreadUtils.UPDATE_THREADS_ARG}=${WorkerThreadUtils.getValue(updateThreads)}`);
62
+ return [
63
+ ...filtered,
64
+ `${prefix}${WorkerThreadUtils.getValue(displayValue)}`,
65
+ ];
66
+ }
67
+ /**
68
+ * Migrates separately-stored thread-count fields into the jvmArguments array.
69
+ * Used for backward compat when loading old persisted data that stored
70
+ * `initializationThreads` / `updateThreads` as independent fields instead of
71
+ * inside `jvmArguments`.
72
+ *
73
+ * Pass `undefined` for either count to leave that arg unchanged.
74
+ *
75
+ * @param jvmArgs the current JVM arguments array
76
+ * @param initializationThreads the old initializationThreads display string, or undefined
77
+ * @param updateThreads the old updateThreads display string, or undefined
78
+ * @returns a new array with the thread counts set (or cleared when undefined)
79
+ */
80
+ static migrateThreadArgs(jvmArgs, initializationThreads, updateThreads) {
81
+ let result = jvmArgs;
82
+ if (initializationThreads != null) {
83
+ result = WorkerThreadUtils.setArg(result, WorkerThreadUtils.INITIALIZATION_THREADS_ARG, initializationThreads);
84
+ }
85
+ if (updateThreads != null) {
86
+ result = WorkerThreadUtils.setArg(result, WorkerThreadUtils.UPDATE_THREADS_ARG, updateThreads);
60
87
  }
61
88
  return result;
62
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven-enterprise/query-utils",
3
- "version": "2026.1.48",
3
+ "version": "2026.1.49",
4
4
  "description": "Deephaven Enterprise Query Utils",
5
5
  "author": "Deephaven Data Labs LLC",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -17,8 +17,8 @@
17
17
  "build": "tsc --build"
18
18
  },
19
19
  "dependencies": {
20
- "@deephaven-enterprise/client-utils": "2026.1.48",
21
- "@deephaven-enterprise/jsapi-types": "2026.1.48",
20
+ "@deephaven-enterprise/client-utils": "2026.1.49",
21
+ "@deephaven-enterprise/jsapi-types": "2026.1.49",
22
22
  "@deephaven/jsapi-types": "1.0.0-dev0.40.5",
23
23
  "@deephaven/log": "^0.97.0",
24
24
  "@deephaven/utils": "^0.97.0",