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 3cab26d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 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/FSharp.Data.Adaptive/AdaptiveValue/AdaptiveValue.fs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ module AVal =
/// Additionally fsproj files have dependencies, such as project.assets.json, that can't be determined until loaded with msbuild
/// but should be reloaded if those dependent files change.
/// </remarks>
let mapWithAdditionalDependencies (mapping: 'a -> 'b * seq<#IAdaptiveValue>) (value: aval<'a>) : aval<'b> =
let mapWithAdditionalDependencies (mapping: 'a -> 'b * #seq<#IAdaptiveValue>) (value: aval<'a>) : aval<'b> =
let mutable lastDeps = HashSet.empty

{ new AbstractVal<'b>() with
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Data.Adaptive/AdaptiveValue/AdaptiveValue.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module AVal =
/// Additionally fsproj files have dependencies, such as project.assets.json, that can't be determined until loaded with msbuild
/// but should be reloaded if those dependent files change.
/// </remarks>
val mapWithAdditionalDependencies : mapping :( 'T1 -> 'T2 * seq<#IAdaptiveValue>) -> value: aval<'T1> -> aval<'T2>
val mapWithAdditionalDependencies : mapping :( 'T1 -> 'T2 * #seq<#IAdaptiveValue>) -> value: aval<'T1> -> aval<'T2>

/// Returns a new adaptive value that adaptively applies the mapping function to the given
/// input and adaptively depends on the resulting adaptive value.
Expand Down
4 changes: 2 additions & 2 deletions src/Test/FSharp.Data.Adaptive.Tests/AMap.fs
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,11 @@ module AMap =
>> HashMap.map(fun _ v ->
AVal.constant v |> AVal.mapWithAdditionalDependencies (id)
)
AMap.batchRecalcDirty mapping map
AMap.batchMap mapping map


[<Test>]
let ``[AMap] batchRecalcDirty``() =
let ``[AMap] batchMap``() =

let file1 = "File1.fs"
let file1Cval = cval 1
Expand Down

0 comments on commit 3cab26d

Please sign in to comment.