Changeset: 539559113640 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=539559113640
Modified Files:
monetdb5/extras/sphinx/sphinx.c
monetdb5/extras/sphinx/sphinx.h
monetdb5/extras/sphinx/sphinx.mal
monetdb5/mal/mal_atom.c
monetdb5/mal/mal_linker.c
monetdb5/mal/mal_linker.h
monetdb5/mal/mal_parser.c
monetdb5/mal/mal_type.c
monetdb5/modules/atoms/streams.c
monetdb5/modules/mal/Makefile.ag
monetdb5/modules/mal/mal_init.mal
monetdb5/optimizer/Makefile.ag
sql/backends/monet5/sql.mx
sql/backends/monet5/sql_optimizer.c
sql/backends/monet5/sql_scenario.c
Branch: headless
Log Message:
Merged from default (lots of manual resolution of conflicts)
diffs (truncated from 1386 to 300 lines):
diff --git a/clients/odbc/driver/ODBCConvert.c
b/clients/odbc/driver/ODBCConvert.c
--- a/clients/odbc/driver/ODBCConvert.c
+++ b/clients/odbc/driver/ODBCConvert.c
@@ -29,15 +29,19 @@
#if SIZEOF_INT==8
# define ULL_CONSTANT(val) (val)
# define O_ULLFMT "u"
+# define O_ULLCAST (unsigned int)
#elif SIZEOF_LONG==8
# define ULL_CONSTANT(val) (val##UL)
# define O_ULLFMT "lu"
+# define O_ULLCAST (unsigned long)
#elif defined(HAVE_LONG_LONG)
# define ULL_CONSTANT(val) (val##ULL)
# define O_ULLFMT "llu"
+# define O_ULLCAST (unsigned long long)
#elif defined(HAVE___INT64)
# define ULL_CONSTANT(val) (val##ui64)
# define O_ULLFMT "I64u"
+# define O_ULLCAST (unsigned __int64)
#endif
#define MAXBIGNUM10 ULL_CONSTANT(1844674407370955161) /* (2**64-1)/10
*/
@@ -257,7 +261,9 @@
if (sscanf(data, "{d '%hd-%hu-%hu'}%n", &dval->year, &dval->month,
&dval->day, &n) < 3 &&
sscanf(data, "%hd-%hu-%hu%n", &dval->year, &dval->month,
&dval->day, &n) < 3)
return 0;
- if (dval->month == 0 || dval->month > 12 || dval->day == 0 || dval->day
> monthlengths[dval->month] || (dval->month == 2 && !isLeap(dval->year) &&
dval->day == 29))
+ if (dval->month == 0 || dval->month > 12 ||
+ dval->day == 0 || dval->day > monthlengths[dval->month] ||
+ (dval->month == 2 && !isLeap(dval->year) && dval->day == 29))
return 0;
data += n;
while (space(*data))
@@ -309,7 +315,10 @@
if (sscanf(data, "{TS '%hd-%hu-%hu %hu:%hu:%hu%n", &tsval->year,
&tsval->month, &tsval->day, &tsval->hour, &tsval->minute, &tsval->second, &n) <
6 &&
sscanf(data, "%hd-%hu-%hu %hu:%hu:%hu%n", &tsval->year,
&tsval->month, &tsval->day, &tsval->hour, &tsval->minute, &tsval->second, &n) <
6)
return 0;
- if (tsval->month == 0 || tsval->month > 12 || tsval->day == 0 ||
tsval->day > monthlengths[tsval->month] || (tsval->month == 2 &&
!isLeap(tsval->year) && tsval->day == 29) || tsval->hour > 23 || tsval->minute
> 59 || tsval->second > 61)
+ if (tsval->month == 0 || tsval->month > 12 ||
+ tsval->day == 0 || tsval->day > monthlengths[tsval->month] ||
+ (tsval->month == 2 && !isLeap(tsval->year) && tsval->day == 29) ||
+ tsval->hour > 23 || tsval->minute > 59 || tsval->second > 61)
return 0;
braces = *data == '{';
tsval->fraction = 0;
@@ -1246,7 +1255,7 @@
for (n = 0, f = 1; n < nval.scale; n++)
f *= 10;
- sz = snprintf(data, buflen, "%s%" O_ULLFMT, nval.sign ?
"" : "-", nval.val / f);
+ sz = snprintf(data, buflen, "%s%" O_ULLFMT, nval.sign ?
"" : "-", O_ULLCAST (nval.val / f));
if (sz < 0 || sz >= buflen) {
/* Numeric value out of range */
addStmtError(stmt, "22003", NULL, 0);
@@ -1265,7 +1274,7 @@
if (lenp)
*lenp += nval.scale + 1;
if (buflen > 2)
- sz = (SQLLEN) snprintf(data, buflen,
".%0*" O_ULLFMT, nval.scale, nval.val % f);
+ sz = (SQLLEN) snprintf(data, buflen,
".%0*" O_ULLFMT, nval.scale, O_ULLCAST (nval.val % f));
if (buflen <= 2 || sz < 0 || sz >= buflen) {
data[buflen - 1] = 0;
/* String data, right-truncated */
@@ -2682,10 +2691,10 @@
for (n = 0, f = 1; n < nval.scale; n++)
f *= 10;
- snprintf(data, sizeof(data), "%s%" O_ULLFMT, nval.sign
? "" : "-", nval.val / f);
+ snprintf(data, sizeof(data), "%s%" O_ULLFMT, nval.sign
? "" : "-", O_ULLCAST (nval.val / f));
assigns(buf, bufpos, buflen, data, stmt);
if (nval.scale > 0) {
- snprintf(data, sizeof(data), ".%0*" O_ULLFMT,
nval.scale, nval.val % f);
+ snprintf(data, sizeof(data), ".%0*" O_ULLFMT,
nval.scale, O_ULLCAST (nval.val % f));
assigns(buf, bufpos, buflen, data, stmt);
}
break;
@@ -3197,11 +3206,11 @@
addStmtError(stmt, "22001", NULL, 0);
}
} else {
- snprintf(data, sizeof(data), "%s%" O_ULLFMT,
nval.sign ? "" : "-", nval.val / f);
+ snprintf(data, sizeof(data), "%s%" O_ULLFMT,
nval.sign ? "" : "-", O_ULLCAST (nval.val / f));
assigns(buf, bufpos, buflen, data, stmt);
if (nval.scale > 0) {
if (sqltype == SQL_DECIMAL) {
- snprintf(data, sizeof(data),
".%0*" O_ULLFMT, nval.scale, nval.val % f);
+ snprintf(data, sizeof(data),
".%0*" O_ULLFMT, nval.scale, O_ULLCAST (nval.val % f));
assigns(buf, bufpos, buflen,
data, stmt);
} else {
/* Fractional truncation */
diff --git a/monetdb5/extras/sphinx/sphinx.c b/monetdb5/extras/sphinx/sphinx.c
--- a/monetdb5/extras/sphinx/sphinx.c
+++ b/monetdb5/extras/sphinx/sphinx.c
@@ -20,12 +20,14 @@
/*
* @f sphinx
* @a S.A.M.M. de Konink
- * @v 0.1
+ * @v 0.2
* @* The Sphinx module
* The Sphinx module implements an external full text search engine returning a
* list of identifiers based on a query string and an index to search upon.
*
*/
+
+
#include "monetdb_config.h"
#include "sphinx.h"
#include "mal.h"
@@ -33,11 +35,11 @@
#include "mal_exception.h"
#include <sphinxclient.h>
-/* COMMAND "SPHINXsearchIndex": Search the query on the specified indices
- * SIGNATURE: SPHINXsearchIndex(str, str) : bat[oid,lng]; */
+/* COMMAND "SPHINXsearchIndexLimit": Search the query on the specified
indices, with limit
+ * SIGNATURE: SPHINXsearchIndexLimit(str, str, int) : bat[oid,lng]; */
str
-sphinx_searchIndex(BAT **ret, /* put pointer to BAT[oid,int] record here. */
- str query, str index)
+sphinx_searchIndexLimit(BAT **ret, /* put pointer to BAT[oid,int] record here.
*/
+ str query, str index, int limit)
{
int i;
BAT *bn;
@@ -47,7 +49,9 @@
client = sphinx_create ( SPH_TRUE );
if (client == NULL)
- throw(MAL, "sphinx.searchIndex", "Cannot create Sphinx object");
+ throw(MAL, "sphinx.searchIndexLimit", "Cannot create Sphinx
object");
+
+ sphinx_set_limits ( client, 0, limit, limit, 0 );
res = sphinx_query ( client, query, index, NULL );
if (!res || (res && res->num_matches == 0)) {
@@ -73,10 +77,10 @@
}
str
-SPHINXsearchIndex(int *ret, str *query, str *index)
+SPHINXsearchIndexLimit(int *ret, str *query, str *index, int *limit)
{
BAT *b = NULL;
- str msg = sphinx_searchIndex(&b, *query, *index);
+ str msg = sphinx_searchIndexLimit(&b, *query, *index, *limit);
if (!b)
throw(MAL, "sphinx.searchIndex", "Cannot create Sphinx object");
@@ -85,26 +89,20 @@
return msg;
}
+/* str sphinx_searchIndexLimit(int *ret, str *query, str *index, int *limit);
*/
str
-SPHINXsearch(int *ret, str *query)
-{
- str index = "*";
- return SPHINXsearchIndex(ret, query, &index);
-}
-
-/* str sphinx_searchIndex(int *ret, str *query, str *index); */
-str
-SPHINXsearchIndexWrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+SPHINXsearchIndexLimitWrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci)
{
bat ret;
BAT *t;
int *r = (int *) getArgReference(stk, pci, 0);
str *query = (str *) getArgReference(stk, pci, 1);
str *index = (str *) getArgReference(stk, pci, 2);
+ int *limit = (int *) getArgReference(stk, pci, 3);
(void) cntxt;
(void) mb;
- SPHINXsearchIndex(&ret, query, index);
+ SPHINXsearchIndexLimit(&ret, query, index, limit);
t = BATnew(TYPE_str, TYPE_bat, 1);
BUNins(t, "id", &ret, FALSE);
diff --git a/monetdb5/extras/sphinx/sphinx.h b/monetdb5/extras/sphinx/sphinx.h
--- a/monetdb5/extras/sphinx/sphinx.h
+++ b/monetdb5/extras/sphinx/sphinx.h
@@ -36,9 +36,7 @@
#define sphinx_export extern
#endif
-sphinx_export str SPHINXsearch(int *ret, str *query);
-sphinx_export str SPHINXsearchIndex(int *ret, str *query, str *index);
-sphinx_export str SPHINXsearchIndexWrap(Client cntxt, MalBlkPtr mb, MalStkPtr
stk, InstrPtr pci);
+sphinx_export str SPHINXsearchIndexLimitWrap(Client cntxt, MalBlkPtr mb,
MalStkPtr stk, InstrPtr pci);
#endif /* SPHINX_H */
diff --git a/monetdb5/extras/sphinx/sphinx.mal
b/monetdb5/extras/sphinx/sphinx.mal
--- a/monetdb5/extras/sphinx/sphinx.mal
+++ b/monetdb5/extras/sphinx/sphinx.mal
@@ -17,15 +17,32 @@
module sphinx;
-command search(q:str) :bat[:int,:lng]
-address SPHINXsearch
-comment "Searches the query on all indices";
+command searchIndexLimit(q:str, i:str, l:int) :bat[:oid,:lng]
+address SPHINXsearchIndexLimit
+comment "Search the query on the specified index, with limit";
-command searchIndex(q:str, i:str) :bat[:oid,:lng]
-address SPHINXsearchIndex
-comment "Search the query on the specified indices";
+function search(q:str) :bat[:oid,:lng];
+ ret := searchIndexLimit(q, "*", 20);
+ return ret;
+end search;
-pattern sphinx_searchIndex(q:str, i:str) :bat[:str,:bat]
-address SPHINXsearchIndexWrap
-comment "Searches the query on all indices";
+function searchIndex(q:str, i:str) :bat[:oid,:lng];
+ ret := searchIndexLimit(q, i, 20);
+ return ret;
+end searchIndex;
+
+pattern sphinx_searchIndexLimit(q:str, i:str, l:int) :bat[:str,:bat]
+address SPHINXsearchIndexLimitWrap
+comment "Search the query on the specified index, with limit";
+
+function sphinx_search(q:str) :bat[:str,:bat];
+ ret := sphinx_searchIndexLimit(q, "*", 20);
+ return ret;
+end sphinx_search;
+
+function sphinx_searchIndex(q:str, i:str) :bat[:str,:bat];
+ ret := sphinx_searchIndexLimit(q, i, 20);
+ return ret;
+end sphinx_searchIndex;
+
diff --git a/monetdb5/mal/mal_atom.c b/monetdb5/mal/mal_atom.c
--- a/monetdb5/mal/mal_atom.c
+++ b/monetdb5/mal/mal_atom.c
@@ -93,145 +93,217 @@
#define MAXPATHLEN 1024
#endif
-void setAtomName(InstrPtr pci){
+void setAtomName(InstrPtr pci)
+{
char buf[MAXPATHLEN];
- snprintf(buf,MAXPATHLEN,"#%s", getFunctionId(pci));
- setFunctionId(pci, putName(buf,strlen(buf)));
+ snprintf(buf, MAXPATHLEN, "#%s", getFunctionId(pci));
+ setFunctionId(pci, putName(buf, strlen(buf)));
}
-int malAtomProperty(MalBlkPtr mb, InstrPtr pci){
- str name= getFunctionId(pci);
- int tpe = getTypeIndex(getModuleId(pci), (int)
strlen(getModuleId(pci)), TYPE_any);
- (void) mb; /* fool compilers */
- if( tpe<0 || tpe>= GDKatomcnt)
+int malAtomProperty(MalBlkPtr mb, InstrPtr pci)
+{
+ str name;
+ int tpe;
+ (void)mb; /* fool compilers */
+ assert(pci != 0);
+ name = getFunctionId(pci);
+ tpe = getTypeIndex(getModuleId(pci), (int)strlen(getModuleId(pci)),
TYPE_any);
+ if (tpe < 0 || tpe >= GDKatomcnt)
return 0;
- assert(pci != 0);
- switch(name[0]){
- case 'd':
- if( idcmp("del",name)==0 && pci->argc==1){
- COLatoms[tpe].atomDel= (void (*)(Heap *, var_t *))
pci->fcn;
+ assert(pci->fcn != NULL);
+ switch (name[0]) {
+ case 'd':
+ if (idcmp("del", name) == 0 && pci->argc == 1) {
+ COLatoms[tpe].atomDel = (void (*)(Heap *, var_t
*))pci->fcn;
setAtomName(pci);
return 1;
}
break;
- case 'c':
- if( idcmp("cmp",name)==0 && pci->argc==1){
- COLatoms[tpe].atomCmp= (int (*)(ptr, ptr)) pci->fcn;
- setAtomName(pci);
- return 1;
- }
- if( idcmp("convert",name)==0 && pci->argc==1){
- COLatoms[tpe].atomConvert= (void (*)(ptr, int))
pci->fcn;
- setAtomName(pci);
- return 1;
- }
- break;
- case 'f':
- if( idcmp("fromstr",name)==0 && pci->argc==1){
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list