MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / DefaultExecutionOptions

Class DefaultExecutionOptions

lib/execution-options.js:363–608  ·  view source on GitHub ↗

* Internal implementation of ExecutionOptions that uses the value from the client options and execution * profile into account. * @ignore

Source from the content-addressed store, hash-verified

361 * @ignore
362 */
363class DefaultExecutionOptions extends ExecutionOptions {
364 /**
365 * Creates a new instance of {@link ExecutionOptions}.
366 * @param {QueryOptions} queryOptions
367 * @param {Client} client
368 * @param {Function|null} rowCallback
369 */
370 constructor(queryOptions, client, rowCallback) {
371 super();
372
373 this._queryOptions = queryOptions;
374 this._rowCallback = rowCallback;
375 this._routingKey = this._queryOptions.routingKey;
376 this._hints = this._queryOptions.hints;
377 this._keyspace = this._queryOptions.keyspace;
378 this._routingIndexes = this._queryOptions.routingIndexes;
379 this._pageState = typeof this._queryOptions.pageState === 'string' ?
380 utils.allocBufferFromString(this._queryOptions.pageState, 'hex') : this._queryOptions.pageState;
381 this._preferredHost = null;
382
383 this._client = client;
384 this._defaultQueryOptions = client.options.queryOptions;
385 this._profile = client.profileManager.getProfile(this._queryOptions.executionProfile);
386
387 // Build a custom payload object designed for DSE-specific functionality
388 this._customPayload = DefaultExecutionOptions.createCustomPayload(this._queryOptions, this._defaultQueryOptions);
389
390 if (!this._profile) {
391 throw new errors.ArgumentError(`Execution profile "${this._queryOptions.executionProfile}" not found`);
392 }
393 }
394
395 /**
396 * Creates a payload for given user.
397 * @param {QueryOptions} userOptions
398 * @param {QueryOptions} defaultQueryOptions
399 * @private
400 */
401 static createCustomPayload(userOptions, defaultQueryOptions) {
402 let customPayload = userOptions.customPayload || defaultQueryOptions.customPayload;
403 const executeAs = userOptions.executeAs || defaultQueryOptions.executeAs;
404
405 if (executeAs) {
406 if (!customPayload) {
407 customPayload = {};
408 customPayload[proxyExecuteKey] = utils.allocBufferFromString(executeAs);
409 } else if (!customPayload[proxyExecuteKey]) {
410 // Avoid appending to the existing payload object
411 customPayload = utils.extend({}, customPayload);
412 customPayload[proxyExecuteKey] = utils.allocBufferFromString(executeAs);
413 }
414 }
415
416 return customPayload;
417 }
418
419 /**
420 * Creates a new instance {@link ExecutionOptions}, based on the query options.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected