nsmcp::accessScanNativeSlice

 nsmcp::accessScanNativeSlice

Defined in

Partial Call Graph (max 5 caller/called nodes):
accessFileScan accessFileScan nsmcp::accessScanNativeSlice nsmcp::accessScanNativeSlice accessFileScan->nsmcp::accessScanNativeSlice instproc instproc instproc->nsmcp::accessScanNativeSlice nsmcp::LogCorrelation nsmcp::LogCorrelation nsmcp::LogCorrelation->nsmcp::accessScanNativeSlice nsmcp::accessEvidenceDone nsmcp::accessEvidenceDone nsmcp::accessScanNativeSlice->nsmcp::accessEvidenceDone nsmcp::accessOrderedEnabled nsmcp::accessOrderedEnabled nsmcp::accessScanNativeSlice->nsmcp::accessOrderedEnabled nsmcp::accessScanCandidate nsmcp::accessScanCandidate nsmcp::accessScanNativeSlice->nsmcp::accessScanCandidate nsmcp::accessScanProgress nsmcp::accessScanProgress nsmcp::accessScanNativeSlice->nsmcp::accessScanProgress nsmcp::accessTimeIndexBuild nsmcp::accessTimeIndexBuild nsmcp::accessScanNativeSlice->nsmcp::accessTimeIndexBuild

Testcases:
No testcase defined.
Source code:
    upvar 1 $fileVar file $stateVar state $statsVar stats $budgetVar budget
    set offset [dict get $file offset]
    set count [expr {min($budget,$readLimit-$offset)}]
    set data [read $channel $count]
    set readCount [string length $data]
    if {$readCount==0 && $count>0} {
        error "access log ended before snapshot boundary"
    }
    dict incr state examinedBytes $readCount
    dict incr file scanReadBytes $readCount
    incr budget -$readCount
    dict set file offset [expr {$offset+$readCount}]
    set base $offset
    if {[dict exists $file nativeTail]} {
        set tail [dict get $file nativeTail]
        set tailBytes [dict get $file nativeTailBytes]
        if {[dict get $file nativeTailOverflow]} {
            set newline [string first \n $data]
            if {$newline<0} {
                dict incr file nativeTailBytes $readCount
                if {[dict get $file offset]>=$sourceSize} {
                    dict incr stats oversizedRecords
                    dict set file rangeUncertain true
                }
                return
            }
            # The complete oversized line cannot be safely parsed or indexed.
            dict incr stats oversizedRecords
            dict set file rangeUncertain true
            set data [string range $data [expr {$newline+1}] end]
            set base [expr {$offset+$newline+1}]
        } else {
            set data $tail$data
            set base [expr {$offset-$tailBytes}]
        }
        foreach key {nativeTail nativeTailBytes nativeTailOverflow} {
            dict unset file $key
        }
    }
    set last [string last \n $data]
    set fragment [string range $data [expr {$last+1}] end]
    if {$fragment ne ""} {
        set length [string length $fragment]
        if {[dict get $file offset]>=$sourceSize} {
            dict incr stats pendingRecords
            dict set file rangeUncertain true
        } else {
            dict set file nativeTail [string range $fragment 0 [expr {[dict get $limits line]-1}]]
            dict set file nativeTailBytes $length
            dict set file nativeTailOverflow [expr {$length>[dict get $limits line]}]
        }
    }
    if {$last<0} {
        return
    }
    set data [string range $data 0 $last]
    if {![accessOrderedEnabled $options]} {
        accessTimeIndexBuild $data $base file $options $limits $publish $state $sourceSize
    }
    set native [expr {[string first \x1b $data]<0}]
    set scanner [::nsmcp::BoundedLogScanner new -cacheDirectory $directory  -literals [list [dict get $options pathLiteral]]  -blockBytes [expr {[dict get $limits slice]+[dict get $limits line]}]]
    set position 0
    set published [clock milliseconds]
    set parsing false
    try {
        $scanner load $data
        while {$position<[string length $data] && ![accessEvidenceDone $stats $options]} {
            set line [$scanner nextLine $position $native]
            if {$line eq ""} {
                break
            }
            set start [dict get $line start]
            set end [dict get $line end]
            if {![dict get $line terminated]} {
                error "native search chunk lost its record boundary"
            }
            if {!$parsing} {
                accessScanProgress $publish scanning $state $file [expr {$base+$start}] $sourceSize
                set parsing true
            }
            accessScanCandidate [dict get $line raw] [expr {$base+$start}] [expr {$base+$end}] state file stats $options $redactor $limits
            set position $end
            if {([dict get $stats examinedRecords] & 255)==0} {
                set now [clock milliseconds]
                if {$publish ne "" && $now-$published >= [dict get $limits heartbeat]} {
                    accessScanProgress $publish scanning $state $file [expr {$base+$end}] $sourceSize
                    set published $now
                }
            }
        }
        if {[accessEvidenceDone $stats $options]} {
            dict set file offset [expr {$base+$position}]
            foreach key {nativeTail nativeTailBytes nativeTailOverflow} {
                dict unset file $key
            }
        }
    } finally {
        $scanner destroy
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: