Changeset: f327f503a797 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f327f503a797
Modified Files:
        gdk/gdk_logger.c
Branch: default
Log Message:

Layout.


diffs (truncated from 378 to 300 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -125,7 +125,7 @@ log_find_int(BAT *b, BAT *d, int val)
 //MK So, if the BAThash construction fails, the BAT b still could have 
information
 //?? protect against failing BAThash() with non-empty b required
                }
-       } 
+       }
        return BUN_NONE;
 #endif
 }
@@ -154,7 +154,7 @@ log_find_bid(BAT *b, BAT *d, log_bid val
                        if (BUNfnd(d, &pos) == BUN_NONE)
                                return p;
                }
-       } 
+       }
        return BUN_NONE;
 #endif
 }
@@ -260,7 +260,7 @@ log_read_clear(logger *lg, trans *tr, ch
 }
 
 static int
-avoid_snapshot( logger *lg, log_bid bid ) 
+avoid_snapshot(logger *lg, log_bid bid)
 {
        if (BATcount(lg->snapshots_bid)-BATcount(lg->dsnapshots)) {
                BUN p = log_find_bid(lg->snapshots_bid, lg->dsnapshots, bid);
@@ -285,7 +285,7 @@ la_bat_clear(logger *lg, logaction *la)
                fprintf(stderr, "#la_bat_clear %s\n", la->name);
 
        /* do we need to skip these old updates */
-       if (avoid_snapshot(lg, bid)) 
+       if (avoid_snapshot(lg, bid))
                return;
 
        b = BATdescriptor(bid);
@@ -362,9 +362,9 @@ log_read_updates(logger *lg, trans *tr, 
                        }
                }
        }
-       assert( (ht == TYPE_void && l->flag == LOG_INSERT) ||
-               (ht == TYPE_void && l->flag == LOG_DELETE) || 
-               ((ht == TYPE_oid || !ht) && l->flag == LOG_UPDATE) );
+       assert((ht == TYPE_void && l->flag == LOG_INSERT) ||
+              (ht == TYPE_void && l->flag == LOG_DELETE) ||
+              ((ht == TYPE_oid || !ht) && l->flag == LOG_UPDATE));
        if (ht >= 0 && tt >= 0) {
                BAT *uid = NULL;
                BAT *r;
@@ -477,7 +477,7 @@ log_read_updates(logger *lg, trans *tr, 
                        }
                        GDKfree(hv);
                }
-               if (tv != lg->buf) 
+               if (tv != lg->buf)
                        GDKfree(tv);
                logbat_destroy(b);
 
