MonetDB: default - CPU affinity does not improve

2012-07-18 Thread Martin Kersten
Changeset: 55fa619d7dfa for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=55fa619d7dfa
Modified Files:
gdk/gdk_system.c
gdk/gdk_system.h
monetdb5/mal/mal_dataflow.c
Branch: default
Log Message:

CPU affinity does not improve
Controlled CPU affinity if it has effect should be visible
on a main-memory run. For this I used 2 triple runs of sf10
with and without affinity control over the workers.

There is no noticable difference, except that no-control
might be slightly better when looking at the minimum overall
numbers.

Conclusion, we don't need to support affinity now in GDK
and the code can be removed.


diffs (79 lines):

diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -748,31 +748,3 @@ GDKms(void)
 {
return (int) (GDKusec() / 1000);
 }
-
-#if !defined(HAVE_PTHREAD_H)  defined(_MSC_VER)
-void MT_init_cpu_set(){}
-int MT_set_affinity(int pid){ return 0;}
-void MT_unset_affinity(int cpu){}
-#else
-
-static cpu_set_t *cpu_set_mask;
-static size_t cpu_set_size;
-
-void MT_init_cpu_set(void)
-{
-   int nrcpus = MT_check_nr_cores_();
-   cpu_set_mask = CPU_ALLOC(nrcpus);
-   cpu_set_size = CPU_ALLOC_SIZE(nrcpus);
-}
-
-int MT_set_affinity(int pid){
-   int cpu = pid % MT_check_nr_cores();
-   //printf(#set affinity %d to %d out of %d\n, pid, cpu, 
MT_check_nr_cores());
-   sched_setaffinity(cpu, cpu_set_size, cpu_set_mask);
-   return cpu;
-}
-void MT_unset_affinity(int cpu){
-   //printf(#unset affinity %d \n, cpu);
-   CPU_CLR(cpu,cpu_set_mask);
-}
-#endif
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -234,16 +234,4 @@ gdk_export int MT_check_nr_cores(void);
 gdk_export lng GDKusec(void);
 gdk_export int GDKms(void);
 
-#if !defined(HAVE_PTHREAD_H)  defined(_MSC_VER)
-gdk_export void MT_init_cpu_set(void);
-gdk_export int MT_set_affinity(int pid);
-gdk_export void MT_unset_affinity(int cpu);
-#else
-#define _GNU_SOURCE_
-#include sched.h
-gdk_export void MT_init_cpu_set(void);
-gdk_export int MT_set_affinity(int pid);
-gdk_export void MT_unset_affinity(int cpu);
-#endif
-
 #endif /*_GDK_SYSTEM_H_*/
diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c
--- a/monetdb5/mal/mal_dataflow.c
+++ b/monetdb5/mal/mal_dataflow.c
@@ -813,12 +813,9 @@ runDFLOWworker(void *t)
Thread thr;
int i, local = 0, last = 0;
long usec=0;
-   //int cpu;
 
thr = THRnew(MT_getpid(), DFLOWworker);
 
-   //cpu = MT_set_affinity(task-id);
-
GDKsetbuf(GDKmalloc(GDKMAXERRLEN)); /* where to leave errors */
GDKerrbuf[0] = 0;
while (task) {
@@ -927,7 +924,6 @@ runDFLOWworker(void *t)
}
GDKfree(GDKerrbuf);
GDKsetbuf(0);
-   //MT_unset_affinity(cpu);
THRdel(thr);
 }
 
___
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged from Jul2012

2012-07-18 Thread Fabian Groffen
Changeset: 1877bf2a9850 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1877bf2a9850
Modified Files:
clients/ChangeLog.Jul2012
monetdb5/extras/jaql/json.c
Branch: default
Log Message:

Merged from Jul2012


diffs (24 lines):

diff --git a/clients/ChangeLog.Jul2012 b/clients/ChangeLog.Jul2012
--- a/clients/ChangeLog.Jul2012
+++ b/clients/ChangeLog.Jul2012
@@ -2,6 +2,6 @@
 # This file is updated with Maddlog
 
 * Tue Jul 17 2012 Fabian Groffen fab...@cwi.nl
-- mclient no longer prints the SQLSTATE at the start each error returned
-  by the SQL-server.
+- mclient no longer prints the SQLSTATE at the start of each error
+  returned by the SQL-server.
 
diff --git a/monetdb5/extras/jaql/json.c b/monetdb5/extras/jaql/json.c
--- a/monetdb5/extras/jaql/json.c
+++ b/monetdb5/extras/jaql/json.c
@@ -1462,7 +1462,7 @@ JSONunwrap(Client cntxt, MalBlkPtr mb, M
break;
case 'n':
default:
-   d = 0.1 / 0.0;
+   d = 0.1 / (1.0 
- 1.0);
BUNins(r, v, 
d, FALSE);
break;
}
___
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Partial de-mx batmtime

2012-07-18 Thread Martin Kersten
Changeset: 29b4294d4bea for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=29b4294d4bea
Modified Files:
monetdb5/modules/kernel/batmtime.mx
Branch: default
Log Message:

Partial de-mx batmtime
Rest should be taken care of by shell scripting


diffs (truncated from 316 to 300 lines):

diff --git a/monetdb5/modules/kernel/batmtime.mx 
b/monetdb5/modules/kernel/batmtime.mx
--- a/monetdb5/modules/kernel/batmtime.mx
+++ b/monetdb5/modules/kernel/batmtime.mx
@@ -30,28 +30,25 @@ All Rights Reserved.
  * In line with the batcalc module, we assume that
  * if two bat operands are provided that they are already
  * aligned on the head. Moreover, the head of the BATs
- * are limited to :void, which can be cheaply realized using
+ * are limited to :oid, which can be cheaply realized using
  * the GRPsplit operation.
  */
 @= compareOp
 command batcalc.@2( l:bat[:oid,:@1], r:bat[:oid,:@1]) :bat[:oid,:bit]
-address MTIMEbat_@1_@3;
-
-command batcalc.@2( l:bat[:void,:@1], r:bat[:void,:@1]) :bat[:void,:bit]
 address MTIMEbat_@1_@3
 comment Compare a bat of @1 against each other;
 command batcalc.@2( l:bat[:oid,:@1], r:@1) :bat[:oid,:bit]
 address MTIMEbat_@1_@3_cst;
-command batcalc.@2( l:bat[:void,:@1], r:@1) :bat[:void,:bit]
+command batcalc.@2(r:@1, l:bat[:oid,:@1]) :bat[:oid,:bit]
 address MTIMEbat_@1_cst_@3
 comment Compare a bat of @1 against a singleton;
 
-command batcalc.@2(a:bat[:void,:bit], l:bat[:void,:@1], r:bat[:void,:@1]) 
:bat[:void,:bit]
+command batcalc.@2(a:bat[:oid,:bit], l:bat[:oid,:@1], r:bat[:oid,:@1]) 
:bat[:oid,:bit]
 address MTIMEaccum_@1_@3
 comment Compare a bat of @1 against each other;
-command batcalc.@2(a:bat[:void,:bit], l:bat[:oid,:@1], r:@1) :bat[:oid,:bit]
+command batcalc.@2(a:bat[:oid,:bit], l:bat[:oid,:@1], r:@1) :bat[:oid,:bit]
 address MTIMEaccum_@1_@3_cst;
-command batcalc.@2(a:bat[:void,:bit], l:bat[:void,:@1], r:@1) :bat[:void,:bit]
+command batcalc.@2(a:bat[:oid,:bit], r:@1, l:bat[:oid,:@1]) :bat[:oid,:bit]
 address MTIMEaccum_@1_cst_@3
 comment Compare a bat of @1 against a singleton;
 
@@ -64,24 +61,35 @@ comment Compare a bat of @1 against a s
 @:compareOp(@1,,GT)@
 @:compareOp(@1,=,GE)@
 
-@= unaryISNIL
-command batcalc.isnil(b:bat[:any_1,:@1]):bat[:any_1,:bit]
-address MTIMEunaryISNIL
-comment Unary check for nil over the tail of the bat;
-
-command batcalc.isnil(b:bat[:void,:@1]):bat[:oid,:bit]
-address MTIMEunaryISNIL
-comment Unary check for nil over the tail of the bat;
-
-@
 @mal
 @:compareGrp(date)@
 @:compareGrp(daytime)@
 @:compareGrp(timestamp)@
 
-@:unaryISNIL(date)@
-@:unaryISNIL(daytime)@
-@:unaryISNIL(timestamp)@
+command batcalc.isnil(b:bat[:any_1,:date]):bat[:any_1,:bit]
+address MTIMEunaryISNIL
+comment Unary check for nil over the tail of the bat;
+
+command batcalc.isnil(b:bat[:oid,:date]):bat[:oid,:bit]
+address MTIMEunaryISNIL
+comment Unary check for nil over the tail of the bat;
+
+command batcalc.isnil(b:bat[:any_1,:daytime]):bat[:any_1,:bit]
+address MTIMEunaryISNIL
+comment Unary check for nil over the tail of the bat;
+
+command batcalc.isnil(b:bat[:oid,:daytime]):bat[:oid,:bit]
+address MTIMEunaryISNIL
+comment Unary check for nil over the tail of the bat;
+
+command batcalc.isnil(b:bat[:any_1,:timestamp]):bat[:any_1,:bit]
+address MTIMEunaryISNIL
+comment Unary check for nil over the tail of the bat;
+
+command batcalc.isnil(b:bat[:oid,:timestamp]):bat[:oid,:bit]
+address MTIMEunaryISNIL
+comment Unary check for nil over the tail of the bat;
+
 
 @h
 /*
@@ -112,9 +120,6 @@ comment Compare a bat of @1 against a s
  * head column. This is not checked and may be mis-used to deploy the
  * implementation for shifted window arithmetic as well.
  */
-@= chkSize
-   if( BATcount(@1) != BATcount(@2) )
-   throw(MAL, batcalc.@3, ILLEGAL_ARGUMENT  Requires bats of 
identical size);
 
 @= implDef
 batmtime_export str MTIMEbat_@1_@2(int *ret, int *l, int *r);
