Permalink
Browse files

[enhance] db3: remove unusefull fields from node structure

min, max & pred_rev
  • Loading branch information...
1 parent 372208f commit 0ac35f01442d8f82cd353346236adabbd2f148f3 Raja committed Jun 30, 2011
Showing with 21 additions and 60 deletions.
  1. +8 −11 database/db3/ioManager.ml
  2. +13 −46 database/db3/node.ml
  3. +0 −3 database/db3/node.mli
View
@@ -506,13 +506,13 @@ let write_node node =
| N.Full full ->
let lst =
[ [c0];
- c0 :: key2fm full.N.max ;
- c1 :: key2fm full.N.min ;
+ c0 :: key2fm (K.IntKey (-1)) (*full.N.max*) ;
+ c1 :: key2fm (K.IntKey (-1)) (*full.N.min*) ;
c2 :: [rev2fm full.N.cur_rev] ;
- c3 ::
- Option.default_map [c1]
+ c3 :: [c1] (* : None *)
+(* Option.default_map [c1]
(fun x -> c0 :: rev2fm x :: [])
- full.N.pred_rev ;
+ full.N.pred_rev*) ;
c4 :: data2fm full.N.content ;
] in
let oldrev = [] in
@@ -557,16 +557,16 @@ let read_node fm =
match F.read_char fm f with
| c when c = cc0 ->
iscorrupted (F.read_char fm f) cc0;
- let nodemax = fm2key fm f in
+ let _nodemax = fm2key fm f in
iscorrupted (F.read_char fm f) cc1;
- let nodemin = fm2key fm f in
+ let _nodemin = fm2key fm f in
iscorrupted (F.read_char fm f) cc2;
let current_revision = fm2rev fm f in
iscorrupted (F.read_char fm f) cc3;
- let previous_revision =
+ let _previous_revision =
let shb = F.read_char fm f in
if shb = cc0 then Some (fm2rev fm f)
else (iscorrupted shb cc1; None) in
@@ -605,10 +605,7 @@ let read_node fm =
| _ -> raise F.Corruption in
N.Full { N.
- max = nodemax ;
- min = nodemin ;
cur_rev = current_revision ;
- pred_rev = previous_revision ;
content ;
map = nodemap ;
}
View
@@ -21,10 +21,7 @@ module List = BaseList
(* -- *)
type full = {
- max : Keys.t ;
- min : Keys.t ;
cur_rev : Revision.t ;
- pred_rev : Revision.t option ; (* TODO: unused! *)
content : Datas.t ;
map : Eid.t KeyMap.t ;
}
@@ -101,13 +98,10 @@ let print_rev_delta delta =
let print_full n =
Printf.sprintf
- "max=%s, min=%s, rev=%s, pred_rev=%s, content=%s, map=%s"
- (Keys.to_string n.max)(Keys.to_string n.min)
+ "rev=%s, content=%s, map=%s"
(Revision.to_string n.cur_rev)
- (match n.pred_rev with
- | Some r -> Revision.to_string r
- | _ -> "none")
- (Datas.to_string n.content)(print_map n.map)
+ (Datas.to_string n.content)
+ (print_map n.map)
let to_string = function
| Full node -> Printf.sprintf "Full {%s}" (print_full node)
@@ -220,10 +214,7 @@ let create ?content rev =
| Some d -> d
| _ -> Datas.empty
in
- Full { max = Keys.newkey
- ; min = Keys.newkey
- ; cur_rev = rev
- ; pred_rev = None
+ Full { cur_rev = rev
; content = content
; map = KeyMap.empty }
@@ -234,26 +225,20 @@ let is_full_map node =
| RevDelta (_uid, _rev, delta) ->
(List.length delta.extra_children >= max_delta)
-let update_full_to_full ?content ?child uid rev node =
- let new_map, new_max, new_min =
+let update_full_to_full ?content ?child _uid rev node =
+ let new_map =
match child with
| Some (k, eid) ->
- KeyMap.add k eid node.map, Keys.max k node.max, Keys.min k node.min
- | _ -> node.map, node.max, node.min
- in
- let new_rev, new_pred_rev =
- if rev = node.cur_rev then node.cur_rev, node.pred_rev
- else rev, Some (node.cur_rev)
+ KeyMap.add k eid node.map
+ | _ -> node.map
in
+ let new_rev = rev in
let new_content =
match content with
| Some d -> d
| _ -> node.content
in
- Full { max = new_max
- ; min = new_min
- ; cur_rev = new_rev
- ; pred_rev = new_pred_rev
+ Full { cur_rev = new_rev
; content = new_content
; map = new_map}
@@ -309,14 +294,7 @@ let update_delta ~f ?content ?child uid rev old_uid old_rev old_delta delta =
| Some d -> d
| _ -> get_content ~f old_node
in
- let max, min =
- if KeyMap.is_empty map then Keys.newkey, Keys.newkey
- else fst (KeyMap.max map), fst (KeyMap.min map)
- in
- Full { max = max
- ; min = min
- ; cur_rev = rev
- ; pred_rev = Some old_rev
+ Full { cur_rev = rev
; content = new_content
; map = map }
| _ ->
@@ -351,14 +329,7 @@ let update_delta ~f ?content ?child uid rev old_uid old_rev old_delta delta =
| Some d -> d
| _ -> get_content ~f old_node
in
- let max, min =
- if KeyMap.is_empty map then Keys.newkey, Keys.newkey
- else fst (KeyMap.max map), fst (KeyMap.min map)
- in
- Full { max = max
- ; min = min
- ; cur_rev = old_rev
- ; pred_rev = None
+ Full { cur_rev = old_rev
; content = new_content
; map = map }
| _ ->
@@ -403,12 +374,8 @@ let rec remove_child ~f rev node key =
match node with
| Full node ->
let new_map = KeyMap.remove key node.map in
- let new_max, new_min =
- if KeyMap.is_empty new_map then Keys.newkey, Keys.newkey
- else fst (KeyMap.max new_map), fst (KeyMap.min new_map)
- in
Full {node with
- map = new_map; max = new_max; min = new_min; cur_rev = rev}
+ map = new_map; cur_rev = rev}
| Delta (uid, _rev, _delta) ->
let new_map = KeyMap.remove key (get_map ~f node) in
let content = get_content ~f node in
View
@@ -63,10 +63,7 @@ val fold_range :
*)
type full = {
- max : Keys.t ;
- min : Keys.t ;
cur_rev : Revision.t ;
- pred_rev : Revision.t option ;
content : Datas.t ;
map : Eid.t KeyMap.t ;
}

0 comments on commit 0ac35f0

Please sign in to comment.