Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 123 lines (98 sloc) 4.09 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (*
19 @author1 Henri Binsztok,
20 @author2 Gregoire Makridis
21 **)
22
23 exception UnqualifiedPath
24 exception Merge
25
26 type t
27 type index = ((Path.t * float) list) StringMap.t
28
29 (* screen printting - debug only *)
30 val print_db : t -> string
31
32 (* the root of the database *)
33 val root_eid:Eid.t
34
35 (* access to the db field *)
36 val get_rev : t -> Revision.t
37 val get_tcount : t -> Eid.t
38 val get_next_uid : t -> Uid.t
39 val is_empty : t -> bool
40 val get_uid_map : t -> Uid.t RevisionMap.t EidMap.t
41 val get_node_map : t -> Node.t UidMap.t
20bbd87 [enhance] db3: Use TabMap instead of Map for uids
Raja authored
42 val get_last_nodes : t -> Node.t Uid.Map.t
fccc685 Initial open-source release
MLstate authored
43 val get_index : t -> index
44
45 (* navigation through the db *)
46 val get_uid_of_eid : t -> Revision.t -> Eid.t -> Uid.t
47 val get_node_of_uid : t -> Uid.t -> Node.t
48 val get_node_of_path : t -> Revision.t -> Path.t -> Node.t * Revision.t
49 val get_node_of_eid : t -> Revision.t -> Eid.t -> Node.t
50 val get_eid_of_path : t -> Revision.t -> Path.t -> Eid.t * Revision.t
51 val is_new_uid : t -> Uid.t -> bool
52
53 (* cleaning *)
54 val clean_tmp_maps : t -> t
55
56 (* creation / rebuilding of a database *)
57 val make : ?weak:(Uid.t -> Node.t) -> unit -> t
58 val restart :
59 ?index:index ->
60 Revision.t -> Eid.t -> Uid.t ->
61 (Uid.t RevisionMap.t EidMap.t) ->
62 Node.t UidMap.t ->
63 t
64
65 (* basic db writing *)
66 val update_db : t -> Revision.t -> (Eid.t * Uid.t) list -> (Uid.t * Node.t) list -> t
67 val remove : t -> Revision.t -> Path.t -> Keys.t -> t
68 val set_rev : t -> Revision.t -> t
69
70 (* basic db reading *)
71 val get : t -> Revision.t -> Path.t -> DataImpl.t
72 val get_data : t -> Node.t -> DataImpl.t
73 val get_children :
74 t -> Revision.t -> (Keys.t option * int) option
75 -> Path.t -> (Path.t * Revision.t) list
76 val get_descendants : t -> Path.t -> (Path.t * DataImpl.t) list
77 val get_all_rev_of_path : t -> Path.t -> Revision.t list
78 val get_last_rev_of_path : t -> Revision.t -> Path.t -> Revision.t
79
80 (* Index management *)
81 val update_index : t -> (Path.t * DataImpl.t) list -> t
82 val remove_from_index : t -> (Path.t * DataImpl.t) list -> t
83 val full_search : t -> string list -> Path.t -> Keys.t list
84
85 (* Links *)
86 val set_link :
87 t -> Revision.t -> Path.t -> Path.t -> t
88
89 (* Copies *)
90 val set_copy :
91 t -> Revision.t -> Path.t -> ?copy_rev:Revision.t -> Path.t -> t
92
93 (** [follow_path db rev node path_end] follows a path until copy or link
94 is encountered, if any.
95
96 @param db the database to inspect
97 @param rev everything will be read in this revision
98 @param node the node to start traversing at
99 @param path_end the path to walk along (as a [Keys.t list])
100
101 @return The node at which a copy or link was encountered
102 and the remaining suffix of the path.
103 *)
104 val follow_path :
105 t -> Revision.t -> Node.t -> Keys.t list -> Keys.t list * Node.t
106
107 (** [follow_link db original_rev path] returns unwound path as it was
108 at db revision [original_rev]. The result is independent on any
109 changes to the databse after [original_rev]. There is no escape
110 to the current revision via links (as would be the case if
111 the old revision came from a Copy node). If there is escape via link,
112 it's to [original_rev]. All copies are followed, just as links are.
113
114 @param db the database to inspect
115 @param original_rev everything will be read in this revision
116 @param path the path to traverse and unwind from root to the end
117
118 @return The path unwound at [original_rev].
119 *)
120 val follow_link : t -> Revision.t -> Path.t -> Path.t * Node.t
7d965b9 [fix] db3: abort of a transaction
Raja authored
121
122 val update_aborted : t -> t -> t
Something went wrong with that request. Please try again.