I am trying to parse a very large log text file (100 000 lines +) after a test run on a certain software. In order to do this, I divide the file in windows of 1 000 lines and read incrementally each of these windows for each test in our test run. When I have finished reading those 1 000 lines, to make sure that I won't parse them for nothing again, I want to set a Boolean to true that means that I should just skip that window since I am sure I have finished parsing it.
This is what I have come up with so far:
...
let windowedAMLogSeq = Seq.windowed 1000 fullAMLogSeq
|> Seq.map (fun (window:string[]) -> (window , false))
for category in sortedTrxFailedTests do
for failedTest in category do
...
match failedTest.StartTime with
| Some x ->
match failedTest.EndTime with
| Some y ->
let accessManagerLogLines = parseAccessManagerLogFile x y windowedAMLogSeq
...
with
let parseAccessManagerLogFile (testStartTime:DateTime) (testEndTime:DateTime) (windowedAMLogSeq:seq<string[] * bool>) =
Seq.map (parseWindow testStartTime testEndTime) windowedAMLogSeq
and
let parseWindow testStartTime testEndTime (window:(string[] * bool)) =
match (snd window) with
| true ->
[||]
| false ->
let lineArray = Array.map (fun (line:string) -> if (isBetweenStartAndEndTime testStartTime testEndTime line) then line else "") (fst window)
let cleansedArray = Array.partition (fun (line:string) -> line <> "") lineArray
|> fst
match cleansedArray.Length > 0 with
| true ->
()
| false ->
window <- ((fst window), true) // Problem here, not mutable or by ref
cleansedArray
Obviously, this won't compile as window is not mutable or passed by reference. I have tried multiple combinations of using mutable and ref or byref keywords with no success. Being fairly new to F#, I am unsure of the correct syntax to use.
What would be the syntax to use in order to modify by reference the window value directly, or to be able to modify by reference the Boolean value in the window tuple?