nsmcp::AccessRecordStoreSQLite method observeBatch (public)
<instance of nsmcp::AccessRecordStoreSQLite> observeBatch \ [ batchSource ]
Defined in /usr/local/ns/tcl/nsmcp/log-traffic-record-store.tcl
Update observation metadata from an inserted or migrated batch. Merge first and latest request times, completion time and parsing-loss counts into persistent state. The caller supplies the surrounding transaction.
- Parameters:
- batchSource (optional, defaults to
"temp.nsmcp_ingest_batch")- Trusted SQL relation containing the batch; defaults to the migration staging table.
- Returns:
- An empty result after the observation state has been saved.
- Testcases:
- No testcase defined.
Source code: set row [lindex [${:db} execute " SELECT coalesce(min(CASE WHEN kind=0 THEN t END), 0) AS first, coalesce(max(t), 0) AS latest, coalesce(max(CASE WHEN kind=0 THEN completed END), 0) AS completed, coalesce(sum(kind=1), 0) AS malformed, coalesce(sum(kind=2), 0) AS oversized FROM $batchSource "] 0] set old [:stateGet observations {first 0 latest 0 completed 0 malformed 0 oversized 0}] set first [dict get $row first] if {$first>0 && ([dict get $old first]==0 || $first<[dict get $old first])} { dict set old first $first } foreach key {latest completed} { dict set old $key [expr {max([dict get $old $key],[dict get $row $key])}] } foreach key {malformed oversized} { dict incr old $key [dict get $row $key] } :statePut observations $oldXQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)