Update of /cvsroot/monetdb/pathfinder/runtime
In directory sc8-pr-cvs16:/tmp/cvs-serv12638/runtime
Modified Files:
pf_support.mx
Log Message:
Implemeted "do replace x with y" as a single update command instead of as a
combination of insert (had to be done first) and delete.
This has the advantage that we can reuse the space that becomes available for
the new element.
Index: pf_support.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/pf_support.mx,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -d -r1.218 -r1.219
--- pf_support.mx 27 Apr 2007 14:20:31 -0000 1.218
+++ pf_support.mx 27 Apr 2007 18:22:42 -0000 1.219
@@ -1987,7 +1987,7 @@
@- update primitives
@mil
-# the UPDATE_INSERT_* and UPDATE_REPLACECONTENT commands MUST be
+# the UPDATE_INSERT_*, UPDATE_REPLACENODE and UPDATE_REPLACECONTENT commands
MUST be
# consecutive, the UPDATE_INSERT_LAST and UPDATE_INSERT_BEFORE
# commands also MUST be consecutive
const UPDATE_INSERT_FIRST := 1LL;
@@ -1995,9 +1995,10 @@
const UPDATE_INSERT_BEFORE := 3LL;
const UPDATE_INSERT_AFTER := 4LL;
const UPDATE_REPLACECONTENT := 5LL;
-const UPDATE_DELETE := 6LL;
-const UPDATE_RENAME := 7LL;
-const UPDATE_REPLACE := 8LL;
+const UPDATE_REPLACENODE := 6LL;
+const UPDATE_DELETE := 7LL;
+const UPDATE_RENAME := 8LL;
+const UPDATE_REPLACE := 9LL;
PROC myupdate(bat[any::1,any::2] oldbat, bat[any::1,any::2] newbat) :
bat[any::1,any::2]
{
@@ -2632,7 +2633,7 @@
}
{
- var insert_update := update_cmd.ord_select(UPDATE_INSERT_FIRST,
UPDATE_REPLACECONTENT);
+ var insert_update := update_cmd.ord_select(UPDATE_INSERT_FIRST,
UPDATE_REPLACENODE);
if (insert_update.count() > 0) {
var update_node_item := [oid]([+]([lng](insert_update.mirror()),
1)).leftfetchjoin(item);
var update_node_kind := [oid]([+]([lng](insert_update.mirror()),
1)).leftfetchjoin(kind);
@@ -3299,6 +3300,8 @@
docinsertafter_oldpre := oid(lng(docinsertafter_oldpre) - 1LL);
} else if (docinsertcmd = lng(UPDATE_INSERT_AFTER)) {
docinsertafter_oldpre := oid(lng(docinsertafter_oldpre) +
lng(ws.fetch(PRE_SIZE).find(doccont).find(docinsertafter_oldpre)));
+ } else if (docinsertcmd = lng(UPDATE_REPLACENODE)) {
+ docinsertafter_oldpre := oid(lng(docinsertafter_oldpre) - 1LL);
} else if (docinsertcmd = lng(UPDATE_REPLACECONTENT)) {
docinsertlevel :+= chr(1);
}
@@ -3381,6 +3384,31 @@
}
extend_unprotect(ws, doccont);
}
+ if (docinsertcmd = lng(UPDATE_REPLACENODE)) {
+ var oldpre := update_node_item.fetch(idx); # the node to be
replaced (i.e. deleted)
+ var newrid := findupdate(nid_rid, nid_rid_update,
pre_nid.find(oldpre));
+ var newpre := swizzle(newrid, map_pid_update);
+ var isoldpg := false;
+ var pgid :=
map_pid_update.reverse().find(oid(lng(docinsertbefore_newpre) >>
REMAP_PAGE_BITS));
+ if (map_pid.exist(pgid)) {
+ isoldpg := not(isnil(map_pid.find(pgid)));
+ }
+ var size;
+ extend_protect(ws, doccont);
+ if (isoldpg) {
+ if (rid_size_update.exist(newrid)) {
+ size := rid_size_update.find(newrid);
+ } else {
+ size := pre_size.find(oldpre);
+ }
+ } else {
+ size := rid_size.find(newrid);
+ }
+ if (size >= 0) {
+ do_delete_nodes(ws, doccont, newpre, size);
+ }
+ extend_unprotect(ws, doccont);
+ }
# figure out the number of holes on the page on which the new
# element is to be inserted (we use the PRE_KIND table for this,
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins