Skip to content

Commit

Permalink
Merge pull request #11 from pascutto/ocamlformat-upgrade
Browse files Browse the repository at this point in the history
Upgrade ocamlformat and fix packaging
  • Loading branch information
pascutto committed Nov 28, 2021
2 parents 4464d8e + e3916e4 commit 6ba5f8f
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 58 deletions.
7 changes: 3 additions & 4 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version = 0.16.0
profile = conventional
break-infix = fit-or-vertical
version = 0.19.0
parse-docstrings = true
indicate-multiline-delimiters = no
break-infix = fit-or-vertical
module-item-spacing = compact
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

5 changes: 0 additions & 5 deletions bench/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ open Bechamel
open Toolkit

let () = Random.self_init ()

let random_char () = char_of_int (Random.int 256)

let random_string n = String.init n (fun _i -> random_char ())

let create size = Staged.stage (fun () -> Bloomf.create size)

let add size =
Expand Down Expand Up @@ -75,9 +72,7 @@ let benchmark () =
|> Analyze.merge ols instances

let () = Bechamel_notty.Unit.add Instance.monotonic_clock "ns"

let () = Bechamel_notty.Unit.add Instance.minor_allocated "w"

let () = Bechamel_notty.Unit.add Instance.major_allocated "mw"

let img (window, results) =
Expand Down
10 changes: 5 additions & 5 deletions bloomf-bench.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opam-version: "2.0"
maintainer: "Clément Pascutto"
authors: ["Clément Pascutto"]
maintainer: "Clément Pascutto <clement@pascutto.fr>"
authors: "Clément Pascutto <clement@pascutto.fr>"
license: "MIT"
homepage: "https://github.com/mirage/bloomf"
bug-reports: "https://github.com/mirage/bloomf/issues"
Expand All @@ -13,12 +13,12 @@ build: [
"dune"
"build"
"-p"
name
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
"@doc" {with-doc}
]
]

Expand All @@ -27,7 +27,7 @@ depends: [
"dune" {>= "2.0.0"}
"bloomf" {=version}
"bechamel-notty"
"alcotest" {with-test}
"alcotest" {>= "1.0.0" & with-test}
]
synopsis: "Benchmarking package for `bloomf`"
description: "Benchmarking package for `bloomf`"
10 changes: 5 additions & 5 deletions bloomf.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opam-version: "2.0"
maintainer: "Clément Pascutto"
authors: ["Clément Pascutto"]
maintainer: "Clément Pascutto <clement@pascutto.fr>"
authors: "Clément Pascutto <clement@pascutto.fr>"
license: "MIT"
homepage: "https://github.com/mirage/bloomf"
bug-reports: "https://github.com/mirage/bloomf/issues"
Expand All @@ -13,20 +13,20 @@ build: [
"dune"
"build"
"-p"
name
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
"@doc" {with-doc}
]
]

depends: [
"ocaml" {>= "4.03.0"}
"dune" {>= "1.7.0"}
"bitv" {>= "1.4"}
"alcotest" {with-test}
"alcotest" {>= "1.0.0" & with-test}
]
synopsis: "Efficient Bloom filters for OCaml"
description: "Efficient Bloom filters for OCaml"
10 changes: 0 additions & 10 deletions src/bloomf.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
type priv = { m : int; k : int; p_len : (int * int) list; b : Bitv.t }

type 'a t = priv

let rec gcd a b = if b = 0 then a else gcd b (a mod b)
Expand Down Expand Up @@ -63,7 +62,6 @@ let op f bf1 bf2 =
{ m = bf1.m; k = bf2.k; p_len = bf1.p_len; b = f bf1.b bf2.b }

let union bf1 bf2 = op Bitv.bw_or bf1 bf2

let inter bf1 bf2 = op Bitv.bw_and bf1 bf2

let mem_priv t hashed_data =
Expand All @@ -77,7 +75,6 @@ let mem_priv t hashed_data =
loop t.p_len

let mem bf data = mem_priv bf (Hashtbl.hash data)

let clear t = Bitv.fill t.b 0 t.m false

(* Bitv.pop is really slow *)
Expand All @@ -90,7 +87,6 @@ let size_estimate t =
(* Serialisers *)

external set_64 : bytes -> int -> int64 -> unit = "%caml_string_set64u"

external swap64 : int64 -> int64 = "%bswap_int64"

let set_uint64 buf off v =
Expand Down Expand Up @@ -146,16 +142,10 @@ module Make (H : Hashable) = struct
type t = priv

let create = create

let add bf data = add_priv bf (H.hash data)

let mem bf data = mem_priv bf (H.hash data)

let clear = clear

let size_estimate = size_estimate

let to_bytes = to_bytes

let of_bytes = of_bytes
end
11 changes: 2 additions & 9 deletions src/bloomf.mli
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ val create : ?error_rate:float -> int -> 'a t
(** [create ~error_rate size] creates a fresh BF for which expected false
positive rate when filled with [size] elements is [error_rate].
@raise Invalid_argument if [error_rate] is not in \]0, 1\[, or [size] is
negative. *)
@raise Invalid_argument
if [error_rate] is not in \]0, 1\[, or [size] is negative. *)

val add : 'a t -> 'a -> unit
(** [add t e] adds [e] to [t]. *)
Expand Down Expand Up @@ -57,7 +57,6 @@ val size_estimate : 'a t -> int
(** {2 Serializers/Deserializers} *)

val to_bytes : 'a t -> bytes

val of_bytes : bytes -> ('a t, [ `Msg of string ]) result

(** {1 Functorial interface} *)
Expand All @@ -80,16 +79,10 @@ module Make (H : Hashable) : sig
type t

val create : ?error_rate:float -> int -> t

val add : t -> H.t -> unit

val mem : t -> H.t -> bool

val clear : t -> unit

val size_estimate : t -> int

val to_bytes : t -> bytes

val of_bytes : bytes -> (t, [ `Msg of string ]) result
end
3 changes: 0 additions & 3 deletions test/main.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
let () = Random.self_init ()

let random_char () = char_of_int (Random.int 256)

let random_string n = String.init n (fun _i -> random_char ())

module StringSet = Set.Make (String)
Expand Down Expand Up @@ -75,7 +73,6 @@ let test_op msg bop sop =
sizes

let test_union () = test_op "union" Bloomf.union StringSet.union

let test_inter () = test_op "intersection" Bloomf.inter StringSet.inter

let test_bytes () =
Expand Down

0 comments on commit 6ba5f8f

Please sign in to comment.