package gw.rating.rtm.query uses gw.api.rating.cache.IRateTableRowCache uses gw.api.system.PCLoggerCategory uses gw.plugin.Plugins @ReadOnly class StatelessMemoryQuery extends AbstractStatelessQuery { var _cache : IRateTableRowCache construct(table : RateTable) { super(table) _cache = Plugins.get(IRateTableRowCache) } override protected property get InterpolationIsOrdered() : boolean { // If rows are not Normalized, is there any possibility this could be false? return true } override function queryMultipleFactors(table : entity.RateTable, inputParams : Comparable[], factorCodes : List) : Map { resetNumActiveOpsAndCheckInputParams(table, inputParams) preRelax(inputParams) var entry = _cache.getCachedRows(table) as RateTableRowCache.CacheEntry var result : Map while (!this.IsFullyRelaxed) { var rows = entry.Rows.get(NumActiveOps) if (rows != null) { var sortingOrder = MatchOps.getSortOrder(NumActiveOps) for (pos in sortingOrder index i) { var op = MatchOps.get(pos) rows = op.filter(rows, inputParams[pos], entry.Normalized) // Some matchops do not maintain the invariant ordering property, namely that // rows is property ordered with respect to the next matchop. In this case, we // need to reorder the rows. SubrangeMerger takes advantage of the existing // partial ordering, performing a merge sort on the existing natural runs. if (rows != null and i < (NumActiveOps - 1)) { var merger = op.getSubrangeMerger(MatchOps, sortingOrder, entry.Normalized) rows = merger == null ? rows : merger.findAndMergeSubranges(rows, NumActiveOps) } } } result = this.extractFactors(table.Definition, rows, factorCodes, inputParams) if (result == null) { relaxQuery() } else { break } } if (result == null || (result.size() == 0 and entry.Rows.get(0) == null)) { PCLoggerCategory.RTM.warn("No results found for Rate Table Query [book=" + table.RateBook.DisplayName + "; table=" + table.DisplayName + "; params=" + inputParams.join(",") + "]") if (PCLoggerCategory.RTM.DebugEnabled) { PCLoggerCategory.RTM.debug("Cache entry contains:") for (i in inputParams.length..0) { PCLoggerCategory.RTM.debug(" ${entry.Rows.get(i).Count} entries with ${i} input parameters") for (r in entry.Rows.get(i)) { PCLoggerCategory.RTM.debug(" ${r}") } } } return {} } return result } }