Changeset: 36a5410bc62c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=36a5410bc62c
Added Files:
monetdb5/extras/crackers/crackers_selectstpl_ops.mx
Modified Files:
monetdb5/extras/crackers/Makefile.ag
monetdb5/extras/crackers/crackers.mx
Branch: holindex
Log Message:
Start implementing thread-safe stochastic cracking.
diffs (truncated from 1345 to 300 lines):
diff --git a/monetdb5/extras/crackers/Makefile.ag
b/monetdb5/extras/crackers/Makefile.ag
--- a/monetdb5/extras/crackers/Makefile.ag
+++ b/monetdb5/extras/crackers/Makefile.ag
@@ -43,6 +43,7 @@ lib_crackers = {
crackers_holisticsideways.c \
crackers_holisticsideways.h \
crackers_selectst_ops.mx \
+ crackers_selectstpl_ops.mx \
crackers_selecthol_ops.mx \
crackers_selectholst_ops.mx \
crackers_selectholpl_ops.mx \
diff --git a/monetdb5/extras/crackers/crackers.mx
b/monetdb5/extras/crackers/crackers.mx
--- a/monetdb5/extras/crackers/crackers.mx
+++ b/monetdb5/extras/crackers/crackers.mx
@@ -298,8 +298,6 @@ comment "Retrieve the subset using a cra
nthreads < 0 -> 1st (inferior) version of new multi-threaded
implementation,
nthreads > 0 -> 2nd (superior) version of new multi-threaded
implementation.";
-#
-
command parallelselect(b:bat[:oid,:@2],l:@2,h:@2,li:bit,hi:bit):bat[:oid,:@2]
address CRKparallelselectBounds_@2
comment "Retrieve the subset using a cracker
@@ -351,6 +349,45 @@ address CRKthetaselectst_@2
comment "Retrieve the subset using a cracker
index producing preferably a BATview.";
+command selectstpl(b:bat[:oid,:@2],l:@2,h:@2):bat[:oid,:@2]
+address CRKselectstpl_@2
+comment "Retrieve the subset using a cracker
+ index producing preferably a BATview.";
+
+command selectstpl(b:bat[:oid,:@2],l:@2):bat[:oid,:@2]
+address CRKselectstplValue_@2
+comment "Retrieve the subset using a cracker
+ index producing preferably a BATview.";
+
+command selectstpl(b:bat[:oid,:@2],l:@2,h:@2,li:bit,hi:bit):bat[:oid,:@2]
+address CRKselectstplBounds_@2
+comment "Retrieve the subset using a cracker
+ index producing preferably a BATview.";
+
+command uselectstpl(b:bat[:any_1,:@2],l:@2,h:@2):bat[:any_1,:void]
+address CRKuselectstpl_@2
+comment "Retrieve the subset using a cracker
+ index producing preferably a BATview.";
+
+command uselectstpl(b:bat[:any_1,:@2],l:@2):bat[:any_1,:void]
+address CRKuselectstplValue_@2
+comment "Retrieve the subset using a cracker
+ index producing preferably a BATview.";
+
+command
uselectstpl(b:bat[:any_1,:@2],l:@2,h:@2,li:bit,hi:bit):bat[:any_1,:void]
+address CRKuselectstplBounds_@2
+comment "Retrieve the subset using a cracker
+ index producing preferably a BATview.";
+
+command thetauselectstpl(b:bat[:any_1,:@2],v:@2,op:str):bat[:any_1,:void]
+address CRKthetauselectstpl_@2
+comment "Retrieve the subset using a cracker
+ index producing preferably a BATview.";
+
+command thetaselectstpl(b:bat[:any_1,:@2],v:@2,op:str):bat[:any_1,:@2]
+address CRKthetaselectstpl_@2
+comment "Retrieve the subset using a cracker
+ index producing preferably a BATview.";
command selecthol(b:bat[:oid,:@2],l:@2,h:@2):bat[:oid,:@2]
address CRKselecthol_@2
@@ -986,6 +1023,7 @@ comment "Calculate aggregate sum of rang
#include "crackers_select_ops.h"
#include "crackers_parallelselect_ops.h"
#include "crackers_selectst_ops.h"
+#include "crackers_selectstpl_ops.h"
#include "crackers_selecthol_ops.h"
#include "crackers_selectholst_ops.h"
#include "crackers_selectholpl_ops.h"
diff --git a/monetdb5/extras/crackers/crackers_selectstpl_ops.mx
b/monetdb5/extras/crackers/crackers_selectstpl_ops.mx
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/crackers/crackers_selectstpl_ops.mx
@@ -0,0 +1,1263 @@
+@/
+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-2013 MonetDB B.V.
+All Rights Reserved.
+@
+
+@f crackers_selectstpl_ops
+
+@c
+/*
+ * @a Martin Kersten, Stratos Idreos, Stefan Manegold
+ * @d March 2006 - July 2007
+ * @* Select Operators
+ *
+ *
+ * @+ Interface
+ *
+ *
+ * @- Type expansion
+ */
+@= TypeSwitch
+@:@1(sht,simple,,sht)@
+@:@1(int,simple,,int)@
+@:@1(lng,simple,,lng)@
+@:@1(flt,simple,,flt)@
+@:@1(dbl,simple,,dbl)@
+@:@1(date,atom,TYPE_,loc)@
+@
+@h
+/*
+ * @- Header file
+ */
+#ifndef _CRACKERS_SELECTSTPL_H_
+#define _CRACKERS_SELECTSTPL_H_
+
+/* Exported signatures */
+@:TypeSwitch(SelectstplFunctions_decl)@
+
+#endif /* _CRACKERS_SELECTSTPL_H */
+/*
+ * @- Exported signatures
+ */
+@= SelectstplFunctions_decl
+crackers_export str CRKselectstplBounds_@1(int *vid, int *bid, @1 *low, @1
*hgh, bit *inclusiveLow, bit *inclusiveHgh);
+crackers_export str CRKuselectstplBounds_@1(int *vid, int *bid, @1 *low, @1
*hgh, bit *inclusiveLow, bit *inclusiveHgh);
+crackers_export str CRKselectstplValue_@1(int *vid, int *bid, @1 *value);
+crackers_export str CRKuselectstplValue_@1(int *vid, int *bid, @1 *value);
+crackers_export str CRKselectstpl_@1(int *vid, int *bid, @1 *low, @1 *hgh);
+crackers_export str CRKuselectstpl_@1(int *vid, int *bid, @1 *low, @1 *hgh);
+crackers_export str CRKthetaselectstpl_@1(int *vid, int *bid, @1 *val, str
*op);
+crackers_export str CRKthetauselectstpl_@1(int *vid, int *bid, @1 *val, str
*op);
+@
+@c
+/*
+ * @+ Implementation
+ *
+ *
+ * @- C file
+ */
+#include "monetdb_config.h"
+#include "crackers.h"
+
+/*This function picks randomly 5 oids and their respective values and then
chooses the median*/
+@= FndMedian
+ static @1 FndMedian_@1(BAT *c,oid a,oid b)
+ {
+ @1 *t;
+ @1 arr[5]={0,0,0,0,0};
+ int i, j, k;
+ @1 temp;
+
+ oid p;
+ int cnt=0;
+ t=(@1 *)Tloc(c,BUNfirst(c));
+ for(cnt=0;cnt<5;cnt++)
+ {
+ p=(rand()%(b-a+1))+a;
+ arr[cnt]=t[p];
+ }
+ for ( i = 1 ; i <= 4 ; i++ )
+ {
+ for ( j = 0 ; j < i ; j++ )
+ {
+ if ( arr[j] > arr[i] )
+ {
+ temp = arr[j] ;
+ arr[j] = arr[i] ;
+
+ for ( k = i ; k > j ; k-- )
+ arr[k] = arr[k - 1] ;
+
+ arr[k + 1] = temp ;
+ }
+ }
+ }
+
+ return arr[2];
+ }
+@c
+
+@:TypeSwitch(FndMedian)@
+
+
+/* Local support functions and macros */
+@:TypeSwitch(crackOperations)@
+
+/* Exported functions */
+@:TypeSwitch(SelectstplFunctions_impl)@
+/*
+ * @- Exported functions
+ */
+@= SelectstplFunctions_impl
+
+str
+CRKselectstplBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit
*inclusiveLow, bit *inclusiveHgh){
+ if (@2_EQ(low,ATOMnilptr(TYPE_@1),@3@1))
+ return CRKRangeLeftNilTree_@1(vid, bid, hgh, inclusiveHgh,
TRUE);
+ else if (@2_EQ(hgh,ATOMnilptr(TYPE_@1),@3@1))
+ return CRKRangeRightNilTree_@1(vid, bid, low, inclusiveLow,
TRUE);
+ else
+ return CRKRangeTree_@1(vid, bid, low, hgh, inclusiveLow,
inclusiveHgh, TRUE);
+}
+
+str
+CRKuselectstplBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit
*inclusiveLow, bit *inclusiveHgh){
+ if (@2_EQ(low,ATOMnilptr(TYPE_@1),@3@1))
+ return CRKRangeLeftNilTree_@1(vid, bid, hgh, inclusiveHgh,
FALSE);
+ else if (@2_EQ(hgh,ATOMnilptr(TYPE_@1),@3@1))
+ return CRKRangeRightNilTree_@1(vid, bid, low, inclusiveLow,
FALSE);
+ else
+ return CRKRangeTree_@1(vid, bid, low, hgh, inclusiveLow,
inclusiveHgh, FALSE);
+}
+
+str
+CRKselectstplValue_@1(int *vid, int *bid, @1 *value){
+ bit inclusive = TRUE;
+ return CRKuselectstplBounds_@1(vid, bid, value, value, &inclusive,
&inclusive);
+}
+
+str
+CRKuselectstplValue_@1(int *vid, int *bid, @1 *value){
+ bit inclusive = TRUE;
+ return CRKuselectstplBounds_@1(vid, bid, value, value, &inclusive,
&inclusive);
+}
+
+str
+CRKselectstpl_@1(int *vid, int *bid, @1 *low, @1 *hgh){
+ bit inclusive = TRUE;
+ return CRKselectstplBounds_@1(vid, bid, low, hgh, &inclusive,
&inclusive);
+}
+
+str
+CRKuselectstpl_@1(int *vid, int *bid, @1 *low, @1 *hgh){
+ bit inclusive = TRUE;
+ return CRKuselectstplBounds_@1(vid, bid, low, hgh, &inclusive,
&inclusive);
+}
+
+str
+CRKthetaselectstpl_@1(int *vid, int *bid, @1 *val, str *OP){
+ ptr nilptr = ATOMnilptr(TYPE_@1);
+ char *op = *OP;
+ bit lin = TRUE, rin = TRUE;
+ @1 *low = nilptr, *high = nilptr;
+
+ if (op[0] == '=') {
+ low = val;
+ high = NULL;
+ } else if (op[0] == '<') {
+ high = val;
+ rin = (op[1] == '=');
+ } else if (op[0] == '>') {
+ low = val;
+ lin = (op[1] == '=');
+ } else {
+ throw(MAL, "crackers.thetaselectstpl", "unknown operator");
+ }
+
+ return CRKselectstplBounds_@1(vid, bid, low, high, &lin, &rin);
+}
+
+str
+CRKthetauselectstpl_@1(int *vid, int *bid, @1 *val, str *OP){
+ ptr nilptr = ATOMnilptr(TYPE_@1);
+ char *op = *OP;
+ bit lin = TRUE, rin = TRUE;
+ @1 *low = nilptr, *high = nilptr;
+
+ if (op[0] == '=') {
+ low = val;
+ } else if (op[0] == '<') {
+ high = val;
+ rin = (op[1] == '=');
+ } else if (op[0] == '>') {
+ low = val;
+ lin = (op[1] == '=');
+ } else {
+ throw(MAL, "crackers.thetauselectstpl", "unknown operator");
+ }
+
+ return CRKuselectstplBounds_@1(vid, bid, low, high, &lin, &rin);
+}
+
+@
+ * @- Local support functions and macros
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list