Changeset: 231efebad0ba for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=231efebad0ba
Added Files:
        monetdb5/extras/crackers/crackers_joinselect_ops.mx
Modified Files:
        monetdb5/extras/crackers/Makefile.ag
        monetdb5/extras/crackers/crackers.mx
        monetdb5/extras/crackers/crackers_core_unordered.mx
        monetdb5/extras/crackers/crackers_sideways.mx
        monetdb5/extras/crackers/crackers_updates.mx
Branch: holindex
Log Message:

Changes in sideways cracking to make TPCH queries work.


diffs (truncated from 640 to 300 lines):

diff --git a/monetdb5/extras/crackers/Makefile.ag 
b/monetdb5/extras/crackers/Makefile.ag
--- a/monetdb5/extras/crackers/Makefile.ag
+++ b/monetdb5/extras/crackers/Makefile.ag
@@ -37,6 +37,7 @@ lib_crackers = {
                          crackers_validation.mx \
                          crackers_core_unordered.mx \
                          crackers_select_ops.mx \
+                         crackers_joinselect_ops.mx \
                          crackers_holistic.c \
                          crackers_holistic.h \
                          crackers_selectst_ops.mx \
diff --git a/monetdb5/extras/crackers/crackers.mx 
b/monetdb5/extras/crackers/crackers.mx
--- a/monetdb5/extras/crackers/crackers.mx
+++ b/monetdb5/extras/crackers/crackers.mx
@@ -124,6 +124,7 @@ All Rights Reserved.
 @:@1(@2,flt)@
 @:@1(@2,dbl)@
 @:@1(@2,date)@
+@:@1(@2,lng)@
 @
 @= TypeSwitch_2
 @:TypeSwitch_temp2(@1,int)@
@@ -137,6 +138,8 @@ All Rights Reserved.
 @:@1(dbl,int)@
 @:@1(dbl,dbl)@
 @:@1(int,lng)@
+@:@1(lng,date)@
+@:@1(lng,lng)@
 @
 @= TypeSwitch_joins1
 @:@1(int,int)@
@@ -155,6 +158,7 @@ module crackers;
 @:TypeSwitch_1(Validate)@
 @:TypeSwitch_1(Updates)@
 @:TypeSwitch_2(Sideways)@
+@:TypeSwitch_1(JoinSelect)@
 
 command getTotalStorage( ):void
 address CRKgetTotalStorage
@@ -298,6 +302,45 @@ comment "Retrieve the subset using a cra
         index producing preferably a BATview.";
 
 @
+@= JoinSelect
+command joinuselect( right:bat[:oid,:@2], l:@2, h:@2, li:bit, hi:bit, 
left:bat[:oid,:void] ):bat[:oid,:void]
+address CRKjoinSelectDefault_@2
+comment "Join left and right on head-OIDs.
+       From right, only those BUNs qualify that satisfy the range-restriction 
on the tail.
+       The result is a new [:oid,:void] BAT.";
+
+command joinuselect( right:bat[:oid,:@2], l:@2, h:@2, li:bit, hi:bit, 
left:bat[:oid,:void], inPlace:bit , isForeignKey:bit):bat[:oid,:void]
+address CRKjoinSelectBounds_@2
+comment "Join left and right on head-OIDs.
+       From right, only those BUNs qualify that satisfy the range-restriction 
on the tail.
+       If inPlace is TRUE (and left has an OID head and is not a BAT-view), we 
operate in-place,
+       overwriting left and returning it as result. Otherwise, the result is a 
new [:oid,:void] BAT.
+       If isForeignKey is TRUE, we assume that each tuple from left finds a 
match in right,
+       and hence skip the respective check.
+       (NOTE: This may lead to CRASHES, if isForeignKey is incorrectly passed 
as TRUE!)";
+
+command jointhetauselect( right:bat[:oid,:@2],v:@2,op:str, 
left:bat[:oid,:void], inPlace:bit , isForeignKey:bit):bat[:oid,:void]
+address CRKjointhetauselect_@2
+comment "Join left and right on head-OIDs.
+       From right, only those BUNs qualify that satisfy the range-restriction 
on the tail.
+       If inPlace is TRUE (and left has an OID head and is not a BAT-view), we 
operate in-place,
+       overwriting left and returning it as result. Otherwise, the result is a 
new [:oid,:void] BAT.
+       If isForeignKey is TRUE, we assume that each tuple from left finds a 
match in right,
+       and hence skip the respective check.
+       (NOTE: This may lead to CRASHES, if isForeignKey is incorrectly passed 
as TRUE!)";
+
+command joinselect( b:bat[:oid,:@2],l:@2, h:@2, li:bit, hi:bit ):bat[:oid,:bit]
+address CRKjoinSelectSideways_@2
+comment "From cpair, only those BUNs qualify that satisfy the 
range-restriction on the tail.
+        The result is a new [:oid,:bit] BAT that reflects the positions of 
buns in cpair. 
+       For each tuple that qualifies in cpair, the respective position in the 
pivot is marked with a 1";
+
+command jointhetaselect( b:bat[:oid,:@2],v:@2,op:str):bat[:oid,:bit]
+address CRKjointhetaSelectSideways_@2
+comment "From cpair, only those BUNs qualify that satisfy the 
range-restriction on the tail.
+        The result is a new [:oid,:bit] BAT that reflects the positions of 
buns in cpair. 
+       For each tuple that qualifies in cpair, the respective position in the 
pivot is marked with a 1";
+@
 @= Updates
 command insertionsPartiallyForget(b:bat[:any_1,:@2], c:bat[:any_1,:@2]):void
 address CRKmergeInsertions_PartiallyForget_@2
diff --git a/monetdb5/extras/crackers/crackers_core_unordered.mx 
b/monetdb5/extras/crackers/crackers_core_unordered.mx
--- a/monetdb5/extras/crackers/crackers_core_unordered.mx
+++ b/monetdb5/extras/crackers/crackers_core_unordered.mx
@@ -42,6 +42,7 @@ All Rights Reserved.
 @
 @= TypeSwitch_2
 @:@1(int,,simple,,int,@2)@
+@:@1(lng,,simple,,lng,@2)@
 @:@1(dbl,,simple,,dbl,@2)@
 @:@1(date,,atom,TYPE_,loc,@2)@
 @
@@ -52,8 +53,11 @@ All Rights Reserved.
 @:@1(int,date,simple,,,@2)@
 @:@1(int,oid,simple,,,@2)@
 @:@1(dbl,date,simple,,,@2)@
+@:@1(lng,date,simple,,,@2)@
 @:@1(dbl,int,simple,,,@2)@
 @:@1(dbl,dbl,simple,,,@2)@
+@:@1(lng,lng,simple,,,@2)@
+
 
 @:@1(date,int,atom,TYPE_,,@2)@
 @:@1(date,lng,atom,TYPE_,,@2)@
@@ -66,6 +70,7 @@ All Rights Reserved.
 @:@1(int,date,simple,,,@2)@
 @:@1(int,oid,simple,,,@2)@
 @:@1(dbl,date,simple,,,@2)@
+@:@1(lng,date,simple,,,@2)@
 @:@1(dbl,int,simple,,,@2)@
 @:@1(dbl,dbl,simple,,,@2)@
 @
diff --git a/monetdb5/extras/crackers/crackers_joinselect_ops.mx 
b/monetdb5/extras/crackers/crackers_joinselect_ops.mx
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/crackers/crackers_joinselect_ops.mx
@@ -0,0 +1,309 @@
+@/
+The contents of this file are subject to the MonetDB Public License
+Version 1.1 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+http://www.monetdb.org/Legal/MonetDBLicense
+
+Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+License for the specific language governing rights and limitations
+under the License.
+
+The Original Code is the MonetDB Database System.
+
+The Initial Developer of the Original Code is CWI.
+Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+Copyright August 2008-2012 MonetDB B.V.
+All Rights Reserved.
+@
+
+@f crackers_joinselect_ops
+
+@c
+/*
+ * @a Martin Kersten, Stratos Idreos, Stefan Manegold
+ * @d March 2006 - July 2007
+ * @* JoinSelect Operators
+ *
+ *
+ * @+ Interface
+ *
+ *
+ * @- Type expansion
+ */
+@= TypeSwitch
+@:@1(sht,simple,)@
+@:@1(int,simple,)@
+@:@1(lng,simple,)@
+@:@1(flt,simple,)@
+@:@1(dbl,simple,)@
+@:@1(date,atom,TYPE_)@
+@
+@h
+/*
+ * @- Header file
+ */
+#ifndef _CRACKERS_JOINSELECT_H_
+#define _CRACKERS_JOINSELECT_H_
+
+/* Exported signatures */
+@:TypeSwitch(JoinSelectFunctions_decl)@
+
+#endif /* _CRACKERS_JOINSELECT_H */
+/*
+ * @- Exported signatures
+ */
+@= JoinSelectFunctions_decl
+crackers_export str CRKjoinSelectDefault_@1(int *res, int *right, @1 *low, @1 
*hgh, bit *inclusiveLow, bit *inclusiveHgh, int *left);
+crackers_export str CRKjoinSelectBounds_@1(int *res, int *right, @1 *low, @1 
*hgh, bit *inclusiveLow, bit *inclusiveHgh, int *left, bit *inPlace, bit 
*isForeignKey);
+crackers_export str CRKjointhetauselect_@1(int *res, int *right, @1 *val, str 
*OP, int *left, bit *inPlace, bit *isForeignKey);
+@
+@c
+/*
+ * @+ Implementation
+ *
+ *
+ * @- C file
+ */
+#include "monetdb_config.h"
+#include "crackers.h"
+#include "crackers_joinselect_ops.h"
+
+/* Local support functions and macros */
+@:TypeSwitch(JoinSelectOperations)@
+
+/* Exported functions */
+@:TypeSwitch(JoinSelectFunctions_impl)@
+/*
+ * @- Exported functions
+ */
+@= JoinSelectFunctions_impl
+str
+CRKjoinSelectDefault_@1(int *res, int *right, @1 *low, @1 *hgh, bit 
*inclusiveLow, bit *inclusiveHgh, int *left){
+       bit inPlace = FALSE;
+       bit isForeignKey = FALSE;
+       return CRKjoinSelectBounds_@1( res, right, low, hgh, inclusiveLow, 
inclusiveHgh, left, &inPlace, &isForeignKey);
+}
+
+str
+CRKjoinSelectBounds_@1(int *res, int *right, @1 *low, @1 *hgh, bit 
*inclusiveLow, bit *inclusiveHgh, int *left, bit *inPlace, bit *isForeignKey){
+       BAT *l, *r;
+
+       if ((l = BATdescriptor(*left)) == NULL) 
+               throw(MAL, "crackers.crackJoinSelect", "Cannot access 
descriptor");
+
+       if ((r = BATdescriptor(*right)) == NULL) {
+               BBPunfix(*left);
+               throw(MAL, "crackers.crackJoinSelect", "Cannot access 
descriptor");
+        }
+
+       if (!BAThdense(r)) {
+               BBPunfix(*left);
+               BBPunfix(*right);
+               throw(MAL, "crackers.crackJoinSelect", "right BAT must have a 
dense head");
+       }
+
+       if (BATcount(l) == 0 || BATcount(r) == 0){
+               BAT *d = BATnew(TYPE_oid, TYPE_void, 0);
+               BATsetcount(d, 0);
+               d->hsorted = 1;
+               d->hdense = TRUE;
+               BATseqbase(d, (oid)0);
+               BATkey(d, TRUE);
+               d->tsorted = FALSE;
+               d->tdense = FALSE;
+               BATseqbase(BATmirror(d), oid_nil);
+               BATkey(BATmirror(d), FALSE);
+               d->batRestricted= BAT_READ;
+               BBPkeepref(d->batCacheid);
+               *res = d->batCacheid;
+               BBPunfix(*left);
+               BBPunfix(*right);
+               return MAL_SUCCEED;
+       }       
+
+        if (@2_EQ(low,ATOMnilptr(TYPE_@1),@3@1)){
+               if (*inclusiveHgh==TRUE)
+                       return JoinSelectSingle_RE_@1(res, l, r, hgh, *inPlace, 
*isForeignKey);
+               else
+                       return JoinSelectSingle_RO_@1(res, l, r, hgh, *inPlace, 
*isForeignKey);
+       }
+        else if (@2_EQ(hgh,ATOMnilptr(TYPE_@1),@3@1))
+               if (*inclusiveLow==TRUE)
+                       return JoinSelectSingle_LE_@1(res, l, r, low, *inPlace, 
*isForeignKey);
+               else
+                       return JoinSelectSingle_LO_@1(res, l, r, low, *inPlace, 
*isForeignKey);
+        else{
+               if ((*inclusiveLow==TRUE) && (*inclusiveHgh==TRUE))
+                       return JoinSelectRange_LE_RE_@1(res, l, r, low, hgh, 
*inPlace, *isForeignKey);
+               else
+               if ((*inclusiveLow==TRUE) && (*inclusiveHgh==FALSE))
+                       return JoinSelectRange_LE_RO_@1(res, l, r, low, hgh, 
*inPlace, *isForeignKey);
+               else
+               if ((*inclusiveLow==FALSE) && (*inclusiveHgh==FALSE))
+                       return JoinSelectRange_LO_RO_@1(res, l, r, low, hgh, 
*inPlace, *isForeignKey);
+               else
+               if ((*inclusiveLow==TRUE) && (*inclusiveHgh==TRUE))
+                       return JoinSelectRange_LE_RE_@1(res, l, r, low, hgh, 
*inPlace, *isForeignKey);
+       }
+        throw(MAL, "crackers.crackJoinSelect", "case not handled");
+}
+
+str
+CRKjointhetauselect_@1(int *vid, int *bid, @1 *val, str *OP, int *left, bit 
*inplace, bit *foreignKey){
+       ptr nilptr = ATOMnilptr(TYPE_@1); 
+       char *op = *OP; 
+       bit lin = TRUE, rin = TRUE;
+       @1 *low = nilptr, *high = nilptr;
+
+       if (op[0] == '=') {
+               low = val; 
+       } else if (op[0] == '<') {
+               high = val;
+               rin = (op[1] == '=');
+       } else if (op[0] == '>') {
+               low = val;
+               lin = (op[1] == '=');
+       } else {
+               throw(MAL, "crackers.thetajoinuselect", "unknown operator");
+       }
+
+       return CRKjoinSelectBounds_@1(vid, bid, low, high, &lin, &rin, left, 
inplace, foreignKey);
+}
+@
+ * @- Local support functions and macros
+@= JoinSelectOperations
+@(
+@:JoinSelectR(@1,LO,RE,GT,LE,@2,@3)@
+@)
+@:JoinSelectR(@1,LE,RE,GE,LE,@2,@3)@
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to