import TableOptions from '@/services/datastores/cassandra/lib/modules/schema-builder/TableOptions' ; import CompactionOptions from './compaction/CompactionOptions' ; import Create from './Create' ; import { Version } from './Version' ; private export default class CreateTableOptions extends TableOptions { private clusterOrder : Array < { name : string ; direction : string ; } > ; private keyCaching : string | undefined = undefined ; private rowCaching : string | undefined = undefined ; private compactionStrategy : string | undefined = undefined ; private compactStorageValue = false ; constructor ( parentStatement , version ) { super ( parentStatement , version ) ; this . clusterOrder = [ ] ; } public caching ( keyCaching , rowCaching ) { this . keyCaching = keyCaching ; this . rowCaching = rowCaching ; return this ; } param columnName param direction return public clusteringOrder ( columnName , direction ) { if ( ! ( this . parentStatement as Create ) . clusteringColumns . find ( ( col ) => col . name === columnName ) ) { throw new Error ( `Clustering column ${ columnName } is unknown. Did you forget to declare it first?` ) ; } this . clusterOrder . push ( { name : columnName , direction , } ) ; return this ; } public compactionOptions ( strategy ) { this . compactionStrategy = strategy . build ( ) ; return this ; } /**
     * Enables compact storage on this table.
     */ public compactStorage ( ) { this . compactStorageValue = true ; return this ; } protected _addSpecificOptions ( options ) { if ( this . clusterOrder . length > 0 ) { const clusterOrderPart = this . clusterOrder . map ( ( col ) => `${ col . name } ${ col . direction }` ) . join ( ', ' ) ; options . push ( `CLUSTERING ORDER BY (${ clusterOrderPart })` ) ; } if ( this . compactStorageValue ) { options . push ( 'COMPACT STORAGE' ) ; } if ( this . compactionStrategy ) { options . push ( `compaction = ${ this . compactionStrategy }` ) ; } if ( this . keyCaching && this . rowCaching ) { options . push ( `caching = { 'keys' : '${ this . keyCaching }', 'rows_per_partition' : '${ this . rowCaching }' }` ) ; } return options ; } }