Update of /cvsroot/monetdb/MonetDB5/src/modules/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15038
Modified Files:
Tag: MonetDB_5-4
bpm.mx
Log Message:
Better layout
CVS ----------------------------------------------------------------------
Index: bpm.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/mal/bpm.mx,v
retrieving revision 1.123.2.2
retrieving revision 1.123.2.3
diff -u -d -r1.123.2.2 -r1.123.2.3
--- bpm.mx 9 Feb 2008 22:31:50 -0000 1.123.2.2
+++ bpm.mx 10 Feb 2008 19:01:47 -0000 1.123.2.3
@@ -29,11 +29,11 @@
based on splitting by tail value.
The following MAL program illustrates the snippet of actions needed:
@example
- bpm.open();
- Ralias:= bpm.deposit("myversion",R:bat[:oid,:int]);
- bpm.rangePartition(Ralias,nil:int,100);
- bpm.rangePartition(Ralias,101,200);
- bpm.close();
+bpm.open();
+Ralias:= bpm.deposit("myversion",R:bat[:oid,:int]);
+bpm.rangePartition(Ralias,nil:int,100);
+bpm.rangePartition(Ralias,101,200);
+bpm.close();
@end example
The command @sc{bpm.deposit} registers a BAT as one
for which a partitioned copy is required.
@@ -48,11 +48,11 @@
The partition manager also supports hash-based partitioning.
Its argument is the number of hash bucket bits.
@example
- bpm.open();
- Rev:= bat.reverse(R:bat[:oid,:int]);
- Ralias:= bpm.deposit("myHashVersion",Rev); # creates side effects
- bpm.hashPartition(Ralias,2);
- bpm.close();
+bpm.open();
+Rev:= bat.reverse(R:bat[:oid,:int]);
+Ralias:= bpm.deposit("myHashVersion",Rev); # creates side effects
+bpm.hashPartition(Ralias,2);
+bpm.close();
@end example
This example creates a hash-partition based on the head.
@@ -67,7 +67,7 @@
Assume a relation R(A,B) which is already partitioned on A
the derived fragmentation on the head is enforced with
@example
- bpm.derivePartition(B,A);
+bpm.derivePartition(B,A);
@end example
@- Using partitions
The partitioned BAT can be used in two ways. A query plan can be
@@ -79,17 +79,17 @@
a partitioned BAT. In this example we collect the partial
results in the accumulator BAT U.
@example
- bpm.open();
- Ralias:bat[:oid,:int]:= bpm.take("myversion");
- U:= bat.new(:oid,:int);
+ bpm.open();
+ Ralias:bat[:oid,:int]:= bpm.take("myversion");
+ U:= bat.new(:oid,:int);
barrier Rp:= bpm.newIterator(Ralias);
- ...
- t:= algebra.select(Rp,0,100);
- U:= algebra.union(tu,t);
- ...
- redo Rp:= bpm.hasMoreElements(Ralias);
+ ...
+ t:= algebra.select(Rp,0,100);
+ U:= algebra.union(tu,t);
+ ...
+ redo Rp:= bpm.hasMoreElements(Ralias);
exit Rp;
- bpm.close();
+ bpm.close();
@end example
The properties of the partitioned BATs are particularly useful during query
@@ -100,21 +100,21 @@
To illustrate, the same problem handled by an optimizer that produces the plan
based on a known number of partitions:
@example
- bpm.open();
- R:bat[:oid,:int]:= bpm.take("myversion"); # get the partition alias
- optimizer.mergetable();
- T:= algebra.select(R,0,100);
+ bpm.open();
+ R:bat[:oid,:int]:= bpm.take("myversion"); # get the partition alias
+ optimizer.mergetable();
+ T:= algebra.select(R,0,100);
@end example
is translated to the plan:
@example
- bpm.open();
- R:bat[:oid,:int]:= bpm.take("myversion"); # get the partition alias
- R0:bat[:oid,:int]:= bpm.take(R,0, nil:oid,nil:oid, 0,100);
- R1:bat[:oid,:int]:= bpm.take(R,1, nil:oid,nil:oid, 101,200);
- R2:bat[:oid,:int]:= bpm.take(R,2, nil:oid,nil:oid, 201,nil:int);
- R:= mat.new(R0,R1,R2);
- T:= algebra.select(R,0,100);
- optimizer.multitable();
+ bpm.open();
+ R:bat[:oid,:int]:= bpm.take("myversion"); # get the partition alias
+ R0:bat[:oid,:int]:= bpm.take(R,0, nil:oid,nil:oid, 0,100);
+ R1:bat[:oid,:int]:= bpm.take(R,1, nil:oid,nil:oid, 101,200);
+ R2:bat[:oid,:int]:= bpm.take(R,2, nil:oid,nil:oid, 201,nil:int);
+ R:= mat.new(R0,R1,R2);
+ T:= algebra.select(R,0,100);
+ optimizer.multitable();
@end example
In this translation Ri also gets the properties of the BATs.
It is now up to the @sc{mat} optimizer to decide about
@@ -127,12 +127,12 @@
Once the transaction is commited, the updates are propagated
(in parallel) to all partitions.
@example
- bpm.open();
- Ralias:bat[:oid,:int] := bpm.take("myversion");
- bpm.insert(Ralias, Rinsert); # handle pending inserts
- bpm.delete(Ralias, Rdelete); # handle pending deletes
- bpm.replace(Ralias, Rold, Rnew); # handle pending updates
- bpm.close();
+ bpm.open();
+ Ralias:bat[:oid,:int] := bpm.take("myversion");
+ bpm.insert(Ralias, Rinsert);# handle pending inserts
+ bpm.delete(Ralias, Rdelete);# handle pending deletes
+ bpm.replace(Ralias, Rold, Rnew);# handle pending updates
+ bpm.close();
@end example
The @sc{replace} operator works on the assumption that
the head of @sc{Rold} and @sc{Rnew} is unique.
@@ -152,23 +152,23 @@
In the previous plan for this becomes
@example
- bpm.open();
- Tmp := bpm.deposit("tmp",:bat[:oid,:int]);
- bpm.rangePartition(tmp,nil:int,100);
- bpm.rangePartition(tmp,101,nil:int);
+ bpm.open();
+ Tmp := bpm.deposit("tmp",:bat[:oid,:int]);
+ bpm.rangePartition(tmp,nil:int,100);
+ bpm.rangePartition(tmp,101,nil:int);
- Ralias:bat[:oid,:int]:= bpm.take("myversion"); # get the partition alias
- R0:bat[:oid,:int]:= bpm.take("myversion", nil:oid,nil:oid, 0,100);
- T0:= algebra.select(R0,0,100);
- bpm.insert(Tmp,T0);
+ Ralias:bat[:oid,:int]:= bpm.take("myversion"); # get the partition alias
+ R0:bat[:oid,:int]:= bpm.take("myversion", nil:oid,nil:oid, 0,100);
+ T0:= algebra.select(R0,0,100);
+ bpm.insert(Tmp,T0);
- R1:bat[:oid,:int]:= bpm.take("myversion", nil:oid,nil:oid, 101,200);
- T1:= algebra.select(R1,0,100);
- bpm.insert(Tmp,T1);
+ R1:bat[:oid,:int]:= bpm.take("myversion", nil:oid,nil:oid, 101,200);
+ T1:= algebra.select(R1,0,100);
+ bpm.insert(Tmp,T1);
- R2:bat[:oid,:int]:= bpm.take("myversion", nil:oid,nil:oid, 201,nil:int);
- T2:= algebra.select(R2,0,100);
- bpm.insert(Tmp,T2);
+ R2:bat[:oid,:int]:= bpm.take("myversion", nil:oid,nil:oid, 201,nil:int);
+ T2:= algebra.select(R2,0,100);
+ bpm.insert(Tmp,T2);
@end example
Note that a symbolic optimizer can reduce this plan to a small snippet.
@@ -181,28 +181,28 @@
stored in the BPM catalog. Instead, the mat approach could
be used to reduce the plan size.
@example
- bpm.open();
- Ralias:= bpm.take("myversion",:bat[:oid,:int]); # get the partition
alias
- [EMAIL PROTECTED]:oid,hhigh=nil:oid,tlow=nil:int,[EMAIL PROTECTED]:=
bpm.take(Ralias, 0);
- T0:=algebra.select(R0,0,100);
+ bpm.open();
+ Ralias:= bpm.take("myversion",:bat[:oid,:int]); # get the partition alias
+ [EMAIL PROTECTED]:oid,hhigh=nil:oid,tlow=nil:int,[EMAIL PROTECTED]:=
bpm.take(Ralias, 0);
+ T0:=algebra.select(R0,0,100);
- [EMAIL PROTECTED]:oid,hhigh=nil:oid,tlow=101,[EMAIL PROTECTED]:=
bpm.take(Ralias, 1);
- T1:= algebra.select(R1,0,100);
+ [EMAIL PROTECTED]:oid,hhigh=nil:oid,tlow=101,[EMAIL PROTECTED]:=
bpm.take(Ralias, 1);
+ T1:= algebra.select(R1,0,100);
- [EMAIL PROTECTED]:oid,hhigh=nil:oid,tlow=201,thigh=nil:[EMAIL
PROTECTED]:= bpm.take(Ralias, 2);
- R:= mat.new(T0,T1,T2);
- T2:=algebra.select(R2,0,100);
+ [EMAIL PROTECTED]:oid,hhigh=nil:oid,tlow=201,thigh=nil:[EMAIL PROTECTED]:=
bpm.take(Ralias, 2);
+ R:= mat.new(T0,T1,T2);
+ T2:=algebra.select(R2,0,100);
@end example
@- Partition iterators
The default strategy for an optimizer is to replace a
reference to a partitioned BAT by an iterator.
@example
- l:= bpm.new();
+ l:= bpm.new();
barrier Elm:bat[:oid,:int]:= bpm.newIterator(Ralias);
- t:= algebra.select(Elm,0,20);
- bpm.addPartition(l,t);
- redo Elm:bat[:oid,:int]:= bpm.newIterator(Ralias);
+ t:= algebra.select(Elm,0,20);
+ bpm.addPartition(l,t);
+ redo Elm:bat[:oid,:int]:= bpm.newIterator(Ralias);
exit Elm;
@end example
Variations on this theme are iterators that search for
@@ -217,7 +217,7 @@
The select operation can be overloaded in the BPM to
improve processing further. For example, the operation
@example
- t := bpm.select(Ralias,0,100);
+ t := bpm.select(Ralias,0,100);
@end example
extracts portions of all three partitions and creates
a non-partitioned result BAT.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins