Skip to content

Commit

Permalink
renamed to batchMap
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Mar 19, 2023
1 parent 9c82dbc commit 2d50ac9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/FSharp.Data.Adaptive/AdaptiveHashMap/AdaptiveHashMap.fs
Original file line number Diff line number Diff line change
Expand Up @@ -756,9 +756,9 @@ module AdaptiveHashMapImplementation =

HashMapDelta.ofHashMap changes

/// Reader for batchRecalc operations.
/// Reader for batchMap operations.
[<Sealed>]
type BatchRecalculateDirty<'k, 'a, 'b>(input : amap<'k, 'a>, mapping : HashMap<'k,'a> -> HashMap<'k, aval<'b>>) =
type BatchMap<'k, 'a, 'b>(input : amap<'k, 'a>, mapping : HashMap<'k,'a> -> HashMap<'k, aval<'b>>) =
inherit AbstractReader<HashMapDelta<'k, 'b>>(HashMapDelta.empty)

let reader = input.GetReader()
Expand Down Expand Up @@ -1415,17 +1415,17 @@ module AMap =
else
create (fun () -> MapAReader(map, mapping))

/// Adaptively applies the given mapping to all changes and reapplies mapping on dirty outputs
let batchRecalcDirty (mapping: HashMap<'K, 'T1> -> HashMap<'K, aval<'T2>>) (map: amap<'K, 'T1>) =
/// Adaptively applies the given mapping to batches of all changes and reapplies mapping on dirty outputs
let batchMap (mapping: HashMap<'K, 'T1> -> HashMap<'K, aval<'T2>>) (map: amap<'K, 'T1>) =
if map.IsConstant then
let map = force map |> mapping
if map |> HashMap.forall (fun _ v -> v.IsConstant) then
constant (fun () -> map |> HashMap.map (fun _ v -> AVal.force v))
else
// TODO better impl possible
create (fun () -> BatchRecalculateDirty(ofHashMap map, id))
create (fun () -> BatchMap(ofHashMap map, id))
else
create (fun () -> BatchRecalculateDirty(map, mapping))
create (fun () -> BatchMap(map, mapping))


/// Adaptively chooses all elements returned by mapping.
Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Data.Adaptive/AdaptiveHashMap/AdaptiveHashMap.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ module AMap =
/// Adaptively applies the given mapping function to all elements and returns a new amap containing the results.
val mapA : mapping: ('K -> 'V -> aval<'T>) -> map: amap<'K, 'V> -> amap<'K, 'T>

/// Adaptively applies the given mapping to all changes.
val batchRecalcDirty : mapping: (HashMap<'K,'T1> -> HashMap<'K,aval<'T2>>) -> map: amap<'K, 'T1> -> amap<'K, 'T2>
/// Adaptively applies the given mapping to batches of all changes and reapplies mapping on dirty outputs
val batchMap : mapping: (HashMap<'K,'T1> -> HashMap<'K,aval<'T2>>) -> map: amap<'K, 'T1> -> amap<'K, 'T2>

/// Adaptively chooses all elements returned by mapping.
val chooseA : mapping: ('K -> 'V -> aval<option<'T>>) -> map: amap<'K, 'V> -> amap<'K, 'T>
Expand Down
2 changes: 1 addition & 1 deletion src/Test/FSharp.Data.Adaptive.Tests/AMap.fs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ module AMap =
>> HashMap.map(fun _ v ->
AVal.constant v |> AVal.mapWithAdditionalDependencies (id)
)
AMap.batchRecalcDirty mapping map
AMap.batchMap mapping map


[<Test>]
Expand Down

0 comments on commit 2d50ac9

Please sign in to comment.