Changeset: 1165fc089192 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1165fc089192
Modified Files:
        gdk/gdk_sample.c
Branch: default
Log Message:

Use finer-grained locking in BATsample.


diffs (43 lines):

diff --git a/gdk/gdk_sample.c b/gdk/gdk_sample.c
--- a/gdk/gdk_sample.c
+++ b/gdk/gdk_sample.c
@@ -130,18 +130,28 @@ do_batsample(BAT *b, BUN n, random_state
                }
 
                /* while we do not have enough sample OIDs yet */
-               if (lock)       /* serialize access to random state engine */
-                       MT_lock_set(lock);
-               for (rescnt = 0; rescnt < n; rescnt++) {
-                       oid candoid;
-                       do {
-                               candoid = minoid + next(rse) % cnt;
-                               /* if that candidate OID was already
-                                * generated, try again */
-                       } while (!OIDTreeMaybeInsert(tree, candoid, rescnt));
+               if (lock) {
+                       /* serialize access to random state engine */
+                       for (rescnt = 0; rescnt < n; rescnt++) {
+                               oid candoid;
+                               do {
+                                       MT_lock_set(lock);
+                                       candoid = minoid + next(rse) % cnt;
+                                       MT_lock_unset(lock);
+                                       /* if that candidate OID was already
+                                        * generated, try again */
+                               } while (!OIDTreeMaybeInsert(tree, candoid, 
rescnt));
+                       }
+               } else {
+                       for (rescnt = 0; rescnt < n; rescnt++) {
+                               oid candoid;
+                               do {
+                                       candoid = minoid + next(rse) % cnt;
+                                       /* if that candidate OID was already
+                                        * generated, try again */
+                               } while (!OIDTreeMaybeInsert(tree, candoid, 
rescnt));
+                       }
                }
-               if (lock)
-                       MT_lock_unset(lock);
                if (!antiset) {
                        OIDTreeToBAT(tree, bn);
                } else {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to