From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id EC7237F617 for ; Thu, 4 May 2017 10:25:07 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=tom.j.ridge@googlemail.com; spf=Pass smtp.mailfrom=tom.j.ridge@googlemail.com; spf=None smtp.helo=postmaster@mail-io0-f180.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of tom.j.ridge@googlemail.com) identity=pra; client-ip=209.85.223.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="tom.j.ridge@googlemail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of tom.j.ridge@googlemail.com designates 209.85.223.180 as permitted sender) identity=mailfrom; client-ip=209.85.223.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="tom.j.ridge@googlemail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-io0-f180.google.com) identity=helo; client-ip=209.85.223.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="postmaster@mail-io0-f180.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3A/K6tYRVo6H1Rz0Lc5KiSUl9hhMPV8LGtZVwlr6E/?= =?us-ascii?q?grcLSJyIuqrYbBWOt8tkgFKBZ4jH8fUM07OQ6PG8HzRYqb+681k6OKRWUBEEjc?= =?us-ascii?q?hE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRo?= =?us-ascii?q?LerpBI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2Drh4I9FmJChAsyQ+Gi3EGFVHhRIWyzU6?= =?us-ascii?q?0xpTU6E56OAoDESYSghbWA2GGwGZgANTMOMUyFDXq9L9bMYPwLci/HesI=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DqAAA05ApZf7TfVdFdHAEBBAEBCgEBG?= =?us-ascii?q?AEFAQsBhAyBDAeDYWMhiRSnRIIdGoV8hD8HPxgBAQEBAQEBAQEBARIBAQkLCwg?= =?us-ascii?q?mMYIzIIJsHQE5Aw0FCQc3AiQSAQUBIgGKGQEDFQ6kAT+MCIImgwoFg1UKGScNg?= =?us-ascii?q?1gCAQUSiCuIK4IfDC6CXwWdYocbi3qRYAJIkiUUH4EVH4FCGhUXCCFzgn+BSoI?= =?us-ascii?q?PPzaIdwEBAQ?= X-IPAS-Result: =?us-ascii?q?A0DqAAA05ApZf7TfVdFdHAEBBAEBCgEBGAEFAQsBhAyBDAe?= =?us-ascii?q?DYWMhiRSnRIIdGoV8hD8HPxgBAQEBAQEBAQEBARIBAQkLCwgmMYIzIIJsHQE5A?= =?us-ascii?q?w0FCQc3AiQSAQUBIgGKGQEDFQ6kAT+MCIImgwoFg1UKGScNg1gCAQUSiCuIK4I?= =?us-ascii?q?fDC6CXwWdYocbi3qRYAJIkiUUH4EVH4FCGhUXCCFzgn+BSoIPPzaIdwEBAQ?= X-IronPort-AV: E=Sophos;i="5.38,287,1491256800"; d="scan'208,217";a="222406903" Received: from mail-io0-f180.google.com ([209.85.223.180]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 04 May 2017 10:25:06 +0200 Received: by mail-io0-f180.google.com with SMTP id p80so12899122iop.3 for ; Thu, 04 May 2017 01:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to; bh=NqvZiqCQ7VAClSvo1iQG1jFr3qWl9q0e5caIwcqfujA=; b=Mm/ShaixjVExkuxU2+Rs4g3JcLMIZrQGPNPp995n0Ne9lvyDG7GTfpVGawtwXnqa36 JGQv1jbmKiS2VzC2d08yQJVtQOM//CNk6tKzIh2MOtctzqa0uw240vmv5YHVp5jL4yGy a9qg8d4aD4uLmVd3+sra2ku0a2b5YDxyFPFWYmR/KkhtqFsxFegi7spe+V15E91IaXrb mUwQctor8uW7EJGJr0FSExs0lrsM05xiidQicFIZwlosE6r9byBig2cnDZHEZurn5gef u0ALMKAKOUTVnFRNtj3Q23D/Ig0syCjtMdkXZ5R3sGpqP17qCxKQYy9h8hgZrPRveElr cAhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=NqvZiqCQ7VAClSvo1iQG1jFr3qWl9q0e5caIwcqfujA=; b=ap+UtdNH9yEzxioIomtenngYr4NQkujJgCi2efmseRq+fnZMzY5mjWYH/MsSQ/HRyi D+uetaJr1vHbBl3lBXwMUqpdxdgnl7slkZvs+FZqCtfCnZwR7BBsQGv1O5w/FHmV5KZI f/pXHASxh2e5zJy8hun+FZuuA0XkZ/dkDiRCRYhXmrlMJBbB4KA0pqpfsH6c27t5vKcv eh2QHavKFTmREb3Cdc9X/VGJaLhjphINtnbr5WrRF3bn2NErnqaVz2O+h7ZMGDNL9d2y hOfmB4i1VraBngA3fo//lfHLxSfUIqe3u8BeJrqP9Q6anR4E9BoNnZvw5PRd1CXfapAF epzQ== X-Gm-Message-State: AN3rC/64iLAxhw5CacuQIfz8gMDrXYw78xM1WDfxaDX5Wi0AI2Sj3VaH LGTn+i/9xo9RyiMH6qf8PfvNpRrJgnBU X-Received: by 10.157.21.4 with SMTP id u4mr14777110otf.29.1493886304999; Thu, 04 May 2017 01:25:04 -0700 (PDT) MIME-Version: 1.0 Sender: tom.j.ridge@googlemail.com Received: by 10.74.142.131 with HTTP; Thu, 4 May 2017 01:24:44 -0700 (PDT) From: Tom Ridge Date: Thu, 4 May 2017 09:24:44 +0100 X-Google-Sender-Auth: FK41W3knpyHS3BuiEY6rq-D8Nsw Message-ID: To: caml-list , mirageos-devel@lists.xenproject.org Content-Type: multipart/alternative; boundary=94eb2c1918e88b5d62054eae8255 Subject: [Caml-list] [ANN] tjr_btree 0.1.0 (initial release) --94eb2c1918e88b5d62054eae8255 Content-Type: text/plain; charset=UTF-8 tjr_btree is a B-tree library written in OCaml. The examples include a simple on-disk key-value store. https://github.com/tomjridge/tjr_btree Example: ---- (** A simple example of a kv store. *) open Small_string.O (* SS is now an alias for Small_string *) open Ss_ss_map_on_fd (* filename *) let fn = Default.default_filename (* construct keys and values from an int *) let k x = "k"^(string_of_int x) |> SS.of_string let v x = "v"^(string_of_int x) |> SS.of_string (* create and init store, write some values, and close *) let do_write () = ( print_endline "Writing..."; (* create and initialize *) let s = ref (from_file ~fn ~create:true ~init:true) in (* get map operations *) let map_ops = imperative_map_ops s in (* write values *) for x=1 to 1000 do (* TODO this would be much faster if we used insert_many *) map_ops.insert (k x) (v x); done; (* close *) close !s ) (* open store, delete some values, and close *) let do_delete () = ( print_endline "Deleting..."; let s = ref (from_file ~fn ~create:false ~init:false) in let map_ops = imperative_map_ops s in for x=100 to 200 do map_ops.delete (k x); done; close !s ) (* open store and check whether various keys and values are correct *) let do_check () = ( print_endline "Checking..."; let s = ref (from_file ~fn ~create:false ~init:false) in let map_ops = imperative_map_ops s in assert(map_ops.find (SS.of_string("k100")) = None); assert(map_ops.find (SS.of_string("k1000")) = Some(SS.of_string("v1000"))); close !s ) (* actually execute the above *) let _ = ( do_write(); do_delete(); do_check() ) ---- --94eb2c1918e88b5d62054eae8255 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
tjr_btree is a B-tree library written in OCaml. The e= xamples include a simple on-disk key-value store.

