123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111(*
* Copyright (c) 2018-2021 Tarides <contact@tarides.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)open!ImportincludeInode_layers_intfmoduleMake(Conf:Irmin_pack.Conf.S)(H:Irmin.Hash.S)(Maker:S.Content_addressable_makerwithtypekey=H.tandtypeindex:=Index.Make(H).t)(Node:Irmin.Private.Node.Swithtypehash=H.t)=structtypeindex=Index.Make(H).tmoduleInternal=Irmin_pack.Inode.Make_internal(Conf)(H)(Node)moduleP=Maker.Make(Internal.Raw)moduleVal=Internal.ValmoduleKey=Htype'at='aP.ttypekey=Key.ttypevalue=Val.tletmemtk=P.memtkletunsafe_find=P.unsafe_findletfindtk=P.findtk>|=function|None->None|Somev->letfind=unsafe_find~check_integrity:truetinletv=Val.of_rawfindvinSomevlethashv=Val.hashvletequal_hash=Irmin.Type.(unstage(equalH.t))letcheck_hashexpectedgot=ifequal_hashexpectedgotthen()elseFmt.invalid_arg"corrupted value: got %a, expecting %a"Internal.pp_hashexpectedInternal.pp_hashgotletbatch=P.batchletv=P.vletintegrity_check=P.integrity_checkletclose=P.closeletsync=P.syncletclear=P.clearletclear_caches=P.clear_cachesletsavetv=letaddkv=P.unsafe_append~ensure_unique:true~overcommit:falsetkvinVal.save~add~mem:(P.unsafe_memt)vletaddtv=savetv;Lwt.return(hashv)letunsafe_addtkv=check_hashk(hashv);savetv;Lwt.return()letclear_caches_next_upper=P.clear_caches_next_uppermoduleU=P.UmoduleL=P.Lletlayer_id=P.layer_idletmem_lower=P.mem_lowerletlower=P.lowerletmem_next=P.mem_nextletflip_upper=P.flip_upperletnext_upper=P.next_upperletcurrent_upper=P.current_upperletconsume_newies=P.consume_newiesletupdate_flip=P.update_flipletflush?indext=P.flush?indexttype'alayer_type=|Upper:readU.tlayer_type|Lower:readL.tlayer_typeletcopy_from_lower~dstt=P.copy_from_lowert"Node"~dstletcopy:typel.llayer_type*l->readt->key->unit=fun(layer,dst)t->matchlayerwith|Lower->P.copy(Lower,dst)t"Node"|Upper->P.copy(Upper,dst)t"Node"letcheck=P.checkletdecode_bin_length=Internal.Raw.decode_bin_lengthletintegrity_check_inodes__=failwith"TODO"end