@@ -124,68 +129,18 @@ batmtime_export str MTIMEaccum_@1_@2(int
 batmtime_export str MTIMEaccum_@1_@2_cst(int *ret, int *r, int *l, @1 *cst);
 batmtime_export str MTIMEaccum_@1_cst_@2(int *ret, int *r, @1 *cst, int *l);
 
-@
- * @- Comparison operator implementation for temporal objects
- * The structure of this code is copied from the arithmetic scheme.
- * @-
-@= voidresultBAT
-   bn = BATnew(TYPE_void, @1, BATcount(b));
-   BATseqbase(bn, b-hseqbase);
-   if (bn == NULL) {
-   throw(MAL, @2, MAL_MALLOC_FAIL);
-   }
-   bn-hsorted = b-hsorted;
-   bn-hrevsorted = b-hrevsorted;
-   bn-tsorted = b-tsorted;
-   bn-trevsorted = b-trevsorted;
-   bn-H-nonil = 1;
+@c
+#define resultBAT(Type,Error)\
+   bn = BATnew(TYPE_void, Type, BATcount(b));\
+   BATseqbase(bn, b-hseqbase);\
+   if (bn == NULL) \
+   throw(MAL, Error, MAL_MALLOC_FAIL);\
+   bn-hsorted = b-hsorted;\
+   bn-hrevsorted = b-hrevsorted;\
+   bn-tsorted = b-tsorted;\
+   bn-trevsorted = 

MonetDB: default - Merging

2012-07-18 Thread Martin Kersten
Changeset: 12a1ca811ea1 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=12a1ca811ea1
Modified Files:
clients/ChangeLog.Jul2012
monetdb5/extras/jaql/json.c
Branch: default
Log Message:

Merging


diffs (24 lines):

diff --git a/clients/ChangeLog.Jul2012 b/clients/ChangeLog.Jul2012
--- a/clients/ChangeLog.Jul2012
+++ b/clients/ChangeLog.Jul2012
@@ -2,6 +2,6 @@
 # This file is updated with Maddlog
 
 * Tue Jul 17 2012 Fabian Groffen fab...@cwi.nl
-- mclient no longer prints the SQLSTATE at the start each error returned
-  by the SQL-server.
+- mclient no longer prints the SQLSTATE at the start of each error
+  returned by the SQL-server.
 
diff --git a/monetdb5/extras/jaql/json.c b/monetdb5/extras/jaql/json.c
--- a/monetdb5/extras/jaql/json.c
+++ b/monetdb5/extras/jaql/json.c
@@ -1462,7 +1462,7 @@ JSONunwrap(Client cntxt, MalBlkPtr mb, M
break;
case 'n':
default:
-   d = 0.1 / 0.0;
+   d = 0.1 / (1.0 
- 1.0);
BUNins(r, v, 
d, FALSE);
break;
}
___
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - gdk_utils: finish affinity removal

2012-07-18 Thread Fabian Groffen
Changeset: 4c9ca8e24c24 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4c9ca8e24c24
Modified Files:
gdk/gdk_utils.c
Branch: default
Log Message:

gdk_utils: finish affinity removal


diffs (11 lines):

diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1298,7 +1298,6 @@ GDKinit(opt *set, int setlen)
GDK_mmap_minsize = MIN( 130 , (GDK_mem_maxsize_max/6) / 
(GDKnr_threads ? GDKnr_threads : 1) );
/*per op:  2 args + 1 res, each with head  tail  =  (2+1)*2 = 6  
^ */
 #endif
-   //MT_init_cpu_set();
 
if (!GDKembedded 
((p = mo_find_option(set, setlen, gdk_vmtrim)) == NULL ||
___
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list


Re: MonetDB: default - Partial de-mx batmtime

2012-07-18 Thread Stefan Manegold
Just wondering ... (and trying to learn):

On Wed, Jul 18, 2012 at 10:41:04AM +0200, Martin Kersten wrote:
 Changeset: 29b4294d4bea for MonetDB
 URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=29b4294d4bea
 Modified Files:
   monetdb5/modules/kernel/batmtime.mx
 Branch: default
 Log Message:
 
 Partial de-mx batmtime
 Rest should be taken care of by shell scripting
 
 
 diffs (truncated from 316 to 300 lines):
 
 diff --git a/monetdb5/modules/kernel/batmtime.mx 
 b/monetdb5/modules/kernel/batmtime.mx
 --- a/monetdb5/modules/kernel/batmtime.mx
 +++ b/monetdb5/modules/kernel/batmtime.mx
 @@ -30,28 +30,25 @@ All Rights Reserved.
   * In line with the batcalc module, we assume that
   * if two bat operands are provided that they are already
   * aligned on the head. Moreover, the head of the BATs
 - * are limited to :void, which can be cheaply realized using
 + * are limited to :oid, which can be cheaply realized using
   * the GRPsplit operation.
   */
  @= compareOp
  command batcalc.@2( l:bat[:oid,:@1], r:bat[:oid,:@1]) :bat[:oid,:bit]
 -address MTIMEbat_@1_@3;
 -
 -command batcalc.@2( l:bat[:void,:@1], r:bat[:void,:@1]) :bat[:void,:bit]
  address MTIMEbat_@1_@3
  comment Compare a bat of @1 against each other;
  command batcalc.@2( l:bat[:oid,:@1], r:@1) :bat[:oid,:bit]
  address MTIMEbat_@1_@3_cst;
 -command batcalc.@2( l:bat[:void,:@1], r:@1) :bat[:void,:bit]
 +command batcalc.@2(r:@1, l:bat[:oid,:@1]) :bat[:oid,:bit]

Is the above signature change (swapping left  right operand) intended?
If so, what is the reason for it?

  address MTIMEbat_@1_cst_@3
  comment Compare a bat of @1 against a singleton;
  
 -command batcalc.@2(a:bat[:void,:bit], l:bat[:void,:@1], r:bat[:void,:@1]) 
 :bat[:void,:bit]
 +command batcalc.@2(a:bat[:oid,:bit], l:bat[:oid,:@1], r:bat[:oid,:@1]) 
 :bat[:oid,:bit]
  address MTIMEaccum_@1_@3
  comment Compare a bat of @1 against each other;
 -command batcalc.@2(a:bat[:void,:bit], l:bat[:oid,:@1], r:@1) :bat[:oid,:bit]
 +command batcalc.@2(a:bat[:oid,:bit], l:bat[:oid,:@1], r:@1) :bat[:oid,:bit]
  address MTIMEaccum_@1_@3_cst;
 -command batcalc.@2(a:bat[:void,:bit], l:bat[:void,:@1], r:@1) 
 :bat[:void,:bit]
 +command batcalc.@2(a:bat[:oid,:bit], r:@1, l:bat[:oid,:@1]) :bat[:oid,:bit]

Is the above signature change (swapping left  right operand) intended?
If so, what is the reason for it?

  address MTIMEaccum_@1_cst_@3
  comment Compare a bat of @1 against a singleton;
  
 @@ -64,24 +61,35 @@ comment Compare a bat of @1 against a s
  @:compareOp(@1,,GT)@
  @:compareOp(@1,=,GE)@
  
 -@= unaryISNIL
 -command batcalc.isnil(b:bat[:any_1,:@1]):bat[:any_1,:bit]
 -address MTIMEunaryISNIL
 -comment Unary check for nil over the tail of the bat;
 -
 -command batcalc.isnil(b:bat[:void,:@1]):bat[:oid,:bit]
 -address MTIMEunaryISNIL
 -comment Unary check for nil over the tail of the bat;
 -
 -@
  @mal
  @:compareGrp(date)@
  @:compareGrp(daytime)@
  @:compareGrp(timestamp)@
  
 -@:unaryISNIL(date)@
 -@:unaryISNIL(daytime)@
 -@:unaryISNIL(timestamp)@
 +command batcalc.isnil(b:bat[:any_1,:date]):bat[:any_1,:bit]
 +address MTIMEunaryISNIL
 +comment Unary check for nil over the tail of the bat;
 +
 +command batcalc.isnil(b:bat[:oid,:date]):bat[:oid,:bit]
 +address MTIMEunaryISNIL
 +comment Unary check for nil over the tail of the bat;
 +
 +command batcalc.isnil(b:bat[:any_1,:daytime]):bat[:any_1,:bit]
 +address MTIMEunaryISNIL
 +comment Unary check for nil over the tail of the bat;
 +
 +command batcalc.isnil(b:bat[:oid,:daytime]):bat[:oid,:bit]
 +address MTIMEunaryISNIL
 +comment Unary check for nil over the tail of the bat;
 +
 +command batcalc.isnil(b:bat[:any_1,:timestamp]):bat[:any_1,:bit]
 +address MTIMEunaryISNIL
 +comment Unary check for nil over the tail of the bat;
 +
 +command batcalc.isnil(b:bat[:oid,:timestamp]):bat[:oid,:bit]
 +address MTIMEunaryISNIL
 +comment Unary check for nil over the tail of the bat;

I see a pattern of three pairs of signatures.
What is the difference between, say,
command batcalc.isnil(b:bat[:any_1,:date]):bat[:any_1,:bit]
and
command batcalc.isnil(b:bat[:oid,:date]):bat[:oid,:bit]
?
Isn't the latter fully covered by the former?


Thanks!
Stefan

ps: I not study the remainder, yet ...


  
  @h
  /*
 @@ -112,9 +120,6 @@ comment Compare a bat of @1 against a s
   * head column. This is not checked and may be mis-used to deploy the
   * implementation for shifted window arithmetic as well.
   */
 -@= chkSize
 - if( BATcount(@1) != BATcount(@2) )
 - throw(MAL, batcalc.@3, ILLEGAL_ARGUMENT  Requires bats of 
 identical size);
  
  @= implDef
  batmtime_export str MTIMEbat_@1_@2(int *ret, int *l, int *r);
 @@ -124,68 +129,18 @@ batmtime_export str MTIMEaccum_@1_@2(int
  batmtime_export str MTIMEaccum_@1_@2_cst(int *ret, int *r, int *l, @1 *cst);
  batmtime_export str MTIMEaccum_@1_cst_@2(int *ret, int *r, @1 *cst, int *l);
  
 -@
 - * @- Comparison operator implementation for temporal objects
 - * The structure 

MonetDB: default - More Mx macros removals

2012-07-18 Thread Martin Kersten
Changeset: 88b641d0812f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=88b641d0812f
Removed Files:
monetdb5/modules/kernel/kprelude.mx
Modified Files:
monetdb5/modules/kernel/Makefile.ag
monetdb5/modules/kernel/algebra.mx
monetdb5/modules/kernel/group.mx
Branch: default
Log Message:

More Mx macros removals
Trimming down the original Mx files to become more amendable
for a final patch round/rewrite.


diffs (truncated from 399 to 300 lines):

diff --git a/monetdb5/modules/kernel/Makefile.ag 
b/monetdb5/modules/kernel/Makefile.ag
--- a/monetdb5/modules/kernel/Makefile.ag
+++ b/monetdb5/modules/kernel/Makefile.ag
@@ -70,6 +70,6 @@ headers_mal = {
counters.mal logger.mal microbenchmark.mal
 }
 
-EXTRA_DIST = aggr_ri.mx kprelude.mx alarm.mal counters.mal lock.mal logger.mal 
microbenchmark.mal sema.mal unix.mal
+EXTRA_DIST = aggr_ri.mx alarm.mal counters.mal lock.mal logger.mal 
microbenchmark.mal sema.mal unix.mal
 
 EXTRA_DIST_DIR = Tests
diff --git a/monetdb5/modules/kernel/algebra.mx 
b/monetdb5/modules/kernel/algebra.mx
--- a/monetdb5/modules/kernel/algebra.mx
+++ b/monetdb5/modules/kernel/algebra.mx
@@ -824,7 +824,7 @@ module algebra;
 # different strategies, according to different status in its operand 
properties,
 # each algebraic operator may have different propagation rules with these
 # different situations as conditions.
-@include kprelude.mx
+
 @h
 #ifndef ALGEBRA_H
 #define ALGEBRA_H
@@ -3548,7 +3548,8 @@ ALGidentity(int *ret, int *bid)
 {
BAT *b;
 
-   @:getBATdescriptor(bid,b,algebra.identity)@
+   if ((b = BATdescriptor(*bid)) == NULL)
+   throw(MAL, algebra.identity, RUNTIME_OBJECT_MISSING);
if (!(b-batDirty2)) b = BATsetaccess(b, BAT_READ); \
BBPkeepref(*ret = b-batCacheid);
return MAL_SUCCEED;
@@ -3558,7 +3559,8 @@ ALGmaterialize(int *ret, int *bid)
 {
BAT *b, *bn;
 
-   @:getBATdescriptor(bid,b,algebra.materialize)@
+   if ((b = BATdescriptor(*bid)) == NULL)
+   throw(MAL, algebra.materialize, RUNTIME_OBJECT_MISSING);
if( b-htype == TYPE_void){
bn= BATmaterialize(b);
if( bn == NULL)
@@ -3573,7 +3575,8 @@ ALGmaterialize(int *ret, int *bid)
 str ALGreuse(int *ret, int *bid)
 {
BAT *b,*bn;
-   @:getBATdescriptor(bid,b,algebra.reuse)@
+   if ((b = BATdescriptor(*bid)) == NULL)
+   throw(MAL, algebra.reuse, RUNTIME_OBJECT_MISSING);
 
if( b-batPersistence != TRANSIENT || b-batRestricted != BAT_WRITE){
if( ATOMvarsized(b-ttype) || b-htype != TYPE_void){
diff --git a/monetdb5/modules/kernel/group.mx b/monetdb5/modules/kernel/group.mx
--- a/monetdb5/modules/kernel/group.mx
+++ b/monetdb5/modules/kernel/group.mx
@@ -262,8 +262,12 @@ group_export int CTrefine_rev(BAT **res,
 #endif /* _GROUP_H_ */
 @c
 #include monetdb_config.h
+#include mal.h
+#include mal_exception.h
+#include mal_atom.h
 #include group.h
 #include algebra.h
+
 static int TYPE_mapentry;
 
 
@@ -1707,24 +1711,7 @@ CTrefine_rev(BAT **res, BAT *b, BAT *a)
return refine(res, b, a, TRUE);
 }
 
-/*
- * @- Wrapping
- * Wrapping the version 4 xtables code base
- */
-#include mal.h
-#include mal_exception.h
-#include mal_atom.h
 
-/*
- * @-
- * Recall that we only support void- and oid- typed heads.
- * This is captured as a runtime check in the implementation.
- */
-@= chkHeader
-   if(@1-htype != TYPE_oid  @1-htype != TYPE_void)
-   throw(MAL, group.@2, SEMANTIC_TYPE_ERROR (v)oid head 
required\n);
-@
-@c
 str
 GRPprelude(void)
 {
@@ -1963,7 +1950,8 @@ GRPgroup(int *rethisto, int *retbid, int
 
return rtrn;
}
-   @:chkHeader(b,GRPgroup)@
+   if(b-htype != TYPE_oid  b-htype != TYPE_void)
+   throw(MAL, group.GRPgroup, SEMANTIC_TYPE_ERROR (v)oid head 
required\n);
if (CTgroup(bn, histo, b) == GDK_FAIL) {
BBPreleaseref(b-batCacheid);
throw(MAL, group.new,OPERATION_FAILED);
@@ -1995,7 +1983,8 @@ GRPgroup_custom(int *rethisto, int *retb
if ((b = BATdescriptor(*bid)) == NULL) {
throw(MAL, group.new, RUNTIME_OBJECT_MISSING);
}
-   @:chkHeader(b,GRPgroup)@
+   if(b-htype != TYPE_oid  b-htype != TYPE_void)
+   throw(MAL, group.GRPgroup, SEMANTIC_TYPE_ERROR (v)oid head 
required\n);
if (CTgroup_custom(bn, histo, b, N, rng) == GDK_FAIL) {
BBPreleaseref(b-batCacheid);
throw(MAL, group.new,OPERATION_FAILED);
@@ -2028,18 +2017,21 @@ GRPderive(int *hid, int *mid, int *ct_hi
if ((ct_map = BATdescriptor(*ct_mapid)) == NULL) {
throw(MAL, group.derive, RUNTIME_OBJECT_MISSING);
}
-   @:chkHeader(ct_map,GRPderive)@
+   if(ct_map-htype != TYPE_oid  ct_map-htype != TYPE_void)
+   throw(MAL, group.GRPderive, SEMANTIC_TYPE_ERROR (v)oid head 
required\n);
if ((ct_histo 

MonetDB: default - Remove non-used file

2012-07-18 Thread Martin Kersten
Changeset: 4203df77a96d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4203df77a96d
Removed Files:
monetdb5/modules/kernel/algebra2.mx
Branch: default
Log Message:

Remove non-used file


diffs (truncated from 521 to 300 lines):

diff --git a/monetdb5/modules/kernel/algebra2.mx 
b/monetdb5/modules/kernel/algebra2.mx
deleted file mode 100644
--- a/monetdb5/modules/kernel/algebra2.mx
+++ /dev/null
@@ -1,516 +0,0 @@
-@/
-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 algebra2
-
-@c
-/*
- * @a Arjen P. de Vries, S. Manegold
- * @v 1.0
- * @t Work around internal select and join algorithm selection
- * @+ Introduction
- *
- * Too many bugs.[ Unclear if this still holds]
- * The module is a copy of modules/contrib/malalgebra and heavily used
- * by Pathfinder.
- * The commands are added to the algebra module, because it is considered
- * a natural extension of the operations provided there.
- */
-@mal
-
-@= join
-command algebra.@1join( left:bat[:any_1,:any_2], right:bat[:any_2,:any_3])
-   :bat[:any_1,:any_3] 
-address AL2@1join
-comment Hook directly into the '@1join' implementation of the join.;
-@= leftjoin
-command algebra.left@1join(left:bat[:any_1,:any_2], 
-   right:bat[:any_2,:any_3] ) :bat[:any_1,:any_3] 
-address AL2@1join
-comment Hook directly into the 'left@1join' implementation of the join.
-prefix 'left' means that left and right input are not swapped during 
-processing, and hence, the order of the left input's head in maintained 
-in the result.;
-@
-@mal
-@:join(fetch)@
-@:join(merge)@
-@:join(hash)@
-@:leftjoin()@
-@:leftjoin(fetch)@
-@:leftjoin(merge)@
-@:leftjoin(hash)@
-
-command algebra.leftjoin(left:bat[:any_1,:any_2], 
-   right:bat[:any_2,:any_3] ) :bat[:any_1,:any_3] 
-address ALGjoin
-comment Hook directly into the 'left@1join' implementation of the join.
-prefix 'left' means that left and right input are not swapped during 
-processing, and hence, the order of the left input's head in maintained 
-in the result.;
-
-command algebra.leftthetajoin(left:bat[:any_1,:any_2],
-   right:bat[:any_2,:any_3], mode:int ) 
:bat[:any_1,:any_3] 
-address AL2leftthetajoin
-comment Hook directly into the 'leftthetajoin' implementation of the join.
-prefix 'left' means that left and right input are not swapped during 
-processing, and hence, the order of the left input's head in maintained 
-in the result.;
-
-command algebra.nlthetajoin(left:bat[:any_1,:any_2],
-   right:bat[:any_2,:any_3], mode:int, estimate:lng) :bat[:any_1,:any_3] 
-address AL2nlthetajoin
-comment Hook directly into the 'nested-loop-thetajoin' implementation 
-   of the join. prefix 'left' means that left and right input are not 
-   swapped during processing, and hence, the order of the left input's 
-   head in maintained in the result.
-   Also, for each left tuple, all matching right tuples will appear in 
-   their order of appearrance in the right BAT. ;
-
-
-@= select
-command algebra.ord_@1select( b:bat[:any_1,:any_2], low:any_2,high:any_2 ) 
-   :bat[:any_1, @2] 
-address AL2ord_@1select
-comment Like standard '@1select(b, low, high);', but preserves the 
-   order of the input BAT; (for the time being) this means, only 
-   the scan-based select algorithm is used.;
-
-command algebra.ord_@1select( b:bat[:any_1,:any_2], low:any_2, 
-   high:any_2,l_in:bit,h_in:bit) :bat[:any_1, @2] 
-address AL2ord_@1select_
-comment Like standard '@1select(b, low, high, l_in, h_in);', but 
-   preserves the order of the input BAT (for the time being) 
-   this means, only the scan-based select algorithm is used.;
-
-command algebra.ord_@1select(b:bat[:any_1,:any_2], value:any_2) :bat[:any_1, 
@2] 
-address AL2ord_@1select1
-comment Like standard '@1select(b, value)', but preserves the order of 
-   the input BAT; (for the time being) this means, only the scan-based 
-   select algorithm is used.;
-@
-@mal
-@:select(,:any_2)@
-@:select(u,:void)@
-
-
-# @-
-# old stuff
-@= sum
-command {_csum}(BAT[oid,@1] b) : BAT[oid,@1] 
-address CMDclustered_sum_@1
-comment grouped tail sum;
-@:sum(bte)@
-@:sum(sht)@
-@:sum(int)@
-@:sum(wrd)@
-@:sum(lng)@
-@:sum(flt)@
-@:sum(dbl)@
-
-@
-@h
-/*
- * @* 

MonetDB: default - Go for oid-headed signatures

2012-07-18 Thread Martin Kersten
Changeset: 4b9b846821d5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4b9b846821d5
Modified Files:
monetdb5/extras/compiler/Tests/mal01.mal
monetdb5/modules/kernel/batmtime.mx
Branch: default
Log Message:

Go for oid-headed signatures
Remove superflous signatures.


diffs (51 lines):

diff --git a/monetdb5/extras/compiler/Tests/mal01.mal 
b/monetdb5/extras/compiler/Tests/mal01.mal
--- a/monetdb5/extras/compiler/Tests/mal01.mal
+++ b/monetdb5/extras/compiler/Tests/mal01.mal
@@ -1,12 +1,12 @@
 include mal_compiler;
 function tst903();
-b:= bat.new(:void,:lng);
-barrier (go,i):= language.newRange(0:lng);
+b:= bat.new(:oid,:lng);
+barrier i:= 0:lng;
 k:= mmath.rand();
 l:= calc.lng(k);
-bat.insert(b,nil,l);
-redo (go,i):= language.nextElement(1:lng,100:lng);
-exit (go,i);
+bat.append(b,l);
+redo i:= iterator.next(1:lng,100:lng);
+exit i;
 end tst903;
 
 t0:= alarm.usec();
diff --git a/monetdb5/modules/kernel/batmtime.mx 
b/monetdb5/modules/kernel/batmtime.mx
--- a/monetdb5/modules/kernel/batmtime.mx
+++ b/monetdb5/modules/kernel/batmtime.mx
@@ -66,26 +66,14 @@ comment Compare a bat of @1 against a s
 @:compareGrp(daytime)@
 @:compareGrp(timestamp)@
 
-command batcalc.isnil(b:bat[:any_1,:date]):bat[:any_1,:bit]
-address MTIMEunaryISNIL
-comment Unary check for nil over the tail of the bat;
-
 command batcalc.isnil(b:bat[:oid,:date]):bat[:oid,:bit]
 address MTIMEunaryISNIL
 comment Unary check for nil over the tail of the bat;
 
-command batcalc.isnil(b:bat[:any_1,:daytime]):bat[:any_1,:bit]
-address MTIMEunaryISNIL
-comment Unary check for nil over the tail of the bat;
-
 command batcalc.isnil(b:bat[:oid,:daytime]):bat[:oid,:bit]
 address MTIMEunaryISNIL
 comment Unary check for nil over the tail of the bat;
 
-command batcalc.isnil(b:bat[:any_1,:timestamp]):bat[:any_1,:bit]
-address MTIMEunaryISNIL
-comment Unary check for nil over the tail of the bat;
-
 command batcalc.isnil(b:bat[:oid,:timestamp]):bat[:oid,:bit]
 address MTIMEunaryISNIL
 comment Unary check for nil over the tail of the bat;
___
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jul2012 - merovingian: update comments to reflect reality

2012-07-18 Thread Fabian Groffen
Changeset: d47c22b290bc for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d47c22b290bc
Modified Files:
tools/merovingian/daemon/merovingian.c
Branch: Jul2012
Log Message:

merovingian: update comments to reflect reality


diffs (22 lines):

diff --git a/tools/merovingian/daemon/merovingian.c 
b/tools/merovingian/daemon/merovingian.c
--- a/tools/merovingian/daemon/merovingian.c
+++ b/tools/merovingian/daemon/merovingian.c
@@ -48,13 +48,11 @@
  * number of times over a recent period.  Note that to date, no such
  * thing has been implemented as the need for it has not arisen yet.
  *
- * By default, merovingian will monitor and control the dbfarm in the
- * build-time configured prefix under var/monetdb5/dbfarm.  However,
- * when a path is given as first argument, merovingian will attempt to
- * monitor and control the directory the path points to.  This allows
- * users to create their own dbfarm, but also expert users to run
- * multiple merovingians on the same system easily, since the
- * (persistent) configuration is read from the dbfarm directory.
+ * merovingian will monitor and control the dbfarm given by path in the
+ * first argument.  This allows users to create their own dbfarm, but
+ * also expert users to run multiple merovingians on the same system
+ * easily, since the (persistent) configuration is read from the dbfarm
+ * directory.
  */
 
 #include monetdb_config.h
___
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Cleanup of logger code to split head and tail...

2012-07-18 Thread Niels Nes
Changeset: 982fdf69e13b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=982fdf69e13b
Modified Files:
gdk/gdk_logger.c
gdk/gdk_logger.h
sql/server/rel_optimizer.c
sql/storage/bat/bat_logger.c
sql/storage/restrict/restrict_logger.c
Branch: default
Log Message:

Cleanup of logger code to split head and tail bat into 2 void headed bats


diffs (truncated from 723 to 300 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -73,7 +73,10 @@
 #include gdk_logger.h
 #include string.h
 
-
+static BUN BUNfndT( BAT *b, ptr v)
+{
+   return BUNfnd(BATmirror(b), v);
+}
 /*
  * @-
  * The log record encoding is geared at reduced storage space, but
@@ -218,12 +221,11 @@ la_bat_clear(logger *lg, logaction *la)
BAT *b;
 
/* do we need to skip these old updates */
-   if (BATcount(lg-snapshots)) {
-   BUN p = BUNfnd(lg-snapshots, bid);
+   if (BATcount(lg-snapshots_bid)) {
+   BUN p = BUNfndT(lg-snapshots_bid, bid);
 
if (p != BUN_NONE) {
-   BATiter i = bat_iterator(lg-snapshots);
-   int tid = *(int *) BUNtloc(i, p);
+   int tid = *(int *) Tloc(lg-snapshots_tid, p);
 
if (lg-tid = tid)
return;
@@ -244,16 +246,18 @@ static int
 log_read_seq(logger *lg, logformat *l)
 {
int seq = l-nr;
-   lng id;
+   lng val;
+   BUN p;
 
-   if (!mnstr_readLng(lg-log, id))
+   if (!mnstr_readLng(lg-log, val))
 return LOG_ERR;
 
-   if (BUNfnd(lg-seqs, seq) != BUN_NONE) {
-   BUNdelHead(lg-seqs, seq, FALSE);
+   if ((p = BUNfndT(lg-seqs_id, seq)) != BUN_NONE) {
+   BUNdelete(lg-seqs_id, p, FALSE);
+   BUNdelete(lg-seqs_val, p, FALSE);
}
-   BUNins(lg-seqs, seq, id, FALSE);
-
+   BUNappend(lg-seqs_id, seq, FALSE);
+   BUNappend(lg-seqs_val, val, FALSE);
return LOG_OK;
 }
 
@@ -404,12 +408,11 @@ la_bat_updates(logger *lg, logaction *la
return; /* ignore bats no longer in the catalog */
 
/* do we need to skip these old updates */
-   if (BATcount(lg-snapshots)) {
-   BUN p = BUNfnd(lg-snapshots, bid);
+   if (BATcount(lg-snapshots_bid)) {
+   BUN p = BUNfndT(lg-snapshots_bid, bid);
 
if (p != BUN_NONE) {
-   BATiter i = bat_iterator(lg-snapshots);
-   int tid = *(int *) BUNtloc(i, p);
+   int tid = *(int *) Tloc(lg-snapshots_tid, p);
 
if (lg-tid = tid)
return;
@@ -477,10 +480,14 @@ la_bat_destroy(logger *lg, logaction *la
log_bid bid = logger_find_bat(lg, la-name);
 
if (bid) {
+   BUN p;
+
logger_del_bat(lg, bid);
-   if (BUNfnd(lg-snapshots, bid) != BUN_NONE) {
-   BUNdelHead(lg-snapshots, bid, FALSE);
-   BUNins(lg-snapshots, bid, lg-tid, FALSE);
+   if ((p = BUNfndT(lg-snapshots_bid, bid)) != BUN_NONE) {
+   BUNdelete(lg-snapshots_bid, p, FALSE);
+   BUNdelete(lg-snapshots_tid, p, FALSE);
+   BUNappend(lg-snapshots_bid, bid, FALSE);
+   BUNappend(lg-snapshots_tid, lg-tid, FALSE);
}
}
 }
@@ -564,15 +571,19 @@ la_bat_use(logger *lg, logaction *la)
 {
log_bid bid = la-nr;
BAT *b = BATdescriptor(bid);
+   BUN p;
 
if (!b) {
GDKerror(logger: could not use bat (%d) for %s\n, (int) bid, 
la-name);
return;
}
logger_add_bat(lg, b, la-name);
-   if (BUNfnd(lg-snapshots, b-batCacheid) != BUN_NONE)
-   BUNdelHead(lg-snapshots, b-batCacheid, FALSE);
-   BUNins(lg-snapshots, b-batCacheid, lg-tid, FALSE);
+   if ((p = BUNfndT(lg-snapshots_bid, b-batCacheid)) != BUN_NONE) {
+   BUNdelete(lg-snapshots_bid, p, FALSE);
+   BUNdelete(lg-snapshots_tid, p, FALSE);
+   }
+   BUNappend(lg-snapshots_bid, b-batCacheid, FALSE);
+   BUNappend(lg-snapshots_tid, lg-tid, FALSE);
logbat_destroy(b);
 }
 
@@ -875,17 +886,23 @@ static int
 logger_commit(logger *lg)
 {
int id = LOG_SID;
+   BUN p;
 
if (lg-debug  1)
fprintf(stderr, logger_commit\n);
 
-   BUNdelHead(lg-seqs, id, FALSE);
-   BUNins(lg-seqs, id, lg-id, FALSE);
+   p = BUNfndT(lg-seqs_id, id);
+   BUNdelete(lg-seqs_id, p, FALSE);
+   BUNdelete(lg-seqs_val, p, FALSE);
+   BUNappend(lg-seqs_id, id, FALSE);
+   BUNappend(lg-seqs_val, lg-id, FALSE);
 
/* cleanup old snapshots */
-   if (BATcount(lg-snapshots)) {
-   BATclear(lg-snapshots, FALSE);
-   

Re: MonetDB: default - Cleanup of logger code to split head and tail...

2012-07-18 Thread Niels Nes
On Wed, Jul 18, 2012 at 12:55:31PM +0200, Niels Nes wrote:
 Changeset: 982fdf69e13b for MonetDB
 URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=982fdf69e13b
 Modified Files:
   gdk/gdk_logger.c
   gdk/gdk_logger.h
   sql/server/rel_optimizer.c
   sql/storage/bat/bat_logger.c
   sql/storage/restrict/restrict_logger.c
 Branch: default
 Log Message:
 
 Cleanup of logger code to split head and tail bat into 2 void headed bats

This checkin breaks the current on disk format, ie if your using the
defaul branch a reload is needed.
Before the (september) release we need to add updating functions
for atleast SQL.

Niels 
 
 
 diffs (truncated from 723 to 300 lines):
 
 diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
 --- a/gdk/gdk_logger.c
 +++ b/gdk/gdk_logger.c
 @@ -73,7 +73,10 @@
  #include gdk_logger.h
  #include string.h
  
 -
 +static BUN BUNfndT( BAT *b, ptr v)
 +{
 + return BUNfnd(BATmirror(b), v);
 +}
  /*
   * @-
   * The log record encoding is geared at reduced storage space, but
 @@ -218,12 +221,11 @@ la_bat_clear(logger *lg, logaction *la)
   BAT *b;
  
   /* do we need to skip these old updates */
 - if (BATcount(lg-snapshots)) {
 - BUN p = BUNfnd(lg-snapshots, bid);
 + if (BATcount(lg-snapshots_bid)) {
 + BUN p = BUNfndT(lg-snapshots_bid, bid);
  
   if (p != BUN_NONE) {
 - BATiter i = bat_iterator(lg-snapshots);
 - int tid = *(int *) BUNtloc(i, p);
 + int tid = *(int *) Tloc(lg-snapshots_tid, p);
  
   if (lg-tid = tid)
   return;
 @@ -244,16 +246,18 @@ static int
  log_read_seq(logger *lg, logformat *l)
  {
   int seq = l-nr;
 - lng id;
 + lng val;
 + BUN p;
  
 - if (!mnstr_readLng(lg-log, id))
 + if (!mnstr_readLng(lg-log, val))
return LOG_ERR;
  
 - if (BUNfnd(lg-seqs, seq) != BUN_NONE) {
 - BUNdelHead(lg-seqs, seq, FALSE);
 + if ((p = BUNfndT(lg-seqs_id, seq)) != BUN_NONE) {
 + BUNdelete(lg-seqs_id, p, FALSE);
 + BUNdelete(lg-seqs_val, p, FALSE);
   }
 - BUNins(lg-seqs, seq, id, FALSE);
 -
 + BUNappend(lg-seqs_id, seq, FALSE);
 + BUNappend(lg-seqs_val, val, FALSE);
   return LOG_OK;
  }
  
 @@ -404,12 +408,11 @@ la_bat_updates(logger *lg, logaction *la
   return; /* ignore bats no longer in the catalog */
  
   /* do we need to skip these old updates */
 - if (BATcount(lg-snapshots)) {
 - BUN p = BUNfnd(lg-snapshots, bid);
 + if (BATcount(lg-snapshots_bid)) {
 + BUN p = BUNfndT(lg-snapshots_bid, bid);
  
   if (p != BUN_NONE) {
 - BATiter i = bat_iterator(lg-snapshots);
 - int tid = *(int *) BUNtloc(i, p);
 + int tid = *(int *) Tloc(lg-snapshots_tid, p);
  
   if (lg-tid = tid)
   return;
 @@ -477,10 +480,14 @@ la_bat_destroy(logger *lg, logaction *la
   log_bid bid = logger_find_bat(lg, la-name);
  
   if (bid) {
 + BUN p;
 +
   logger_del_bat(lg, bid);
 - if (BUNfnd(lg-snapshots, bid) != BUN_NONE) {
 - BUNdelHead(lg-snapshots, bid, FALSE);
 - BUNins(lg-snapshots, bid, lg-tid, FALSE);
 + if ((p = BUNfndT(lg-snapshots_bid, bid)) != BUN_NONE) {
 + BUNdelete(lg-snapshots_bid, p, FALSE);
 + BUNdelete(lg-snapshots_tid, p, FALSE);
 + BUNappend(lg-snapshots_bid, bid, FALSE);
 + BUNappend(lg-snapshots_tid, lg-tid, FALSE);
   }
   }
  }
 @@ -564,15 +571,19 @@ la_bat_use(logger *lg, logaction *la)
  {
   log_bid bid = la-nr;
   BAT *b = BATdescriptor(bid);
 + BUN p;
  
   if (!b) {
   GDKerror(logger: could not use bat (%d) for %s\n, (int) bid, 
 la-name);
   return;
   }
   logger_add_bat(lg, b, la-name);
 - if (BUNfnd(lg-snapshots, b-batCacheid) != BUN_NONE)
 - BUNdelHead(lg-snapshots, b-batCacheid, FALSE);
 - BUNins(lg-snapshots, b-batCacheid, lg-tid, FALSE);
 + if ((p = BUNfndT(lg-snapshots_bid, b-batCacheid)) != BUN_NONE) {
 + BUNdelete(lg-snapshots_bid, p, FALSE);
 + BUNdelete(lg-snapshots_tid, p, FALSE);
 + }
 + BUNappend(lg-snapshots_bid, b-batCacheid, FALSE);
 + BUNappend(lg-snapshots_tid, lg-tid, FALSE);
   logbat_destroy(b);
  }
  
 @@ -875,17 +886,23 @@ static int
  logger_commit(logger *lg)
  {
   int id = LOG_SID;
 + BUN p;
  
   if (lg-debug  1)
   fprintf(stderr, logger_commit\n);
  
 - BUNdelHead(lg-seqs, id, FALSE);
 - BUNins(lg-seqs, id, lg-id, FALSE);
 + p = BUNfndT(lg-seqs_id, id);
 + BUNdelete(lg-seqs_id, p, FALSE);
 + BUNdelete(lg-seqs_val, p, FALSE);
 + 

MonetDB: Jul2012 - uncrustify

2012-07-18 Thread Fabian Groffen
Changeset: 35ea2bcd7db8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=35ea2bcd7db8
Modified Files:
tools/mserver/mserver5.c
Branch: Jul2012
Log Message:

uncrustify


diffs (truncated from 374 to 300 lines):

diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c
--- a/tools/mserver/mserver5.c
+++ b/tools/mserver/mserver5.c
@@ -46,14 +46,14 @@
 #endif
 
 #ifdef _MSC_VER
-#include Psapi.h /* for GetModuleFileName */
+#include Psapi.h  /* for GetModuleFileName */
 #endif
 
 #ifdef _CRTDBG_MAP_ALLOC
 /* Windows only:
our definition of new and delete clashes with the one if
_CRTDBG_MAP_ALLOC is defined.
-*/
+ */
 #undef _CRTDBG_MAP_ALLOC
 #endif
 
@@ -75,7 +75,7 @@ mserver_abort()
 #endif
 
 static void usage(char *prog)
-   __attribute__((__noreturn__));
+__attribute__((__noreturn__));
 
 static void
 usage(char *prog)
@@ -92,19 +92,19 @@ usage(char *prog)
fprintf(stderr, --helpPrint this list of 
options\n);
fprintf(stderr, --version Print version and 
compile time info\n);
 
-   fprintf(stderr,The debug, testing  trace options:\n);
-   fprintf(stderr, --threads\n);
-   fprintf(stderr, --memory\n);
-   fprintf(stderr, --properties\n);
-   fprintf(stderr, --io\n);
-   fprintf(stderr, --transactions\n);
-   fprintf(stderr, --modules\n);
-   fprintf(stderr, --algorithms\n);
-   fprintf(stderr, --xproperties\n);
-   fprintf(stderr, --performance\n);
-   fprintf(stderr, --optimizers\n);
-   fprintf(stderr, --forcemito\n);
-   fprintf(stderr, --debug=bitmask\n);
+   fprintf(stderr, The debug, testing  trace options:\n);
+   fprintf(stderr,  --threads\n);
+   fprintf(stderr,  --memory\n);
+   fprintf(stderr,  --properties\n);
+   fprintf(stderr,  --io\n);
+   fprintf(stderr,  --transactions\n);
+   fprintf(stderr,  --modules\n);
+   fprintf(stderr,  --algorithms\n);
+   fprintf(stderr,  --xproperties\n);
+   fprintf(stderr,  --performance\n);
+   fprintf(stderr,  --optimizers\n);
+   fprintf(stderr,  --forcemito\n);
+   fprintf(stderr,  --debug=bitmask\n);
 
exit(0);
 }
@@ -118,9 +118,9 @@ monet_hello(void)
char *linkinfo = dynamically;
 #endif
 
-   dblsz_mem_h;
+   dbl sz_mem_h;
char  *qc =  kMGTPE;
-   intqi = 0;
+   int qi = 0;
 
monet_memory = MT_npages() * MT_pagesize();
sz_mem_h = (dbl) monet_memory;
@@ -139,7 +139,7 @@ monet_hello(void)
GDKnr_threads, (GDKnr_threads != 1) ? s : );
printf(# Compiled for %s/ SZFMT bit with  SZFMT bit OIDs %s 
linked\n,
HOST, sizeof(ptr) * 8, sizeof(oid) * 8, linkinfo);
-   printf(# Found %.3f %ciB available main-memory.\n, 
+   printf(# Found %.3f %ciB available main-memory.\n,
sz_mem_h, qc[qi]);
 #ifdef MONET_GLOBAL_DEBUG
printf(# Database farm:%s\n, GDKgetenv(gdk_dbfarm));
@@ -156,7 +156,7 @@ absolute_path(str s)
if (!MT_path_absolute(s)) {
str ret = (str) GDKmalloc(strlen(s) + strlen(monet_cwd) + 2);
 
-   if ( ret )
+   if (ret)
sprintf(ret, %s%c%s, monet_cwd, DIR_SEP, s);
return ret;
}
@@ -185,14 +185,15 @@ monet_init(opt *set, int setlen)
return 1;
 }
 
-static void emergencyBreakpoint(void){
+static void emergencyBreakpoint(void)
+{
/* just a handle to break after system initialization for GDB */
 }
 
 static void
 handler(int sig)
 {
-   (void)sig;
+   (void) sig;
mal_exit();
 }
 
@@ -201,62 +202,62 @@ main(int argc, char **av)
 {
char *prog = *av;
opt *set = NULL;
-   int idx = 0, grpdebug=0, debug = 0, setlen = 0, listing = 0, i = 0;
+   int idx = 0, grpdebug = 0, debug = 0, setlen = 0, listing = 0, i = 0;
str dbinit = NULL;
str err = MAL_SUCCEED;
char prmodpath[1024];
char *modpath = NULL;
 
static struct option long_options[] = {
-   {config, 1, 0, 'c'},
-   {dbname, 1, 0, 0},
-   {dbfarm, 1, 0, 0},
-   {dbinit, 1, 0, 0},
-   {daemon, 1, 0, 0},
-   {debug, 2, 0, 'd'},
-   {help, 0, 0, 'h'},
-   {version, 0, 0, 0},
-   {readonly, 0, 0, 'r'},
-   {single-user, 0, 0, 0},
-   {set, 1, 0, 's'},
-   {trace, 0, 0, 't'},
-   {threads,0,0,0},
-   {memory,0,0,0},
-   {properties,0,0,0},
-   {io,0,0,0},
-   {transaction,0,0,0},
-   {modules,0,0,0},
-   {algorithms,0,0,0},
-   {optimizers,0,0,0},
-   {performance,0,0,0},
-   {xproperties,0,0,0},
- 

MonetDB: default - first version to upgrade logger format

2012-07-18 Thread Niels Nes
Changeset: 8168421ac2e9 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8168421ac2e9
Modified Files:
gdk/gdk_logger.c
Branch: default
Log Message:

first version to upgrade logger format


diffs (104 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1012,7 +1012,7 @@ logger_new(int debug, char *fn, char *lo
char filename[BUFSIZ];
char bak[BUFSIZ];
log_bid seqs_id = 0;
-   bat catalog_bid, catalog_nme;
+   bat catalog_bid, catalog_nme, bid;
 
if (lg == NULL)
return NULL;
@@ -1062,6 +1062,91 @@ logger_new(int debug, char *fn, char *lo
}
fp = fopen(filename, r);
 
+   snprintf(bak, BUFSIZ, %s_catalog, fn);
+   bid = BBPindex(bak);
+
+   /* upgrade from old logger format */
+   if (bid) {
+   /* split catalog - catalog_bid, catalog_nme */
+   BAT *b = BATdescriptor(bid);
+
+   lg-catalog_bid = logbat_new(TYPE_void, TYPE_int, BATSIZE);
+   lg-catalog_nme = logbat_new(TYPE_void, TYPE_str, BATSIZE);
+
+   BATappend(lg-catalog_bid, BATmirror(b), FALSE);
+   BATappend(lg-catalog_nme, b, FALSE);
+
+   /* Make persistent */
+   bid = lg-catalog_bid-batCacheid;
+   BBPincref(bid, TRUE);
+   BATmode(lg-catalog_bid, PERSISTENT);
+   snprintf(bak, BUFSIZ, %s_catalog_bid, fn);
+   BBPrename(lg-catalog_bid-batCacheid, bak);
+
+   /* Make persistent */
+   bid = lg-catalog_nme-batCacheid;
+   BBPincref(bid, TRUE);
+   BATmode(lg-catalog_nme, PERSISTENT);
+   snprintf(bak, BUFSIZ, %s_catalog_nme, fn);
+   BBPrename(lg-catalog_nme-batCacheid, bak);
+
+   logbat_destroy(b);
+
+   /* split snapshots - snapshots_bid, snapshots_tid */
+   bid = logger_find_bat(lg, snapshots);
+   b = BATdescriptor(bid);
+
+   lg-snapshots_bid = logbat_new(TYPE_void, TYPE_int, 1);
+   BATappend(lg-snapshots_bid, BATmirror(b), FALSE);
+   BATmode(lg-snapshots_bid, PERSISTENT);
+   snprintf(bak, BUFSIZ, %s_snapshots_bid, fn);
+   BBPrename(lg-snapshots_bid-batCacheid, bak);
+   logger_add_bat(lg, lg-snapshots_bid, snapshots_bid);
+
+   lg-snapshots_tid = logbat_new(TYPE_void, TYPE_int, 1);
+   BATappend(lg-snapshots_tid, b, FALSE);
+   BATmode(lg-snapshots_tid, PERSISTENT);
+   snprintf(bak, BUFSIZ, %s_snapshots_tid, fn);
+   BBPrename(lg-snapshots_tid-batCacheid, bak);
+   logger_add_bat(lg, lg-snapshots_tid, snapshots_tid);
+
+   logbat_destroy(b);
+
+   /* split seqs - seqs_id, seqs_val */
+   bid = logger_find_bat(lg, seqs);
+   b = BATdescriptor(bid);
+
+   lg-seqs_id = logbat_new(TYPE_void, TYPE_int, 1);
+   BATappend(lg-seqs_id, BATmirror(b), FALSE);
+   BATmode(lg-seqs_id, PERSISTENT);
+   snprintf(bak, BUFSIZ, %s_seqs_id, fn);
+   BBPrename(lg-seqs_id-batCacheid, bak);
+   logger_add_bat(lg, lg-seqs_id, seqs_id);
+
+   lg-seqs_val = logbat_new(TYPE_void, TYPE_lng, 1);
+   BATappend(lg-seqs_val, b, FALSE);
+   BATmode(lg-seqs_val, PERSISTENT);
+   snprintf(bak, BUFSIZ, %s_seqs_val, fn);
+   BBPrename(lg-seqs_val-batCacheid, bak);
+   logger_add_bat(lg, lg-seqs_val, seqs_val);
+
+   logbat_destroy(b);
+
+   bm_subcommit(lg-catalog_bid, lg-catalog_nme, lg-catalog_bid, 
lg-catalog_nme, NULL, lg-debug);
+   logbat_destroy(lg-catalog_bid);
+   logbat_destroy(lg-catalog_nme);
+   logbat_destroy(lg-snapshots_bid);
+   logbat_destroy(lg-snapshots_tid);
+   logbat_destroy(lg-seqs_id);
+   logbat_destroy(lg-seqs_val);
+   lg-catalog_bid = NULL;
+   lg-catalog_nme = NULL;
+   lg-snapshots_bid = NULL;
+   lg-snapshots_tid = NULL;
+   lg-seqs_id = NULL;
+   lg-seqs_val = NULL;
+   }
+
snprintf(bak, BUFSIZ, %s_catalog_bid, fn);
catalog_bid = BBPindex(bak);
 
___
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Added variants for SQL compiler.

2012-07-18 Thread Martin Kersten
Changeset: 5c4d3dc1ded0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5c4d3dc1ded0
Modified Files:
monetdb5/modules/kernel/algebra.mx
Branch: default
Log Message:

Added variants for SQL compiler.
In the move towards :oid headed BATs we need a few intermediates,
that work on the tails only.


diffs (153 lines):

diff --git a/monetdb5/modules/kernel/algebra.mx 
b/monetdb5/modules/kernel/algebra.mx
--- a/monetdb5/modules/kernel/algebra.mx
+++ b/monetdb5/modules/kernel/algebra.mx
@@ -362,6 +362,10 @@ comment Returns the intersection taken 
Does *not* do double- elimination over the 'left' BUNs.
If you want this, use: 
'kintersect(kunique(left),kunique(right))' 
or: 'kunique(kintersect(left,right))'.;
+command tintersect( left:bat[:any_1,:any_2], right:bat[:any_1,:any] ) 
+   :bat[:any_1,:any_2] 
+address ALGtintersect;
+
 # @- Bun-differing elements
 command difference( left:bat[:any_1,:any_2], right:bat[:any_1,:any_2] ) 
:bat[:any_1,:any_2] 
@@ -385,6 +389,9 @@ comment Returns the difference taken ov
If you want this, use:
 'kdifference(left.kunique,right.kunique)' 
or: 'kdifference(left,right).kunique'.;
+command tdifference ( left:bat[:any_1,:any_2], right:bat[:any_1,:any] ) 
+   :bat[:any_1,:any_2] 
+address ALGtdiff;
 # @- Unions on bun
 command union ( left:bat[:any_1,:any_2], right:bat[:any_1,:any_2]) 
:bat[:any_1,:any_2] 
@@ -408,6 +415,9 @@ comment Returns the union of two BATs; 
If you want this, do:
'kunion(left.kunique,right.kunique)' 
or: 'sunion(left,right).kunique'.;
+command tunion ( left:bat[:any_1,:any_2], right:bat[:any_1,:any_2])
+   :bat[:any_1,:any_2] 
+address ALGtunion;
 # @+ Join operations
 # The core of every relational engine.
 # The join collection provided by the GDK kernel.
@@ -976,6 +986,7 @@ algebra_export str ALG@1(int *result, in
 @:ALGunaryExport(copy)@
 @:ALGunaryExport(kunique)@
 @:ALGunaryExport(sunique)@
+@:ALGunaryExport(tunique)@
 @:ALGbinaryExport(cross)@
 @:ALGbinaryExport(antijoin)@
 @:ALGbinaryestimateExport(join)@
@@ -986,10 +997,13 @@ algebra_export str ALG@1(int *result, in
 @:ALGbinaryExport(semijoin)@
 @:ALGbinaryExport(sunion)@
 @:ALGbinaryExport(kunion)@
+@:ALGbinaryExport(tunion)@
 @:ALGbinaryExport(sintersect)@
 @:ALGbinaryExport(kintersect)@
+@:ALGbinaryExport(tintersect)@
 @:ALGbinaryExport(sdiff)@
 @:ALGbinaryExport(kdiff)@
+@:ALGbinaryExport(tdiff)@
 @:ALGbinaryintExport(sample)@
 
 algebra_export str ALGtunique(int *result, int *bid);
@@ -2688,7 +2702,7 @@ ALGsample(bat *result, bat *bid, int *pa
 }
 
 
-/* add item missing in the kernel */
+/* add items missing in the kernel */
 str
 ALGtunique(int *result, int *bid)
 {
@@ -2711,6 +2725,87 @@ ALGtunique(int *result, int *bid)
 }
 
 str
+ALGtunion(int *result, int *bid, int *bid2)
+{
+   BAT *b, *b2, *bn;
+
+   if ((b = BATdescriptor(*bid)) == NULL)
+   throw(MAL, algebra.tunion, RUNTIME_OBJECT_MISSING);
+   if ((b2 = BATdescriptor(*bid2)) == NULL){
+   BBPreleaseref(*bid2);
+   throw(MAL, algebra.tunion, RUNTIME_OBJECT_MISSING);
+   }
+   
+   bn = BATkunion(BATmirror(b),BATmirror(b2));
+   if (bn) {
+   bn = BATmirror(bn);
+   if (!(bn-batDirty2)) bn = BATsetaccess(bn, BAT_READ);
+   *result = bn-batCacheid;
+   BBPkeepref(*result);
+   BBPreleaseref(b-batCacheid);
+   BBPreleaseref(b2-batCacheid);
+   return MAL_SUCCEED;
+   }
+   BBPreleaseref(b-batCacheid);
+   BBPreleaseref(b2-batCacheid);
+   throw(MAL, algebra.tunion, GDK_EXCEPTION);
+}
+
+str
+ALGtdiff(int *result, int *bid, int *bid2)
+{
+   BAT *b, *b2, *bn;
+
+   if ((b = BATdescriptor(*bid)) == NULL)
+   throw(MAL, algebra.tdifference, RUNTIME_OBJECT_MISSING);
+   if ((b2 = BATdescriptor(*bid2)) == NULL){
+   BBPreleaseref(*bid2);
+   throw(MAL, algebra.tdifference, RUNTIME_OBJECT_MISSING);
+   }
+   
+   bn = BATkdiff(BATmirror(b),BATmirror(b2));
+   if (bn) {
+   bn = BATmirror(bn);
+   if (!(bn-batDirty2)) bn = BATsetaccess(bn, BAT_READ);
+   *result = bn-batCacheid;
+   BBPkeepref(*result);
+   BBPreleaseref(b-batCacheid);
+   BBPreleaseref(b2-batCacheid);
+   return MAL_SUCCEED;
+   }
+   BBPreleaseref(b-batCacheid);
+   BBPreleaseref(b2-batCacheid);
+   throw(MAL, algebra.tdifference, GDK_EXCEPTION);
+}
+
+str
+ALGtintersect(int *result, int *bid, int *bid2)
+{
+   BAT *b, *b2, *bn;
+
+   if ((b = BATdescriptor(*bid)) == NULL)
+   throw(MAL, algebra.tdifference, RUNTIME_OBJECT_MISSING);
+   if ((b2 = BATdescriptor(*bid2)) == NULL){
+   BBPreleaseref(*bid2);
+   

MonetDB: default - use tunique instead of reverse(unique(reverse...

2012-07-18 Thread Niels Nes
Changeset: e88e352b26fe for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e88e352b26fe
Modified Files:
monetdb5/optimizer/opt_mergetable.c
sql/backends/monet5/sql_gencode.c
sql/server/sql_statement.c
Branch: default
Log Message:

use tunique instead of reverse(unique(reverse(x)))


diffs (45 lines):

diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -1985,7 +1985,7 @@ OPTmergetableImplementation(Client cntxt
 getFunctionId(p)== sumRef ||
 getFunctionId(p) == prodRef)) ||
(getModuleId(p) == algebraRef 
-getFunctionId(p) == kuniqueRef)) 
+getFunctionId(p) == tuniqueRef)) 
(m=isMATalias(getArg(p,1), mat, mtop)) = 0) {
mat_aggr(mb, p, mat, m);
actions++;
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -1450,16 +1450,8 @@ _dumpstmt(backend *sql, MalBlkPtr mb, st
q = pushArgument(mb, q, e);
q = pushArgument(mb, q, l);
} else {
-   int k;
-
-   q = newStmt2(mb, batRef, reverseRef);
+   q = newStmt2(mb, algebraRef, tuniqueRef);
q = pushArgument(mb, q, l);
-   k = getDestVar(q);
-   q = newStmt1(mb, algebraRef, kunique);
-   q = pushArgument(mb, q, k);
-   k = getDestVar(q);
-   q = newStmt2(mb, batRef, reverseRef);
-   q = pushArgument(mb, q, k);
}
s-nr = getDestVar(q);
break;
diff --git a/sql/server/sql_statement.c b/sql/server/sql_statement.c
--- a/sql/server/sql_statement.c
+++ b/sql/server/sql_statement.c
@@ -992,7 +992,7 @@ stmt_unique(sql_allocator *sa, stmt *s, 
if (g) 
ns-op2 = g-grp;
ns-nrcols = s-nrcols;
-   ns-key = 1;/* ?? maybe change key to unique ? */
+   ns-key = 1;
ns-aggr = s-aggr;
ns-t = s-t;
return ns;
___
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jul2012 - forkmserver: fix possible race condition when...

2012-07-18 Thread Fabian Groffen
Changeset: fc516173a646 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fc516173a646
Modified Files:
tools/merovingian/ChangeLog.Jul2012
tools/merovingian/daemon/forkmserver.c
Branch: Jul2012
Log Message:

forkmserver: fix possible race condition when starting mservers

As reported in bug #3107, when multiple clients would trigger monetdbd
to auto-start an mserver at the same time, monetdbd could wrongly start
forking mserver5's for the same database, obviously with failing
behaviour as a result.

This is now resolved by using a global lock for forkmserver when it
figures out it really needs to fork an mserver5 process.  Multiple
concurrent clients would in this case block, and have to re-evaluate
whether they still need to start an mserver5 or not in serial order.

Upside of this fix, is that successive connects to a database should be
slightly faster now, as a shortcut is taken when the database already
appears to be running, avoiding expensive calls which results aren't
used.


diffs (160 lines):

diff --git a/tools/merovingian/ChangeLog.Jul2012 
b/tools/merovingian/ChangeLog.Jul2012
--- a/tools/merovingian/ChangeLog.Jul2012
+++ b/tools/merovingian/ChangeLog.Jul2012
@@ -1,3 +1,7 @@
 # ChangeLog file for sql/src/backends/monet5/merovingian
 # This file is updated with mchangelog
 
+* Wed Jul 18 2012 Fabian Groffen fab...@cwi.nl
+- Resolved a problem where automatic starting of a database initiated by
+  multiple clients at the same time could cause failed starts.  Bug #3107
+
diff --git a/tools/merovingian/daemon/forkmserver.c 
b/tools/merovingian/daemon/forkmserver.c
--- a/tools/merovingian/daemon/forkmserver.c
+++ b/tools/merovingian/daemon/forkmserver.c
@@ -40,6 +40,8 @@
 #include forkmserver.h
 
 
+static pthread_mutex_t fork_lock = PTHREAD_MUTEX_INITIALIZER;
+
 /**
  * Fork an mserver and detach.  Before forking off, Sabaoth is consulted
  * to see if forking makes sense, or whether it is necessary at all, or
@@ -86,6 +88,29 @@ forkMserver(char *database, sabdb** stat
 * more than one entry in the list, so we assume we have the right
 * one here. */
 
+   if ((*stats)-state == SABdbRunning)
+   /* return before doing expensive stuff, when this db just seems
+* to be running */
+   return(NO_ERR);
+
+   /* Make sure we only start one mserver5 at the same time, this is a
+* horsedrug for preventing race-conditions where two or more
+* clients start the same database at the same time, because they
+* were all identified as being SABdbInactive.  If this global
+* lock ever becomes a problem, we can reduce it to a per-database
+* lock instead. */
+   pthread_mutex_lock(fork_lock);
+
+   /* refetch the status, as it may have changed */
+   msab_freeStatus(stats);
+   er = msab_getStatus(stats, database);
+   if (er != NULL) {
+   err e = newErr(%s, er);
+   free(er);
+   pthread_mutex_unlock(fork_lock);
+   return(e);
+   }
+
ckv = getDefaultProps();
readProps(ckv, (*stats)-path);
kv = findConfKey(ckv, type);
@@ -98,6 +123,7 @@ forkMserver(char *database, sabdb** stat
kv-val, database);
freeConfFile(ckv);
free(ckv);
+   pthread_mutex_unlock(fork_lock);
return(NO_ERR);
} else {
Mfprintf(stdout, startup of %s under maintenance 
@@ -113,6 +139,7 @@ forkMserver(char *database, sabdb** stat
msab_freeStatus(stats);
freeConfFile(ckv);
free(ckv);
+   pthread_mutex_unlock(fork_lock);
return(e);
}
 
@@ -120,6 +147,7 @@ forkMserver(char *database, sabdb** stat
case SABdbRunning:
freeConfFile(ckv);
free(ckv);
+   pthread_mutex_unlock(fork_lock);
return(NO_ERR);
case SABdbCrashed:
t = localtime(info.lastcrash);
@@ -152,6 +180,7 @@ forkMserver(char *database, sabdb** stat
msab_freeStatus(stats);
freeConfFile(ckv);
free(ckv);
+   pthread_mutex_unlock(fork_lock);
return(newErr(unknown state: %d, 
(int)(*stats)-state));
}
 
@@ -161,6 +190,7 @@ forkMserver(char *database, sabdb** stat
msab_freeStatus(stats);
freeConfFile(ckv);
free(ckv);
+   pthread_mutex_unlock(fork_lock);
return(newErr(unable to create pipe: %s, strerror(errno)));
}
if (pipe(pfde) == -1) {
@@ -169,6 +199,7 @@ forkMserver(char *database, sabdb** stat
msab_freeStatus(stats);

MonetDB: default - fix problem with median and mergetable optimizer

2012-07-18 Thread Niels Nes
Changeset: c6fe5acf0f8e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c6fe5acf0f8e
Modified Files:
monetdb5/optimizer/opt_mergetable.c
sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
sql/test/Tests/median_stdev.sql
sql/test/Tests/median_stdev.stable.out
sql/test/Tests/trace.stable.out
Branch: default
Log Message:

fix problem with median and mergetable optimizer


diffs (116 lines):

diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -1967,8 +1967,11 @@ OPTmergetableImplementation(Client cntxt
actions++;
continue;
}
-   if (match == 3  getModuleId(p) == aggrRef  p-argc == 4)
-   assert(0); 
+   /* median */
+   if (match == 3  getModuleId(p) == aggrRef  p-argc == 4) {
+   error++;
+   goto fail;
+   }
/*
 * @-
 * Aggregate handling is a prime target for optimization.
diff --git 
a/sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err 
b/sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
--- a/sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
+++ b/sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
@@ -80,12 +80,13 @@ stderr of test 'cardinality_violation.SF
 # 21:00:43   mclient -lsql -umonetdb -Pmonetdb --host=alf --port=38808 
 # 21:00:43   
 
-MAPI  = monetdb@niels:39633
+MAPI  = monetdb@niels:35277
 QUERY = select * from env() as env where name = ( select 'prefix' from env() 
as env );
 ERROR = !cardinality violation (211)
-MAPI  = monetdb@niels:39633
+MAPI  = monetdb@niels:35277
 QUERY = select * from columns where name = (select columns.name from _tables, 
columns where _tables.id = columns.table_id);
-ERROR = !cardinality violation (3001)
+ERROR = !cardinality violation (2991)
+
 
 # 21:00:43   
 # 21:00:43   Done.
diff --git a/sql/test/Tests/median_stdev.sql b/sql/test/Tests/median_stdev.sql
--- a/sql/test/Tests/median_stdev.sql
+++ b/sql/test/Tests/median_stdev.sql
@@ -20,9 +20,9 @@ INSERT INTO sampleData VALUES ( 5,   0 )
 SELECT count(*) from sampleData;
 
 -- Median tests
-SELECT median(numValue) FROM sampleData;  -- should return 6.5 (or 6, or 7)
+SELECT median(numValue) FROM sampleData;  -- should return 6
 SELECT median(groupID) FROM sampleData;  -- should return 2
-SELECT groupID, median(numValue) FROM sampleData GROUP BY groupID;  -- should 
return (6, 5, 34.5, 18,  0)
+SELECT groupID, median(numValue) FROM sampleData GROUP BY groupID;  -- should 
return (6, 5, 17, 18,  0)
 
 
 SELECT R.groupID, AVG(1.0*R.numValue) AS medianValue
diff --git a/sql/test/Tests/median_stdev.stable.out 
b/sql/test/Tests/median_stdev.stable.out
--- a/sql/test/Tests/median_stdev.stable.out
+++ b/sql/test/Tests/median_stdev.stable.out
@@ -39,6 +39,48 @@ Ready.
 [ 1]
 [ 1]
 [ 1]
+#INSERT INTO sampleData VALUES ( 5,   0 );
+[ 1]
+#SELECT count(*) from sampleData;
+% sys.sampledata # table_name
+% L1 # name
+% wrd # type
+% 2 # length
+[ 17   ]
+#SELECT median(numValue) FROM sampleData;  -- should return 6.5 (or 6, or 7)
+% sys.sampledata # table_name
+% L1 # name
+% int # type
+% 1 # length
+[ 6]
+#SELECT median(groupID) FROM sampleData;  -- should return 2
+% sys.sampledata # table_name
+% L1 # name
+% int # type
+% 1 # length
+[ 2]
+#SELECT groupID, median(numValue) FROM sampleData GROUP BY groupID;  -- should 
return (6, 5, 34.5, 18,  0)
+% sys.sampledata,  sys.sampledata # table_name
+% groupid, L1 # name
+% int, int # type
+% 1,   2 # length
+[ 1,   6   ]
+[ 2,   5   ]
+[ 3,   17  ]
+[ 4,   18  ]
+[ 5,   0   ]
+#SELECT R.groupID, AVG(1.0*R.numValue) AS medianValue
+#FROM
+#(SELECT GroupID, numValue, ROW_NUMBER() OVER(PARTITION BY groupID ORDER 
BY NumValue) AS rowno
+#FROM sampleData
+#) R
+#INNER JOIN
+#(SELECT GroupID, 1+count(*) as N
+#FROM sampleData
+#GROUP BY GroupID
+#) G
+#ON R.GroupID = G.GroupID AND R.rowNo BETWEEN N/2 AND N/2+N%2
+#GROUP BY R.groupID;
 % sys.r,   . # table_name
 % groupid, medianvalue # name
 % int, double # type
diff --git a/sql/test/Tests/trace.stable.out b/sql/test/Tests/trace.stable.out
--- a/sql/test/Tests/trace.stable.out
+++ b/sql/test/Tests/trace.stable.out
@@ -35,7 +35,7 @@ Ready.
 % L1 # name
 % wrd # type
 % 2 # length
-[ 17   ]
+[ 16   ]
 
 # 11:14:41   
 # 11:14:41   Done.
___
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - approved output

2012-07-18 Thread Niels Nes
Changeset: 8dd44dc0e5fa for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8dd44dc0e5fa
Modified Files:
sql/test/leaks/Tests/check0.stable.out
sql/test/leaks/Tests/check1.stable.out
sql/test/leaks/Tests/check2.stable.out
sql/test/leaks/Tests/check3.stable.out
sql/test/leaks/Tests/check4.stable.out
sql/test/leaks/Tests/check5.stable.out
sql/test/leaks/Tests/drop3.stable.out
sql/test/leaks/Tests/select1.stable.out
sql/test/leaks/Tests/select2.stable.out
sql/test/leaks/Tests/temp1.stable.out
sql/test/leaks/Tests/temp2.stable.out
sql/test/leaks/Tests/temp3.stable.out
Branch: default
Log Message:

approved output


diffs (truncated from 924 to 300 lines):

diff --git a/sql/test/leaks/Tests/check0.stable.out 
b/sql/test/leaks/Tests/check0.stable.out
--- a/sql/test/leaks/Tests/check0.stable.out
+++ b/sql/test/leaks/Tests/check0.stable.out
@@ -48,23 +48,26 @@ Ready.
 % htype,   ttype,  count # name
 % clob,clob,   bigint # type
 % 3,   3,  4 # length
-[ int,   int,  8   ]
-[ int,   lng,  2   ]
-[ int,   str,  142 ]
-[ oid,   int,  20  ]
-[ oid,   int,  20  ]
-[ oid,   int,  1149]
-[ oid,   int,  3168]
-[ oid,   int,  3168]
-[ oid,   int,  3168]
-[ oid,   int,  3168]
-[ oid,   int,  3168]
-[ oid,   lng,  20  ]
+[ oid,   int,  1   ]
+[ oid,   int,  1   ]
+[ oid,   int,  2   ]
+[ oid,   int,  8   ]
+[ oid,   int,  8   ]
+[ oid,   int,  144 ]
+[ oid,   int,  1148]
+[ oid,   int,  3163]
+[ oid,   int,  3163]
+[ oid,   int,  3163]
+[ oid,   int,  3163]
+[ oid,   int,  3163]
+[ oid,   lng,  1   ]
+[ oid,   lng,  2   ]
 [ oid,   str,  1   ]
 [ oid,   str,  1   ]
-[ oid,   str,  20  ]
-[ oid,   str,  3168]
-[ oid,   str,  3168]
+[ oid,   str,  1   ]
+[ oid,   str,  144 ]
+[ oid,   str,  3163]
+[ oid,   str,  3163]
 #select 'transient', count(*) from bbp() as bbp where kind like 'tran%';
 % .L1, .bbp # table_name
 % L1,  L2 # name
@@ -76,7 +79,7 @@ Ready.
 % L1,  L2 # name
 % char,wrd # type
 % 10,  2 # length
-[ persistent,17  ]
+[ persistent,20  ]
 
 # 22:02:15   
 # 22:02:15   Done.
diff --git a/sql/test/leaks/Tests/check1.stable.out 
b/sql/test/leaks/Tests/check1.stable.out
--- a/sql/test/leaks/Tests/check1.stable.out
+++ b/sql/test/leaks/Tests/check1.stable.out
@@ -28,15 +28,14 @@ Ready.
 % htype,   ttype,  count # name
 % clob,clob,   bigint # type
 % 3,   9,  4 # length
-[ int,   int,  0   ]
-[ int,   lng,  2   ]
-[ int,   str,  142 ]
 [ oid,   bit,  0   ]
-[ oid,   bit,  59  ]
-[ oid,   bit,  59  ]
-[ oid,   bit,  300 ]
-[ oid,   bit,  1149]
-[ oid,   bit,  1149]
+[ oid,   bit,  58  ]
+[ oid,   bit,  58  ]
+[ oid,   bit,  299 ]
+[ oid,   bit,  1148]
+[ oid,   bit,  1148]
+[ oid,   int,  0   ]
+[ oid,   int,  0   ]
 [ oid,   int,  0   ]
 [ oid,   int,  0   ]
 [ oid,   int,  0   ]
@@ -46,6 +45,9 @@ Ready.
 [ oid,   int,  0   ]
 [ oid,   int,  0   ]
 [ oid,   int,  1   ]
+[ oid,   int,  1   ]
+[ oid,   int,  1   ]
+[ oid,   int,  2   ]
 [ oid,   int,  2   ]
 [ oid,   int,  2   ]
 [ oid,   int,  2   ]
@@ -61,8 +63,6 @@ Ready.
 [ oid,   int,  3   ]
 [ oid,   int,  4   ]
 [ oid,   int,  4   ]
-[ oid,   int,  5   ]
-[ oid,   int,  5   ]
 [ oid,   int,  19  ]
 [ oid,   int,  19  ]
 [ oid,   int,  19  ]
@@ -74,24 +74,25 @@ Ready.
 [ oid,   int,  42  ]
 [ oid,   int,  42  ]
 [ oid,   int,  42  ]
-[ oid,   int,  59  ]
-[ oid,   int,  59  ]
+[ oid,   int,  58  ]
+[ oid,   int,  58  ]
+[ oid,   int,  144 ]
 [ oid,   int,  195 ]
 [ oid,   int,  195 ]
-[ oid,   int,  300 ]
-[ oid,   int,  300 ]
-[ oid,   int,  300 ]
-[ oid,   int,  300 ]
-[ oid,   int,  300 ]
-[ oid,   int,  1149]
-[ oid,   int,  1149]
-[ oid,   int,  1149]
-[ oid,   int,  1149]
-[ oid,   int,  3168]
-[ oid,   int,  3168]
-[ oid,   int,  3168]
-[ oid,   int,  3168]
-[ oid,   int,  3168]
+[ oid,   int,  299 ]
+[ oid,   int,  299 ]
+[ oid,   int,  299 ]
+[ oid,   int,  299 ]
+[ oid,   int,  299 ]
+[ oid,   int,  1148]
+[ oid,   int,  1148]
+[ oid,   int,  1148]
+[ oid,   int,  1148]
+[ oid,   int,  3163]
+[ oid,   int,  3163]
+[ oid,   int,  3163]
+[ 

MonetDB: default - tst1506: tests make sense only when stable ou...

2012-07-18 Thread Stefan Manegold
Changeset: 3db36d029a10 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3db36d029a10
Modified Files:
monetdb5/mal/Tests/tst1506.stable.err
monetdb5/mal/Tests/tst1506.stable.out
Branch: default
Log Message:

tst1506: tests make sense only when stable output is correct ...

Fixed (IMHO) expected stable output,
and in particular removed Assertion message,
which must never be approved as correct stable output!


diffs (75 lines):

diff --git a/monetdb5/mal/Tests/tst1506.stable.err 
b/monetdb5/mal/Tests/tst1506.stable.err
--- a/monetdb5/mal/Tests/tst1506.stable.err
+++ b/monetdb5/mal/Tests/tst1506.stable.err
@@ -24,9 +24,6 @@ stderr of test 'tst1506` in directory 'm
 # cmdline opt  monet_prompt = 
 # cmdline opt  mal_listing = 2
 # cmdline opt  gdk_dbname = mTests_mal
-mserver5: /export/scratch1/mk/current//package/gdk/gdk_bat.c:2903: 
BATassertHeadProps: Assertion `!b-H-revsorted || cmp = 0' failed.
-
-Aborted
 
 # 13:51:17   
 # 13:51:17   Done.
diff --git a/monetdb5/mal/Tests/tst1506.stable.out 
b/monetdb5/mal/Tests/tst1506.stable.out
--- a/monetdb5/mal/Tests/tst1506.stable.out
+++ b/monetdb5/mal/Tests/tst1506.stable.out
@@ -146,12 +146,12 @@ end main;
 # void bit str   # type
 #-#
 [ 0@0,   true,   hello ]
-[ 2@0,   nil,nil ]
-#-#
+[ 2@0,   nil,nil ]
+#-#
 # ht   t # name
 # void bit str   # type
-#-#
-[ 0@0,   true,   moon  ]
+#-#
+[ 0@0,   true,   moon  ]
 [ 2@0,   nil,nil ]
 #-#
 # ht   t # name
@@ -159,7 +159,41 @@ end main;
 #-#
 [ 0@0,   true,   hello ]
 [ 1@0,   false,  NEW   ]
+[ 2@0,   nil,nil ]
+#-#
+# ht   t # name
+# void bit str   # type
+#-#
+[ 0@0,   true,   hello ]
+[ 1@0,   false,  unknown   ]
 [ 2@0,   nil,nil ]
+#-#
+# ht   t # name
+# void bit str   # type
+#-#
+[ 0@0,   true,   unknown   ]
+[ 1@0,   false,  NEW   ]
+[ 2@0,   nil,nil ]
+#-#
+# ht   t # name
+# void bit bit   # type
+#-#
+[ 0@0,   true,   false   ]
+[ 2@0,   nil,nil ]
+#-#
+# ht   t   t # name
+# void bit bit bit   # type
+#-#
+[ 0@0,   true,   true,   true]
+[ 1@0,   false,  false,  true]
+[ 2@0,   nil,nil,nil ]
+#-#
+# ht   t # name
+# void bit int   # type
+#-#
+[ 0@0,   true,   1   ]
+[ 1@0,   false,  2   ]
+[ 2@0,   nil,nil ]
 
 # 13:51:17   
 # 13:51:17   Done.
___
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - More steps towards columns.

2012-07-18 Thread Niels Nes
Changeset: 8cb9aaea0019 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8cb9aaea0019
Modified Files:
clients/examples/C/sample2.c
sql/backends/monet5/sql_gencode.c
sql/server/bin_optimizer.c
sql/server/rel_bin.c
sql/server/sql_rel2bin.c
sql/server/sql_statement.c
sql/server/sql_statement.h
Branch: default
Log Message:

More steps towards columns.
use of semijoin/diff is split in intersect/difference and tintersect/tdifference


diffs (truncated from 855 to 300 lines):

diff --git a/clients/examples/C/sample2.c b/clients/examples/C/sample2.c
--- a/clients/examples/C/sample2.c
+++ b/clients/examples/C/sample2.c
@@ -40,6 +40,7 @@ main(int argc, char **argv)
int age = 0;
char *parm[] = { peter, 0 };
char *parm2[] = { 25, 0 };
+   char *parm3[] = { peter, 25, 0 };
Mapi dbh= NULL;
MapiHdl hdl = NULL;
 
@@ -61,7 +62,7 @@ main(int argc, char **argv)
die(dbh, hdl);
if (mapi_close_handle(hdl) != MOK)
die(dbh, hdl);
-   if ((hdl = mapi_query_array(dbh, insert into emp values('?', 
?), parm)) == NULL || mapi_error(dbh))
+   if ((hdl = mapi_query_array(dbh, insert into emp values('?', 
?), parm3)) == NULL || mapi_error(dbh))
die(dbh, hdl);
if (mapi_close_handle(hdl) != MOK)
die(dbh, hdl);
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -588,6 +588,19 @@ dump_2(backend *sql, MalBlkPtr mb, stmt 
s-nr = _dump_2(mb, mod, name, o1, o2);
 }
 
+static void
+dump_2_(backend *sql, MalBlkPtr mb, stmt *s, char *mod, char *name)
+{
+   InstrPtr q;
+   int o1 = _dumpstmt(sql, mb, s-op1);
+   int o2 = _dumpstmt(sql, mb, s-op2);
+
+   q = newStmt1(mb, mod, name);
+   q = pushArgument(mb, q, o1);
+   q = pushArgument(mb, q, o2);
+   s-nr = getDestVar(q);
+}
+
 static InstrPtr
 multiplex2(MalBlkPtr mb, char *mod, char *name /* should be eaten */, int o1, 
int o2, int rtype)
 {
@@ -1275,7 +1288,15 @@ _dumpstmt(backend *sql, MalBlkPtr mb, st
case st_joinN:
s-nr = dump_joinN(sql, mb, s);
break;
-   case st_semijoin:{
+   case st_tinter:{
+   dump_2_(sql, mb, s, algebraRef, tintersect);
+   }
+   break;
+   case st_tdiff:{
+   dump_2_(sql, mb, s, algebraRef, tdifference);
+   }
+   break;
+   case st_inter:{
dump_2(sql, mb, s, algebraRef, semijoinRef);
}
break;
diff --git a/sql/server/bin_optimizer.c b/sql/server/bin_optimizer.c
--- a/sql/server/bin_optimizer.c
+++ b/sql/server/bin_optimizer.c
@@ -38,12 +38,12 @@ stmt_uselect_select(stmt *s)
 }
 
 static stmt *
-eliminate_semijoin(sql_allocator *sa, stmt *s)
+eliminate_inter(sql_allocator *sa, stmt *s)
 {
stmt *s1, *s2;
sql_column *bc1, *bc2;
 
-   assert(s-type == st_semijoin);
+   assert(s-type == st_inter);
s1 = s-op1;
s2 = s-op2;
bc1 = basecolumn(s1);
@@ -53,7 +53,7 @@ eliminate_semijoin(sql_allocator *sa, st
int match2 = (PSEL(s2) || RSEL(s2));
 
if (match1  match2) {
-   /* semijoin( select(x,..), select(x,..) ) */
+   /* intersect( select(x,..), select(x,..) ) */
int swap = 0;
 
if (PSEL(s1)  s1-flag == cmp_equal) {
@@ -87,7 +87,7 @@ eliminate_semijoin(sql_allocator *sa, st
s1 = stmt_uselect_select(s1);
}
} else if (match1) {
-   /* semijoin( select(x,..), f(x) )  =  semijoin( f(x), 
select(x,..) ) */
+   /* intersect( select(x,..), f(x) )  =  intersect( 
f(x), select(x,..) ) */
stmt *os;
int m;
 
@@ -99,18 +99,18 @@ eliminate_semijoin(sql_allocator *sa, st
s2 = os;
}
if (match2  0) {
-   /* semijoin( f(x), select(x,..) )  =  select( f(x), .. 
) */
+   /* intersect( f(x), select(x,..) )  =  select( f(x), 
.. ) */
stmt *ns = NULL;
 
switch (s2-type) {
case st_select:
case st_uselect:
-   /* uselect = select  as semijoin also 
propagates the left input's tail */
+   /* uselect = select  as intersect also 
propagates the left input's tail */
ns = stmt_select(sa, s1, s2-op2, (comp_type)