Changeset: 8d39fb1b000d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8d39fb1b000d
Modified Files:
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_group.c
        gdk/gdk_unique.c
Branch: default
Log Message:

Shorten filename for temporary hash heap.
MT_getpid() potentially returns a large value that needs up to 19
positions, together with maximum of 17 positions and the string
".hash", that is too much to fit in 32 bytes.  THRgetpid returns an
integer that is at most THREADS (1024), so only requires up to 4
positions.  And it's still unique per thread.


diffs (48 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -2180,7 +2180,7 @@ BATassertProps(BAT *b)
                                goto abort_check;
                        }
                        snprintf(hp->filename, sizeof(hp->filename),
-                                "%s.hash" SZFMT, nme, MT_getpid());
+                                "%s.hash%d", nme, THRgettid());
                        ext = GDKstrdup(hp->filename + nmelen + 1);
                        if (ATOMsize(b->ttype) == 1)
                                mask = 1 << 8;
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1120,7 +1120,7 @@ BATkeyed(BAT *b)
                        }
                        if ((hp = GDKzalloc(sizeof(Heap))) == NULL ||
                            snprintf(hp->filename, sizeof(hp->filename),
-                                    "%s.hash" SZFMT, nme, MT_getpid()) < 0 ||
+                                    "%s.hash%d", nme, THRgettid()) < 0 ||
                            (ext = GDKstrdup(hp->filename + nmelen + 1)) == 
NULL ||
                            (hs = HASHnew(hp, b->ttype, BUNlast(b), mask, 
BUN_NONE)) == NULL) {
                                if (hp) {
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -1119,7 +1119,7 @@ BATgroup_internal(BAT **groups, BAT **ex
                if ((hp = GDKzalloc(sizeof(Heap))) == NULL ||
                    (hp->farmid = BBPselectfarm(TRANSIENT, b->ttype, hashheap)) 
< 0 ||
                    snprintf(hp->filename, sizeof(hp->filename),
-                            "%s.hash" SZFMT, nme, MT_getpid()) < 0 ||
+                            "%s.hash%d", nme, THRgettid()) < 0 ||
                    (ext = GDKstrdup(hp->filename + nmelen + 1)) == NULL ||
                    (hs = HASHnew(hp, b->ttype, BUNlast(b),
                                  mask, BUN_NONE)) == NULL) {
diff --git a/gdk/gdk_unique.c b/gdk/gdk_unique.c
--- a/gdk/gdk_unique.c
+++ b/gdk/gdk_unique.c
@@ -315,7 +315,7 @@ BATunique(BAT *b, BAT *s)
                }
                if ((hp = GDKzalloc(sizeof(Heap))) == NULL ||
                    snprintf(hp->filename, sizeof(hp->filename),
-                            "%s.hash" SZFMT, nme, MT_getpid()) < 0 ||
+                            "%s.hash%d", nme, THRgettid()) < 0 ||
                    (ext = GDKstrdup(hp->filename + nmelen + 1)) == NULL ||
                    (hs = HASHnew(hp, b->ttype, BUNlast(b), mask, BUN_NONE)) == 
NULL) {
                        GDKfree(hp);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to