Skip to content

Commit

Permalink
Basic dropping on merges
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Jul 12, 2024
1 parent 9bc6130 commit cef23d8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Propulsion/Streams.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,19 @@ module StreamSpan =
let index = idx x
let currNext = ver curr
if index > currNext then // Gap
if buffer = null then buffer <- ResizeArray(candidates.Length)
buffer.Add curr
match curr |> Array.filter (_.IsUnfold >> not) with
| [||] -> ()
| eventsOnly ->
if buffer = null then buffer <- ResizeArray(candidates.Length)
buffer.Add eventsOnly
curr <- x
// Overlapping, join
elif index + x.LongLength > currNext then
curr <- Array.append curr (dropBeforeIndex currNext x)
if buffer = null then Array.singleton curr
else buffer.Add curr; buffer.ToArray()
let v = ver curr - 1L
let last = curr |> Array.filter (fun x -> not x.IsUnfold || x.Index = v)
if buffer = null then Array.singleton last
else buffer.Add last; buffer.ToArray()

/// A Single Event from an Ordered stream being supplied for ingestion into the internal data structures
type StreamEvent<'Format> = (struct (FsCodec.StreamName * FsCodec.ITimelineEvent<'Format>))
Expand Down

0 comments on commit cef23d8

Please sign in to comment.