- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::nsmcp::BufferedResultReader
::nsmcp::BufferedResultReadercreate ... \
[ -buffer (default "") ] \
[ -channel:required channel:required ] \
[ -index (default "0") ] \
[ -limit:required limit:required ] \
[ -maxBytes:integer (default "2097152") ] \
[ -offset:required offset:required ] \
[ -readBytes (default "0") ] \
[ -readCalls (default "0") ] \
[ -readMicroseconds (default "0") ]
Defined in /usr/local/ns/tcl/nsmcp/log-01-scanner.tcl
Class Relations
::nx::Class create ::nsmcp::BufferedResultReader \ -superclass ::nsmcp::ObjectMethods (to be applied on instances)
next (scripted, public)
<instance of nsmcp::BufferedResultReader> next
Read one complete JSONL record inside the published snapshot. Keep unused channel bytes for the next record. Reject oversized or incomplete records without reading beyond the fixed published limit.
- Returns:
- A dictionary with start, end and raw, or empty at exhaustion.
- Testcases:
- No testcase defined.
if {${:offset}>=${:limit}} { return {} } set start ${:offset} set raw {} while {${:offset}<${:limit}} { if {${:index}>=[string length ${:buffer}]} { set started [clock clicks -microseconds] set :buffer [read ${:channel} [expr {min(65536,${:limit}-${:offset})}]] incr :readMicroseconds [expr {max(0,[clock clicks -microseconds]-$started)}] incr :readBytes [string length ${:buffer}] incr :readCalls set :index 0 if {${:buffer} eq ""} { error "incomplete result cache" } } set newline [string first \n ${:buffer} ${:index}] set end [expr {$newline<0 ? [string length ${:buffer}] : $newline}] set count [expr {$end-${:index}}] set consumed [expr {$count+($newline>=0)}] if {${:offset}-$start+$consumed>${:maxBytes}} { error "cached record exceeds the page byte limit" } append raw [string range ${:buffer} ${:index} [expr {$end-1}]] incr :index $consumed incr :offset $consumed if {$newline>=0} { return [dict create start $start end ${:offset} raw $raw] } } error "incomplete result cache"statistics (scripted, public)
<instance of nsmcp::BufferedResultReader> statistics
Report channel work for this result page. Buffered bytes can include the next record in this published snapshot; they are not a count of physical disk bytes or returned JSON bytes.
- Returns:
- Read time in microseconds and channel byte/call counts.
- Testcases:
- No testcase defined.
return [dict create readMicroseconds ${:readMicroseconds} readBytes ${:readBytes} readCalls ${:readCalls}]
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
![[i]](/resources/acs-subsite/ZoomIn16.gif)