123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100(*
* Copyright (c) 2018-2022 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!Import(** A [Pack_store.S] is a closeable, persistent implementation of {!Indexable.S}
that uses an append-only file of variable-length data blocks.
Certain values in the data file are indexed by hash via a {!Pack_index.S}
implementation, but not all of them need be. *)moduletypeS=sigincludeIrmin_pack.Indexable.Stypefile_managertypedicttypedispatchervalv:config:Irmin.Backend.Conf.t->fm:file_manager->dict:dict->dispatcher:dispatcher->readtvalcast:readt->read_writet(** @inline *)includeIrmin_pack.Checkablewithtype'at:='atandtypehash:=hashmoduleEntry_prefix:sigtypet={hash:hash;kind:Pack_value.Kind.t;size_of_value_and_length_header:intoption;(** Remaining bytes in the entry after reading the hash and the kind
(i.e. the length of the length header + the value of the length
header), if the entry has a length header (otherwise [None]).
NOTE: the length stored in the index and in direct pack keys is
the {!total_entry_length} (including the hash and the kind). *)}valtotal_entry_length:t->intoptionendvalread_and_decode_entry_prefix:off:int63->dispatcher->Entry_prefix.t(** Read the entry prefix at offset [off]. *)valindex_direct_with_kind:'at->hash->(key*Pack_value.Kind.t)option(** Returns the key and the kind of an object indexed by hash. *)valpurge_lru:'at->unitvalkey_of_offset:'at->int63->key(** Returns the key associated with the offset. *)valunsafe_find_no_prefetch:'at->key->valueoption(** Similar to [unsafe_find], returns the value associated with the [key] in
the store but without prefetching the [hash] and [length] of the children
(or doing any integrity check). As a result, the produced children keys
only contain their [offset] and are not usable without calling
[key_of_offset] first. This function only exists to optimize the GC
reachability traversal. *)endmoduletypeSigs=sigexceptionInvalid_readofstringmoduletypeS=SmoduleMake(Fm:File_manager.S)(Dict:Dict.SwithmoduleFm=Fm)(Dispatcher:Dispatcher.SwithmoduleFm=Fm)(Hash:Irmin.Hash.Swithtypet=Fm.Index.key)(Val:Pack_value.Persistentwithtypehash:=Hash.tandtypekey:=Hash.tPack_key.t)(Errs:Io_errors.SwithmoduleIo=Fm.Io):Swithtypekey=Hash.tPack_key.tandtypehash=Hash.tandtypevalue=Val.tandtypefile_manager=Fm.tandtypedispatcher=Dispatcher.tandtypedict=Dict.tend