##// END OF EJS Templates
rustdoc: nodemap doc refreshing...
Georges Racinet -
r51276:3894763d default
parent child Browse files
Show More
@@ -26,6 +26,8 b' use std::ops::Index;'
26 #[derive(Debug, PartialEq)]
26 #[derive(Debug, PartialEq)]
27 pub enum NodeMapError {
27 pub enum NodeMapError {
28 /// A `NodePrefix` matches several [`Revision`]s.
28 /// A `NodePrefix` matches several [`Revision`]s.
29 ///
30 /// This can be returned by methods meant for (at most) one match.
29 MultipleResults,
31 MultipleResults,
30 /// A `Revision` stored in the nodemap could not be found in the index
32 /// A `Revision` stored in the nodemap could not be found in the index
31 RevisionNotInIndex(Revision),
33 RevisionNotInIndex(Revision),
@@ -36,8 +38,8 b' pub enum NodeMapError {'
36 /// ## `RevlogIndex` and `NodeMap`
38 /// ## `RevlogIndex` and `NodeMap`
37 ///
39 ///
38 /// One way to think about their relationship is that
40 /// One way to think about their relationship is that
39 /// the `NodeMap` is a prefix-oriented reverse index of the `Node` information
41 /// the `NodeMap` is a prefix-oriented reverse index of the [`Node`]
40 /// carried by a [`RevlogIndex`].
42 /// information carried by a [`RevlogIndex`].
41 ///
43 ///
42 /// Many of the methods in this trait take a `RevlogIndex` argument
44 /// Many of the methods in this trait take a `RevlogIndex` argument
43 /// which is used for validation of their results. This index must naturally
45 /// which is used for validation of their results. This index must naturally
@@ -46,14 +48,10 b' pub enum NodeMapError {'
46 /// Notably, the `NodeMap` must not store
48 /// Notably, the `NodeMap` must not store
47 /// information about more `Revision` values than there are in the index.
49 /// information about more `Revision` values than there are in the index.
48 /// In these methods, an encountered `Revision` is not in the index, a
50 /// In these methods, an encountered `Revision` is not in the index, a
49 /// [`RevisionNotInIndex`] error is returned.
51 /// [RevisionNotInIndex](NodeMapError) error is returned.
50 ///
52 ///
51 /// In insert operations, the rule is thus that the `NodeMap` must always
53 /// In insert operations, the rule is thus that the `NodeMap` must always
52 /// be updated after the `RevlogIndex`
54 /// be updated after the `RevlogIndex` it is about.
53 /// be updated first, and the `NodeMap` second.
54 ///
55 /// [`RevisionNotInIndex`]: enum.NodeMapError.html#variant.RevisionNotInIndex
56 /// [`RevlogIndex`]: ../trait.RevlogIndex.html
57 pub trait NodeMap {
55 pub trait NodeMap {
58 /// Find the unique `Revision` having the given `Node`
56 /// Find the unique `Revision` having the given `Node`
59 ///
57 ///
@@ -95,7 +93,8 b' pub trait NodeMap {'
95 node_prefix: NodePrefix,
93 node_prefix: NodePrefix,
96 ) -> Result<Option<usize>, NodeMapError>;
94 ) -> Result<Option<usize>, NodeMapError>;
97
95
98 /// Same as `unique_prefix_len_bin`, with a full `Node` as input
96 /// Same as [unique_prefix_len_bin](Self::unique_prefix_len_bin), with
97 /// a full [`Node`] as input
99 fn unique_prefix_len_node(
98 fn unique_prefix_len_node(
100 &self,
99 &self,
101 idx: &impl RevlogIndex,
100 idx: &impl RevlogIndex,
@@ -157,7 +156,9 b' impl From<Element> for RawElement {'
157 }
156 }
158 }
157 }
159
158
160 /// A logical block of the `NodeTree`, packed with a fixed size.
159 const ELEMENTS_PER_BLOCK: usize = 16; // number of different values in a nybble
160
161 /// A logical block of the [`NodeTree`], packed with a fixed size.
161 ///
162 ///
162 /// These are always used in container types implementing `Index<Block>`,
163 /// These are always used in container types implementing `Index<Block>`,
163 /// such as `&Block`
164 /// such as `&Block`
@@ -180,9 +181,6 b' impl From<Element> for RawElement {'
180 /// Another related difference is that `NULL_REVISION` (-1) is not
181 /// Another related difference is that `NULL_REVISION` (-1) is not
181 /// represented at all, because we want an immutable empty nodetree
182 /// represented at all, because we want an immutable empty nodetree
182 /// to be valid.
183 /// to be valid.
183
184 const ELEMENTS_PER_BLOCK: usize = 16; // number of different values in a nybble
185
186 #[derive(Copy, Clone, BytesCast, PartialEq)]
184 #[derive(Copy, Clone, BytesCast, PartialEq)]
187 #[repr(transparent)]
185 #[repr(transparent)]
188 pub struct Block([RawElement; ELEMENTS_PER_BLOCK]);
186 pub struct Block([RawElement; ELEMENTS_PER_BLOCK]);
@@ -219,7 +217,7 b' impl fmt::Debug for Block {'
219 /// Because of the append only nature of our node trees, we need to
217 /// Because of the append only nature of our node trees, we need to
220 /// keep the original untouched and store new blocks separately.
218 /// keep the original untouched and store new blocks separately.
221 ///
219 ///
222 /// The mutable root `Block` is kept apart so that we don't have to rebump
220 /// The mutable root [`Block`] is kept apart so that we don't have to rebump
223 /// it on each insertion.
221 /// it on each insertion.
224 pub struct NodeTree {
222 pub struct NodeTree {
225 readonly: Box<dyn Deref<Target = [Block]> + Send>,
223 readonly: Box<dyn Deref<Target = [Block]> + Send>,
@@ -243,7 +241,7 b' impl Index<usize> for NodeTree {'
243 }
241 }
244 }
242 }
245
243
246 /// Return `None` unless the `Node` for `rev` has given prefix in `index`.
244 /// Return `None` unless the [`Node`] for `rev` has given prefix in `idx`.
247 fn has_prefix_or_none(
245 fn has_prefix_or_none(
248 idx: &impl RevlogIndex,
246 idx: &impl RevlogIndex,
249 prefix: NodePrefix,
247 prefix: NodePrefix,
@@ -261,7 +259,7 b' fn has_prefix_or_none('
261 }
259 }
262
260
263 /// validate that the candidate's node starts indeed with given prefix,
261 /// validate that the candidate's node starts indeed with given prefix,
264 /// and treat ambiguities related to `NULL_REVISION`.
262 /// and treat ambiguities related to [`NULL_REVISION`].
265 ///
263 ///
266 /// From the data in the NodeTree, one can only conclude that some
264 /// From the data in the NodeTree, one can only conclude that some
267 /// revision is the only one for a *subprefix* of the one being looked up.
265 /// revision is the only one for a *subprefix* of the one being looked up.
@@ -305,12 +303,10 b' impl NodeTree {'
305
303
306 /// Create from an opaque bunch of bytes
304 /// Create from an opaque bunch of bytes
307 ///
305 ///
308 /// The created `NodeTreeBytes` from `buffer`,
306 /// The created [`NodeTreeBytes`] from `bytes`,
309 /// of which exactly `amount` bytes are used.
307 /// of which exactly `amount` bytes are used.
310 ///
308 ///
311 /// - `buffer` could be derived from `PyBuffer` and `Mmap` objects.
309 /// - `buffer` could be derived from `PyBuffer` and `Mmap` objects.
312 /// - `offset` allows for the final file format to include fixed data
313 /// (generation number, behavioural flags)
314 /// - `amount` is expressed in bytes, and is not automatically derived from
310 /// - `amount` is expressed in bytes, and is not automatically derived from
315 /// `bytes`, so that a caller that manages them atomically can perform
311 /// `bytes`, so that a caller that manages them atomically can perform
316 /// temporary disk serializations and still rollback easily if needed.
312 /// temporary disk serializations and still rollback easily if needed.
General Comments 0
You need to be logged in to leave comments. Login now