Changeset: d04da1e49397 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d04da1e49397 Added Files: monetdb5/extras/crackers/crackers_updates.mx Branch: holindex Log Message:
Add updates. diffs (truncated from 1651 to 300 lines): diff --git a/monetdb5/extras/crackers/crackers_updates.mx b/monetdb5/extras/crackers/crackers_updates.mx new file mode 100644 --- /dev/null +++ b/monetdb5/extras/crackers/crackers_updates.mx @@ -0,0 +1,1646 @@ +@/ +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. +@ + +@f crackers_updates + +@c +/* + * @a Martin Kersten, Stratos Idreos, Stefan Manegold + * @d March 2006 - July 2007 + * @* Cracker Updates + * + * + * @+ Interface + * + * + * @- Type expansion + */ +@= TypeSwitch +@:@1(sht,simple,,oid)@ +@:@1(int,simple,,oid)@ +@:@1(lng,simple,,oid)@ +@:@1(flt,simple,,oid)@ +@:@1(dbl,simple,,oid)@ +@:@1(date,atom,TYPE_,oid)@ + +@:@1(int,simple,,lng)@ +@:@1(int,simple,,int)@ +@:@1(int,simple,,str)@ +@:@1(int,simple,,date)@ + +@:@1(dbl,simple,,int)@ +@:@1(dbl,simple,,str)@ +@:@1(dbl,simple,,dbl)@ +@:@1(dbl,simple,,date)@ + +@:@1(date,atom,TYPE_,int)@ +@:@1(date,atom,TYPE_,str)@ +@:@1(date,atom,TYPE_,lng)@ +@:@1(date,atom,TYPE_,dbl)@ +@:@1(date,atom,TYPE_,date)@ +@ +@h +/* + * @- Header file + */ +#ifndef _CRACKERS_UPDATES_H_ +#define _CRACKERS_UPDATES_H_ + +/* Signatures shared within the crackers module/library */ +@:UpdatesSharedFunctions_decl_0@ +@:TypeSwitch(UpdatesSharedFunctions_decl_1)@ + +/* Exported signatures */ +@:UpdatesFunctions_decl_0@ +@:TypeSwitch(UpdatesFunctions_decl_1)@ + +#endif /* _CRACKERS_UPDATES_H */ +/* + * @- Exported signatures + */ +@= UpdatesFunctions_decl_0 +crackers_export str CRKsizeCrackerInsertions(int *k, int *bid); +crackers_export str CRKsizeCrackerDeletions(int *k, int *bid); +crackers_export str CRKprintCrackerInsertions(int *k, int *bid); +crackers_export str CRKprintCrackerDeletions(int *k, int *bid); +crackers_export str CRKmergeInsertions_Forget(int *k, int *bid, int *new); +crackers_export str CRKextendCrackerBAT(int *k, int *bid, lng *positions); +crackers_export str CRKmergeInsertionsB_OnNeed(int *k, int *bid, int *new); +crackers_export str CRKmergeInsertionsB_OnNeedGradually(int *k, int *bid, int *new); +crackers_export str CRKmergeInsertionsB_OnNeedGraduallyRipple(int *k, int *bid, int *new); +crackers_export str CRKmergeDeletions_OnNeed(int *k, int *bid, int *new); +crackers_export str CRKmergeDeletions_OnNeedGradually(int *k, int *bid, int *new); +crackers_export str CRKmergeDeletions_OnNeedGraduallyRipple(int *k, int *bid, int *new); +@ +@= UpdatesFunctions_decl_1 +crackers_export str CRKmergeInsertions_PartiallyForget_@1_@4(int *k, int *bid, int *new); +crackers_export str CRKmergeInsertionsB_Force_@1_@4(int *k, int *bid, int *new); +@ + * @- Signatures shared within the crackers module/library +@= UpdatesSharedFunctions_decl_0 +str appendInsertions(int *new, int position); +@ +@= UpdatesSharedFunctions_decl_1 +/* mergeInsertionOperations */ +str mergeInsertionsB_@1_@4(int *bid, int *new, oid startPosition, oid endPosition); +str mergeInsertionsBGradually_@1_@4(int *bid, int *new, oid startPosition, oid endPosition); +str mergeInsertionsBRipple_@1_@4(BAT *b, BAT *u, oid startPosition, oid endPosition, @1 *hgh, bit inclusive, int position); +str mergeDeletions_@1_@4(int *bid, int *del, oid startPosition, oid endPosition); +str mergeDeletionsGradually_@1_@4(int *bid, int *del, oid startPosition, oid endPosition); +str mergeDeletionsGraduallyRipple_@1_@4(int *bid, int *del, oid startPosition, oid endPosition, @1 *lowV, bit inclusiveL, @1 *hghV, bit inclusiveH); +@ +@c +/* + * @+ Implementation + * + * + * @- C file + */ +#include "monetdb_config.h" +#include "crackers.h" + +/* Local support functions and macros */ +@:UpdatesLocal@ + +/* Functions shared within the crackers module/library */ +@:UpdatesSharedFunctions_impl_0@ +@:TypeSwitch(UpdatesSharedFunctions_impl_1)@ + +/* Exported functions */ +@:UpdatesFunctions_impl_0@ +@:updatesOnNeed(,0)@ +@:updatesOnNeed(Gradually,1)@ +@:updatesOnNeed(GraduallyRipple,2)@ +@:TypeSwitch(UpdatesFunctions_impl_1)@ +/* + * @- Exported functions + */ +@= UpdatesFunctions_impl_0 +str +CRKsizeCrackerDeletions(int *k, int *bid){ + (void)k; + sizeCrackerDeletions(*bid); + return MAL_SUCCEED; +} + +str +CRKsizeCrackerInsertions(int *k, int *bid){ + (void)k; + sizeCrackerInsertions(*bid); + + return MAL_SUCCEED; +} + +str +CRKprintCrackerDeletions(int *k, int *bid){ + (void)k; + printCrackerDeletions(*bid); + + return MAL_SUCCEED; +} + +str +CRKprintCrackerInsertions(int *k, int *bid){ + (void)k; + printCrackerInsertions(*bid); + + return MAL_SUCCEED; +} + +str +CRKmergeInsertions_Forget(int *k, int *bid, int *new){ + (void) k; + appendCrackerBAT(bid,new); + removeCrackerIndex(bid); + + return MAL_SUCCEED; +} + +str +CRKextendCrackerBAT(int *k, int *bid, lng *positions){ + BAT *b; + int position = existsCrackerIndex(*bid); + (void) k; + + if (position == -1) + throw(MAL, "crackers.CRKextendCrackerBAT", "Cannot find cracker index"); + if ((b = BATdescriptor(CrackerIndex[position].cbid)) == NULL) + throw(MAL, "crackers.CRKextendCrackerBAT", "Cannot access cracker BAT"); + + if ( (oid)*positions > BATcapacity(b) - BATcount(b) ){ + BUN ncap; + BUN grows; + oid needed = (oid)*positions - (BATcapacity(b) - BATcount(b)); + ncap = BATcapacity(b) + needed; + grows = BATgrows(b); + if (ncap > grows) + grows = ncap; + if (BATextend(b, grows) == NULL) + throw(MAL, "crackers.CRKextendCrackerBAT", "Failed to extend the cracker BAT"); + } + + BBPunfix(b->batCacheid); + + return MAL_SUCCEED; +} +@ +@= updatesOnNeed +str +CRKmergeInsertionsB_OnNeed@1(int *k, int *bid, int *new){ + int position = existsCrackerIndex(*bid); + (void) k; + + if (position == -1) + throw(MAL, "crackers.CRKmergeInsertionsB_OnNeed@1", "Cannot find cracker index"); + + appendInsertions(new,position); + CrackerIndex[position].mergeInsertions = @2; + CrackerIndex[position].deleteNodes = FALSE; + + return MAL_SUCCEED; +} + +#if 0 +static str +CRKmergeInsertions_OnNeed@1(int *k, int *bid, int *new, bit *deleteNodes){ + int position = existsCrackerIndex(*bid); + (void) k; + + if (position == -1) + throw(MAL, "crackers.CRKmergeInsertions_OnNeed@1", "Cannot find cracker index"); + + appendInsertions(new,position); + CrackerIndex[position].mergeInsertions = @2; + CrackerIndex[position].deleteNodes = *deleteNodes; + + return MAL_SUCCEED; +} +#endif + +str +CRKmergeDeletions_OnNeed@1(int *k, int *bid, int *del){ + int position = existsCrackerIndex(*bid); + (void) k; + + if (position == -1) + throw(MAL, "crackers.CRKmergeDeletions_OnNeed@1", "Cannot find cracker index"); + + appendDeletions(del,position); + CrackerIndex[position].mergeDeletions = @2; + + return MAL_SUCCEED; +} +@ +@= UpdatesFunctions_impl_1 +str +CRKmergeInsertions_PartiallyForget_@1_@4(int *k, int *bid, int *new){ + BAT *c, *u; + @1 min; + @1 *inst, *insLast; + int position = -1; + int i; + + (void) k; + + if ((u = BATdescriptor(*new)) == NULL) + throw(MAL, "crackers.mergeInsertions_PartiallyForget_@1", "Cannot access insertions"); + + if (BATcount(u) == 0) + return MAL_SUCCEED; + + for (i = 0; i < maxCrackMap; i++) + if (CrackerIndex[i].bid == *bid){ + position = i; + break; + } + + /*if (position == -1) return; Trying to erase an index that does not exist*/ + + if ((c = BATdescriptor(CrackerIndex[position].cid)) == NULL){ + BBPunfix(u->batCacheid); + throw(MAL, "crackers.CRKmergeInsertions_PartiallyForget_@1", "Cannot access cracker index"); + } + + /* get the min value */ + inst = (@1*)Tloc(u,BUNfirst(u)); + insLast = (@1*)Tloc(u,BUNlast(u)); + min = *inst; + for(inst+=1;inst < insLast; inst++) + if (@2_GT(&min,inst,@3@1)) + min = *inst; + + /* Partially delete tree with lazy deletion */ + PartiallyLazyFreeAVLTree_@1(CrackerIndex[position].Tree, min, c, BUNfirst(c)); + + appendCrackerBAT(bid,new); + + BBPunfix(c->batCacheid); + BBPunfix(u->batCacheid); + _______________________________________________ checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
