Changeset: a477afa11b57 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a477afa11b57
Modified Files:
        monetdb5/mal/mal_errors.h
        monetdb5/mal/mal_exception.h
        monetdb5/modules/mal/mkey.c
        monetdb5/modules/mal/mkey.mal
Branch: default
Log Message:

Some textual cleanup


diffs (truncated from 438 to 300 lines):

diff --git a/monetdb5/mal/mal_errors.h b/monetdb5/mal/mal_errors.h
--- a/monetdb5/mal/mal_errors.h
+++ b/monetdb5/mal/mal_errors.h
@@ -18,34 +18,30 @@
  */
 
 /*
- * @f mal_errors
- * @-
- * The error strings are
- * geared at answering the question "what happened".
+ * The error strings are geared at answering the question "what happened".
  * Optional information about "why it happened" is added
  * as local strings in the code base with possibly runtime information.
  * Information on "how to avoid it" is sporadically added using expected 
values.
  *
  * General considerations on error classes are summarized below:
- * @itemize
- * @item MAL_MALLOC_FAIL
+ * MAL_MALLOC_FAIL
  * An operation allocates space for an object failed.
  * Either the pre-requisites are not satisfied, or the system
  * runs low on resources and can not accomodate the object.
  * For failures to create BATs it sometimes indicates that an
  * intermediate BAT size is too large.
- * @item OPERATION_FAILED
+ * OPERATION_FAILED
  * Mostly the module and function name are indicative enough.
  * If possible more is said about the error context,
  * informative references to arguments or variables,
  * provided it is produced by the underlying implementation.
- * @item GDK_EXCEPTION
+ * GDK_EXCEPTION
  * In general these are generated deep inside the kernel.
  * They are captured by the MAL interpreter.
- * @item SEMANTIC_*
+ * SEMANTIC_*
  * The patterns can be used to defer semantic type errors
  * to runtime.
- * @end itemize
+ * 
  * Getting all exception strings in one place improves consistency
  * and maintenance.
  *
diff --git a/monetdb5/mal/mal_exception.h b/monetdb5/mal/mal_exception.h
--- a/monetdb5/mal/mal_exception.h
+++ b/monetdb5/mal/mal_exception.h
@@ -49,7 +49,7 @@ enum malexception {
 #define throw \
        return createException
 #define rethrow(FCN, TMP, PRV) \
-       if ((TMP = PRV) != MAL_SUCCEED) return(TMP);
+       {if ((TMP = PRV) != MAL_SUCCEED) return(TMP);}
 
 mal_export str createException(enum malexception, const char *,
        _In_z_ _Printf_format_string_ const char *, ...)
diff --git a/monetdb5/modules/mal/mkey.c b/monetdb5/modules/mal/mkey.c
--- a/monetdb5/modules/mal/mkey.c
+++ b/monetdb5/modules/mal/mkey.c
@@ -18,21 +18,16 @@
  */
 
 /*
- * @f mkey
- * @a Peter Boncz, Stefan Manegold, Niels Nes
- * @-
- * @v 1.1
- * @+ Multi-Attribute Equi-Join
- */
-/*
- * @-
- * new functionality for the low-resource-consumption ds_link. It will
+ * (c) Peter Boncz, Stefan Manegold, Niels Nes
+ *
+ * new functionality for the low-resource-consumption. It will
  * first one by one create a hash value out of the multiple attributes.
  * This hash value is computed by xoring and rotating individual hash
  * values together. We create a hash and rotate command to do this.
  */
 #include "monetdb_config.h"
 #include "mkey.h"
+
 /* TODO: nil handling. however; we do not want to lose time in 
bulk_rotate_xor_hash with that */
 static int
 CMDrotate(wrd *res, wrd *val, int *n)
@@ -41,109 +36,69 @@ CMDrotate(wrd *res, wrd *val, int *n)
        return GDK_SUCCEED;
 }
 
-static int
-CMDhash_bte(wrd *res, bte *val)
+str
+MKEYhash_bte(wrd *ret, bte *val)
+{
+       *ret = *val;
+       return MAL_SUCCEED;
+}
+
+str
+MKEYhash_sht(wrd *res, sht *val)
 {
        *res = *val;
-       return GDK_SUCCEED;
+       return MAL_SUCCEED;
 }
 
-static int
-CMDhash_sht(wrd *res, sht *val)
+str
+MKEYhash_int(wrd *res, int *val)
 {
        *res = *val;
-       return GDK_SUCCEED;
+       return MAL_SUCCEED;
 }
 
-static int
-CMDhash_int(wrd *res, int *val)
+str
+MKEYhash_flt(wrd *res, flt *val)
+{
+       *res = *(int*) val;
+       return MAL_SUCCEED;
+}
+
+str
+MKEYhash_wrd(wrd *res, wrd *val)
 {
        *res = *val;
-       return GDK_SUCCEED;
+       return MAL_SUCCEED;
 }
 
-static int
-CMDhash_flt(wrd *res, flt *val)
-{
-       *res = *(int*) val;
-       return GDK_SUCCEED;
-}
-
-static int
-CMDhash_wrd(wrd *res, wrd *val)
-{
-       *res = *val;
-       return GDK_SUCCEED;
-}
-
-static int
-CMDhash_lng(wrd *res, lng *val)
+str
+MKEYhash_lng(wrd *res, lng *val)
 {
 #if SIZEOF_WRD == SIZEOF_LNG
        *res = (wrd) *val;
 #else
        *res = ((wrd *) val)[0] ^ ((wrd *) val)[1];
 #endif
-       return GDK_SUCCEED;
+       return MAL_SUCCEED;
 }
 
