nsmcp::BoundedLogScanner method first (protected)

 <instance of nsmcp::BoundedLogScanner[i]> first position ceiling

Defined in /usr/local/ns/tcl/nsmcp/log-01-scanner.tcl

Parameters:
position (required)
ceiling (required)

Testcases:
No testcase defined.
Source code:
set relative [expr {$position-${:bufferFrom}}]
set available [expr {$ceiling-${:bufferFrom}}]
set found -1
# Native descriptor searching is safe only on this bounded private file.
# Dense windows switch to C string searching in the cached byte buffer,
# avoiding one descriptor seek/read per adjacent candidate.
if {${:native} && [llength ${:keys}]==1 && ${:windowHits}<${:nativeThreshold}
    && [info commands ns_fseekchars] ne ""} {
    :prepareNative
    seek ${:temporaryChannel} $relative
    set candidate [ns_fseekchars ${:temporaryChannel} [lindex ${:literals} 0]]
    if {$candidate>=0 && $candidate+[string length [lindex ${:keys} 0]]<=$available} {set found $candidate}
} else {
    set buffer ${:buffer}
    foreach key ${:keys} {
        set candidate [string first $key $buffer $relative]
        if {$candidate>=0 && $candidate+[string length $key]<=$available
            && ($found<0 || $candidate<$found)} {set found $candidate}
    }
}
if {$found>=0} {return [expr {${:bufferFrom}+$found}]}
return -1
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: