Update of /cvsroot/monetdb/MonetDB5/src/modules/mal/crackers
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16034
Modified Files:
crackers_joins.mx
Log Message:
Removed the 'forbidden' // structure and wrapped all
debugging code with DEBUG_CRACKERS_JOIN
it is the preferred way to keep the code easily accessible.
Index: crackers_joins.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/mal/crackers/crackers_joins.mx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- crackers_joins.mx 17 Jan 2008 09:03:17 -0000 1.5
+++ crackers_joins.mx 17 Jan 2008 10:05:43 -0000 1.6
@@ -38,6 +38,7 @@
@:TypeSwitch_1(JoinFunctions_decl1)@
crackers_export str CRKbatCount(lng *count, int *bid);
+/* #define DEBUG_CRACKERS_JOIN to enable debug trace */
#endif /* _CRACKERS_JOINS_H */
@
@@ -125,7 +126,7 @@
@:hashjoin(atom,any,tail)@
}
- bunins_failed: // blindly assume bunins does NOT fail
+ bunins_failed: /* blindly assume bunins does NOT fail*/
BATmmap_unpin(r);
return;
}
@@ -161,15 +162,16 @@
markedViewRight = (BAT*)BATmark(viewRight,prevPosRight+1);
BBPunfix(viewRight->batCacheid);
-/* {
+/* STRATOS look at this, should it remain?
+ {
BAT * partialRes;
- TJ1=GDKusec();
- //partialRes = BATmirror((BAT*)BATjoin(BATmirror(markedViewRight),
markedViewLeft, oid_nil));
- partialRes = BATjoin(BATmirror(markedViewLeft), markedViewRight,
oid_nil);
- TJ2=GDKusec();
- TJtotal += TJ2 - TJ1;
+ TJ1=GDKusec();
+ / * partialRes = BATmirror((BAT*)BATjoin(BATmirror(markedViewRight),
markedViewLeft, oid_nil)); * /
+ partialRes = BATjoin(BATmirror(markedViewLeft), markedViewRight,
oid_nil);
+ TJ2=GDKusec();
+ TJtotal += TJ2 - TJ1;
- BATins(res,partialRes,TRUE);
+ BATins(res,partialRes,TRUE);
BBPunfix(partialRes->batCacheid);
}
*/
@@ -188,13 +190,16 @@
BBPunfix(markedViewLeft->batCacheid);
@
[EMAIL PROTECTED] JoinTwoPiecesReuseHashTables
-/* printf("\n Index Left \n");
-printAVLTree(CrackerIndex[mapLpos].Tree, indexLeft, baseLeft, bunSizeLeft);
[EMAIL PROTECTED] dumpIndex
+#ifdef DEBUG_CRACKERS_JOIN
+ printf("\n @1 \n");
+ printAVLTree(CrackerIndex[mapLpos].Tree, indexLeft, baseLeft,
bunSizeLeft);
+ printf("\n Index Right \n");
+ printAVLTree(CrackerIndex[mapRpos].Tree, indexRight, baseRight,
bunSizeRight);
+#endif
-printf("\n Index Right \n");
-printAVLTree(CrackerIndex[mapRpos].Tree, indexRight, baseRight, bunSizeRight);
-*/
[EMAIL PROTECTED] JoinTwoPiecesReuseHashTables
+ @:dumpIndex(Index Left)@
/* Exploit existing views if possible */
if (prevNodeLeft != NULL){
if (prevNodeLeft->slice != -1){
@@ -211,8 +216,10 @@
markedViewLeft = (BAT*)BATmark(viewLeft,prevPosLeft+1);
BBPunfix(viewLeft->batCacheid);
}
- //else
- // printf("\n found hash table left \n");
+#ifdef DEBUG_CRACKERS_JOIN
+ else
+ printf("\n found hash table left \n"); */
+#endif
if (prevNodeRight != NULL){
if (prevNodeRight->slice != -1){
@@ -229,15 +236,18 @@
markedViewRight = (BAT*)BATmark(viewRight,prevPosRight+1);
BBPunfix(viewRight->batCacheid);
}
- //else
- // printf("\n found hash table right \n");
+#ifdef DEBUG_CRACKERS_JOIN
+ else
+ printf("\n found hash table right \n");
+#endif
-/*
+#ifdef DEBUG_CRACKERS_JOIN
printf("\n Left \n");
BATprint(markedViewLeft);
printf("\n Right \n");
BATprint(markedViewRight);
-*/
+#endif
+
TJ1=GDKusec();
if (curPosLeft - prevPosLeft > 0 && curPosRight - prevPosRight > 0) {
if ( (existsHashTableLeft == FALSE && existsHashTableRight ==
FALSE) || (existsHashTableLeft == TRUE && existsHashTableRight == TRUE) ){
@@ -282,26 +292,15 @@
}
TJ2=GDKusec();
TJtotal += TJ2 - TJ1;
-/*
+#ifdef DEBUG_CRACKERS_JOIN
printf("\n Res \n");
BATprint(res);
-*/
-/*
-printf("\n Index Left \n");
-printAVLTree(CrackerIndex[mapLpos].Tree, indexLeft, baseLeft, bunSizeLeft);
-
-printf("\n Index Right \n");
-printAVLTree(CrackerIndex[mapRpos].Tree, indexRight, baseRight, bunSizeRight);
-*/
+ @:dumpIndex(Index Left)@
+#endif
@
@= JoinTwoPiecesReuseHashTablesRight
-/* printf("\n Index Left \n");
-printAVLTree(CrackerIndex[mapLpos].Tree, indexLeft, baseLeft, bunSizeLeft);
-
-printf("\n Index Right \n");
-printAVLTree(CrackerIndex[mapRpos].Tree, indexRight, baseRight, bunSizeRight);
-*/
+ @:dumpIndex(Index Left)@
/* Exploit existing views if possible */
viewHeadLeft = VIEWhead_(mapLeft, BAT_READ);
viewLeft = BATslice(viewHeadLeft, prevPosLeft+1, curPosLeft +1);
@@ -326,12 +325,12 @@
BBPunfix(viewRight->batCacheid);
}
-/*
+#ifdef DEBUG_CRACKERS_JOIN
printf("\n Left \n");
BATprint(markedViewLeft);
printf("\n Right \n");
BATprint(markedViewRight);
-*/
+#endif
TJ1=GDKusec();
if (curPosLeft - prevPosLeft > 0 && curPosRight - prevPosRight > 0) {
if (existsHashTableRight == FALSE){
@@ -351,25 +350,23 @@
}
TJ2=GDKusec();
TJtotal += TJ2 - TJ1;
-/*
+#ifdef DEBUG_CRACKERS_JOIN
printf("\n Res \n");
BATprint(res);
-*/
-/*
-printf("\n Index Left \n");
-printAVLTree(CrackerIndex[mapLpos].Tree, indexLeft, baseLeft, bunSizeLeft);
-
-printf("\n Index Right \n");
-printAVLTree(CrackerIndex[mapRpos].Tree, indexRight, baseRight, bunSizeRight);
-*/
+ @:dumpIndex(Index Left)@
+#endif
@
@= MoveToNextPiece
- //printf("Move @2 \n");
+#ifdef DEBUG_CRACKERS_JOIN
+ printf("Move @2 \n");
+#endif
[EMAIL PROTECTED] = [EMAIL PROTECTED];
[EMAIL PROTECTED] = findNextPiece([EMAIL PROTECTED]);
if ([EMAIL PROTECTED] == NULL){
-// printf(" Skip the rest of the opposite(@2) pieces because @2
pieces are done \n");
+#ifdef DEBUG_CRACKERS_JOIN
+ printf(" Skip the rest of the opposite(@2) pieces because @2
pieces are done \n");
+#endif
break;
}
[EMAIL PROTECTED] = [EMAIL PROTECTED] + [EMAIL PROTECTED]>position;
@@ -472,7 +469,8 @@
BAT *res;
- /* Get the cracker tape for the set of the left map or create one if it
does not exist */
+ /* Get the cracker tape for the set of the left
+ map or create one if it does not exist */
tapeLpos = existsCrackerIndexSideways(*bidL1, -1);
if (tapeLpos == -1)
tapeLpos = [EMAIL PROTECTED](*bidL1);
@@ -496,7 +494,8 @@
baseLeft = BUNfirst(indexLeft);
- /* Get the cracker tape for the set of the right map or create one if
it does not exist */
+ /* Get the cracker tape for the set of the right map or
+ create one if it does not exist */
tapeRpos = existsCrackerIndexSideways(*bidR1, -1);
if (tapeRpos == -1)
tapeRpos = [EMAIL PROTECTED](*bidR1);
@@ -628,11 +627,11 @@
/* Take the map */
if ((mapRight = BATdescriptor(CrackerIndex[mapRpos].cbid)) == NULL)
throw(MAL, "crackers.simpleJoin", "Cannot access crack index");
- /*
+#ifdef DEBUG_CRACKERS_JOIN
printf("maps\n");
BATprint(mapLeft);
BATprint(mapRight);
- */
+#endif
/* Get the piece that holds the lowest values */
curNodeRight = getFirstNode(CrackerIndex[mapRpos].Tree);
@@ -645,11 +644,11 @@
while (1){
- /*
+#ifdef DEBUG_CRACKERS_JOIN
printf(" new loop maps\n");
BATprint(mapLeft);
BATprint(mapRight);
- */
+#endif
crackedLeft = crackedRight = FALSE;
@@ -661,11 +660,11 @@
curValueRight = *(@1 *)Tloc(indexRight, curTupleRight);
curPosRight = *(oid*)Hloc(indexRight, curTupleRight);
- /*
+#ifdef DEBUG_CRACKERS_JOIN
printf(" leftVal %d rightVal %d \n", curValueLeft,
curValueRight);
printf(" prevPosLeft %lld curPosLeft %lld \n",
prevPosLeft,curPosLeft);
printf(" prevPosRight %lld curPosRight %lld \n",
prevPosRight,curPosRight);
- */
+#endif
if (curValueLeft < curValueRight ||
((curValueLeft == curValueRight) && (curNodeLeft->inclusive ==
FALSE) && (curNodeRight->inclusive == TRUE))){
@@ -749,11 +748,11 @@
curPosRight = *(oid*)Hloc(indexRight, curTupleRight);
}
- /*
+#ifdef DEBUG_CRACKERS_JOIN
printf(" leftVal %d rightVal %d \n", curValueLeft,
curValueRight);
printf(" prevPosLeft %lld curPosLeft %lld \n",
prevPosLeft,curPosLeft);
printf(" prevPosRight %lld curPosRight %lld \n",
prevPosRight,curPosRight);
- */
+#endif
if (curNodeLeft != NULL && curNodeRight == NULL){
crackedOperationsRight++;
@@ -931,20 +930,17 @@
prevPosLeft = prevPosRight = -1;
prevNodeLeft = prevNodeRight = NULL;
-/*
-printf("\n New Join Index Left \n");
-printAVLTree(CrackerIndex[mapLpos].Tree, indexLeft, baseLeft, bunSizeLeft);
-
-printf("\n Index Right \n");
-printAVLTree(CrackerIndex[mapRpos].Tree, indexRight, baseRight, bunSizeRight);
-*/
+#ifdef DEBUG_CRACKERS_JOIN
+ printf("\n New Join Index Left \n");
+ @:dumpIndex(Index Left)@
+#endif
while (curNodeLeft != NULL && curNodeRight != NULL){
-/*
+#ifdef DEBUG_CRACKERS_JOIN
printf(" new loop maps\n");
BATprint(mapLeft);
BATprint(mapRight);
-*/
+#endif
crackedLeft = crackedRight = FALSE;
existsHashTableLeft = existsHashTableRight = FALSE;
@@ -957,11 +953,11 @@
curValueRight = *(@1 *)Tloc(indexRight, curTupleRight);
curPosRight = *(oid*)Hloc(indexRight, curTupleRight);
- /*
+#ifdef DEBUG_CRACKERS_JOIN
printf(" leftVal %d rightVal %d \n", curValueLeft,
curValueRight);
printf(" prevPosLeft %lld curPosLeft %lld \n",
prevPosLeft,curPosLeft);
printf(" prevPosRight %lld curPosRight %lld \n",
prevPosRight,curPosRight);
- */
+#endif
if (curValueLeft < curValueRight ||
((curValueLeft == curValueRight) && (curNodeLeft->inclusive ==
FALSE) && (curNodeRight->inclusive == TRUE))){
@@ -1057,14 +1053,16 @@
curPosRight = *(oid*)Hloc(indexRight, curTupleRight);
}
- /*
+#ifdef DEBUG_CRACKERS_JOIN
printf(" leftVal %d rightVal %d \n", curValueLeft,
curValueRight);
printf(" prevPosLeft %lld curPosLeft %lld \n",
prevPosLeft,curPosLeft);
printf(" prevPosRight %lld curPosRight %lld \n",
prevPosRight,curPosRight);
- */
+#endif
if (curNodeLeft != NULL && curNodeRight == NULL){
- // printf("crack Right \n");
+#ifdef DEBUG_CRACKERS_JOIN
+ printf("crack Right \n");
+#endif
crackedOperationsRight++;
TC1=GDKusec();
@@ -1073,7 +1071,9 @@
else
[EMAIL PROTECTED]@1(mapRight, curValueLeft,
prevPosRight+1, curPosRight, &newPosition);
- //printf("newPos %lld \n",newPosition);
+#ifdef DEBUG_CRACKERS_JOIN
+ printf("newPos %lld \n",newPosition);
+#endif
TC2=GDKusec();
TCtotal+=TC2-TC1;
@@ -1085,7 +1085,9 @@
}
else { /* this means that there is no chance to join
with the future pieces of the other side */
- //printf("skippiing the rest of the pieces
left");
+#ifdef DEBUG_CRACKERS_JOIN
+ printf("skippiing the rest of the pieces left");
+#endif
@:JoinTwoPiecesReuseHashTables()@
joinsDone++;
@@ -1093,7 +1095,9 @@
}
}
else if (curNodeLeft == NULL && curNodeRight != NULL){
- //printf("crack Left \n");
+#ifdef DEBUG_CRACKERS_JOIN
+ printf("crack Left \n");
+#endif
crackedOperationsLeft++;
@@ -1103,7 +1107,9 @@
else
[EMAIL PROTECTED]@1(mapLeft, curValueRight,
prevPosLeft+1, curPosLeft, &newPosition);
- //printf("newPos %lld \n",newPosition);
+#ifdef DEBUG_CRACKERS_JOIN
+ printf("newPos %lld \n",newPosition);
+#endif
TC2=GDKusec();
TCtotal+=TC2-TC1;
@@ -1115,7 +1121,9 @@
}
else {
- //printf("skipping the rest of the pieces
right");
+#ifdef DEBUG_CRACKERS_JOIN
+ printf("skipping the rest of the pieces right");
+#endif
@:JoinTwoPiecesReuseHashTables()@
joinsDone++;
@@ -1124,7 +1132,9 @@
}
else if (curNodeLeft == NULL && curNodeRight == NULL){
- //printf(" into the last piece for both maps \n");
+#ifdef DEBUG_CRACKERS_JOIN
+ printf(" into the last piece for both maps \n");
+#endif
@:JoinTwoPiecesReuseHashTables()@
joinsDone++;
@@ -1230,11 +1240,11 @@
if ((mapRight = BATdescriptor(CrackerIndex[mapRpos].cbid)) == NULL)
throw(MAL, "crackers.Join", "Cannot access crack map right");
-/*
+#ifdef DEBUG_CRACKERS_JOIN
printf("maps\n");
BATprint(mapLeft);
BATprint(mapRight);
-*/
+#endif
/* Get the piece that holds the lowest values */
curNodeRight = getFirstNode(CrackerIndex[mapRpos].Tree);
@@ -1246,13 +1256,7 @@
prevPosLeft = prevPosRight = -1;
prevNodeRight = NULL;
-/*
-printf("\n New Join Index Left \n");
-printAVLTree(CrackerIndex[mapLpos].Tree, indexLeft, baseLeft, bunSizeLeft);
-
-printf("\n Index Right \n");
-printAVLTree(CrackerIndex[mapRpos].Tree, indexRight, baseRight, bunSizeRight);
-*/
+ @:dumpIndex(New Join Index Left)@
/* the left has no index and it all falls into the first piece of the
right */
if (curNodeLeft == NULL){
curTupleRight = baseRight + curNodeRight->position;
@@ -1282,11 +1286,11 @@
curValueRight = *(@1 *)Tloc(indexRight, curTupleRight);
curPosRight = *(oid*)Hloc(indexRight, curTupleRight);
-/*
+#ifdef DEBUG_CRACKERS_JOIN
printf(" leftVal %d rightVal %d \n", curValueLeft,
curValueRight);
printf(" prevPosLeft %lld curPosLeft %lld \n",
prevPosLeft,curPosLeft);
printf(" prevPosRight %lld curPosRight %lld \n",
prevPosRight,curPosRight);
-*/
+#endif
while (curValueRight < curValueLeft ||
((curValueLeft == curValueRight) && (curNodeRight->inclusive
== FALSE) && (curNodeLeft->inclusive == TRUE))){
@@ -1587,13 +1591,7 @@
if (CrackerIndex[mapRpos].Tree == NULL) printf("\n head is null \n");
alignStep(mapLeft, CrackerIndex[mapRpos].Tree, 0, BATcount(mapLeft)-1,
indexRight, baseRight, indexLeft, mapLpos);
-/*
-printf("\n Index Left \n");
-printAVLTree(CrackerIndex[mapLpos].Tree, indexLeft, BUNfirst(indexLeft),
bunSizeLeft);
-
-printf("\n Index Right \n");
-printAVLTree(CrackerIndex[mapRpos].Tree, indexRight, baseRight, bunSizeRight);
-*/
+ @:dumpIndex(Index Left)@
BBPunfix(indexLeft->batCacheid);
BBPkeepref(mapLeft->batCacheid);
BBPunfix(indexRight->batCacheid);
-------------------------------------------------------------------------
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