| author | wenzelm | 
| Fri, 05 May 2023 12:01:09 +0200 | |
| changeset 77967 | 6bb2f9b32804 | 
| parent 77723 | b761c91c2447 | 
| child 77974 | 93999ffdb9dd | 
| permissions | -rw-r--r-- | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 1 | (* Title: Pure/General/change_table.ML | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 2 | Author: Makarius | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 3 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 4 | Generic tables with extra bookkeeping of changes relative to some | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 5 | common base version, subject to implicit block structure. Support for | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 6 | efficient join/merge of big global tables with small local updates. | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 7 | *) | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 8 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 9 | signature CHANGE_TABLE = | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 10 | sig | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 11 | structure Table: TABLE | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 12 | type key = Table.key | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 13 | exception DUP of key | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 14 | exception SAME | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 15 | type 'a T | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 16 | val table_of: 'a T -> 'a Table.table | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 17 | val empty: 'a T | 
| 56054 | 18 | val is_empty: 'a T -> bool | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 19 | val change_base: bool -> 'a T -> 'a T | 
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 20 | val change_ignore: 'a T -> 'a T | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 21 | val join: (key -> 'a * 'a -> 'a) (*exception SAME*) -> 'a T * 'a T -> 'a T (*exception DUP*) | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 22 |   val merge: ('a * 'a -> bool) -> 'a T * 'a T -> 'a T  (*exception DUP*)
 | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 23 | val fold: (key * 'b -> 'a -> 'a) -> 'b T -> 'a -> 'a | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 24 | val dest: 'a T -> (key * 'a) list | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 25 | val lookup_key: 'a T -> key -> (key * 'a) option | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 26 | val lookup: 'a T -> key -> 'a option | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 27 | val defined: 'a T -> key -> bool | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 28 | val update: key * 'a -> 'a T -> 'a T | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 29 | val update_new: key * 'a -> 'a T -> 'a T (*exception DUP*) | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 30 |   val map_entry: key -> ('a -> 'a) -> 'a T -> 'a T
 | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 31 |   val map_default: key * 'a -> ('a -> 'a) -> 'a T -> 'a T
 | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 32 | val delete_safe: key -> 'a T -> 'a T | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 33 | end; | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 34 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 35 | functor Change_Table(Key: KEY): CHANGE_TABLE = | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 36 | struct | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 37 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 38 | structure Table = Table(Key); | 
| 77723 
b761c91c2447
performance tuning: prefer functor Set() over Table();
 wenzelm parents: 
56139diff
changeset | 39 | structure Set = Set(Key); | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 40 | type key = Table.key; | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 41 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 42 | exception SAME = Table.SAME; | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 43 | exception DUP = Table.DUP; | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 44 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 45 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 46 | (* optional change *) | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 47 | |
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 48 | datatype change = | 
| 77723 
b761c91c2447
performance tuning: prefer functor Set() over Table();
 wenzelm parents: 
56139diff
changeset | 49 |   No_Change | Change of {base: serial, depth: int, changes: Set.T option};
 | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 50 | |
| 56067 | 51 | fun make_change base depth changes = | 
| 52 |   Change {base = base, depth = depth, changes = changes};
 | |
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 53 | |
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 54 | fun ignore_change (Change {base, depth, changes = SOME _}) =
 | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 55 | make_change base depth NONE | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 56 | | ignore_change change = change; | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 57 | |
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 58 | fun update_change key (Change {base, depth, changes = SOME ch}) =
 | 
| 77723 
b761c91c2447
performance tuning: prefer functor Set() over Table();
 wenzelm parents: 
56139diff
changeset | 59 | make_change base depth (SOME (Set.insert key ch)) | 
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 60 | | update_change _ change = change; | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 61 | |
| 56067 | 62 | fun base_change true No_Change = | 
| 77723 
b761c91c2447
performance tuning: prefer functor Set() over Table();
 wenzelm parents: 
56139diff
changeset | 63 | make_change (serial ()) 0 (SOME Set.empty) | 
| 56067 | 64 |   | base_change true (Change {base, depth, changes}) =
 | 
| 65 | make_change base (depth + 1) changes | |
| 66 |   | base_change false (Change {base, depth, changes}) =
 | |
