Changeset: dbe605ad1e20 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dbe605ad1e20
Modified Files:
gdk/gdk_heap.c
gdk/gdk_posix.c
monetdb5/modules/mal/tablet.c
sql/backends/monet5/UDF/udf.c
sql/backends/monet5/UDF/udf_impl.h
Branch: SciQL-2
Log Message:
Merge with Feb2013 branch.
diffs (truncated from 311 to 300 lines):
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -344,6 +344,7 @@ int
HEAPextend(Heap *h, size_t size)
{
char nme[PATHLENGTH], *ext = NULL;
+ char *failure = "None";
if (h->filename) {
strncpy(nme, h->filename, sizeof(nme));
@@ -352,6 +353,8 @@ HEAPextend(Heap *h, size_t size)
}
if (size <= h->size)
return 0;
+ else
+ failure = "size > h->size";
if (h->storage != STORE_MEM) {
char *p;
@@ -370,6 +373,8 @@ HEAPextend(Heap *h, size_t size)
h->maxsize = h->size = size;
h->base = p;
return 0;
+ } else {
+ failure = "MT_mremap() failed";
}
} else {
/* extend a malloced heap, possibly switching over to
@@ -395,6 +400,8 @@ HEAPextend(Heap *h, size_t size)
HEAPDEBUG fprintf(stderr, "#HEAPextend: extending
malloced heap " SZFMT " " SZFMT " " PTRFMT " " PTRFMT "\n", size, h->size,
PTRFMTCAST p, PTRFMTCAST h->base);
if (h->base)
return 0;
+ else
+ failure = "h->storage == STORE_MEM && !must_map
&& !h->base";
}
/* too big: convert it to a disk-based temporary heap */
if (can_mmap) {
@@ -417,8 +424,10 @@ HEAPextend(Heap *h, size_t size)
* to use a file from the cache (or
* create a new one) */
h->filename = GDKmalloc(strlen(nme) +
strlen(ext) + 2);
- if (h->filename == NULL)
+ if (h->filename == NULL) {
+ failure = "h->storage == STORE_MEM &&
can_map && h->filename == NULL";
goto failed;
+ }
sprintf(h->filename, "%s.%s", nme, ext);
h->base = HEAPcacheFind(&h->size, h->filename,
STORE_MMAP);
if (h->base) {
@@ -427,6 +436,8 @@ HEAPextend(Heap *h, size_t size)
memcpy(h->base, bak.base, bak.free);
HEAPfree(&bak);
return 0;
+ } else {
+ failure = "h->storage == STORE_MEM &&
can_map && !h->base";
}
}
fd = GDKfdlocate(nme, "wb", ext);
@@ -449,11 +460,15 @@ HEAPextend(Heap *h, size_t size)
memcpy(h->base, bak.base, bak.free);
HEAPfree(&bak);
return 0;
+ } else {
+ failure = "h->storage == STORE_MEM &&
can_map && fd >= 0 && HEAPload() < 0";
}
/* couldn't allocate, now first save
* data to file */
- if (HEAPsave_intern(&bak, nme, ext, ".tmp") < 0)
+ if (HEAPsave_intern(&bak, nme, ext, ".tmp") <
0) {
+ failure = "h->storage == STORE_MEM &&
can_map && fd >= 0 && HEAPsave_intern() < 0";
goto failed;
+ }
/* then free memory */
HEAPfree(&bak);
/* and load heap back in via
@@ -462,15 +477,21 @@ HEAPextend(Heap *h, size_t size)
/* success! */
GDKclrerr(); /* don't leak errors
from e.g. HEAPload */
return 0;
+ } else {
+ failure = "h->storage == STORE_MEM &&
can_map && fd >= 0 && HEAPload_intern() < 0";
}
/* we failed */
+ } else {
+ failure = "h->storage == STORE_MEM && can_map
&& fd < 0";
}
+ } else {
+ failure = "h->storage == STORE_MEM && !can_map";
}
failed:
*h = bak;
}
- GDKerror("HEAPextend: failed to extend to " SZFMT " for %s%s%s\n",
- size, nme, ext ? "." : "", ext ? ext : "");
+ GDKerror("HEAPextend: failed to extend to " SZFMT " for %s%s%s: %s\n",
+ size, nme, ext ? "." : "", ext ? ext : "", failure);
return -1;
}
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -412,8 +412,10 @@ MT_mremap(const char *path, int mode, vo
if (*new_size < old_size) {
/* shrink */
if (munmap((char *) old_address + *new_size,
- old_size - *new_size) < 0)
+ old_size - *new_size) < 0) {
+ fprintf(stderr, "= %s:%d:
MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): munmap() failed\n", __FILE__, __LINE__,
path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size);
return NULL;
+ }
if (truncate(path, (off_t) *new_size) < 0)
fprintf(stderr, "#MT_mremap(%s): truncate failed\n",
path);
#ifdef MMAP_DEBUG
@@ -433,11 +435,14 @@ MT_mremap(const char *path, int mode, vo
/* "normal" memory map */
struct stat stb;
- if ((fd = open(path, O_RDWR)) < 0)
+ if ((fd = open(path, O_RDWR)) < 0) {
+ fprintf(stderr, "= %s:%d:
MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): open() failed\n", __FILE__, __LINE__,
path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size);
return NULL;
+ }
if (fstat(fd, &stb) < 0) {
/* shouldn't happen */
close(fd);
+ fprintf(stderr, "= %s:%d:
MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): fstat() failed\n", __FILE__, __LINE__,
path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size);
return NULL;
}
/* if necessary, extend the underlying file */
@@ -445,6 +450,7 @@ MT_mremap(const char *path, int mode, vo
(lseek(fd, *new_size - 1, SEEK_SET) < 0 ||
write(fd, "\0", 1) < 0)) {
close(fd);
+ fprintf(stderr, "= %s:%d:
MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): lseek() or write() failed\n", __FILE__,
__LINE__, path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size);
return NULL;
}
#ifdef HAVE_MREMAP
@@ -483,8 +489,10 @@ MT_mremap(const char *path, int mode, vo
#ifdef MAP_ANONYMOUS
flags |= MAP_ANONYMOUS;
#else
- if ((fd = open("/dev/zero", O_RDWR)) < 0)
+ if ((fd = open("/dev/zero", O_RDWR)) < 0) {
+ fprintf(stderr, "= %s:%d:
MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): open('/dev/zero') failed\n", __FILE__,
__LINE__, path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size);
return NULL;
+ }
#endif
/* try to map an anonymous area as extent to the
* current map */
@@ -548,14 +556,17 @@ MT_mremap(const char *path, int mode, vo
fd = open(p, O_RDWR | O_CREAT,
MONETDB_MODE);
free(p);
- if (fd < 0)
+ if (fd < 0) {
+ fprintf(stderr, "= %s:%d:
MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): fd < 0\n", __FILE__, __LINE__,
path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size);
return NULL;
+ }
if (write(fd, old_address,
old_size) < 0 ||
lseek(fd, *new_size - 1,
SEEK_SET) < 0 ||
write(fd, "\0", 1) < 0) {
close(fd);
+ fprintf(stderr, "= %s:%d:
MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): write() or lseek() or write()
failed\n", __FILE__, __LINE__, path?path:"NULL", PTRFMTCAST old_address,
old_size, *new_size);
return NULL;
}
p = mmap(NULL, *new_size, prot, flags,
@@ -572,6 +583,8 @@ MT_mremap(const char *path, int mode, vo
#ifdef MMAP_DEBUG
fprintf(stderr, "MT_mremap(%s,"PTRFMT","SZFMT","SZFMT") ->
"PTRFMT"%s\n", path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size,
PTRFMTCAST p, path && mode & MMAP_COPY ? " private" : "");
#endif
+ if (p == MAP_FAILED)
+ fprintf(stderr, "= %s:%d:
MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): p == MAP_FAILED\n", __FILE__, __LINE__,
path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size);
return p == MAP_FAILED ? NULL : p;
}
@@ -783,8 +796,10 @@ MT_mremap(const char *path, int mode, vo
*new_size = old_size;
return old_address; /* don't bother shrinking */
}
- if (GDKextend(path, *new_size) < 0)
+ if (GDKextend(path, *new_size) < 0) {
+ fprintf(stderr, "= %s:%d:
MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): GDKextend() failed\n", __FILE__,
__LINE__, path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size);
return NULL;
+ }
if (path && !(mode & MMAP_COPY))
MT_munmap(old_address, old_size);
p = MT_mmap(path, mode, *new_size);
@@ -795,6 +810,8 @@ MT_mremap(const char *path, int mode, vo
#ifdef MMAP_DEBUG
fprintf(stderr, "MT_mremap(%s,"PTRFMT","SZFMT","SZFMT") -> "PTRFMT"\n",
path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size, PTRFMTCAST p);
#endif
+ if (p == NULL)
+ fprintf(stderr, "= %s:%d:
MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): p == NULL\n", __FILE__, __LINE__,
path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size);
return p;
}
diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -1064,8 +1064,8 @@ SQLinsert_val(Column *fmt, char *s, char
bunins_failed:
if (*err == NULL) {
snprintf(buf, BUFSIZ,
- "parsing error from line " BUNFMT " field %d
not inserted\n",
- BATcount(fmt->c[0]) + 1, col);
+ "value from line " BUNFMT " field %d not
inserted: %s\n",
+ BATcount(fmt->c[0]) + 1, col, GDKerrbuf);
*err = GDKstrdup(buf);
}
return -1;
diff --git a/sql/backends/monet5/UDF/udf.c b/sql/backends/monet5/UDF/udf.c
--- a/sql/backends/monet5/UDF/udf.c
+++ b/sql/backends/monet5/UDF/udf.c
@@ -254,15 +254,15 @@ UDFBATfuse_(BAT **ret, const BAT *bone,
switch (bone->ttype) {
case TYPE_bte:
msg = UDFBATfuse_bte_sht ( bres, bone, btwo, n,
- &two_tail_sorted_unsigned, &two_tail_revsorted_unsigned
);
+ &two_tail_sorted_unsigned, &two_tail_revsorted_unsigned
);
break;
case TYPE_sht:
msg = UDFBATfuse_sht_int ( bres, bone, btwo, n,
- &two_tail_sorted_unsigned, &two_tail_revsorted_unsigned
);
+ &two_tail_sorted_unsigned, &two_tail_revsorted_unsigned
);
break;
case TYPE_int:
msg = UDFBATfuse_int_lng ( bres, bone, btwo, n,
- &two_tail_sorted_unsigned, &two_tail_revsorted_unsigned
);
+ &two_tail_sorted_unsigned, &two_tail_revsorted_unsigned
);
break;
default:
BBPreleaseref(bres->batCacheid);
diff --git a/sql/backends/monet5/UDF/udf_impl.h
b/sql/backends/monet5/UDF/udf_impl.h
--- a/sql/backends/monet5/UDF/udf_impl.h
+++ b/sql/backends/monet5/UDF/udf_impl.h
@@ -41,7 +41,7 @@
static char *
UF(UDFfuse_,UI,UO,_) ( UO *ret , UI one , UI two )
{
- int shift = sizeof(UI) * 8;
+ int shift = sizeof(UI) * 8;
/* assert calling sanity */
assert(ret != NULL);
@@ -71,16 +71,37 @@ UF(UDFfuse_,UI,UO,) ( UO *ret , const UI
* accessing value arrays directly.
*/
-/* type-specific core algorithm */
+/* type-specific core algorithm on arrays */
+static char *
+UF(UDFarrayfuse_,UI,UO,) ( UO *res, const UI *one, const UI *two, BUN n )
+{
+ BUN i;
+ int shift = sizeof(UI) * 8;
+
+ /* assert calling sanity */
+ assert(res != NULL && one != NULL && two != NULL);
+
+ /* iterate over all values/tuples and do the work */
+ for (i = 0; i < n; i++)
+ if (one[i] == UN(UI) || two[i] == UN(UI))
+ /* NULL/nil in => NULL/nil out */
+ res[i] = UN(UO);
+ else
+ /* do the work; watch out for sign bits */
+ res[i] = ((UO) (UU) one[i] << shift) | (UU) two[i];
+
+ return MAL_SUCCEED;
+}
+
+/* type-specific core algorithm on BATs */
static char *
UF(UDFBATfuse_,UI,UO,) ( const BAT *bres, const BAT *bone, const BAT *btwo,
BUN n,
- bit *two_tail_sorted_unsigned,
- bit *two_tail_revsorted_unsigned )
+ bit *two_tail_sorted_unsigned,
+ bit *two_tail_revsorted_unsigned )
{
UI *one = NULL, *two = NULL;
UO *res = NULL;
- BUN i;
- int shift = sizeof(UI) * 8;
+ str msg = NULL;
/* assert calling sanity */
assert(bres != NULL && bone != NULL && btwo != NULL);
@@ -93,14 +114,11 @@ UF(UDFBATfuse_,UI,UO,) ( const BAT *bre
one = (UI*) Tloc(bone, BUNfirst(bone));
two = (UI*) Tloc(btwo, BUNfirst(btwo));
res = (UO*) Tloc(bres, BUNfirst(bres));
- /* iterate over all values/tuples and do the work */
- for (i = 0; i < n; i++)
- if (one[i] == UN(UI) || two[i] == UN(UI))
- /* NULL/nil in => NULL/nil out */
- res[i] = UN(UO);
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list