package gw.rating.rtm.query @ReadOnly class QueryStrategyHandler { var _memoryThreshold : int construct() { _memoryThreshold = 1000 } construct(memoryThreshold : int) { this._memoryThreshold = memoryThreshold } // Sets the query strategy for rate tables associated with book. // @param book targeted book whose rate tables the query strategy will be set for function setTableStrategyFor(book : RateBook) { book.RateTables.each(\ rt -> { rt.QueryStrategy = getStrategyFor(rt) }) } // Returns the appropriate FactorQueryStrategy the passed in table. // @param table The rate table whose FactorQueryStrategy will be determined for // @return FactorQueryStrategy to use for the associated table private function getStrategyFor(table : RateTable) : FactorQueryStrategy { return table.NumRows <= _memoryThreshold ? FactorQueryStrategy.TC_MEMORY : FactorQueryStrategy.TC_DATABASE } }