-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move batched ds into examples directory
- Loading branch information
Showing
11 changed files
with
60 additions
and
1,127 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(* Flat-combining hashtable, with no fancy internal parallelism *) | ||
|
||
open Picos | ||
|
||
module Batched = struct | ||
type t = (int, string) Stdlib.Hashtbl.t | ||
|
||
type 'a op = | ||
| Add : int * string -> unit op | ||
| Replace : int * string -> unit op | ||
| Remove : int -> unit op | ||
| Find : int -> string op | ||
|
||
type wrapped_op = Mk : 'a op * 'a Computation.t -> wrapped_op | ||
type cfg = { random : bool option; initial_size : int } | ||
|
||
let init ?(cfg = { random = None; initial_size = 0 }) () = | ||
Stdlib.Hashtbl.create ?random:cfg.random cfg.initial_size | ||
|
||
let run t (batch : wrapped_op array) = | ||
Array.iter | ||
(function | ||
| Mk (Add (k, v), comp) -> | ||
Computation.return comp (Stdlib.Hashtbl.add t k v) | ||
| Mk (Replace (k, v), comp) -> | ||
Computation.return comp (Stdlib.Hashtbl.replace t k v) | ||
| Mk (Remove k, comp) -> | ||
Computation.return comp (Stdlib.Hashtbl.remove t k) | ||
| Mk (Find k, comp) -> Computation.return comp (Stdlib.Hashtbl.find t k)) | ||
batch | ||
end | ||
|
||
(* Set up implicit batching *) | ||
include Obatcher.Make (Batched) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
(library | ||
(name ds) | ||
(public_name obatcher.ds) | ||
(libraries picos picos.structured obatcher logs) | ||
(synopsis "Batched Data Structures") | ||
(modules batched_counter batched_hashtbl batched_skiplist utils)) | ||
|
||
(executable | ||
(name run_counter) | ||
(libraries obatcher logs logs.fmt fmt.tty unix picos.fifos picos.threaded picos.randos)) | ||
(libraries ds logs logs.fmt fmt.tty picos.threaded picos.randos picos.fifos) | ||
(modules run_counter)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters