Changeset: 78f1dd084b9a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/78f1dd084b9a
Modified Files:
        gdk/gdk_strimps.c
        gdk/gdk_strimps.h
Branch: string_imprints
Log Message:

Add function to append bitstring to a strimp


diffs (69 lines):

diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -716,6 +716,7 @@ STRMPcreate(BAT *b, BAT *s) {
                        }
                        bat_iterator_end(&bi);
 
+                       r->strimps.free += ncand*sizeof(uint64_t);
                        pb->tstrimps = r;
                        pb->batDirtydesc = true;
                        persistStrimp(pb);
@@ -726,6 +727,48 @@ STRMPcreate(BAT *b, BAT *s) {
        return GDK_SUCCEED;
 }
 
+gdk_return
+STRMPappendBitstring(BAT *b, const str s) {
+       lng t0 = 0;
+       BAT *pb;
+
+       TRC_DEBUG_IF(ACCELERATOR) t0 = GDKusec();
+       if (ATOMstorage(b->ttype) != TYPE_str) {
+               GDKerror("Cannot manipulate strimps index for non string 
bats\n");
+               return GDK_FAIL;
+       }
+
+       if (VIEWtparent(b)) {
+               pb = BBP_cache(VIEWtparent(b));
+               assert(pb);
+       } else {
+               pb = b;
+       }
+
+       if (!BATcheckstrimps(pb)) {
+               GDKerror("Strimp missing, cannot append value\n");
+               return GDK_FAIL;
+       }
+       MT_lock_set(&pb->batIdxLock);
+       // Check that there is space in the heap
+       if (pb->tstrimps->strimps.free < pb->tstrimps->strimps.size + 
sizeof(uint64_t)) {
+               pb->tstrimps->strimps.base[pb->tstrimps->strimps.free] = 
STRMPmakebitstring(s, pb->tstrimps);
+               pb->tstrimps->strimps.free += sizeof(uint64_t);
+       }
+       else {
+               // TODO reallocate buffer
+       }
+
+       // TODO increase reconstruction counter if
+       // reconstruction counter is larger than a threshold
+       // recompute the strimp from scratch.
+
+       MT_lock_unset(&pb->batIdxLock);
+
+       TRC_DEBUG(ACCELERATOR, "appending to strimp took " LLFMT " usec\n", 
GDKusec()-t0);
+       return GDK_SUCCEED;
+}
+
 /* Parallel creation. does not wok*/
 #if 0
 /* Creates the heap for a string imprint. Returns NULL on failure. This
diff --git a/gdk/gdk_strimps.h b/gdk/gdk_strimps.h
--- a/gdk/gdk_strimps.h
+++ b/gdk/gdk_strimps.h
@@ -45,4 +45,5 @@ typedef struct {
 // gdk_export gdk_return STRMP_make_header(BAT *b);
 gdk_export gdk_return STRMPcreate(BAT *b, BAT *s);
 gdk_export BAT *STRMPfilter(BAT *b, BAT *s, const str q);
+gdk_export gdk_return STRMPappendBitstring(BAT *b, const str s);
 #endif /* _GDK_STRIMPS_H_ */
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to