Changeset: 50095ca99ed2 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=50095ca99ed2 Modified Files: gdk/gdk.h gdk/gdk_align.c gdk/gdk_bat.c gdk/gdk_bbp.c gdk/gdk_search.c gdk/gdk_select.c monetdb5/modules/mal/orderidx.c sql/backends/monet5/sql.c sql/storage/bat/bat_storage.c Branch: leftmart Log Message:
orderidx is just a bat id on the BAT descriptor diffs (259 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -674,11 +674,6 @@ typedef struct { Heap *heap; /* heap where the hash is stored */ } Hash; -typedef struct { - unsigned int set:1; /* oid index is set */ - bat o; /* bat with oid order map */ -} OrderIdx; - typedef struct Imprints Imprints; @@ -802,7 +797,7 @@ gdk_export int VALisnil(const ValRecord * Heap *hheap; // heap for varsized head values * Hash *hhash; // linear chained hash table on head * Imprints *himprints; // column imprints index on head - * OrderIdx horderidx; // order oid index on head + * orderidx horderidx; // order oid index on head * // Tail properties * int ttype; // Tail type number * str tident; // name for tail column @@ -816,7 +811,7 @@ gdk_export int VALisnil(const ValRecord * Heap *theap; // heap for varsized tail values * Hash *thash; // linear chained hash table on tail * Imprints *timprints; // column imprints index on tail - * OrderIdx torderidx; // order oid index on tail + * orderidx torderidx; // order oid index on tail * } BAT; * @end verbatim * @@ -896,7 +891,7 @@ typedef struct { Heap *vheap; /* space for the varsized data. */ Hash *hash; /* hash table */ Imprints *imprints; /* column imprints index */ - OrderIdx orderidx; /* order oid index */ + bat orderidx; /* order oid index */ PROPrec *props; /* list of dynamic properties stored in the bat descriptor */ } COLrec; diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c --- a/gdk/gdk_align.c +++ b/gdk/gdk_align.c @@ -331,8 +331,8 @@ VIEWcreate_(BAT *h, BAT *t, int slice_vi bn->H->imprints = NULL; bn->T->imprints = NULL; /* Order OID index */ - bn->H->orderidx.set = 0; - bn->T->orderidx.set = 0; + bn->H->orderidx = 0; + bn->T->orderidx = 0; BBPcacheit(bs, 1); /* enter in BBP */ /* View of VIEW combine, ie we need to fix the head of the mirror */ if (vc) { diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -128,8 +128,8 @@ BATcreatedesc(int ht, int tt, int heapna /* * Default zero for order oid index */ - bn->torderidx.set = 0; - bn->torderidx.o = 0; + bn->torderidx = 0; + bn->horderidx = 0; /* * fill in heap names, so HEAPallocs can resort to disk for * very large writes. diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -699,7 +699,7 @@ heapinit(COLrec *col, const char *buf, i lng align; lng free; lng size; - int orderidx; + int orderidx = 0; unsigned short storage; int n; @@ -777,7 +777,7 @@ heapinit(COLrec *col, const char *buf, i col->heap.newstorage = (storage_t) storage; col->heap.farmid = BBPselectfarm(PERSISTENT, col->type, offheap); col->heap.dirty = 0; - col->orderidx.o = orderidx; + col->orderidx = orderidx; if (bbpversion <= GDKLIBRARY_INET_COMPARE && strcmp(type, "inet") == 0) { /* don't trust ordering information on inet columns */ col->sorted = 0; @@ -1230,7 +1230,7 @@ static inline int heap_entry(FILE *fp, COLrec *col) { return fprintf(fp, " %s %d %d %d " BUNFMT " " BUNFMT " " BUNFMT " " - BUNFMT " " OIDFMT " " OIDFMT " " SZFMT " " SZFMT " %d %d ", + BUNFMT " " OIDFMT " " OIDFMT " " SZFMT " " SZFMT " %d %d", col->type >= 0 ? BATatoms[col->type].name : ATOMunknown_name(col->type), col->width, col->varsized | (col->vheap ? col->vheap->hashash << 1 : 0), @@ -1249,7 +1249,7 @@ heap_entry(FILE *fp, COLrec *col) col->heap.free, col->heap.size, (int) col->heap.newstorage, - (int)col->orderidx.o); + (int) col->orderidx); } static inline int diff --git a/gdk/gdk_search.c b/gdk/gdk_search.c --- a/gdk/gdk_search.c +++ b/gdk/gdk_search.c @@ -689,7 +689,7 @@ SORTfndwhich(BAT *b, const void *v, enum int tp; if (b == NULL || (!b->tsorted && !b->trevsorted && !use_orderidx) - || (use_orderidx && !b->torderidx.set)) + || (use_orderidx && b->torderidx)) return BUN_NONE; lo = BUNfirst(b); @@ -726,7 +726,7 @@ SORTfndwhich(BAT *b, const void *v, enum tp = ATOMbasetype(b->ttype); if (use_orderidx) { - o = BBPdescriptor(b->torderidx.o); + o = BATdescriptor(b->torderidx); if (o == NULL) { GDKerror("#ORDERfindwhich: order idx not found\n"); } @@ -744,6 +744,7 @@ SORTfndwhich(BAT *b, const void *v, enum /* shortcut: if BAT is empty or first (and * hence all) tail value is >= v (if sorted) * or <= v (if revsorted), we're done */ + if (use_orderidx) BBPunfix(o->batCacheid); return lo; } break; @@ -755,6 +756,7 @@ SORTfndwhich(BAT *b, const void *v, enum /* shortcut: if BAT is empty or last (and * hence all) tail value is <= v (if sorted) * or >= v (if revsorted), we're done */ + if (use_orderidx) BBPunfix(o->batCacheid); return hi; } break; @@ -762,6 +764,7 @@ SORTfndwhich(BAT *b, const void *v, enum end = 0; /* not used in this case */ if (lo >= hi) { /* empty BAT: value not found */ + if (use_orderidx) BBPunfix(o->batCacheid); return BUN_NONE; } break; @@ -891,6 +894,8 @@ SORTfndwhich(BAT *b, const void *v, enum } break; } + + if (use_orderidx) BBPunfix(o->batCacheid); return cur; } diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -1428,7 +1428,7 @@ BATsubselect(BAT *b, BAT *s, const void * Selective queries are the ones below 0.1% and less than 1000 results * TODO: Test if this heuristic works in practice * TODO: we do not support anti-select with order index */ - if (!anti && b->torderidx.set && !(b->tsorted || b->trevsorted) && + if (!anti && b->torderidx && !(b->tsorted || b->trevsorted) && ((ORDERfnd(b, th) - ORDERfnd(b, tl)) < ((BUN)1000 < b->batCount/1000 ? (BUN)1000: b->batCount/1000))) use_orderidx = 1; @@ -1557,7 +1557,7 @@ BATsubselect(BAT *b, BAT *s, const void if (use_orderidx) { BAT *order; - if ((order = BATdescriptor(b->torderidx.o)) == NULL) { + if ((order = BATdescriptor(b->torderidx)) == NULL) { GDKerror("Runtime object (order index) not found"); } bn = BATslice(order, low + order->hseqbase, diff --git a/monetdb5/modules/mal/orderidx.c b/monetdb5/modules/mal/orderidx.c --- a/monetdb5/modules/mal/orderidx.c +++ b/monetdb5/modules/mal/orderidx.c @@ -36,7 +36,7 @@ OIDXcreateImplementation(Client cntxt, i return MAL_SUCCEED; /* check if b already has index */ - if (b->torderidx.set) + if (b->torderidx) return MAL_SUCCEED; if( pieces < 0 ){ @@ -109,7 +109,7 @@ OIDXcreateImplementation(Client cntxt, i pushInstruction(smb,pack); q = newAssignment(smb); q->barrier = EXITsymbol; - q->argv[0] =loopvar; + q->argv[0] = loopvar; pushEndInstruction(smb); chkProgram(cntxt->fdout, cntxt->nspace, smb); printFunction(THRdata[0], smb, 0 , 23); @@ -170,7 +170,7 @@ OIDXgetorderidx(Client cntxt, MalBlkPtr if (b == NULL) throw(MAL, "bat.getorderidx", RUNTIME_OBJECT_MISSING); - *ret = b->torderidx.o; + *ret = b->torderidx; BBPunfix(b->batCacheid); return MAL_SUCCEED; @@ -441,9 +441,8 @@ do { \ } } - m->batDirtydesc = TRUE; - b->torderidx.o = m->batCacheid; - b->torderidx.set = 1; + b->batDirtydesc = TRUE; + b->torderidx = m->batCacheid; BBPincref(m->batCacheid, TRUE); GDKfree(aid); diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c --- a/sql/backends/monet5/sql.c +++ b/sql/backends/monet5/sql.c @@ -4952,7 +4952,7 @@ sql_storage(Client cntxt, MalBlkPtr mb, w = BATtordered(bn); BUNappend(sort, &w, FALSE); - sz = bn->torderidx.set ; + sz = bn->torderidx != 0; BUNappend(oidx, &sz, FALSE); BBPunfix(bn->batCacheid); } @@ -5033,7 +5033,7 @@ sql_storage(Client cntxt, MalBlkPtr mb, /*printf("\n"); */ w = BATtordered(bn); BUNappend(sort, &w, FALSE); - sz = bn->torderidx.set ; + sz = bn->torderidx != 0; BUNappend(oidx, &sz, FALSE); BBPunfix(bn->batCacheid); } diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c --- a/sql/storage/bat/bat_storage.c +++ b/sql/storage/bat/bat_storage.c @@ -1187,7 +1187,7 @@ create_idx(sql_trans *tr, sql_idx *ni) /* what to do with the result msg */ msg = OIDXcreateImplementation(cntxt, newBatType(TYPE_oid,b->ttype), b, -1); assert(msg == NULL); - bat->bid = b->torderidx.o; + bat->bid = b->torderidx; (void)msg; bat_destroy(b); } else _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list