<= div>https://github.com/t= omjridge/tjr_btree

Example:

=
----
(** A simple example of a kv store. *)
=

open Small_string.O
(* SS is now an alias for= Small_string *)

open Ss_ss_map_on_fd
(* filename *)
let fn =3D Default.default_filename

(* construct keys and values from an int *)
let k x =3D "k"^(string_of_int x) |> SS.of_string
let v x =3D "v"^(string_of_int x) |> SS.of_string
<= br>
(* create and init store, write some values, and close *)
let do_write () =3D (
=C2=A0 print_endline "Writing..= .";
=C2=A0 (* create and initialize *)
=C2=A0 let = s =3D ref (from_file ~fn ~create:true ~init:true) in
=C2=A0 (* ge= t map operations *)
=C2=A0 let map_ops =3D imperative_map_ops s i= n
=C2=A0 (* write values *)
=C2=A0 for x=3D1 to 1000 do=
=C2=A0 =C2=A0 (* TODO this would be much faster if we used inser= t_many *)
=C2=A0 =C2=A0 map_ops.insert (k x) (v x);
=C2= =A0 done;
=C2=A0 (* close *)
=C2=A0 close !s
= )

(* open store, delete some values, and close *)<= /div>
let do_delete () =3D (
=C2=A0 print_endline "Delet= ing...";
=C2=A0 let s =3D ref (from_file ~fn ~create:false ~= init:false) in
=C2=A0 let map_ops =3D imperative_map_ops s in
=C2=A0 for x=3D100 to 200 do
=C2=A0 =C2=A0 map_ops.delete = (k x);
=C2=A0 done;
=C2=A0 close !s
)

(* open store and check whether various keys and values a= re correct *)
let do_check () =3D (
=C2=A0 print_endlin= e "Checking...";
=C2=A0 let s =3D ref (from_file ~fn ~c= reate:false ~init:false) in
=C2=A0 let map_ops =3D imperative_map= _ops s in
=C2=A0 assert(map_ops.find (SS.of_string("k100&quo= t;)) =3D None);
=C2=A0 assert(map_ops.find (SS.of_string("k1= 000")) =3D Some(SS.of_string("v1000")));
=C2=A0 cl= ose !s
)

(* actually execute the above *= )
let _ =3D (
=C2=A0 do_write();
=C2=A0 do_de= lete();
=C2=A0 do_check()
)
----
<= /div> --94eb2c1918e88b5d62054eae8255--