changeset 28:e925d55b369b

Updated to Aug2018 (11.31.X) version of MonetDB.
author Sjoerd Mullender <sjoerd@acm.org>
date Thu, 02 Aug 2018 21:15:48 +0200 (2018-08-02)
parents 07a6ef1fde8e
children e44cffee8312
files regexp/README.rst regexp/regexp.c reverse/README.rst reverse/reverse.c
diffstat 4 files changed, 47 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/regexp/README.rst	Wed Jan 24 16:42:47 2018 +0100
+++ b/regexp/README.rst	Thu Aug 02 21:15:48 2018 +0200
@@ -343,7 +343,7 @@
 
   s = NULL;
   b = BATdescriptor(bid);
-  if (sid != 0 && sid != bat_nil)
+  if (!is_bat_nil(sid))
       s = BATdescriptor(sid);
 
 We create the output BAT.  The third arguments of ``COLnew`` is the
@@ -427,7 +427,15 @@
 ``tkey``
   All values are distinct
 
+``tseqbase``
+  The starting ``oid`` value of a dense column.  If a BAT has type
+  ``oid`` or ``void`` (virtual oid), this value gives the start of the
+  dense sequence of values in the BAT.  If the BAT is not dense,
+  ``tseqbase`` should be set to ``oid_nil``.
+
 ``tdense``
+  This property has been removed as of the Aug2018 (11.31.X) release.
+  Use tseqbases instead.
   Only valid for ``TYPE_oid`` columns: each value in the column is
   exactly one larger than the one before.
 
@@ -438,24 +446,25 @@
   There are no NIL values in the column.
 
 ``tnosorted``
-  If ``tsorted == 0``, the index in the column that proofs not sorted.
+  If ``tsorted == false``, the index in the column that proofs not
+  sorted.  Must be ``0`` if ``tsorted == true``.
 
 ``tnorevsorted``
-  If ``trevsorted == 0``, the index in the column that proofs not
-  reverse sorted.
+  If ``trevsorted == false``, the index in the column that proofs not
+  reverse sorted.  Must be ``0`` if ``trevsorted == true``.
 
 ``tnokey[0]`` and ``tnokey[1]``
-  If ``tkey == 0``, a pair of indexes that together proof not all
-  values are distinct.
+  If ``tkey == false``, a pair of indexes that together proof not all
+  values are distinct.  Must both be ``0`` if ``tkey == true``.
 
 Because of the way we created the output we know a number of these
 properties::
 
-  bn->tsorted = 1;
-  bn->tkey = 1;
+  bn->tsorted = true;
+  bn->tkey = true;
   bn->trevsorted = BATcount(bn) <= 1;
-  bn->tnil = 0;
-  bn->tnonil = 1;
+  bn->tnil = false;
+  bn->tnonil = true;
   bn->tnosorted = 0;
   if (!bn->trevsorted) bn->tnorevsorted = 1;
 
@@ -464,16 +473,13 @@
 there are more rows: we just need to look at the difference between
 the first and last rows and compare that with the number of rows::
 
+  bn->tseqbase = oid_nil;
   if (BATcount(bn) > 1) {
       outp = (oid *) Tloc(bn, 0); /* pointer to start */
-      bn->tdense = outp[BATcount(bn) - 1] - outp[0] == BATcount(bn) - 1;
+      if (outp[BATcount(bn) - 1] - outp[0] == BATcount(bn) - 1)
+          bn->tseqbase = outp[0];
   }
 
-If the column is dense, we need to set ``tseqbase`` to the first value
-(or ``0`` if there are no values)::
-
-  bn->tseqbase = BATcount(bn) > 0 ? * (oid *) Tloc(bn, 0) : 0;
-
 Now we can return::
 
   *ret = bn->batCacheid;
--- a/regexp/regexp.c	Wed Jan 24 16:42:47 2018 +0100
+++ b/regexp/regexp.c	Thu Aug 02 21:15:48 2018 +0200
@@ -157,7 +157,7 @@
 		BBPunfix(b->batCacheid);
 		throw(MAL, "regexp.rematchselect", SEMANTIC_TYPE_MISMATCH);
 	}