@@ -508,7 +508,7 @@ la_bat_updates(logger *lg, logaction *la
                return;         /* ignore bats no longer in the catalog */
 
        /* do we need to skip these old updates */
-       if (avoid_snapshot(lg, bid)) 
+       if (avoid_snapshot(lg, bid))
                return;
 
        b = BATdescriptor(bid);
@@ -849,6 +849,10 @@ tr_abort(logger *lg, trans *tr)
 
 static int log_sequence_nrs(logger *lg);
 
+#ifdef _MSC_VER
+#define access(file, mode)     _access(file, mode)
+#endif
+
 /* Update the last transaction id written in the catalog file.
  * Only used by the shared logger. */
 static int
@@ -860,11 +864,7 @@ logger_update_catalog_file(logger *lg, c
 
        bak_exists = 0;
        /* check if an older file exists and move bak it up */
-#if defined(_MSC_VER)
-       if (_access(filename, 0) != -1) {
-#else
        if (access(filename, 0) != -1) {
-#endif
                bak_exists = 1;
                if (GDKmove(farmid, dir, filename, NULL, dir, filename, "bak") 
== GDK_FAIL) {
                        fprintf(stderr, "!ERROR: logger_update_catalog_file: 
rename %s to %s.bak in %s failed\n", filename, filename, dir);
@@ -907,7 +907,7 @@ logger_open(logger *lg)
        lg->log = open_wstream(filename);
        lg->end = 0;
 
-       if (lg->log == NULL || mnstr_errnr(lg->log) || log_sequence_nrs(lg) != 
LOG_OK) { 
+       if (lg->log == NULL || mnstr_errnr(lg->log) || log_sequence_nrs(lg) != 
LOG_OK) {
                fprintf(stderr, "!ERROR: logger_open: creating %s failed\n", 
filename);
                return LOG_ERR;
        }
@@ -1111,11 +1111,11 @@ logger_readlogs(logger *lg, FILE *fp, ch
                                /* Increment the id only at the end, since we 
want to re-read the last file.
                                 * That is because last time we read it, it was 
empty, since the logger creates empty files
                                 * and fills them in later. */
-                lg->id++;
+                               lg->id++;
                        }
-            if (lid < lg->id) {
-                lg->id = lid;
-            }
+                       if (lid < lg->id) {
+                               lg->id = lid;
+                       }
                        /* if this is a shared logger, write the id in the 
shared file */
                        logger_update_catalog_file(lg, lg->local_dir, 
LOGFILE_SHARED, lg->local_dbfarm_role);
                }
@@ -1184,7 +1184,7 @@ check_version(logger *lg, FILE *fp)
 }
 
 static BAT *
-bm_tids(BAT *b, BAT *d) 
+bm_tids(BAT *b, BAT *d)
 {
        BUN sz = BATcount(b);
        BAT *tids = BATnew(TYPE_void, TYPE_void, 0, TRANSIENT);
@@ -1318,7 +1318,7 @@ logger_set_logdir_path(char *filename, c
                        BBPaddfarm(logdir_parent_path, 1 << role);
                } else {
                        logger_fatal("logger_set_logdir_path: logdir path is 
not correct (%s)."
-                                       "Make sure you specify a valid absolute 
or relative path.\n", logdir, 0, 0);
+                                    "Make sure you specify a valid absolute or 
relative path.\n", logdir, 0, 0);
                }
        } else {
                /* just concat the logdir and fn with appropriate separators */
@@ -1338,7 +1338,7 @@ logger_load(int debug, const char* fn, c
        int id = LOG_SID;
        FILE *fp;
        char bak[BUFSIZ];
-    log_bid snapshots_bid = 0;
+       log_bid snapshots_bid = 0;
        bat catalog_bid, catalog_nme, dcatalog, bid;
        int farmid = BBPselectfarm(lg->dbfarm_role, 0, offheap);
 
@@ -1441,7 +1441,7 @@ logger_load(int debug, const char* fn, c
                        /* cannot commit catalog, so remove log */
                        unlink(filename);
                        goto error;
-           }
+               }
        } else {
                /* find the persistent catalog. As non persistent bats
                 * require a logical reference we also add a logical
@@ -1603,17 +1603,17 @@ logger_load(int debug, const char* fn, c
                bat snapshots_tid = logger_find_bat(lg, "snapshots_tid");
                bat dsnapshots = logger_find_bat(lg, "dsnapshots");
 
-        if (seqs_id) {
-            BAT *o_id = BATdescriptor(seqs_id);
-            BAT *o_val = BATdescriptor(seqs_val);
-        
-            lg->seqs_id = BATcopy(o_id, TYPE_void, TYPE_int, 1, TRANSIENT);
-            lg->seqs_val = BATcopy(o_val, TYPE_void, TYPE_lng, 1, TRANSIENT);
-            BBPunfix(o_id->batCacheid);
-            BBPunfix(o_val->batCacheid);
+               if (seqs_id) {
+                       BAT *o_id = BATdescriptor(seqs_id);
+                       BAT *o_val = BATdescriptor(seqs_val);
+
+                       lg->seqs_id = BATcopy(o_id, TYPE_void, TYPE_int, 1, 
TRANSIENT);
+                       lg->seqs_val = BATcopy(o_val, TYPE_void, TYPE_lng, 1, 
TRANSIENT);
+                       BBPunfix(o_id->batCacheid);
+                       BBPunfix(o_val->batCacheid);
                } else {
-            lg->seqs_id = BATnew(TYPE_void, TYPE_int, 1, TRANSIENT);
-            lg->seqs_val = BATnew(TYPE_void, TYPE_lng, 1, TRANSIENT);
+                       lg->seqs_id = BATnew(TYPE_void, TYPE_int, 1, TRANSIENT);
+                       lg->seqs_val = BATnew(TYPE_void, TYPE_lng, 1, 
TRANSIENT);
                }
                lg->dseqs = BATnew(TYPE_void, TYPE_oid, 1, TRANSIENT);
                if (lg->seqs_id == NULL ||
@@ -1628,18 +1628,18 @@ logger_load(int debug, const char* fn, c
                lg->snapshots_tid = BATdescriptor(snapshots_tid);
                if (lg->snapshots_tid == 0)
                        logger_fatal("logger_load: inconsistent database, 
snapshots_tid does not exist", 0, 0, 0);
-        
-        if (dsnapshots) {
-            lg->dsnapshots = BATdescriptor(dsnapshots);
-            if (lg->dsnapshots == 0)
-                logger_fatal("Logger_new: inconsistent database, snapshots_tid 
does not exist", 0, 0, 0);
-        } else {
-            lg->dsnapshots = logbat_new(TYPE_oid, 1, PERSISTENT);
-            snprintf(bak, sizeof(bak), "%s_dsnapshots", fn);
-            if (BBPrename(lg->dsnapshots->batCacheid, bak) < 0)
-                logger_fatal("Logger_new: BBPrename to %s failed", bak, 0, 0);
-            logger_add_bat(lg, lg->dsnapshots, "dsnapshots");
-        }
+
+               if (dsnapshots) {
+                       lg->dsnapshots = BATdescriptor(dsnapshots);
+                       if (lg->dsnapshots == 0)
+                               logger_fatal("Logger_new: inconsistent 
database, snapshots_tid does not exist", 0, 0, 0);
+               } else {
+                       lg->dsnapshots = logbat_new(TYPE_oid, 1, PERSISTENT);
+                       snprintf(bak, sizeof(bak), "%s_dsnapshots", fn);
+                       if (BBPrename(lg->dsnapshots->batCacheid, bak) < 0)
+                               logger_fatal("Logger_new: BBPrename to %s 
failed", bak, 0, 0);
+                       logger_add_bat(lg, lg->dsnapshots, "dsnapshots");
+               }
        }
        lg->freed = BATnew(TYPE_void, TYPE_int, 1, TRANSIENT);
        if (lg->freed == NULL)
@@ -1703,40 +1703,40 @@ logger_load(int debug, const char* fn, c
                                fseek(fp, off, SEEK_SET);
 
 
-                       if ((fp1 = GDKfileopen(farmid, bak, NULL, NULL, "r")) 
!= NULL) {
-                               /* file indicating that we need to do
-                                * a 32->64 bit OID conversion exists;
-                                * record the fact in case we get
-                                * interrupted, and set the flag so
-                                * that we actually do what's asked */
-                               fclose(fp1);
-                               /* first create a versioned file using
-                                * the current log id */
-                               if ((fp1 = GDKfileopen(farmid, cvfile, NULL, 
NULL, "w")) == NULL ||
-                                   fprintf(fp1, "%d\n", curid) < 2 ||
-                                   fflush(fp1) != 0 || /* make sure it's save 
on disk */
+                               if ((fp1 = GDKfileopen(farmid, bak, NULL, NULL, 
"r")) != NULL) {
+                                       /* file indicating that we need to do
+                                        * a 32->64 bit OID conversion exists;
+                                        * record the fact in case we get
+                                        * interrupted, and set the flag so
+                                        * that we actually do what's asked */
+                                       fclose(fp1);
+                                       /* first create a versioned file using
+                                        * the current log id */
+                                       if ((fp1 = GDKfileopen(farmid, cvfile, 
NULL, NULL, "w")) == NULL ||
+                                           fprintf(fp1, "%d\n", curid) < 2 ||
+                                           fflush(fp1) != 0 || /* make sure 
it's save on disk */
 #if defined(_MSC_VER)
-                                   _commit(_fileno(fp1)) < 0 ||
+                                           _commit(_fileno(fp1)) < 0 ||
 #elif defined(HAVE_FDATASYNC)
-                                   fdatasync(fileno(fp1)) < 0 ||
+                                           fdatasync(fileno(fp1)) < 0 ||
 #elif defined(HAVE_FSYNC)
-                                   fsync(fileno(fp1)) < 0 ||
+                                           fsync(fileno(fp1)) < 0 ||
 #endif
-                                   fclose(fp1) != 0)
-                                       logger_fatal("logger_load: failed to 
write %s\n", cvfile, 0, 0);
-                               /* then remove the unversioned file
-                                * that gdk_bbp created (in this
-                                * order!) */
-                               unlink(bak);
-                               /* set the flag that we need to convert */
-                               lg->read32bitoid = 1;
-                       } else if ((fp1 = GDKfileopen(farmid, cvfile, NULL, 
NULL, "r")) != NULL) {
-                               /* the versioned conversion file
-                                * exists: check version */
-                               int newid;
+                                           fclose(fp1) != 0)
+                                               logger_fatal("logger_load: 
failed to write %s\n", cvfile, 0, 0);
+                                       /* then remove the unversioned file
+                                        * that gdk_bbp created (in this
+                                        * order!) */
+                                       unlink(bak);
+                                       /* set the flag that we need to convert 
*/
+                                       lg->read32bitoid = 1;
+                               } else if ((fp1 = GDKfileopen(farmid, cvfile, 
NULL, NULL, "r")) != NULL) {
+                                       /* the versioned conversion file
+                                        * exists: check version */
+                                       int newid;
 
                                        if (fscanf(fp1, "%d", &newid) == 1 &&
-                                               newid == curid) {
+                                           newid == curid) {
                                                /* versions match, we need to
                                                 * convert */
                                                lg->read32bitoid = 1;
@@ -1770,7 +1770,7 @@ logger_load(int debug, const char* fn, c
        }
 
        return LOG_OK;
-       error:
+  error:
        if (fp)
                fclose(fp);
        if (lg)
@@ -1840,11 +1840,7 @@ logger_new(int debug, const char *fn, co
                /* get last shared logger id from the local log dir,
                 * but first check if the file exists */
                snprintf(shared_log_filename, sizeof(shared_log_filename), 
"%s%s", lg->local_dir, LOGFILE_SHARED);
-#if defined(_MSC_VER)
-               if (_access(shared_log_filename, 0) != -1) {
-#else
                if (access(shared_log_filename, 0) != -1) {
-#endif
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to