PK      Safe]This module provides helpers for emitting and reading binary files with a trailing "header".An internal data structure placed at the very end of the file which describes the header and provides a magic number for sanity checking.KWrite the produced bytestrings to the file followed by the returned headerRead and verify the header from the file, then pass it along with the file's handle to an action. The file handle sits at the beginning of the written content when passed to the action. SafeN7A file containing a finite list of binary encoded itemsGet the path to the  BinaryList file&Encode the items of the given producerStream the items out of a  BinaryList  !"#$# !"#$None*04 %B-tree file header&''BTree k f e' is a B* tree of key type k with elements of type e2. Subtree references are contained within a type fThe Node constructor contains a left child, and a list of key/child pairs where each child's keys are greater than or equal to the given key.!A tree leaf (e.g. key/value pair)'/'OnDisk a' is a reference to an object of type ar on disk. The offset does not include the header; e.g. the first object after the header is located at offset 0.5The maximum number of children of a B-tree inner node!The number of entries in a B-tree(An offset within the stream)This only compares on the keys*This only compares on the keysA read-only B-tree for lookups$%+,-./0&12'3(456)*789:;<=>?@ABC%+,-./0&12'3(489:;<=>?@BC%+,-./0&12'3(456)*789:;<=>?@ABCNone D'nodes to be included in the active nodeEthe length of dNodesF6the desired number of elements to fill the active nodeGBA Producer which accepts offsets for the yielded objects in returnHRCompute the optimal node sizes for each stratum of a tree of given size and orderIGiven a producer of a known number of leaves, produces an optimal B-tree. Technically the size is only an upper bound: the producer may terminate before providing the given number of leaves although the resulting tree will break the minimal fill invariant.JbProduce a bytestring representing the nodes and leaves of the B-tree and return a suitable header#Build a B-tree into the given file.-As the name suggests, this requires that the Producer& emits leaves in ascending key order.Build a B-tree into  ByteString-As the name suggests, this requires that the Producer& emits leaves in ascending key order.This is primarily used for testing. In particular, note that this is a bad idea for large trees as the entire contents of the tree will need to be kept in memory until all leaves have been added so that the header can be prepended.KLike Pipes.Prelude.foldA but provides returns producer result in addition to accumulatorLMDEFGNOPQRHIJS Order of treeMaximum tree size Output fileT of elements Order of treeMaximum tree sizeT of elementsKNILMDEFGNOPQRHIJSKNoneRead a B-tree from a  ByteString produced by Open a B-tree file. Lookup a key in a B-tree.U  U None AIterate over the leaves of the given tree in ascending key order.VVIterate over the nodes and leaves of the given tree. These aren't necessarily sorted.W VX VXW VX NoneC BMerge trees' leaves taking ordered leaves from a set of producers.Each producer must be annotated with the number of leaves it is expected to produce. The size of the resulting tree will be at most the sum of these sizes. Merge several  LookupTreesnThis is a convenience function for merging several trees already on disk. For a more flexible interface, see  .  Get a sized T suitable for   from a  merge operation on elementsorder of merged treename of output fileproducers of leaves to merge merge operation on elementsorder of merged treename of output filetrees to merge a treea sized T suitable for passing to    None4NYlMaximum number of leaf lists to attempt to merge at once. This is bounded by the maximum file handle count.#Build a B-tree into the given file.This does not assume that the leaves are produced in order. Instead, the sorting is handled internally through a simple merge sort. Chunks of leaves are collected, sorted in memory, and then written to intermediate trees. At the end these trees are then merged.ZJSplit the list into chunks of bounded size and run each through a function[Take the first n elements and collect them in a Set . Return a T? which will emit the remaining elements (or the return value).Y\Path to scratch directoryMaximum chunk size Order of tree Output fileT of elementsZ]^[Y\Z]^[None  _         !"#$%&''()*+,-./01-2345678.9:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\] ^ _ ` a b cdbtree_8EKzNV6o9D44Fn0ZjdZBq2BTreeBTree.BinaryFileBTree.BinaryList BTree.Types BTree.Builder BTree.LookupBuilder BTree.Walk BTree.MergeBTree.BuildUnorderedBLeafOrderSize LookupTreefromOrderedToFilefromOrderedToByteStringfromByteStringopenlookup walkLeaves mergeLeaves mergeTreessizedProducerForTreefromUnorderedToFileEpiloguewriteWithHeaderreadWithHeadermagic headerLen epiLength magicNumberannotaterunGetT$fBinaryEpilogue BinaryListfilePath toBinaryListstreamHeader hdrLengthBinList withHeaderlength$fBinaryHeader BTreeHeaderOnDiskOffset $fOrdBLeaf $fEqBLeaf_btMagic _btVersion_btOrder_btSize_btRootNodeLeaf $fBinaryBTree $fBinaryBLeaf$fBinaryOnDisk_ltData _ltHeaderbtMagicbtOrderbtRootbtSize btVersionvalidateHeader$fBinaryBTreeHeaderltDataltHeader_dNodes _dNodeCount _dMinFill DiskProducer optimalFill buildNodes buildTreefoldR DepthStateDepthSputBSdMinFill dNodeCountdNodesnext' dropUpstreampipes_E83Gh9X08vG1gU7tlpfBH7 Pipes.CoreProducerfetch walkNodes filterLeaveswalkNodesWithOffset maxChunkMerge splitChunks takeChunk tempFilePath throwLeft mergeLists