Changeset: 7bd065f302f6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7bd065f302f6
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_logger.c
gdk/gdk_utils.c
monetdb5/extras/rdf/rdf_shredder.c
monetdb5/mal/mal_authorize.c
monetdb5/mal/mal_debugger.c
monetdb5/modules/atoms/mtime.c
monetdb5/modules/kernel/algebra.c
monetdb5/modules/mal/querylog.c
monetdb5/modules/mal/tablet.c
monetdb5/modules/mal/tokenizer.c
monetdb5/optimizer/opt_statistics.c
sql/backends/monet5/sql_user.c
sql/storage/bat/bat_table.c
sql/storage/restrict/restrict_storage.c
sql/storage/restrict/restrict_table.c
Branch: default
Log Message:
BUNfnd and BUNfndVOID now search tail; removed BUNfndOID and BUNfndSTD.
diffs (truncated from 795 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -233,7 +233,7 @@ BAT *BUNdel(BAT *b, const void *left, co
BAT *BUNdelHead(BAT *b, const void *left, bit force);
BUN BUNdelete(BAT *b, BUN p, bit force);
BAT *BUNfastins(BAT *b, const void *left, const void *right);
-BUN BUNfnd(BAT *b, const void *left);
+BUN BUNfnd(BAT *b, const void *right);
BAT *BUNinplace(BAT *b, BUN p, const void *left, const void *right, bit force);
BAT *BUNins(BAT *b, const void *left, const void *right, bit force);
BAT *BUNreplace(BAT *b, const void *left, const void *right, bit force);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1160,11 +1160,7 @@ gdk_export bte ATOMelmshift(int sz);
* @item int
* @tab BUNdelHead (BAT *b, ptr left, bit force)
* @item BUN
- * @tab BUNfnd (BAT *b, ptr head)
- * @item void
- * @tab BUNfndOID (BUN result, BATiter bi, oid *head)
- * @item void
- * @tab BUNfndSTD (BUN result, BATiter bi, ptr head)
+ * @tab BUNfnd (BAT *b, ptr tail)
* @item BUN
* @tab BUNlocate (BAT *b, ptr head, ptr tail)
* @item ptr
@@ -1196,9 +1192,7 @@ gdk_export bte ATOMelmshift(int sz);
* flags. Beware!
*
* The routine BUNfnd provides fast access to a single BUN providing a
- * value for the head of the binary association. A very fast shortcut
- * for BUNfnd if the selection type is known to be integer or OID, is
- * provided in the form of the macro BUNfndOID.
+ * value for the tail of the binary association.
*
* To select on a tail, one should use the reverse view obtained by
* BATmirror.
@@ -1391,24 +1385,14 @@ gdk_export BAT *BUNreplace(BAT *b, const
gdk_export BAT *BUNinplace(BAT *b, BUN p, const void *left, const void *right,
bit force);
gdk_export BAT *BATreplace(BAT *b, BAT *n, bit force);
-gdk_export BUN BUNfnd(BAT *b, const void *left);
+gdk_export BUN BUNfnd(BAT *b, const void *right);
-#define BUNfndVOID(p,bi,v) \
- ((p) = (((*(const oid*)(v) == oid_nil) ^ ((bi).b->hseqbase == oid_nil))
| \
- (*(const oid*)(v) < (bi).b->hseqbase) | \
- (*(const oid*)(v) >= (bi).b->hseqbase + (bi).b->batCount)) ? \
+#define BUNfndVOID(b, v) \
+ (((*(const oid*)(v) == oid_nil) ^ ((b)->tseqbase == oid_nil)) | \
+ (*(const oid*)(v) < (b)->tseqbase) | \
+ (*(const oid*)(v) >= (b)->tseqbase + (b)->batCount) ? \
BUN_NONE : \
- BUNfirst((bi).b) + (BUN) (*(const oid*)(v) - (bi).b->hseqbase))
-
-#define BUNfndOID(p,bi,v) \
- do { \
- if (BAThdense(bi.b)) { \
- BUNfndVOID(p,bi,v); \
- } else { \
- HASHfnd_oid(p,bi,v); \
- } \
- } while (0)
-#define BUNfndSTD(p,bi,v) ((p) = BUNfnd(bi.b,v))
+ BUNfirst((b)) + (BUN) (*(const oid*)(v) - (b)->tseqbase))
#define BAThtype(b) ((b)->htype == TYPE_void && (b)->hseqbase != oid_nil ? \
TYPE_oid : (b)->htype)
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1197,10 +1197,10 @@ BUNins(BAT *b, const void *h, const void
void_materialize(b, h);
void_materialize(b, t);
- if ((b->hkey & BOUND2BTRUE) && (p = BUNfnd(b, h)) != BUN_NONE) {
+ if ((b->hkey & BOUND2BTRUE) && (p = BUNfnd(bm, h)) != BUN_NONE) {
if (BUNinplace(b, p, h, t, force) == NULL)
return NULL;
- } else if ((b->tkey & BOUND2BTRUE) && (p = BUNfnd(bm, t)) != BUN_NONE) {
+ } else if ((b->tkey & BOUND2BTRUE) && (p = BUNfnd(b, t)) != BUN_NONE) {
if (BUNinplace(bm, p, t, h, force) == NULL)
return NULL;
} else {
@@ -1292,8 +1292,8 @@ BUNappend(BAT *b, const void *t, bit for
}
assert(!isVIEW(b));
- bm = BBP_cache(-b->batCacheid);
- if ((b->tkey & BOUND2BTRUE) && BUNfnd(bm, t) != BUN_NONE) {
+ bm = BATmirror(b);
+ if ((b->tkey & BOUND2BTRUE) && BUNfnd(b, t) != BUN_NONE) {
return b;
}
@@ -1566,17 +1566,19 @@ BAT *
BUNdelHead(BAT *b, const void *x, bit force)
{
BUN p;
+ BAT *bm;
BATcheck(b, "BUNdelHead");
+ bm = BATmirror(b);
if (x == NULL) {
x = ATOMnilptr(b->htype);
}
- if ((p = BUNfnd(b, x)) != BUN_NONE) {
+ if ((p = BUNfnd(bm, x)) != BUN_NONE) {
ALIGNdel(b, "BUNdelHead", force); /* zap alignment info */
do {
BUNdelete(b, p, force);
- } while ((p = BUNfnd(b, x)) != BUN_NONE);
+ } while ((p = BUNfnd(bm, x)) != BUN_NONE);
}
return b;
}
@@ -1686,10 +1688,10 @@ BUNreplace(BAT *b, const void *h, const
BATcheck(h, "BUNreplace: head value is nil");
BATcheck(t, "BUNreplace: tail value is nil");
- if ((p = BUNfnd(b, h)) == BUN_NONE)
+ if ((p = BUNfnd(BATmirror(b), h)) == BUN_NONE)
return b;
- if ((b->tkey & BOUND2BTRUE) && BUNfnd(BATmirror(b), t) != BUN_NONE) {
+ if ((b->tkey & BOUND2BTRUE) && BUNfnd(b, t) != BUN_NONE) {
return b;
}
if (b->ttype == TYPE_void) {
@@ -1714,14 +1716,14 @@ void_inplace(BAT *b, oid id, const void
int res = GDK_SUCCEED;
BUN p = BUN_NONE;
BUN oldInserted = b->batInserted;
- BATiter bi = bat_iterator(b);
+ BAT *bm = BATmirror(b);
assert(b->htype == TYPE_void);
assert(b->hseqbase != oid_nil);
assert(b->batCount > (id -b->hseqbase));
b->batInserted = 0;
- BUNfndVOID(p, bi, (ptr) &id);
+ p = BUNfndVOID(bm, &id);
assert(force || p >= b->batInserted); /* we don't want delete/ins */
assert(force || !b->batRestricted);
@@ -1766,10 +1768,10 @@ slowfnd(BAT *b, const void *v)
{
BATiter bi = bat_iterator(b);
BUN p, q;
- int (*cmp)(const void *, const void *) = BATatoms[b->htype].atomCmp;
+ int (*cmp)(const void *, const void *) = BATatoms[b->ttype].atomCmp;
BATloop(b, p, q) {
- if ((*cmp)(v, BUNhead(bi, p)) == 0)
+ if ((*cmp)(v, BUNtail(bi, p)) == 0)
return p;
}
return BUN_NONE;
@@ -1779,20 +1781,19 @@ BUN
BUNfnd(BAT *b, const void *v)
{
BUN r = BUN_NONE;
- BATiter bi = bat_iterator(b);
+ BATiter bi;
BATcheck(b, "BUNfnd");
if (!v)
return r;
- if (BAThvoid(b)) {
- BUNfndVOID(r, bi, v);
- return r;
+ if (BATtvoid(b))
+ return BUNfndVOID(b, v);
+ if (!b->T->hash) {
+ if (BATtordered(b) || BATtrevordered(b))
+ return SORTfnd(b, v);
}
- if (!b->H->hash) {
- if (BAThordered(b) || BAThrevordered(b))
- return SORTfnd(BATmirror(b), v);
- }
- switch (ATOMstorage(b->htype)) {
+ bi = bat_iterator(BATmirror(b)); /* HASHfnd works on head */
+ switch (ATOMstorage(b->ttype)) {
case TYPE_bte:
HASHfnd_bte(r, bi, v);
break;
@@ -1876,7 +1877,7 @@ BUNlocate(BAT *b, const void *x, const v
(BATtordered(b) &&
(*tcmp) (y, BUNtail(bi, p)) == 0 &&
(*tcmp) (y, BUNtail(bi, q - 1)) == 0)) {
- return BUNfnd(b, x);
+ return BUNfnd(BATmirror(b), x);
}
/* positional lookup is always the best choice */
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -625,7 +625,6 @@ BATappend(BAT *b, BAT *n, bit force)
} else {
BUN p, q;
BUN i = BUNlast(b);
- BAT *bm = BBP_cache(-b->batCacheid);
BATiter ni = bat_iterator(n);
if (b->tkey & BOUND2BTRUE) {
@@ -636,7 +635,7 @@ BATappend(BAT *b, BAT *n, bit force)
BATloop(n, p, q) {
const void *t = BUNtail(ni, p);
- if (BUNfnd(bm, t) == BUN_NONE) {
+ if (BUNfnd(b, t) == BUN_NONE) {
bunfastins(b, &h, t);
if (b->T->hash) {
HASHins(b, i, t);
@@ -652,7 +651,7 @@ BATappend(BAT *b, BAT *n, bit force)
BATloop(n, p, q) {
const void *t = BUNtail(ni, p);
- if (BUNfnd(bm, t) == BUN_NONE) {
+ if (BUNfnd(b, t) == BUN_NONE) {
bunfastins(b, &on, t);
if (b->T->hash) {
HASHins(b, i, t);
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -70,10 +70,6 @@
#include "gdk_logger.h"
#include <string.h>
-static BUN BUNfndT(BAT *b, const void *v)
-{
- return BUNfnd(BATmirror(b), v);
-}
/*
* The log record encoding is geared at reduced storage space, but at
* the expense of readability. A user can not easily inspect the log a
@@ -239,7 +235,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 (BATcount(lg->snapshots_bid)) {
- BUN p = BUNfndT(lg->snapshots_bid, &bid);
+ BUN p = BUNfnd(lg->snapshots_bid, &bid);
if (p != BUN_NONE) {
int tid = *(int *) Tloc(lg->snapshots_tid, p);
@@ -272,7 +268,7 @@ log_read_seq(logger *lg, logformat *l)
return LOG_ERR;
}
- if ((p = BUNfndT(lg->seqs_id, &seq)) != BUN_NONE) {
+ if ((p = BUNfnd(lg->seqs_id, &seq)) != BUN_NONE) {
BUNdelete(lg->seqs_id, p, FALSE);
BUNdelete(lg->seqs_val, p, FALSE);
}
@@ -431,7 +427,7 @@ la_bat_updates(logger *lg, logaction *la
/* do we need to skip these old updates */
if (BATcount(lg->snapshots_bid)) {
- BUN p = BUNfndT(lg->snapshots_bid, &bid);
+ BUN p = BUNfnd(lg->snapshots_bid, &bid);
if (p != BUN_NONE) {
int tid = *(int *) Tloc(lg->snapshots_tid, p);
@@ -459,7 +455,7 @@ la_bat_updates(logger *lg, logaction *la
const void *h = BUNhead(bi, p);
const void *t = BUNtail(bi, p);
- if (BUNfnd(b, h) == BUN_NONE) {
+ if (BUNfnd(BATmirror(b), h) ==
BUN_NONE) {
/* if value doesn't
* exist, insert it if
* b void headed,
@@ -508,7 +504,7 @@ la_bat_destroy(logger *lg, logaction *la
BUN p;
logger_del_bat(lg, bid);
- if ((p = BUNfndT(lg->snapshots_bid, &bid)) != BUN_NONE) {
+ if ((p = BUNfnd(lg->snapshots_bid, &bid)) != BUN_NONE) {
#ifndef NDEBUG
assert(BBP_desc(bid)->S.role == PERSISTENT);
assert(0 <= BBP_desc(bid)->H.heap.farmid &&
BBP_desc(bid)->H.heap.farmid < MAXFARMS);
@@ -621,7 +617,7 @@ la_bat_use(logger *lg, logaction *la)
return;
}
logger_add_bat(lg, b, la->name);
- if ((p = BUNfndT(lg->snapshots_bid, &b->batCacheid)) != BUN_NONE) {
+ if ((p = BUNfnd(lg->snapshots_bid, &b->batCacheid)) != BUN_NONE) {
BUNdelete(lg->snapshots_bid, p, FALSE);
BUNdelete(lg->snapshots_tid, p, FALSE);
}
@@ -973,7 +969,7 @@ logger_commit(logger *lg)
if (lg->debug & 1)
fprintf(stderr, "#logger_commit\n");
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list