-static int
-CMDhash_dbl(wrd *res, dbl *val)
+str
+MKEYhash_dbl(wrd *res, dbl *val)
 {
 #if SIZEOF_WRD == SIZEOF_LNG
        *res = (wrd) *val;
 #else
        *res = ((wrd *) val)[0] ^ ((wrd *) val)[1];
 #endif
-       return GDK_SUCCEED;
+       return MAL_SUCCEED;
 }
 
-static int
-CMDhash_str(wrd *res, str val)
+str
+MKEYhash_str(wrd *res, str *val)
 {
-       BUN h = strHash(val);
+       BUN h = strHash(*val);
        *res = h;
-       return GDK_SUCCEED;
-}
-
-static int
-CMDhash(wrd *res, ptr val, int tpe)
-{
-       wrd code;
-       BUN h;
-
-       switch (ATOMstorage(tpe)) {
-       case TYPE_void:
-               code = int_nil;
-               break;
-       case TYPE_bte:
-               code = *(bte *) val;
-               break;
-       case TYPE_sht:
-               code = *(sht *) val;
-               break;
-       case TYPE_int:
-       case TYPE_flt:
-               code = *(int *) val;
-               break;
-       case TYPE_lng:
-       case TYPE_dbl:
-#if SIZEOF_WRD == SIZEOF_LNG
-               code = *(wrd *) val;
-#else
-               code = ((wrd *) val)[0] ^ ((wrd *) val)[1];
-#endif
-               break;
-       case TYPE_str:
-               h = strHash((char*)val);
-               code = h;
-               break;
-       default:
-               h = (*BATatoms[tpe].atomHash)(val);
-               code = h;
-       }
-       *res = code;
-       return GDK_SUCCEED;
+       return MAL_SUCCEED;
 }
 
 static str
@@ -156,7 +111,7 @@ voidbathash(BAT **res, BAT *b )
 
        dst = BATnew(TYPE_void, TYPE_wrd, BATcount(b));
        if (!dst)
-               throw(SQL, "bathash", "can not create bat");
+               throw(SQL, "mkey.bathash", MAL_MALLOC_FAIL);
        BATseqbase(dst, b->hseqbase);
 
        dsti = bat_iterator(dst);
@@ -220,9 +175,9 @@ MKEYbathash(bat *res, bat *bid )
        str msg;
        BAT *b, *dst = 0;
 
-       if( (b = BATdescriptor(*bid)) == NULL ){
-               throw(SQL, "bathash", "Cannot access descriptor");
-       }
+       if( (b = BATdescriptor(*bid)) == NULL )
+               throw(SQL, "mkey.bathash", RUNTIME_OBJECT_MISSING);
+       
        assert(BAThvoid(b) || BAThrestricted(b));
 
        msg = voidbathash(&dst, b);
@@ -232,7 +187,7 @@ MKEYbathash(bat *res, bat *bid )
                dst = x;
        }
        BBPkeepref( *res = dst->batCacheid);
-       BBPunfix(b->batCacheid);
+       BBPreleaseref(b->batCacheid);
        return msg;
 }
 
@@ -305,33 +260,21 @@ CMDconstbulk_rotate_xor_hash(BAT **res, 
        BATseqbase(br, b->hseqbase);
        dst = (wrd *) Tloc(br, BUNfirst(br));
 
-       if (tpe == TYPE_bte) {
-               bte *cur = (bte *) BUNtloc(bi, BUNfirst(b));
-               bte *end = (bte *) BUNtloc(bi, BUNlast(b));
-
-               while (cur < end) {
-                       *dst = GDK_ROTATE(*hsh, lbit, rbit, mask) ^ *cur;
-                       cur++;
-                       dst++;
-               }
-       } else if (tpe == TYPE_sht) {
-               sht *cur = (sht *) BUNtloc(bi, BUNfirst(b));
-               sht *end = (sht *) BUNtloc(bi, BUNlast(b));
-
-               while (cur < end) {
-                       *dst = GDK_ROTATE(*hsh, lbit, rbit, mask) ^ *cur;
-                       cur++;
-                       dst++;
-               }
+#define COL_ROTATE(TYPE) \
+TYPE *cur = (TYPE *) BUNtloc(bi, BUNfirst(b));\
+TYPE *end = (TYPE *) BUNtloc(bi, BUNlast(b));\
+\
+while (cur < end) {\
+       *dst = GDK_ROTATE(*hsh, lbit, rbit, mask) ^ *cur;\
+       cur++;\
+       dst++;\
+}
+       if (tpe == TYPE_bte){
+               COL_ROTATE(bte);
+       } else if (tpe == TYPE_sht){
+               COL_ROTATE(sht);
        } else if (tpe == TYPE_int || tpe == TYPE_flt) {
-               int *cur = (int *) BUNtloc(bi, BUNfirst(b));
-               int *end = (int *) BUNtloc(bi, BUNlast(b));
-
-               while (cur < end) {
-                       *dst = GDK_ROTATE(*hsh, lbit, rbit, mask) ^ *cur;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to