-	if (sid != 0 && sid != bat_nil &&
+	if (!is_bat_nil(sid) &&
 	    (s = BATdescriptor(sid)) == NULL) {
 		BBPunfix(b->batCacheid);
 		throw(MAL, "regexp.rematchselect", RUNTIME_OBJECT_MISSING);
@@ -303,12 +303,13 @@
 	 * all values MUST be distinct (i.e. it is a candidate list);
 	 * due to the way we created the result, we know this is the
 	 * case */
-	bn->tsorted = 1;
+	bn->tsorted = true;
 	bn->tnosorted = 0;
-	bn->tkey = 1;
+	bn->tkey = true;
+	bn->tseqbase = oid_nil;
 	if (BATcount(bn) > 1) {
 		/* if more than 1 result, it is not reverse sorted */
-		bn->trevsorted = 0;
+		bn->trevsorted = false;
 		bn->tnorevsorted = 1; /* index 1 is larger than index 0 */
 		/* the BAT is dense if the type is TYPE_oid, the
 		 * values are sorted in ascending order, they are all
@@ -317,26 +318,18 @@
 		 * condition, which we do by checking the difference
 		 * between the first and last values */
 		outp = (oid *) Tloc(bn, 0); /* pointer to start */
-		bn->tdense = outp[BATcount(bn) - 1] - outp[0] == BATcount(bn) - 1;
+		if (outp[BATcount(bn) - 1] - outp[0] == BATcount(bn) - 1)
+			bn->tseqbase = outp[0];
 	} else {
 		/* if empty or a single result, it is reverse sorted
 		 * and dense */
-		bn->trevsorted = 1;
+		bn->trevsorted = true;
 		bn->tnorevsorted = 0;
-		bn->tdense = 1;
-	}
-	if (bn->tdense) {
-		/* if dense, we must also set tseqbase to the first value */
-		if (BATcount(bn) == 0)
-			bn->tseqbase = 0; /* no first value */
-		else
-			bn->tseqbase = * (oid *) Tloc(bn, 0);
-	} else {
-		bn->tseqbase = oid_nil;
+		bn->tseqbase = BATcount(bn) == 0 ? 0 : *(oid *) Tloc(bn, 0);
 	}
 	/* there are no NIL values in the result */
-	bn->tnil = 0;
-	bn->tnonil = 1;
+	bn->tnil = false;
+	bn->tnonil = true;
 
 	*ret = bn->batCacheid;
 	BBPkeepref(*ret);
@@ -401,13 +394,13 @@
 
 	l = BATdescriptor(lid);
 	r = BATdescriptor(rid);
-	if (slid != 0 && slid != bat_nil)
+	if (!is_bat_nil(slid))
 		sl = BATdescriptor(slid);
-	if (srid != 0 && srid != bat_nil)
+	if (!is_bat_nil(srid))
 		sr = BATdescriptor(srid);
 	if (l == NULL || r == NULL ||
-	    (slid != 0 && slid != bat_nil && sl == NULL) ||
-	    (srid != 0 && srid != bat_nil && sr == NULL)) {
+	    (!is_bat_nil(slid) && sl == NULL) ||
+	    (!is_bat_nil(srid) && sr == NULL)) {
 		/* one of the calls to BATdescriptor failed */
 		if (l)
 			BBPunfix(l->batCacheid);
@@ -438,7 +431,7 @@
 
 	/* if there is no valid estimate, use the size of the left
 	 * input as size estimate */
-	if (estimate == lng_nil || estimate == 0)
+	if (is_lng_nil(estimate) || estimate == 0)
 		estimate = sl ? BATcount(sl) : BATcount(l);
 
 	/* create the output BATs */
@@ -512,8 +505,8 @@
 				pos = pcre_exec(re, sd, val, (int) strlen(val), 0, 0, NULL, 0);
 				if (pos >= 0) {
 					/* regular expression matched */
-					if (BUNappend(bn1, cand, FALSE) != GDK_SUCCEED ||
-					    BUNappend(bn2, &ro, FALSE) != GDK_SUCCEED)
+					if (BUNappend(bn1, cand, false) != GDK_SUCCEED ||
+					    BUNappend(bn2, &ro, false) != GDK_SUCCEED)
 						goto bailout;
 				} else if (pos != PCRE_ERROR_NOMATCH) {
 					/* error during processing */
@@ -530,8 +523,8 @@
 				if (pos >= 0) {
 					/* regular expression matched */
 					oid lo = start + l->hseqbase;
-					if (BUNappend(bn1, &lo, FALSE) != GDK_SUCCEED ||
-					    BUNappend(bn2, &ro, FALSE) != GDK_SUCCEED)
+					if (BUNappend(bn1, &lo, false) != GDK_SUCCEED ||
+					    BUNappend(bn2, &ro, false) != GDK_SUCCEED)
 						goto bailout;
 				} else if (pos != PCRE_ERROR_NOMATCH) {
 					/* error during processing */
--- a/reverse/README.rst	Wed Jan 24 16:42:47 2018 +0100
+++ b/reverse/README.rst	Thu Aug 02 21:15:48 2018 +0200
@@ -381,10 +381,10 @@
 you start adding data to a column, you must deal with the property
 flags.  The simplest solution is to just clear all properties::
 
-  bn->tsorted = bn->trevsorted = 0;
-  bn->tkey = 0;
-  bn->tnil = 0;
-  bn->tnonil = 0;
+  bn->tsorted = bn->trevsorted = false;
+  bn->tkey = false;
+  bn->tnil = false;
+  bn->tnonil = false;
   bn->tnosorted = bn->tnorevsorted = 0;
   bn->tnokey[0] = bn->tnokey[1] = 0;
 
--- a/reverse/reverse.c	Wed Jan 24 16:42:47 2018 +0100
+++ b/reverse/reverse.c	Thu Aug 02 21:15:48 2018 +0200
@@ -148,7 +148,7 @@
 			dst = ndst;
 		}
 		do_reverse(dst, src, len);
-		if (BUNappend(bn, dst, 0) != GDK_SUCCEED) {
+		if (BUNappend(bn, dst, false) != GDK_SUCCEED) {
 			/* BUNappend can fail since it may have to
 			 * grow memory areas--especially true for
 			 * string BATs */