| 67 | if depth = 0 then No_Change else make_change base (depth - 1) changes | |
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 68 | | base_change false No_Change = raise Fail "Unbalanced change structure"; | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 69 | |
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 70 | fun cannot_merge () = raise Fail "Cannot merge: incompatible change structure"; | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 71 | |
| 56067 | 72 | fun merge_change (No_Change, No_Change) = NONE | 
| 73 | | merge_change (Change change1, Change change2) = | |
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 74 | let | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 75 |         val {base = base1, depth = depth1, changes = changes1} = change1;
 | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 76 |         val {base = base2, depth = depth2, changes = changes2} = change2;
 | 
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 77 | val _ = if base1 = base2 andalso depth1 = depth2 then () else cannot_merge (); | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 78 | val (swapped, ch2) = | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 79 | (case (changes1, changes2) of | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 80 | (_, SOME ch2) => (false, ch2) | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 81 | | (SOME ch1, _) => (true, ch1) | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 82 | | _ => cannot_merge ()); | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 83 | in SOME (swapped, ch2, make_change base1 depth1 NONE) end | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 84 | | merge_change _ = cannot_merge (); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 85 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 86 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 87 | (* table with changes *) | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 88 | |
| 56067 | 89 | datatype 'a T = Change_Table of {change: change, table: 'a Table.table};
 | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 90 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 91 | fun table_of (Change_Table {table, ...}) = table;
 | 
| 56054 | 92 | |
| 56067 | 93 | val empty = Change_Table {change = No_Change, table = Table.empty};
 | 
| 94 | ||
| 95 | fun is_empty (Change_Table {change, table}) =
 | |
| 96 | (case change of No_Change => Table.is_empty table | _ => false); | |
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 97 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 98 | fun make_change_table (change, table) = Change_Table {change = change, table = table};
 | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 99 | fun map_change_table f (Change_Table {change, table}) = make_change_table (f (change, table));
 | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 100 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 101 | fun change_base begin = (map_change_table o apfst) (base_change begin); | 
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 102 | fun change_ignore arg = (map_change_table o apfst) ignore_change arg; | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 103 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 104 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 105 | (* join and merge *) | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 106 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 107 | fun join f (arg1, arg2) = | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 108 | let | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 109 |     val Change_Table {change = change1, table = table1} = arg1;
 | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 110 |     val Change_Table {change = change2, table = table2} = arg2;
 | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 111 | in | 
| 56054 | 112 | if pointer_eq (change1, change2) andalso pointer_eq (table1, table2) then arg1 | 
| 113 | else if is_empty arg2 then arg1 | |
| 114 | else if is_empty arg1 then arg2 | |
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 115 | else | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 116 | (case merge_change (change1, change2) of | 
| 56067 | 117 | NONE => make_change_table (No_Change, Table.join f (table1, table2)) | 
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 118 | | SOME (swapped, ch2, change') => | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 119 | let | 
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 120 | fun maybe_swap (x, y) = if swapped then (y, x) else (x, y); | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 121 | val (tab1, tab2) = maybe_swap (table1, table2); | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 122 | fun update key tab = | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 123 | (case Table.lookup tab2 key of | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 124 | NONE => tab | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 125 | | SOME y => | 
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 126 | (case Table.lookup tab key of | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 127 | NONE => Table.update (key, y) tab | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 128 | | SOME x => | 
| 56139 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 129 | (case (SOME (f key (maybe_swap (x, y))) handle Table.SAME => NONE) of | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 130 | NONE => tab | 
| 
b7add947a6ef
more frugal recording of changes: join merely requires information from one side;
 wenzelm parents: 
56068diff
changeset | 131 | | SOME z => Table.update (key, z) tab))); | 
| 77723 
b761c91c2447
performance tuning: prefer functor Set() over Table();
 wenzelm parents: 
56139diff
changeset | 132 | in make_change_table (change', Set.fold update ch2 tab1) end) | 
| 56053 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 133 | end; | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 134 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 135 | fun merge eq = | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 136 | join (fn key => fn xy => if eq xy then raise Table.SAME else raise Table.DUP key); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 137 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 138 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 139 | (* derived operations *) | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 140 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 141 | fun fold f arg = Table.fold f (table_of arg); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 142 | fun dest arg = Table.dest (table_of arg); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 143 | fun lookup_key arg = Table.lookup_key (table_of arg); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 144 | fun lookup arg = Table.lookup (table_of arg); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 145 | fun defined arg = Table.defined (table_of arg); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 146 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 147 | fun change_table key f = | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 148 | map_change_table (fn (change, table) => (update_change key change, f table)); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 149 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 150 | fun update (key, x) = change_table key (Table.update (key, x)); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 151 | fun update_new (key, x) = change_table key (Table.update_new (key, x)); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 152 | fun map_entry key f = change_table key (Table.map_entry key f); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 153 | fun map_default (key, x) f = change_table key (Table.map_default (key, x) f); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 154 | fun delete_safe key = change_table key (Table.delete_safe key); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 155 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 156 | end; | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 157 | |
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 158 | structure Change_Table = Change_Table(type key = string val ord = fast_string_ord); | 
| 
030531cc4c62
tables with changes relative to some common base version -- support for efficient join/merge of big global tables with small local updates;
 wenzelm parents: diff
changeset | 159 |