changeset 7:38931ec299f8

Some updates.
author Sjoerd Mullender <sjoerd@acm.org>
date Tue, 07 Jun 2016 15:18:22 +0200 (2016-06-07)
parents 2eb5b736d522
children 25168f9188a8
files .hgignore reverse/README.rst reverse/reverse.mal
diffstat 3 files changed, 42 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Tue Jun 07 15:18:22 2016 +0200
@@ -0,0 +1,6 @@
+syntax: glob
+
+README.pdf
+README.html
+*.o
+*.so
--- a/reverse/README.rst	Fri Dec 11 10:33:27 2015 +0100
+++ b/reverse/README.rst	Tue Jun 07 15:18:22 2016 +0200
@@ -63,6 +63,8 @@
 the front of the file name to force the order.  So we have a file
 ``80_reverse.sql`` where we put this statement.
 
+At the SQL side we don't have to do anything more.
+
 Now that we have the SQL interface, we need to create the MAL
 interface.
 
@@ -90,12 +92,10 @@
 
  module batreverse;
 
- command reverse(b:bat[:oid,:str]):bat[:oid,:str]
+ command reverse(b:bat[:str]):bat[:str]
  address UDFBATreverse
  comment "Reverse a column of strings";
 
-At the SQL side we don't have to do anything more.
-
 We put these MAL commands in the file
 ``$libdir/monetdb5/reverse.mal``.  In addition we create a file
 ``$libdir/monetdb5/autoload/80_reverse.mal`` that just contains::
@@ -103,7 +103,8 @@
  include reverse;
 
 The files in the ``autoload`` directory are executed in order every
-time the server is started.
+time the server is started so that by putting the ``80_reverse.mal``
+file there, we make sure that the system knows about these functions.
 
 Note that instead of using ``command``, we could have used
 ``pattern``.  The ``pattern`` interface is more complicated to work
@@ -215,9 +216,12 @@
 reference count of zero.  Before returning a new BAT, the physical
 reference count must be converted to a logical reference count.
 
-We start with loading the BAT into memory.  We do that by calling
-``BATdescriptor`` which increments the physical reference count and
-loads the BAT into memory (if it wasn't there already)::
+When a C function is called by the MAL interpreter, it passes a
+*logical* reference to any BAT parameters.  This means that the C
+function must first make sure that the BAT gets a *physical* reference
+and is loaded into memory.  We start with doing just that.  We do that
+by calling ``BATdescriptor`` which increments the physical reference
+count and loads the BAT into memory (if it wasn't there already)::
 
  BAT *b;
  b = BATdescriptor(*arg);
@@ -245,7 +249,9 @@
 entries to the BAT, we're actually not concerned about the size of the
 new BAT (``BUNappend`` takes care of resizing if necessary), but from
 an efficiency point of view, it's better to create the BAT with the
-required size (growing a BAT can be expensive).
+required size (growing a BAT can be expensive).  Note that the type of
+the *head* column must always be ``TYPE_void`` (this argument will
+likely be removed in a future version of MonetDB).
 
 We then set the sequence base for the head column of the new BAT to be
 the same as that of the input BAT::
@@ -295,8 +301,8 @@
 installation and the arguments needed to compile the module.  This
 Makefile works on Fedora Linux if you have the package
 ``MonetDB5-server-devel`` with all its dependencies installed
-(available in the feature release after the Feb2013 release cycle),
-and on Debian/Ubuntu if you have the packages ``libmonetdb-dev`` and
+(available starting in the Jan2014 feature release), and on
+Debian/Ubuntu if you have the packages ``libmonetdb-dev`` and
 ``monetdb5-server-dev`` with all their dependencies installed
 (available starting in the Oct2014-SP3 bugfix release).  The file may
 need to be changed for other systems.
@@ -334,6 +340,17 @@
   there are nil values in the column (this property isn't used
   internally)
 
+In addition to these flags there are a few other properties:
+
+``nosorted``
+  the location that proofs the column is *not* sorted
+
+``norevsorted``
+  the location that proofs the column is *not* reverse sorted
+
+``nokey[0]`` and ``nokey[1]``
+  two locations that together proof *not* all values are distinct
+
 The property flags ``sorted`` and ``revsorted`` may both be set at the
 same time.  When they are, it implies that all values are equal to
 each other.
@@ -343,6 +360,14 @@
 means that the property must hold, i.e. when an attempt is made to
 insert a new value that already occurs, the insert must fail.
 
+When the ``sorted`` property is unset, the ``nosorted`` property is
+a position in the BAT where the previous value is not less than or
+equal to the position itself.  If the ``nosorted`` value is 0, we
+truly don't know whether the BAT is sorted.  Similarly for the
+``revsorted`` and ``norevsorted`` properties.  The two ``nokey``
+values are either both 0 (we really don't know), or two distinct
+locations whose values are equal.
+
 Note that most of the properties are true for an empty column, hence
 when ``BATnew`` returns, all property flags except for ``nil`` are set
 (there are no nils in an empty column).  This means that as soon as
--- a/reverse/reverse.mal	Fri Dec 11 10:33:27 2015 +0100
+++ b/reverse/reverse.mal	Tue Jun 07 15:18:22 2016 +0200
@@ -12,6 +12,6 @@
 
 module batreverse;
 
-command reverse(b:bat[:oid,:str]):bat[:oid,:str]
+command reverse(b:bat[:str]):bat[:str]
 address UDFBATreverse
 comment "Reverse a BAT of strings";