Changeset: 48db4970b7e1 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=48db4970b7e1
Modified Files:
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_private.h
Branch: default
Log Message:
Merge with Oct2014 branch.
diffs (109 lines):
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1214,6 +1214,11 @@ BUNins(BAT *b, const void *h, const void
return NULL;
}
+ if (unshare_string_heap(b) == GDK_FAIL) {
+ GDKerror("BUNins: failed to unshare string heap\n");
+ return NULL;
+ }
+
ALIGNins(b, "BUNins", force);
b->batDirty = 1;
if (b->H->hash && b->H->vheap)
@@ -1320,6 +1325,11 @@ BUNappend(BAT *b, const void *t, bit for
}
void_materialize(b, t);
+ if (unshare_string_heap(b) == GDK_FAIL) {
+ GDKerror("BUNappend: failed to unshare string heap\n");
+ return NULL;
+ }
+
setcolprops(b, b->H, h);
setcolprops(b, b->T, t);
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -41,6 +41,35 @@
} \
} while (0)
+gdk_return
+unshare_string_heap(BAT *b)
+{
+ if (b->ttype == TYPE_str &&
+ b->T->vheap->parentid != abs(b->batCacheid)) {
+ Heap *h = GDKzalloc(sizeof(Heap));
+ if (h == NULL)
+ return GDK_FAIL;
+ h->parentid = abs(b->batCacheid);
+ h->farmid = BBPselectfarm(b->batRole, TYPE_str, varheap);
+ if (b->T->vheap->filename) {
+ char *nme = BBP_physical(b->batCacheid);
+ h->filename = GDKfilepath(NOFARM, NULL, nme, "theap");
+ if (h->filename == NULL) {
+ GDKfree(h);
+ return GDK_FAIL;
+ }
+ }
+ if (HEAPcopy(h, b->T->vheap) < 0) {
+ HEAPfree(h, 1);
+ GDKfree(h);
+ return GDK_FAIL;
+ }
+ BBPunshare(b->T->vheap->parentid);
+ b->T->vheap = h;
+ }
+ return GDK_SUCCEED;
+}
+
/* We try to be clever when appending one string bat to another.
* First of all, we try to actually share the string heap so that we
* don't need an extra copy, and if that can't be done, we see whether
@@ -108,27 +137,9 @@ insert_string_bat(BAT *b, BAT *n, int ap
toff = 0;
} else if (b->T->vheap->parentid ==
n->T->vheap->parentid) {
toff = 0;
- } else if (b->T->vheap->parentid != bid) {
- Heap *h = GDKzalloc(sizeof(Heap));
- if (h == NULL)
- return NULL;
- h->parentid = bid;
- h->farmid = BBPselectfarm(b->batRole, TYPE_str,
varheap);
- if (b->T->vheap->filename) {
- char *nme = BBP_physical(b->batCacheid);
- h->filename = GDKfilepath(NOFARM, NULL,
nme, "theap");
- if (h->filename == NULL) {
- GDKfree(h);
- return NULL;
- }
- }
- if (HEAPcopy(h, b->T->vheap) < 0) {
- HEAPfree(h, 1);
- GDKfree(h);
- return NULL;
- }
- BBPunshare(b->T->vheap->parentid);
- b->T->vheap = h;
+ } else if (b->T->vheap->parentid != bid &&
+ unshare_string_heap(b) == GDK_FAIL) {
+ return NULL;
}
}
if (toff == ~(size_t) 0 && n->batCount > 1024) {
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -170,6 +170,8 @@ int IMPSgetbin(int tpe, bte bits, const
void IMPSprint(BAT *b)
__attribute__((__visibility__("hidden")));
#endif
+gdk_return unshare_string_heap(BAT *b)
+ __attribute__((__visibility__("hidden")));
oid MAXoid(BAT *i)
__attribute__((__visibility__("hidden")));
void MT_global_exit(int status)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list