Changeset: 65fc3ec56c51 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=65fc3ec56c51
Removed Files:
gdk/gdk_bat.h
Modified Files:
gdk/Makefile.ag
gdk/gdk.h
gdk/gdk_bat.c
gdk/gdk_bbp.c
gdk/gdk_bbp.h
gdk/gdk_private.h
Branch: default
Log Message:
Cleanup some code.
diffs (270 lines):
diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag
--- a/gdk/Makefile.ag
+++ b/gdk/Makefile.ag
@@ -29,7 +29,7 @@ lib_gdk = {
gdk_heap.c gdk_setop.mx gdk_utils.c gdk_utils.h \
gdk_atoms.c gdk_atoms.h \
gdk_qsort.c gdk_qsort_impl.h gdk_ssort.c gdk_ssort_impl.h \
- gdk_storage.c gdk_bat.c gdk_bat.h \
+ gdk_storage.c gdk_bat.c \
gdk_delta.c gdk_relop.mx gdk_system.c gdk_value.c \
gdk_rangejoin.mx \
gdk_posix.c gdk_logger.c gdk_sample.c \
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2283,7 +2283,11 @@ gdk_export int GDKfatal(_In_z_ _Printf_f
#include "gdk_atoms.h"
#include "gdk_bbp.h"
#include "gdk_utils.h"
-#include "gdk_bat.h"
+
+/* functions defined in gdk_bat.c */
+gdk_export BUN void_replace_bat(BAT *b, BAT *u, bit force);
+gdk_export int void_inplace(BAT *b, oid id, const void *val, bit force);
+gdk_export BAT *BATattach(int tt, const char *heapfile);
#ifdef NATIVE_WIN32
#ifdef _MSC_VER
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -64,7 +64,7 @@
char *BATstring_h = "h";
char *BATstring_t = "t";
-int
+static int
default_ident(char *s)
{
return ((s) == BATstring_h || (s) == BATstring_t);
@@ -1009,16 +1009,16 @@ BATcopy(BAT *b, int ht, int tt, int writ
*_dst++ = *_src++; \
} \
} while (0)
-#define hacc_update(del, get, p, idx) \
+#define hacc_update(func, get, p, idx) \
do { \
if (b->H->hash) { \
- hash##del(b->H->hash, idx, BUN##get(bi, p), p < last); \
+ func(b->H->hash, idx, get(bi, p), p < last); \
} \
} while (0)
-#define tacc_update(del, get, p, idx) \
+#define tacc_update(func, get, p, idx) \
do { \
if (b->T->hash) { \
- hash##del(b->T->hash, idx, BUN##get(bi, p), p < last); \
+ func(b->T->hash, idx, get(bi, p), p < last); \
} \
} while (0)
#define acc_move(l, p, idx2, idx1) \
@@ -1360,6 +1360,9 @@ BUNappend(BAT *b, const void *t, bit for
* one now must do:
* BATloopDEL(b,p) p = BUNdelete(b,p,FALSE)
*/
+#define hashins(h,i,v,n) HASHins_any(h,i,v)
+#define hashdel(h,i,v,n) HASHdel(h,i,v,n)
+
static inline BUN
BUNdelete_(BAT *b, BUN p, bit force)
{
@@ -1377,8 +1380,8 @@ BUNdelete_(BAT *b, BUN p, bit force)
if (p < b->batInserted && !force) {
idx1 = p;
if (p == b->batFirst) { /* first can simply be discarded */
- hacc_update(del,head,p,idx1);
- tacc_update(del,tail,p,idx1);
+ hacc_update(hashdel,BUNhead,p,idx1);
+ tacc_update(hashdel,BUNtail,p,idx1);
if (BAThdense(b)) {
bm->tseqbase = ++b->hseqbase;
@@ -1389,8 +1392,8 @@ BUNdelete_(BAT *b, BUN p, bit force)
} else {
unsigned short hs = Hsize(b), ts = Tsize(b);
- hacc_update(del,head,p,idx1);
- tacc_update(del,tail,p,idx1);
+ hacc_update(hashdel,BUNhead,p,idx1);
+ tacc_update(hashdel,BUNtail,p,idx1);
l = BUNfirst(b);
idx2 = l;
@@ -1448,8 +1451,8 @@ BUNdelete_(BAT *b, BUN p, bit force)
(*tatmdel) (b->T->vheap, (var_t *) BUNtloc(bi, p));
}
idx1 = p;
- hacc_update(del,head,p,idx1);
- tacc_update(del,tail,p,idx1);
+ hacc_update(hashdel,BUNhead,p,idx1);
+ tacc_update(hashdel,BUNtail,p,idx1);
idx2 = last;
if (p != last) {
unsigned short hs = Hsize(b), ts = Tsize(b);
@@ -1605,9 +1608,9 @@ BUNinplace(BAT *b, BUN p, const void *h,
* property, so we must clear it */
b->T->nil = 0;
}
- tacc_update(del,tail,p,pit);
+ tacc_update(hashdel,BUNtail,p,pit);
Treplacevalue(b, BUNtloc(bi, p), t);
- tacc_update(ins,tail,p,pit);
+ tacc_update(hashins,BUNtail,p,pit);
tt = b->ttype;
prv = p > b->batFirst ? p - 1 : BUN_NONE;
diff --git a/gdk/gdk_bat.h b/gdk/gdk_bat.h
deleted file mode 100644
--- a/gdk/gdk_bat.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * The contents of this file are subject to the MonetDB Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.monetdb.org/Legal/MonetDBLicense
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the MonetDB Database System.
- *
- * The Initial Developer of the Original Code is CWI.
- * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
- * Copyright August 2008-2012 MonetDB B.V.
- * All Rights Reserved.
- */
-
-#ifndef _GDK_BAT_H_
-#define _GDK_BAT_H_
-
-gdk_export BUN void_replace_bat(BAT *b, BAT *u, bit force);
-gdk_export int void_inplace(BAT *b, oid id, const void *val, bit force);
-gdk_export BAT *BATattach(int tt, const char *heapfile);
-
-extern int default_ident(char *s);
-extern oid MAXoid(BAT *i);
-
-#endif /* _GDK_BAT_H_ */
-/*
- * @+ BAT Unit Manipulation
- * Binary units (tuples) are the elements stored in BATs. We
- * discuss here BUN insert, replace and delete.
- * Below are help macros that actually move the BUNs
- * around and adapt search accelerator structures.
- */
-#define hashins(h,i,v,n) HASHins_any(h,i,v)
-#define hashdel(h,i,v,n) HASHdel(h,i,v,n)
-
-/*
- * @+ BAT permissions, persistency and memory mapped heaps
- * The way large heaps are memory mapped is dependent both on the BAT
- * persistency status (persistent or not) as well as their update
- * permissions (readonly,append-only,writable).
- *
- * Let us recall the two main memory mapped file modes used to store
- * heaps:
- * @multitable @columnfractions .12 .8
- * @item STORE_MMAP
- * @tab files must be readonly, because you never know the exact saved status.
- * HEAPsave consists of the rather efficient msync(X).
- * @item STORE_PRIV
- * @tab files modify pages in swap area, and can be writable.
- * HEAPsave actually does a full write(X.new), while the mapped
- * file stays in X
- * @end multitable
- * Notice that PRIV storage is only required for persistent BATs that
- * are already committed on disk. The crash-consistent state of
- * transient BATs is irrelevant as they disappear after a crash. Even
- * the crash-consistency of persistent BATs that did not make their
- * first commit is not relevant as they also will disappear.
- *
- * Also, some heaps may be in use with STORE_MMAP even if they are
- * appendable, as we suppose our code is bug-free and we know we won't
- * modify the already committed parts of the mapped file pages. For
- * string-heaps append-bats may mmap the heap if doubles are not being
- * eliminated anymore (i.e. when the contents of the builtin hash
- * table at the start of the string heap are not crucial anymore).
- */
-#define ATOMappendpriv(t,h) ((BATatoms[t].atomHeapCheck != HEAP_check ||
!HEAP_mmappable(h)) && \
- (ATOMstorage(t) != TYPE_str || GDK_ELIMDOUBLES(h)))
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -117,6 +117,7 @@ static int BBPprepare(bit subcommit);
static BAT *getBBPdescriptor(bat i, int lock);
static int BBPbackup(BAT *b, bit subcommit);
+#define BBPnamecheck(s) (BBPtmpcheck(s) ? ((s)[3] == '_' ? strtol((s) + 4,
NULL, 8) : -strtol((s) + 5, NULL, 8)) : 0)
static int stamp = 0;
static inline int
diff --git a/gdk/gdk_bbp.h b/gdk/gdk_bbp.h
--- a/gdk/gdk_bbp.h
+++ b/gdk/gdk_bbp.h
@@ -50,9 +50,6 @@ gdk_export int BBPdir(int cnt, bat *subc
/* update interface */
gdk_export void BBPclear(bat bid);
-#ifdef LIBGDK /* only used within GDK */
-extern bat BBPinsert(BATstore *bs);
-#endif
gdk_export int BBPreclaim(BAT *b);
gdk_export int BBPsave(BAT *b);
gdk_export int BBPrename(bat bid, const char *nme);
@@ -69,8 +66,9 @@ gdk_export void BBPreleaseref(bat i);
gdk_export int BBPdecref(bat b, int logical);
gdk_export void BBPshare(bat b);
-#define BBPtmpcheck(s) ((s)[0] == 't' && (s)[1] == 'm' && (s)[2] == 'p' &&
((s)[3] == '_' || ((s)[3] == 'r' && (s)[4] == '_'))) /* (strncmp((s),
"tmp_", 4) == 0) */
-#define BBPnamecheck(s) (BBPtmpcheck(s) ? ((s)[3] == '_' ? strtol((s) + 4,
NULL, 8) : -strtol((s) + 5, NULL, 8)) : 0)
+/* (strncmp(s, "tmp_", 4) == 0 || strncmp(s, "tmpr_", 5) == 0) */
+#define BBPtmpcheck(s) ((s)[0] == 't' && (s)[1] == 'm' && (s)[2] == 'p' && \
+ ((s)[3] == '_' || ((s)[3] == 'r' && (s)[4] == '_')))
#define BBP_status_set(bid, mode, nme) \
do { \
@@ -100,9 +98,5 @@ gdk_export void BBPshare(bat b);
} while (0)
#define BBPswappable(b) ((b) && (b)->batCacheid && BBP_refs((b)->batCacheid)
== 0)
#define BBPtrimmable(b) (BBPswappable(b) && isVIEW(b) == 0 &&
(BBP_status((b)->batCacheid)&BBPWAITING) == 0)
-/*
- * The BBP_ref contains the amount of live references to a BAT. These
- * might be in recursive BATs, C or MAL variables. The count is
- * incremented with BBPfix and decremented with BBPunfix.
- */
+
#endif /* _GDK_BBP_H_ */
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -53,6 +53,7 @@ void BBPdumpcache(void); /* never called
void BBPdump(void); /* never called: for debugging only */
void BBPexit(void);
void BBPinit(void);
+bat BBPinsert(BATstore *bs);
int BBPrecover(void);
void BBPreleaselref(bat i);
void BBPtrim(size_t delta);
@@ -86,6 +87,7 @@ int HEAPsave(Heap *h, const char *nme, c
int HEAPwarm(Heap *h);
int intCmp(const int *r, const int *l);
int lngCmp(const lng *r, const lng *l);
+oid MAXoid(BAT *i);
void MT_global_exit(int status)
__attribute__((__noreturn__));
void MT_init_posix(void);
@@ -138,6 +140,10 @@ extern MT_Cond GDKunloadCond;
extern MT_Lock GDKunloadLock;
extern MT_Lock MT_system_lock;
+#define ATOMappendpriv(t, h) \
+ ((BATatoms[t].atomHeapCheck != HEAP_check || !HEAP_mmappable(h)) && \
+ (ATOMstorage(t) != TYPE_str || GDK_ELIMDOUBLES(h)))
+
#define BBPdirty(x) (BBP_dirty=(x))
#define GDKswapLock(x) GDKbatLock[(x)&BBP_BATMASK].swap
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list