import CompressionOptions from '@/services/datastores/cassandra/lib/modules/schema-builder/CompressionOptions' ; import SchemaStatement from '@/services/datastores/cassandra/lib/modules/schema-builder/SchemaStatement' ; import { Version } from './Version' ; /**
 * Encapsulates some of the options used for creating new tables.
 *
 * Constructor expects to be passed the original SQL statement used to create the table (the `parentStatement`).
 * When ready to generate the query, the user is expected to call `getQueryString()` of the table options.
 */ export default abstract class TableOptions extends SchemaStatement { private bloomFilterFPChance : number | undefined = undefined ; private cacheStrategy : string | undefined = undefined ; private commentOption : string | undefined = undefined ; private compressionStrategy : string | undefined = undefined ; private gcGraceSecondsValue : number | undefined = undefined ; private defaultTtlValue : number | undefined = undefined ; private memTableFlushValue : number | undefined = undefined ; private readRepairChanceValue : number | undefined = undefined ; private speculativeRetryValue : number | undefined = undefined ; constructor ( readonly parentStatement , readonly version ) { super ( ) ; } param bloomFilterFalsePositiveChance return public bloomFilterFalsePositiveChance ( bloomFilterFPChance ) { this . bloomFilterFPChance = bloomFilterFPChance ; return this ; } param cacheValue return public useCacheStrategy ( cacheStrategy ) { this . cacheStrategy = cacheStrategy ; return this ; } param comment return public comment ( comment ) { this . commentOption = comment ; return this ; } public compression ( compression ) { this . compressionStrategy = compression . build ( ) ; return this ; } public gcGraceSeconds ( gcGraceSecondsValue ) { this . gcGraceSecondsValue = gcGraceSecondsValue ; return this ; } public defaultTtl ( defaultTtlValue ) { this . defaultTtlValue = defaultTtlValue ; return this ; } public memtableFlushPeriod ( memTableFlushValue ) { this . memTableFlushValue = memTableFlushValue ; return this ; } public readRepairChance ( readRepairChanceValue ) { this . readRepairChanceValue = readRepairChanceValue ; return this ; } public speculativeRetry ( speculativeRetryValue ) { this . speculativeRetryValue = speculativeRetryValue ; return this ; } return public getQueryString ( ) { let combinedStatement = this . parentStatement . getQueryString ( ) ; const options = this . _buildCommonOptions ( ) ; this . _addSpecificOptions ( options ) ; if ( options . length > 0 ) { combinedStatement += `${ this . STATEMENT_START }WITH ` ; combinedStatement += options . sort ( ) . join ( `${ this . STATEMENT_START }AND ` ) ; } return combinedStatement ; } protected abstract _addSpecificOptions ( options ) ; private _buildCommonOptions ( ) { const options = [ ] ; if ( this . bloomFilterFPChance !== undefined ) { options . push ( `bloom_filter_fp_chance = ${ this . bloomFilterFPChance }` ) ; } if ( this . cacheStrategy !== undefined ) { options . push ( `caching = '${ this . cacheStrategy }'` ) ; } if ( this . commentOption !== undefined ) { options . push ( `comment = '${ this . commentOption }'` ) ; } if ( this . compressionStrategy !== undefined ) { options . push ( `compression = ${ this . compressionStrategy }` ) ; } if ( this . defaultTtlValue !== undefined ) { options . push ( `default_time_to_live = ${ this . defaultTtlValue }` ) ; } if ( this . gcGraceSecondsValue !== undefined ) { options . push ( `gc_grace_seconds = ${ this . gcGraceSecondsValue }` ) ; } if ( this . memTableFlushValue !== undefined ) { options . push ( `memtable_flush_period_in_ms = ${ this . memTableFlushValue }` ) ; } if ( this . readRepairChanceValue !== undefined ) { options . push ( `read_repair_chance = ${ this . readRepairChanceValue }` ) ; } if ( this . speculativeRetryValue !== undefined ) { options . push ( `speculative_retry = '${ this . speculativeRetryValue }'` ) ; } return options ; } }