nsmcp::AccessTimeIndex object method build (public)

 nsmcp::AccessTimeIndex[i] build data base fileVar options limits publish \
    state sourceSize

Defined in /usr/local/ns/tcl/nsmcp/log-traffic-index.tcl

Build a sparse segment from complete physical lines in a scanned byte slice.

Parameters:
data (required)
Scanned bytes.
base (required)
Starting byte offset.
fileVar (required)
Caller variable holding the source descriptor.
options (required)
Request options.
limits (required)
Scan limits.
publish (required)
Progress callback.
state (required)
Scan state.
sourceSize (required)
Source size in bytes.

Testcases:
No testcase defined.
Source code:
upvar 1 $fileVar file
if {$data eq "" || [:stamp $file] eq ""} {
    return
}
set entry [:load $file]
if {$entry ne "" && [dict exists $entry segments $base]
    && [dict get $entry segments $base end]==$base+[string length $data]
    && [dict get $entry segments $base stamp] eq [:stamp $file]
    && [dict exists $entry segments $base trusted] && [dict get $entry segments $base trusted]
    && [accessScanRangeMature $file $limits]} {
    return
}
set minimum {}
set maximum {}
set uncertain false
set offset 0
set rows 0
set published [clock milliseconds]
::nsmcp::AccessScan progress $publish indexing $state $file $base $sourceSize
while {$offset<[string length $data]} {
    set newline [string first \n $data $offset]
    if {$newline<0} {
        return
    }
    set raw [string range $data $offset [expr {$newline-1}]]
    set offset [expr {$newline+1}]
    if {[string length $raw]>[dict get $limits line]} {
        set uncertain true
        continue
    }
    set text [encoding convertfrom utf-8 [string trimright $raw \r]]
    regsub -all {\x1b\[[0-9;]*m} $text {} text
    set time [::nsmcp::accessRecordParser indexTime $text]
    if {$time eq ""} {
        set uncertain true
        continue
    }
    if {$minimum eq "" || $time<$minimum} {
        set minimum $time
    }
    if {$maximum eq "" || $time>$maximum} {
        set maximum $time
    }
    incr rows
    if {($rows & 255)==0 && [clock milliseconds]-$published>=[dict get $limits heartbeat]} {
        ::nsmcp::AccessScan progress $publish indexing $state $file [expr {$base+$offset}] $sourceSize
        set published [clock milliseconds]
    }
}
:save $file [dict create start $base end [expr {$base+[string length $data]}]  minimum $minimum maximum $maximum uncertain $uncertain  stamp [:stamp $file] trusted [accessScanRangeMature $file $limits] final [expr {$base+[string length $data]==$sourceSize}]  digest [ns_crypto::md string -digest sha256 -- $data]]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: