base_lmdb_store.c 743 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469
  1. /* Generated by Cython 0.28.4 */
  2. /* BEGIN: Cython Metadata
  3. {
  4. "distutils": {
  5. "depends": [
  6. "/home/scossu/code/lsup/src/ext/include/lmdb.h"
  7. ],
  8. "include_dirs": [
  9. "/home/scossu/code/lsup/src/ext/include",
  10. "/home/scossu/code/lsup/src/lakesuperior/cy_include"
  11. ],
  12. "name": "lakesuperior.store.base_lmdb_store",
  13. "sources": [
  14. "/home/scossu/code/lsup/src/lakesuperior/store/base_lmdb_store.pyx",
  15. "/home/scossu/code/lsup/src/ext/lib/mdb.c",
  16. "/home/scossu/code/lsup/src/ext/lib/midl.c"
  17. ]
  18. },
  19. "module_name": "lakesuperior.store.base_lmdb_store"
  20. }
  21. END: Cython Metadata */
  22. #define PY_SSIZE_T_CLEAN
  23. #include "Python.h"
  24. #ifndef Py_PYTHON_H
  25. #error Python headers needed to compile C extensions, please install development version of Python.
  26. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
  27. #error Cython requires Python 2.6+ or Python 3.3+.
  28. #else
  29. #define CYTHON_ABI "0_28_4"
  30. #define CYTHON_FUTURE_DIVISION 1
  31. #include <stddef.h>
  32. #ifndef offsetof
  33. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  34. #endif
  35. #if !defined(WIN32) && !defined(MS_WINDOWS)
  36. #ifndef __stdcall
  37. #define __stdcall
  38. #endif
  39. #ifndef __cdecl
  40. #define __cdecl
  41. #endif
  42. #ifndef __fastcall
  43. #define __fastcall
  44. #endif
  45. #endif
  46. #ifndef DL_IMPORT
  47. #define DL_IMPORT(t) t
  48. #endif
  49. #ifndef DL_EXPORT
  50. #define DL_EXPORT(t) t
  51. #endif
  52. #define __PYX_COMMA ,
  53. #ifndef HAVE_LONG_LONG
  54. #if PY_VERSION_HEX >= 0x02070000
  55. #define HAVE_LONG_LONG
  56. #endif
  57. #endif
  58. #ifndef PY_LONG_LONG
  59. #define PY_LONG_LONG LONG_LONG
  60. #endif
  61. #ifndef Py_HUGE_VAL
  62. #define Py_HUGE_VAL HUGE_VAL
  63. #endif
  64. #ifdef PYPY_VERSION
  65. #define CYTHON_COMPILING_IN_PYPY 1
  66. #define CYTHON_COMPILING_IN_PYSTON 0
  67. #define CYTHON_COMPILING_IN_CPYTHON 0
  68. #undef CYTHON_USE_TYPE_SLOTS
  69. #define CYTHON_USE_TYPE_SLOTS 0
  70. #undef CYTHON_USE_PYTYPE_LOOKUP
  71. #define CYTHON_USE_PYTYPE_LOOKUP 0
  72. #if PY_VERSION_HEX < 0x03050000
  73. #undef CYTHON_USE_ASYNC_SLOTS
  74. #define CYTHON_USE_ASYNC_SLOTS 0
  75. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  76. #define CYTHON_USE_ASYNC_SLOTS 1
  77. #endif
  78. #undef CYTHON_USE_PYLIST_INTERNALS
  79. #define CYTHON_USE_PYLIST_INTERNALS 0
  80. #undef CYTHON_USE_UNICODE_INTERNALS
  81. #define CYTHON_USE_UNICODE_INTERNALS 0
  82. #undef CYTHON_USE_UNICODE_WRITER
  83. #define CYTHON_USE_UNICODE_WRITER 0
  84. #undef CYTHON_USE_PYLONG_INTERNALS
  85. #define CYTHON_USE_PYLONG_INTERNALS 0
  86. #undef CYTHON_AVOID_BORROWED_REFS
  87. #define CYTHON_AVOID_BORROWED_REFS 1
  88. #undef CYTHON_ASSUME_SAFE_MACROS
  89. #define CYTHON_ASSUME_SAFE_MACROS 0
  90. #undef CYTHON_UNPACK_METHODS
  91. #define CYTHON_UNPACK_METHODS 0
  92. #undef CYTHON_FAST_THREAD_STATE
  93. #define CYTHON_FAST_THREAD_STATE 0
  94. #undef CYTHON_FAST_PYCALL
  95. #define CYTHON_FAST_PYCALL 0
  96. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  97. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  98. #undef CYTHON_USE_TP_FINALIZE
  99. #define CYTHON_USE_TP_FINALIZE 0
  100. #elif defined(PYSTON_VERSION)
  101. #define CYTHON_COMPILING_IN_PYPY 0
  102. #define CYTHON_COMPILING_IN_PYSTON 1
  103. #define CYTHON_COMPILING_IN_CPYTHON 0
  104. #ifndef CYTHON_USE_TYPE_SLOTS
  105. #define CYTHON_USE_TYPE_SLOTS 1
  106. #endif
  107. #undef CYTHON_USE_PYTYPE_LOOKUP
  108. #define CYTHON_USE_PYTYPE_LOOKUP 0
  109. #undef CYTHON_USE_ASYNC_SLOTS
  110. #define CYTHON_USE_ASYNC_SLOTS 0
  111. #undef CYTHON_USE_PYLIST_INTERNALS
  112. #define CYTHON_USE_PYLIST_INTERNALS 0
  113. #ifndef CYTHON_USE_UNICODE_INTERNALS
  114. #define CYTHON_USE_UNICODE_INTERNALS 1
  115. #endif
  116. #undef CYTHON_USE_UNICODE_WRITER
  117. #define CYTHON_USE_UNICODE_WRITER 0
  118. #undef CYTHON_USE_PYLONG_INTERNALS
  119. #define CYTHON_USE_PYLONG_INTERNALS 0
  120. #ifndef CYTHON_AVOID_BORROWED_REFS
  121. #define CYTHON_AVOID_BORROWED_REFS 0
  122. #endif
  123. #ifndef CYTHON_ASSUME_SAFE_MACROS
  124. #define CYTHON_ASSUME_SAFE_MACROS 1
  125. #endif
  126. #ifndef CYTHON_UNPACK_METHODS
  127. #define CYTHON_UNPACK_METHODS 1
  128. #endif
  129. #undef CYTHON_FAST_THREAD_STATE
  130. #define CYTHON_FAST_THREAD_STATE 0
  131. #undef CYTHON_FAST_PYCALL
  132. #define CYTHON_FAST_PYCALL 0
  133. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  134. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  135. #undef CYTHON_USE_TP_FINALIZE
  136. #define CYTHON_USE_TP_FINALIZE 0
  137. #else
  138. #define CYTHON_COMPILING_IN_PYPY 0
  139. #define CYTHON_COMPILING_IN_PYSTON 0
  140. #define CYTHON_COMPILING_IN_CPYTHON 1
  141. #ifndef CYTHON_USE_TYPE_SLOTS
  142. #define CYTHON_USE_TYPE_SLOTS 1
  143. #endif
  144. #if PY_VERSION_HEX < 0x02070000
  145. #undef CYTHON_USE_PYTYPE_LOOKUP
  146. #define CYTHON_USE_PYTYPE_LOOKUP 0
  147. #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
  148. #define CYTHON_USE_PYTYPE_LOOKUP 1
  149. #endif
  150. #if PY_MAJOR_VERSION < 3
  151. #undef CYTHON_USE_ASYNC_SLOTS
  152. #define CYTHON_USE_ASYNC_SLOTS 0
  153. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  154. #define CYTHON_USE_ASYNC_SLOTS 1
  155. #endif
  156. #if PY_VERSION_HEX < 0x02070000
  157. #undef CYTHON_USE_PYLONG_INTERNALS
  158. #define CYTHON_USE_PYLONG_INTERNALS 0
  159. #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
  160. #define CYTHON_USE_PYLONG_INTERNALS 1
  161. #endif
  162. #ifndef CYTHON_USE_PYLIST_INTERNALS
  163. #define CYTHON_USE_PYLIST_INTERNALS 1
  164. #endif
  165. #ifndef CYTHON_USE_UNICODE_INTERNALS
  166. #define CYTHON_USE_UNICODE_INTERNALS 1
  167. #endif
  168. #if PY_VERSION_HEX < 0x030300F0
  169. #undef CYTHON_USE_UNICODE_WRITER
  170. #define CYTHON_USE_UNICODE_WRITER 0
  171. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  172. #define CYTHON_USE_UNICODE_WRITER 1
  173. #endif
  174. #ifndef CYTHON_AVOID_BORROWED_REFS
  175. #define CYTHON_AVOID_BORROWED_REFS 0
  176. #endif
  177. #ifndef CYTHON_ASSUME_SAFE_MACROS
  178. #define CYTHON_ASSUME_SAFE_MACROS 1
  179. #endif
  180. #ifndef CYTHON_UNPACK_METHODS
  181. #define CYTHON_UNPACK_METHODS 1
  182. #endif
  183. #ifndef CYTHON_FAST_THREAD_STATE
  184. #define CYTHON_FAST_THREAD_STATE 1
  185. #endif
  186. #ifndef CYTHON_FAST_PYCALL
  187. #define CYTHON_FAST_PYCALL 1
  188. #endif
  189. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  190. #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
  191. #endif
  192. #ifndef CYTHON_USE_TP_FINALIZE
  193. #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  194. #endif
  195. #endif
  196. #if !defined(CYTHON_FAST_PYCCALL)
  197. #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
  198. #endif
  199. #if CYTHON_USE_PYLONG_INTERNALS
  200. #include "longintrepr.h"
  201. #undef SHIFT
  202. #undef BASE
  203. #undef MASK
  204. #endif
  205. #ifndef __has_attribute
  206. #define __has_attribute(x) 0
  207. #endif
  208. #ifndef __has_cpp_attribute
  209. #define __has_cpp_attribute(x) 0
  210. #endif
  211. #ifndef CYTHON_RESTRICT
  212. #if defined(__GNUC__)
  213. #define CYTHON_RESTRICT __restrict__
  214. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  215. #define CYTHON_RESTRICT __restrict
  216. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  217. #define CYTHON_RESTRICT restrict
  218. #else
  219. #define CYTHON_RESTRICT
  220. #endif
  221. #endif
  222. #ifndef CYTHON_UNUSED
  223. # if defined(__GNUC__)
  224. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  225. # define CYTHON_UNUSED __attribute__ ((__unused__))
  226. # else
  227. # define CYTHON_UNUSED
  228. # endif
  229. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  230. # define CYTHON_UNUSED __attribute__ ((__unused__))
  231. # else
  232. # define CYTHON_UNUSED
  233. # endif
  234. #endif
  235. #ifndef CYTHON_MAYBE_UNUSED_VAR
  236. # if defined(__cplusplus)
  237. template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
  238. # else
  239. # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
  240. # endif
  241. #endif
  242. #ifndef CYTHON_NCP_UNUSED
  243. # if CYTHON_COMPILING_IN_CPYTHON
  244. # define CYTHON_NCP_UNUSED
  245. # else
  246. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  247. # endif
  248. #endif
  249. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  250. #ifdef _MSC_VER
  251. #ifndef _MSC_STDINT_H_
  252. #if _MSC_VER < 1300
  253. typedef unsigned char uint8_t;
  254. typedef unsigned int uint32_t;
  255. #else
  256. typedef unsigned __int8 uint8_t;
  257. typedef unsigned __int32 uint32_t;
  258. #endif
  259. #endif
  260. #else
  261. #include <stdint.h>
  262. #endif
  263. #ifndef CYTHON_FALLTHROUGH
  264. #if defined(__cplusplus) && __cplusplus >= 201103L
  265. #if __has_cpp_attribute(fallthrough)
  266. #define CYTHON_FALLTHROUGH [[fallthrough]]
  267. #elif __has_cpp_attribute(clang::fallthrough)
  268. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  269. #elif __has_cpp_attribute(gnu::fallthrough)
  270. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  271. #endif
  272. #endif
  273. #ifndef CYTHON_FALLTHROUGH
  274. #if __has_attribute(fallthrough)
  275. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  276. #else
  277. #define CYTHON_FALLTHROUGH
  278. #endif
  279. #endif
  280. #if defined(__clang__ ) && defined(__apple_build_version__)
  281. #if __apple_build_version__ < 7000000
  282. #undef CYTHON_FALLTHROUGH
  283. #define CYTHON_FALLTHROUGH
  284. #endif
  285. #endif
  286. #endif
  287. #ifndef CYTHON_INLINE
  288. #if defined(__clang__)
  289. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  290. #elif defined(__GNUC__)
  291. #define CYTHON_INLINE __inline__
  292. #elif defined(_MSC_VER)
  293. #define CYTHON_INLINE __inline
  294. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  295. #define CYTHON_INLINE inline
  296. #else
  297. #define CYTHON_INLINE
  298. #endif
  299. #endif
  300. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  301. #define Py_OptimizeFlag 0
  302. #endif
  303. #define __PYX_BUILD_PY_SSIZE_T "n"
  304. #define CYTHON_FORMAT_SSIZE_T "z"
  305. #if PY_MAJOR_VERSION < 3
  306. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  307. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  308. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  309. #define __Pyx_DefaultClassType PyClass_Type
  310. #else
  311. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  312. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  313. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  314. #define __Pyx_DefaultClassType PyType_Type
  315. #endif
  316. #ifndef Py_TPFLAGS_CHECKTYPES
  317. #define Py_TPFLAGS_CHECKTYPES 0
  318. #endif
  319. #ifndef Py_TPFLAGS_HAVE_INDEX
  320. #define Py_TPFLAGS_HAVE_INDEX 0
  321. #endif
  322. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  323. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  324. #endif
  325. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  326. #define Py_TPFLAGS_HAVE_FINALIZE 0
  327. #endif
  328. #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  329. #ifndef METH_FASTCALL
  330. #define METH_FASTCALL 0x80
  331. #endif
  332. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  333. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  334. Py_ssize_t nargs, PyObject *kwnames);
  335. #else
  336. #define __Pyx_PyCFunctionFast _PyCFunctionFast
  337. #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  338. #endif
  339. #if CYTHON_FAST_PYCCALL
  340. #define __Pyx_PyFastCFunction_Check(func)\
  341. ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
  342. #else
  343. #define __Pyx_PyFastCFunction_Check(func) 0
  344. #endif
  345. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  346. #define PyObject_Malloc(s) PyMem_Malloc(s)
  347. #define PyObject_Free(p) PyMem_Free(p)
  348. #define PyObject_Realloc(p) PyMem_Realloc(p)
  349. #endif
  350. #if CYTHON_COMPILING_IN_PYSTON
  351. #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
  352. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
  353. #else
  354. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  355. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  356. #endif
  357. #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  358. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  359. #elif PY_VERSION_HEX >= 0x03060000
  360. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  361. #elif PY_VERSION_HEX >= 0x03000000
  362. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  363. #else
  364. #define __Pyx_PyThreadState_Current _PyThreadState_Current
  365. #endif
  366. #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
  367. #include "pythread.h"
  368. #define Py_tss_NEEDS_INIT 0
  369. typedef int Py_tss_t;
  370. static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  371. *key = PyThread_create_key();
  372. return 0; // PyThread_create_key reports success always
  373. }
  374. static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  375. Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  376. *key = Py_tss_NEEDS_INIT;
  377. return key;
  378. }
  379. static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  380. PyObject_Free(key);
  381. }
  382. static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  383. return *key != Py_tss_NEEDS_INIT;
  384. }
  385. static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  386. PyThread_delete_key(*key);
  387. *key = Py_tss_NEEDS_INIT;
  388. }
  389. static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  390. return PyThread_set_key_value(*key, value);
  391. }
  392. static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  393. return PyThread_get_key_value(*key);
  394. }
  395. #endif // TSS (Thread Specific Storage) API
  396. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  397. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  398. #else
  399. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  400. #endif
  401. #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  402. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  403. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  404. #else
  405. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  406. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  407. #endif
  408. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
  409. #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  410. #else
  411. #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
  412. #endif
  413. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  414. #define CYTHON_PEP393_ENABLED 1
  415. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  416. 0 : _PyUnicode_Ready((PyObject *)(op)))
  417. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  418. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  419. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  420. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  421. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  422. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  423. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
  424. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  425. #else
  426. #define CYTHON_PEP393_ENABLED 0
  427. #define PyUnicode_1BYTE_KIND 1
  428. #define PyUnicode_2BYTE_KIND 2
  429. #define PyUnicode_4BYTE_KIND 4
  430. #define __Pyx_PyUnicode_READY(op) (0)
  431. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  432. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  433. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  434. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  435. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  436. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  437. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  438. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  439. #endif
  440. #if CYTHON_COMPILING_IN_PYPY
  441. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  442. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  443. #else
  444. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  445. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  446. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  447. #endif
  448. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  449. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  450. #endif
  451. #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  452. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  453. #endif
  454. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  455. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  456. #endif
  457. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  458. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  459. #if PY_MAJOR_VERSION >= 3
  460. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  461. #else
  462. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  463. #endif
  464. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  465. #define PyObject_ASCII(o) PyObject_Repr(o)
  466. #endif
  467. #if PY_MAJOR_VERSION >= 3
  468. #define PyBaseString_Type PyUnicode_Type
  469. #define PyStringObject PyUnicodeObject
  470. #define PyString_Type PyUnicode_Type
  471. #define PyString_Check PyUnicode_Check
  472. #define PyString_CheckExact PyUnicode_CheckExact
  473. #define PyObject_Unicode PyObject_Str
  474. #endif
  475. #if PY_MAJOR_VERSION >= 3
  476. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  477. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  478. #else
  479. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  480. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  481. #endif
  482. #ifndef PySet_CheckExact
  483. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  484. #endif
  485. #if CYTHON_ASSUME_SAFE_MACROS
  486. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  487. #else
  488. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  489. #endif
  490. #if PY_MAJOR_VERSION >= 3
  491. #define PyIntObject PyLongObject
  492. #define PyInt_Type PyLong_Type
  493. #define PyInt_Check(op) PyLong_Check(op)
  494. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  495. #define PyInt_FromString PyLong_FromString
  496. #define PyInt_FromUnicode PyLong_FromUnicode
  497. #define PyInt_FromLong PyLong_FromLong
  498. #define PyInt_FromSize_t PyLong_FromSize_t
  499. #define PyInt_FromSsize_t PyLong_FromSsize_t
  500. #define PyInt_AsLong PyLong_AsLong
  501. #define PyInt_AS_LONG PyLong_AS_LONG
  502. #define PyInt_AsSsize_t PyLong_AsSsize_t
  503. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  504. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  505. #define PyNumber_Int PyNumber_Long
  506. #endif
  507. #if PY_MAJOR_VERSION >= 3
  508. #define PyBoolObject PyLongObject
  509. #endif
  510. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  511. #ifndef PyUnicode_InternFromString
  512. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  513. #endif
  514. #endif
  515. #if PY_VERSION_HEX < 0x030200A4
  516. typedef long Py_hash_t;
  517. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  518. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  519. #else
  520. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  521. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  522. #endif
  523. #if PY_MAJOR_VERSION >= 3
  524. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
  525. #else
  526. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  527. #endif
  528. #if CYTHON_USE_ASYNC_SLOTS
  529. #if PY_VERSION_HEX >= 0x030500B1
  530. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  531. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  532. #else
  533. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  534. #endif
  535. #else
  536. #define __Pyx_PyType_AsAsync(obj) NULL
  537. #endif
  538. #ifndef __Pyx_PyAsyncMethodsStruct
  539. typedef struct {
  540. unaryfunc am_await;
  541. unaryfunc am_aiter;
  542. unaryfunc am_anext;
  543. } __Pyx_PyAsyncMethodsStruct;
  544. #endif
  545. #if defined(WIN32) || defined(MS_WINDOWS)
  546. #define _USE_MATH_DEFINES
  547. #endif
  548. #include <math.h>
  549. #ifdef NAN
  550. #define __PYX_NAN() ((float) NAN)
  551. #else
  552. static CYTHON_INLINE float __PYX_NAN() {
  553. float value;
  554. memset(&value, 0xFF, sizeof(value));
  555. return value;
  556. }
  557. #endif
  558. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  559. #define __Pyx_truncl trunc
  560. #else
  561. #define __Pyx_truncl truncl
  562. #endif
  563. #define __PYX_ERR(f_index, lineno, Ln_error) \
  564. { \
  565. __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
  566. }
  567. #ifndef __PYX_EXTERN_C
  568. #ifdef __cplusplus
  569. #define __PYX_EXTERN_C extern "C"
  570. #else
  571. #define __PYX_EXTERN_C extern
  572. #endif
  573. #endif
  574. #define __PYX_HAVE__lakesuperior__store__base_lmdb_store
  575. #define __PYX_HAVE_API__lakesuperior__store__base_lmdb_store
  576. /* Early includes */
  577. #include <stdint.h>
  578. #include <sys/types.h>
  579. #include "lmdb.h"
  580. #include <errno.h>
  581. #ifdef _OPENMP
  582. #include <omp.h>
  583. #endif /* _OPENMP */
  584. #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
  585. #define CYTHON_WITHOUT_ASSERTIONS
  586. #endif
  587. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  588. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  589. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  590. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  591. #define __PYX_DEFAULT_STRING_ENCODING ""
  592. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  593. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  594. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  595. #define __Pyx_long_cast(x) ((long)x)
  596. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  597. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  598. (sizeof(type) > sizeof(Py_ssize_t) &&\
  599. likely(v < (type)PY_SSIZE_T_MAX ||\
  600. v == (type)PY_SSIZE_T_MAX) &&\
  601. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  602. v == (type)PY_SSIZE_T_MIN))) ||\
  603. (sizeof(type) == sizeof(Py_ssize_t) &&\
  604. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  605. v == (type)PY_SSIZE_T_MAX))) )
  606. #if defined (__cplusplus) && __cplusplus >= 201103L
  607. #include <cstdlib>
  608. #define __Pyx_sst_abs(value) std::abs(value)
  609. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  610. #define __Pyx_sst_abs(value) abs(value)
  611. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  612. #define __Pyx_sst_abs(value) labs(value)
  613. #elif defined (_MSC_VER)
  614. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  615. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  616. #define __Pyx_sst_abs(value) llabs(value)
  617. #elif defined (__GNUC__)
  618. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  619. #else
  620. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  621. #endif
  622. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  623. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  624. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  625. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  626. #define __Pyx_PyBytes_FromString PyBytes_FromString
  627. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  628. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  629. #if PY_MAJOR_VERSION < 3
  630. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  631. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  632. #else
  633. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  634. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  635. #endif
  636. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  637. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  638. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  639. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  640. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  641. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  642. #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
  643. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  644. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  645. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  646. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  647. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  648. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  649. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  650. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  651. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  652. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
  653. const Py_UNICODE *u_end = u;
  654. while (*u_end++) ;
  655. return (size_t)(u_end - u - 1);
  656. }
  657. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  658. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  659. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  660. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  661. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  662. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  663. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  664. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  665. #define __Pyx_PySequence_Tuple(obj)\
  666. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  667. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  668. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  669. #if CYTHON_ASSUME_SAFE_MACROS
  670. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  671. #else
  672. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  673. #endif
  674. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  675. #if PY_MAJOR_VERSION >= 3
  676. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  677. #else
  678. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  679. #endif
  680. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  681. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  682. static int __Pyx_sys_getdefaultencoding_not_ascii;
  683. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  684. PyObject* sys;
  685. PyObject* default_encoding = NULL;
  686. PyObject* ascii_chars_u = NULL;
  687. PyObject* ascii_chars_b = NULL;
  688. const char* default_encoding_c;
  689. sys = PyImport_ImportModule("sys");
  690. if (!sys) goto bad;
  691. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  692. Py_DECREF(sys);
  693. if (!default_encoding) goto bad;
  694. default_encoding_c = PyBytes_AsString(default_encoding);
  695. if (!default_encoding_c) goto bad;
  696. if (strcmp(default_encoding_c, "ascii") == 0) {
  697. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  698. } else {
  699. char ascii_chars[128];
  700. int c;
  701. for (c = 0; c < 128; c++) {
  702. ascii_chars[c] = c;
  703. }
  704. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  705. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  706. if (!ascii_chars_u) goto bad;
  707. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  708. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  709. PyErr_Format(
  710. PyExc_ValueError,
  711. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  712. default_encoding_c);
  713. goto bad;
  714. }
  715. Py_DECREF(ascii_chars_u);
  716. Py_DECREF(ascii_chars_b);
  717. }
  718. Py_DECREF(default_encoding);
  719. return 0;
  720. bad:
  721. Py_XDECREF(default_encoding);
  722. Py_XDECREF(ascii_chars_u);
  723. Py_XDECREF(ascii_chars_b);
  724. return -1;
  725. }
  726. #endif
  727. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  728. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  729. #else
  730. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  731. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  732. static char* __PYX_DEFAULT_STRING_ENCODING;
  733. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  734. PyObject* sys;
  735. PyObject* default_encoding = NULL;
  736. char* default_encoding_c;
  737. sys = PyImport_ImportModule("sys");
  738. if (!sys) goto bad;
  739. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  740. Py_DECREF(sys);
  741. if (!default_encoding) goto bad;
  742. default_encoding_c = PyBytes_AsString(default_encoding);
  743. if (!default_encoding_c) goto bad;
  744. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
  745. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  746. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  747. Py_DECREF(default_encoding);
  748. return 0;
  749. bad:
  750. Py_XDECREF(default_encoding);
  751. return -1;
  752. }
  753. #endif
  754. #endif
  755. /* Test for GCC > 2.95 */
  756. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  757. #define likely(x) __builtin_expect(!!(x), 1)
  758. #define unlikely(x) __builtin_expect(!!(x), 0)
  759. #else /* !__GNUC__ or GCC < 2.95 */
  760. #define likely(x) (x)
  761. #define unlikely(x) (x)
  762. #endif /* __GNUC__ */
  763. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  764. static PyObject *__pyx_m = NULL;
  765. static PyObject *__pyx_d;
  766. static PyObject *__pyx_b;
  767. static PyObject *__pyx_cython_runtime = NULL;
  768. static PyObject *__pyx_empty_tuple;
  769. static PyObject *__pyx_empty_bytes;
  770. static PyObject *__pyx_empty_unicode;
  771. static int __pyx_lineno;
  772. static int __pyx_clineno = 0;
  773. static const char * __pyx_cfilenm= __FILE__;
  774. static const char *__pyx_filename;
  775. static const char *__pyx_f[] = {
  776. "lakesuperior/store/base_lmdb_store.pyx",
  777. "stringsource",
  778. "lakesuperior/store/base_lmdb_store.pxd",
  779. };
  780. /*--- Type declarations ---*/
  781. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  782. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx;
  783. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check;
  784. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis;
  785. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin;
  786. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists;
  787. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open;
  788. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi;
  789. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put;
  790. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data;
  791. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete;
  792. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env;
  793. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy;
  794. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data;
  795. /* "lakesuperior/store/base_lmdb_store.pxd":10
  796. * lmdb.MDB_dbi dbi
  797. *
  798. * void _check(int rc, str message=*) except * # <<<<<<<<<<<<<<
  799. *
  800. *
  801. */
  802. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check {
  803. int __pyx_n;
  804. PyObject *message;
  805. };
  806. /* "lakesuperior/store/base_lmdb_store.pxd":26
  807. * void _clear_stale_readers(self) except *
  808. * void _cur_close(self, lmdb.MDB_cursor *cur) except *
  809. * void _init_dbis(self, create=*) except * # <<<<<<<<<<<<<<
  810. * void _txn_begin(self, write=*, lmdb.MDB_txn *parent=*) except *
  811. * void _txn_commit(self) except *
  812. */
  813. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis {
  814. int __pyx_n;
  815. PyObject *create;
  816. };
  817. /* "lakesuperior/store/base_lmdb_store.pxd":27
  818. * void _cur_close(self, lmdb.MDB_cursor *cur) except *
  819. * void _init_dbis(self, create=*) except *
  820. * void _txn_begin(self, write=*, lmdb.MDB_txn *parent=*) except * # <<<<<<<<<<<<<<
  821. * void _txn_commit(self) except *
  822. * void _txn_abort(self) except *
  823. */
  824. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin {
  825. int __pyx_n;
  826. PyObject *write;
  827. MDB_txn *parent;
  828. };
  829. /* "lakesuperior/store/base_lmdb_store.pxd":30
  830. * void _txn_commit(self) except *
  831. * void _txn_abort(self) except *
  832. * inline bint _key_exists( # <<<<<<<<<<<<<<
  833. * self, unsigned char *key, unsigned char klen,
  834. * unsigned char *dblabel=*) except -1
  835. */
  836. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists {
  837. int __pyx_n;
  838. unsigned char *dblabel;
  839. };
  840. /* "lakesuperior/store/base_lmdb_store.pxd":35
  841. *
  842. * size_t _txn_id(self) except -1
  843. * lmdb.MDB_cursor *_cur_open( # <<<<<<<<<<<<<<
  844. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*) except *
  845. *
  846. */
  847. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open {
  848. int __pyx_n;
  849. unsigned char *dblabel;
  850. MDB_txn *txn;
  851. };
  852. /* "lakesuperior/store/base_lmdb_store.pxd":38
  853. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*) except *
  854. *
  855. * lmdb.MDB_dbi get_dbi( # <<<<<<<<<<<<<<
  856. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*)
  857. *
  858. */
  859. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi {
  860. int __pyx_n;
  861. unsigned char *dblabel;
  862. MDB_txn *txn;
  863. };
  864. /* "lakesuperior/store/base_lmdb_store.pxd":41
  865. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*)
  866. *
  867. * void _put( # <<<<<<<<<<<<<<
  868. * self, unsigned char *key, size_t key_size, unsigned char *data,
  869. * size_t data_size, unsigned char *dblabel=*,
  870. */
  871. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put {
  872. int __pyx_n;
  873. unsigned char *dblabel;
  874. MDB_txn *txn;
  875. unsigned int flags;
  876. };
  877. /* "lakesuperior/store/base_lmdb_store.pxd":46
  878. * lmdb.MDB_txn *txn=*, unsigned int flags=*) except *
  879. *
  880. * void _get_data( # <<<<<<<<<<<<<<
  881. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  882. * unsigned char *dblabel=*) except *
  883. */
  884. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data {
  885. int __pyx_n;
  886. unsigned char *dblabel;
  887. };
  888. /* "lakesuperior/store/base_lmdb_store.pxd":50
  889. * unsigned char *dblabel=*) except *
  890. *
  891. * void _delete( # <<<<<<<<<<<<<<
  892. * self, unsigned char *key, size_t klen,
  893. * unsigned char *dblabel=*) except *
  894. */
  895. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete {
  896. int __pyx_n;
  897. unsigned char *dblabel;
  898. };
  899. /* "lakesuperior/store/base_lmdb_store.pxd":57
  900. * #int _reader_list_callback(self, const unsigned char *msg, void *str_)
  901. *
  902. * cpdef void close_env(self, bint commit_pending_transaction=*) except * # <<<<<<<<<<<<<<
  903. * cpdef void destroy(self, _path=*) except *
  904. * #cpdef get_dup_data(self, unsigned char *key, db=*)
  905. */
  906. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env {
  907. int __pyx_n;
  908. int commit_pending_transaction;
  909. };
  910. /* "lakesuperior/store/base_lmdb_store.pxd":58
  911. *
  912. * cpdef void close_env(self, bint commit_pending_transaction=*) except *
  913. * cpdef void destroy(self, _path=*) except * # <<<<<<<<<<<<<<
  914. * #cpdef get_dup_data(self, unsigned char *key, db=*)
  915. * #cpdef get_all_pairs(self, db=*)
  916. */
  917. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy {
  918. int __pyx_n;
  919. PyObject *_path;
  920. };
  921. /* "lakesuperior/store/base_lmdb_store.pxd":61
  922. * #cpdef get_dup_data(self, unsigned char *key, db=*)
  923. * #cpdef get_all_pairs(self, db=*)
  924. * cpdef bytes get_data(self, key, dblabel=*) # <<<<<<<<<<<<<<
  925. * cpdef dict stats(self)
  926. * cpdef int txn_id(self)
  927. */
  928. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data {
  929. int __pyx_n;
  930. PyObject *dblabel;
  931. };
  932. /* "lakesuperior/store/base_lmdb_store.pxd":13
  933. *
  934. *
  935. * cdef class BaseLmdbStore: # <<<<<<<<<<<<<<
  936. * cdef:
  937. * readonly bint is_txn_open
  938. */
  939. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore {
  940. PyObject_HEAD
  941. struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_vtab;
  942. int is_txn_open;
  943. int _open;
  944. unsigned int _readers;
  945. PyObject *env_path;
  946. MDB_dbi *dbis;
  947. MDB_env *dbenv;
  948. MDB_txn *txn;
  949. MDB_cursor **curs;
  950. };
  951. /* "lakesuperior/store/base_lmdb_store.pyx":334
  952. *
  953. * @contextmanager
  954. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  955. * """
  956. * Transaction context manager.
  957. */
  958. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx {
  959. PyObject_HEAD
  960. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self;
  961. PyObject *__pyx_v_write;
  962. PyObject *__pyx_t_0;
  963. PyObject *__pyx_t_1;
  964. PyObject *__pyx_t_2;
  965. };
  966. /* "lakesuperior/store/base_lmdb_store.pyx":49
  967. *
  968. *
  969. * cdef class BaseLmdbStore: # <<<<<<<<<<<<<<
  970. * """
  971. * Generic LMDB store abstract class.
  972. */
  973. struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore {
  974. void (*_clear_stale_readers)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  975. void (*_cur_close)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, MDB_cursor *);
  976. void (*_init_dbis)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis *__pyx_optional_args);
  977. void (*_txn_begin)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin *__pyx_optional_args);
  978. void (*_txn_commit)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  979. void (*_txn_abort)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  980. int (*_key_exists)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, unsigned char *, unsigned char, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists *__pyx_optional_args);
  981. size_t (*_txn_id)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  982. MDB_cursor *(*_cur_open)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open *__pyx_optional_args);
  983. MDB_dbi (*get_dbi)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi *__pyx_optional_args);
  984. void (*_put)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, unsigned char *, size_t, unsigned char *, size_t, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put *__pyx_optional_args);
  985. void (*_get_data)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, unsigned char *, size_t, struct MDB_val *, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data *__pyx_optional_args);
  986. void (*_delete)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, unsigned char *, size_t, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete *__pyx_optional_args);
  987. PyObject *(*_stats)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  988. void (*close_env)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env *__pyx_optional_args);
  989. void (*destroy)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy *__pyx_optional_args);
  990. PyObject *(*get_data)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data *__pyx_optional_args);
  991. PyObject *(*stats)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch);
  992. int (*txn_id)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch);
  993. };
  994. static struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  995. static CYTHON_INLINE int __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, unsigned char *, unsigned char, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists *__pyx_optional_args);
  996. /* --- Runtime support code (head) --- */
  997. /* Refnanny.proto */
  998. #ifndef CYTHON_REFNANNY
  999. #define CYTHON_REFNANNY 0
  1000. #endif
  1001. #if CYTHON_REFNANNY
  1002. typedef struct {
  1003. void (*INCREF)(void*, PyObject*, int);
  1004. void (*DECREF)(void*, PyObject*, int);
  1005. void (*GOTREF)(void*, PyObject*, int);
  1006. void (*GIVEREF)(void*, PyObject*, int);
  1007. void* (*SetupContext)(const char*, int, const char*);
  1008. void (*FinishContext)(void**);
  1009. } __Pyx_RefNannyAPIStruct;
  1010. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  1011. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  1012. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  1013. #ifdef WITH_THREAD
  1014. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1015. if (acquire_gil) {\
  1016. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1017. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  1018. PyGILState_Release(__pyx_gilstate_save);\
  1019. } else {\
  1020. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  1021. }
  1022. #else
  1023. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1024. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  1025. #endif
  1026. #define __Pyx_RefNannyFinishContext()\
  1027. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  1028. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1029. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1030. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1031. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1032. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  1033. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  1034. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  1035. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  1036. #else
  1037. #define __Pyx_RefNannyDeclarations
  1038. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  1039. #define __Pyx_RefNannyFinishContext()
  1040. #define __Pyx_INCREF(r) Py_INCREF(r)
  1041. #define __Pyx_DECREF(r) Py_DECREF(r)
  1042. #define __Pyx_GOTREF(r)
  1043. #define __Pyx_GIVEREF(r)
  1044. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  1045. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  1046. #define __Pyx_XGOTREF(r)
  1047. #define __Pyx_XGIVEREF(r)
  1048. #endif
  1049. #define __Pyx_XDECREF_SET(r, v) do {\
  1050. PyObject *tmp = (PyObject *) r;\
  1051. r = v; __Pyx_XDECREF(tmp);\
  1052. } while (0)
  1053. #define __Pyx_DECREF_SET(r, v) do {\
  1054. PyObject *tmp = (PyObject *) r;\
  1055. r = v; __Pyx_DECREF(tmp);\
  1056. } while (0)
  1057. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  1058. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  1059. /* PyObjectGetAttrStr.proto */
  1060. #if CYTHON_USE_TYPE_SLOTS
  1061. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  1062. #else
  1063. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  1064. #endif
  1065. /* GetBuiltinName.proto */
  1066. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  1067. /* PyThreadStateGet.proto */
  1068. #if CYTHON_FAST_THREAD_STATE
  1069. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1070. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  1071. #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
  1072. #else
  1073. #define __Pyx_PyThreadState_declare
  1074. #define __Pyx_PyThreadState_assign
  1075. #define __Pyx_PyErr_Occurred() PyErr_Occurred()
  1076. #endif
  1077. /* PyErrFetchRestore.proto */
  1078. #if CYTHON_FAST_THREAD_STATE
  1079. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  1080. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1081. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1082. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1083. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1084. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1085. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1086. #if CYTHON_COMPILING_IN_CPYTHON
  1087. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  1088. #else
  1089. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1090. #endif
  1091. #else
  1092. #define __Pyx_PyErr_Clear() PyErr_Clear()
  1093. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1094. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1095. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1096. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  1097. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  1098. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1099. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1100. #endif
  1101. /* Profile.proto */
  1102. #ifndef CYTHON_PROFILE
  1103. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  1104. #define CYTHON_PROFILE 0
  1105. #else
  1106. #define CYTHON_PROFILE 1
  1107. #endif
  1108. #endif
  1109. #ifndef CYTHON_TRACE_NOGIL
  1110. #define CYTHON_TRACE_NOGIL 0
  1111. #else
  1112. #if CYTHON_TRACE_NOGIL && !defined(CYTHON_TRACE)
  1113. #define CYTHON_TRACE 1
  1114. #endif
  1115. #endif
  1116. #ifndef CYTHON_TRACE
  1117. #define CYTHON_TRACE 0
  1118. #endif
  1119. #if CYTHON_TRACE
  1120. #undef CYTHON_PROFILE_REUSE_FRAME
  1121. #endif
  1122. #ifndef CYTHON_PROFILE_REUSE_FRAME
  1123. #define CYTHON_PROFILE_REUSE_FRAME 0
  1124. #endif
  1125. #if CYTHON_PROFILE || CYTHON_TRACE
  1126. #include "compile.h"
  1127. #include "frameobject.h"
  1128. #include "traceback.h"
  1129. #if CYTHON_PROFILE_REUSE_FRAME
  1130. #define CYTHON_FRAME_MODIFIER static
  1131. #define CYTHON_FRAME_DEL(frame)
  1132. #else
  1133. #define CYTHON_FRAME_MODIFIER
  1134. #define CYTHON_FRAME_DEL(frame) Py_CLEAR(frame)
  1135. #endif
  1136. #define __Pyx_TraceDeclarations\
  1137. static PyCodeObject *__pyx_frame_code = NULL;\
  1138. CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL;\
  1139. int __Pyx_use_tracing = 0;
  1140. #define __Pyx_TraceFrameInit(codeobj)\
  1141. if (codeobj) __pyx_frame_code = (PyCodeObject*) codeobj;
  1142. #ifdef WITH_THREAD
  1143. #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  1144. if (nogil) {\
  1145. if (CYTHON_TRACE_NOGIL) {\
  1146. PyThreadState *tstate;\
  1147. PyGILState_STATE state = PyGILState_Ensure();\
  1148. tstate = __Pyx_PyThreadState_Current;\
  1149. if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
  1150. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1151. __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
  1152. }\
  1153. PyGILState_Release(state);\
  1154. if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
  1155. }\
  1156. } else {\
  1157. PyThreadState* tstate = PyThreadState_GET();\
  1158. if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
  1159. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1160. __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
  1161. if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
  1162. }\
  1163. }
  1164. #else
  1165. #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  1166. { PyThreadState* tstate = PyThreadState_GET();\
  1167. if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
  1168. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1169. __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
  1170. if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
  1171. }\
  1172. }
  1173. #endif
  1174. #define __Pyx_TraceException()\
  1175. if (likely(!__Pyx_use_tracing)); else {\
  1176. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1177. if (tstate->use_tracing &&\
  1178. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1179. tstate->tracing++;\
  1180. tstate->use_tracing = 0;\
  1181. PyObject *exc_info = __Pyx_GetExceptionTuple(tstate);\
  1182. if (exc_info) {\
  1183. if (CYTHON_TRACE && tstate->c_tracefunc)\
  1184. tstate->c_tracefunc(\
  1185. tstate->c_traceobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
  1186. tstate->c_profilefunc(\
  1187. tstate->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
  1188. Py_DECREF(exc_info);\
  1189. }\
  1190. tstate->use_tracing = 1;\
  1191. tstate->tracing--;\
  1192. }\
  1193. }
  1194. static void __Pyx_call_return_trace_func(PyThreadState *tstate, PyFrameObject *frame, PyObject *result) {
  1195. PyObject *type, *value, *traceback;
  1196. __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
  1197. tstate->tracing++;
  1198. tstate->use_tracing = 0;
  1199. if (CYTHON_TRACE && tstate->c_tracefunc)
  1200. tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_RETURN, result);
  1201. if (tstate->c_profilefunc)
  1202. tstate->c_profilefunc(tstate->c_profileobj, frame, PyTrace_RETURN, result);
  1203. CYTHON_FRAME_DEL(frame);
  1204. tstate->use_tracing = 1;
  1205. tstate->tracing--;
  1206. __Pyx_ErrRestoreInState(tstate, type, value, traceback);
  1207. }
  1208. #ifdef WITH_THREAD
  1209. #define __Pyx_TraceReturn(result, nogil)\
  1210. if (likely(!__Pyx_use_tracing)); else {\
  1211. if (nogil) {\
  1212. if (CYTHON_TRACE_NOGIL) {\
  1213. PyThreadState *tstate;\
  1214. PyGILState_STATE state = PyGILState_Ensure();\
  1215. tstate = __Pyx_PyThreadState_Current;\
  1216. if (tstate->use_tracing) {\
  1217. __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
  1218. }\
  1219. PyGILState_Release(state);\
  1220. }\
  1221. } else {\
  1222. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1223. if (tstate->use_tracing) {\
  1224. __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
  1225. }\
  1226. }\
  1227. }
  1228. #else
  1229. #define __Pyx_TraceReturn(result, nogil)\
  1230. if (likely(!__Pyx_use_tracing)); else {\
  1231. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1232. if (tstate->use_tracing) {\
  1233. __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
  1234. }\
  1235. }
  1236. #endif
  1237. static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno);
  1238. static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, PyThreadState* tstate, const char *funcname, const char *srcfile, int firstlineno);
  1239. #else
  1240. #define __Pyx_TraceDeclarations
  1241. #define __Pyx_TraceFrameInit(codeobj)
  1242. #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error) if ((1)); else goto_error;
  1243. #define __Pyx_TraceException()
  1244. #define __Pyx_TraceReturn(result, nogil)
  1245. #endif
  1246. #if CYTHON_TRACE
  1247. static int __Pyx_call_line_trace_func(PyThreadState *tstate, PyFrameObject *frame, int lineno) {
  1248. int ret;
  1249. PyObject *type, *value, *traceback;
  1250. __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
  1251. __Pyx_PyFrame_SetLineNumber(frame, lineno);
  1252. tstate->tracing++;
  1253. tstate->use_tracing = 0;
  1254. ret = tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_LINE, NULL);
  1255. tstate->use_tracing = 1;
  1256. tstate->tracing--;
  1257. if (likely(!ret)) {
  1258. __Pyx_ErrRestoreInState(tstate, type, value, traceback);
  1259. } else {
  1260. Py_XDECREF(type);
  1261. Py_XDECREF(value);
  1262. Py_XDECREF(traceback);
  1263. }
  1264. return ret;
  1265. }
  1266. #ifdef WITH_THREAD
  1267. #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  1268. if (likely(!__Pyx_use_tracing)); else {\
  1269. if (nogil) {\
  1270. if (CYTHON_TRACE_NOGIL) {\
  1271. int ret = 0;\
  1272. PyThreadState *tstate;\
  1273. PyGILState_STATE state = PyGILState_Ensure();\
  1274. tstate = __Pyx_PyThreadState_Current;\
  1275. if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
  1276. ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
  1277. }\
  1278. PyGILState_Release(state);\
  1279. if (unlikely(ret)) goto_error;\
  1280. }\
  1281. } else {\
  1282. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1283. if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
  1284. int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
  1285. if (unlikely(ret)) goto_error;\
  1286. }\
  1287. }\
  1288. }
  1289. #else
  1290. #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  1291. if (likely(!__Pyx_use_tracing)); else {\
  1292. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1293. if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
  1294. int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
  1295. if (unlikely(ret)) goto_error;\
  1296. }\
  1297. }
  1298. #endif
  1299. #else
  1300. #define __Pyx_TraceLine(lineno, nogil, goto_error) if ((1)); else goto_error;
  1301. #endif
  1302. /* GetModuleGlobalName.proto */
  1303. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
  1304. /* PyCFunctionFastCall.proto */
  1305. #if CYTHON_FAST_PYCCALL
  1306. static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
  1307. #else
  1308. #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
  1309. #endif
  1310. /* PyFunctionFastCall.proto */
  1311. #if CYTHON_FAST_PYCALL
  1312. #define __Pyx_PyFunction_FastCall(func, args, nargs)\
  1313. __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
  1314. #if 1 || PY_VERSION_HEX < 0x030600B1
  1315. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
  1316. #else
  1317. #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
  1318. #endif
  1319. #endif
  1320. /* PyObjectCall.proto */
  1321. #if CYTHON_COMPILING_IN_CPYTHON
  1322. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  1323. #else
  1324. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  1325. #endif
  1326. /* PyObjectCallMethO.proto */
  1327. #if CYTHON_COMPILING_IN_CPYTHON
  1328. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  1329. #endif
  1330. /* PyObjectCallOneArg.proto */
  1331. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  1332. /* PyObjectCallNoArg.proto */
  1333. #if CYTHON_COMPILING_IN_CPYTHON
  1334. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  1335. #else
  1336. #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
  1337. #endif
  1338. /* RaiseException.proto */
  1339. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  1340. /* IncludeStringH.proto */
  1341. #include <string.h>
  1342. /* decode_c_string_utf16.proto */
  1343. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
  1344. int byteorder = 0;
  1345. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1346. }
  1347. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
  1348. int byteorder = -1;
  1349. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1350. }
  1351. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
  1352. int byteorder = 1;
  1353. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1354. }
  1355. /* decode_c_string.proto */
  1356. static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
  1357. const char* cstring, Py_ssize_t start, Py_ssize_t stop,
  1358. const char* encoding, const char* errors,
  1359. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
  1360. /* RaiseDoubleKeywords.proto */
  1361. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  1362. /* ParseKeywords.proto */
  1363. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
  1364. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
  1365. const char* function_name);
  1366. /* RaiseArgTupleInvalid.proto */
  1367. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  1368. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  1369. /* WriteUnraisableException.proto */
  1370. static void __Pyx_WriteUnraisable(const char *name, int clineno,
  1371. int lineno, const char *filename,
  1372. int full_traceback, int nogil);
  1373. /* SaveResetException.proto */
  1374. #if CYTHON_FAST_THREAD_STATE
  1375. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  1376. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1377. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  1378. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1379. #else
  1380. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  1381. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  1382. #endif
  1383. /* PyErrExceptionMatches.proto */
  1384. #if CYTHON_FAST_THREAD_STATE
  1385. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  1386. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  1387. #else
  1388. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  1389. #endif
  1390. /* GetException.proto */
  1391. #if CYTHON_FAST_THREAD_STATE
  1392. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  1393. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1394. #else
  1395. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  1396. #endif
  1397. /* SwapException.proto */
  1398. #if CYTHON_FAST_THREAD_STATE
  1399. #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
  1400. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1401. #else
  1402. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
  1403. #endif
  1404. /* PyUnicode_Unicode.proto */
  1405. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj);
  1406. /* JoinPyUnicode.proto */
  1407. static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
  1408. Py_UCS4 max_char);
  1409. /* PyObjectFormatSimple.proto */
  1410. #if CYTHON_COMPILING_IN_PYPY
  1411. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1412. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1413. PyObject_Format(s, f))
  1414. #elif PY_MAJOR_VERSION < 3
  1415. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1416. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1417. likely(PyString_CheckExact(s)) ? PyUnicode_FromEncodedObject(s, NULL, "strict") :\
  1418. PyObject_Format(s, f))
  1419. #elif CYTHON_USE_TYPE_SLOTS
  1420. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1421. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1422. likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_str(s) :\
  1423. likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_str(s) :\
  1424. PyObject_Format(s, f))
  1425. #else
  1426. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1427. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1428. PyObject_Format(s, f))
  1429. #endif
  1430. /* FastTypeChecks.proto */
  1431. #if CYTHON_COMPILING_IN_CPYTHON
  1432. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  1433. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  1434. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  1435. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  1436. #else
  1437. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  1438. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  1439. #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
  1440. #endif
  1441. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  1442. /* PyObjectSetAttrStr.proto */
  1443. #if CYTHON_USE_TYPE_SLOTS
  1444. #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
  1445. static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
  1446. #else
  1447. #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
  1448. #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
  1449. #endif
  1450. /* PyObjectLookupSpecial.proto */
  1451. #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
  1452. static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
  1453. PyObject *res;
  1454. PyTypeObject *tp = Py_TYPE(obj);
  1455. #if PY_MAJOR_VERSION < 3
  1456. if (unlikely(PyInstance_Check(obj)))
  1457. return __Pyx_PyObject_GetAttrStr(obj, attr_name);
  1458. #endif
  1459. res = _PyType_Lookup(tp, attr_name);
  1460. if (likely(res)) {
  1461. descrgetfunc f = Py_TYPE(res)->tp_descr_get;
  1462. if (!f) {
  1463. Py_INCREF(res);
  1464. } else {
  1465. res = f(res, obj, (PyObject *)tp);
  1466. }
  1467. } else {
  1468. PyErr_SetObject(PyExc_AttributeError, attr_name);
  1469. }
  1470. return res;
  1471. }
  1472. #else
  1473. #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
  1474. #endif
  1475. /* PyIntBinop.proto */
  1476. #if !CYTHON_COMPILING_IN_PYPY
  1477. static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
  1478. #else
  1479. #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
  1480. (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
  1481. #endif
  1482. /* DictGetItem.proto */
  1483. #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
  1484. static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
  1485. #define __Pyx_PyObject_Dict_GetItem(obj, name)\
  1486. (likely(PyDict_CheckExact(obj)) ?\
  1487. __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
  1488. #else
  1489. #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
  1490. #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
  1491. #endif
  1492. /* PyObject_GenericGetAttrNoDict.proto */
  1493. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1494. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
  1495. #else
  1496. #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
  1497. #endif
  1498. /* PyObject_GenericGetAttr.proto */
  1499. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1500. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
  1501. #else
  1502. #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
  1503. #endif
  1504. /* SetVTable.proto */
  1505. static int __Pyx_SetVtable(PyObject *dict, void *vtable);
  1506. /* SetupReduce.proto */
  1507. static int __Pyx_setup_reduce(PyObject* type_obj);
  1508. /* Import.proto */
  1509. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
  1510. /* ImportFrom.proto */
  1511. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  1512. /* CalculateMetaclass.proto */
  1513. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
  1514. /* Py3ClassCreate.proto */
  1515. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
  1516. PyObject *mkw, PyObject *modname, PyObject *doc);
  1517. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
  1518. PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
  1519. /* GetNameInClass.proto */
  1520. static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);
  1521. /* CLineInTraceback.proto */
  1522. #ifdef CYTHON_CLINE_IN_TRACEBACK
  1523. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  1524. #else
  1525. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  1526. #endif
  1527. /* CodeObjectCache.proto */
  1528. typedef struct {
  1529. PyCodeObject* code_object;
  1530. int code_line;
  1531. } __Pyx_CodeObjectCacheEntry;
  1532. struct __Pyx_CodeObjectCache {
  1533. int count;
  1534. int max_count;
  1535. __Pyx_CodeObjectCacheEntry* entries;
  1536. };
  1537. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  1538. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  1539. static PyCodeObject *__pyx_find_code_object(int code_line);
  1540. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  1541. /* AddTraceback.proto */
  1542. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1543. int py_line, const char *filename);
  1544. /* CIntToPy.proto */
  1545. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
  1546. /* CIntToPy.proto */
  1547. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
  1548. /* CIntToPy.proto */
  1549. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value);
  1550. /* CIntToPy.proto */
  1551. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  1552. /* CIntToPy.proto */
  1553. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_MDB_dbi(MDB_dbi value);
  1554. static PyObject* __pyx_convert__to_py_struct__MDB_stat(struct MDB_stat s);
  1555. /* CIntFromPy.proto */
  1556. static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
  1557. /* CIntFromPy.proto */
  1558. static CYTHON_INLINE MDB_dbi __Pyx_PyInt_As_MDB_dbi(PyObject *);
  1559. /* CIntFromPy.proto */
  1560. static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *);
  1561. /* CIntFromPy.proto */
  1562. static CYTHON_INLINE mode_t __Pyx_PyInt_As_mode_t(PyObject *);
  1563. /* CIntFromPy.proto */
  1564. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  1565. /* CIntFromPy.proto */
  1566. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  1567. /* FetchCommonType.proto */
  1568. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
  1569. /* PyObjectCallMethod1.proto */
  1570. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
  1571. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg);
  1572. /* CoroutineBase.proto */
  1573. typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
  1574. typedef struct {
  1575. PyObject_HEAD
  1576. __pyx_coroutine_body_t body;
  1577. PyObject *closure;
  1578. PyObject *exc_type;
  1579. PyObject *exc_value;
  1580. PyObject *exc_traceback;
  1581. PyObject *gi_weakreflist;
  1582. PyObject *classobj;
  1583. PyObject *yieldfrom;
  1584. PyObject *gi_name;
  1585. PyObject *gi_qualname;
  1586. PyObject *gi_modulename;
  1587. PyObject *gi_code;
  1588. int resume_label;
  1589. char is_running;
  1590. } __pyx_CoroutineObject;
  1591. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  1592. PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  1593. PyObject *name, PyObject *qualname, PyObject *module_name);
  1594. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  1595. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  1596. PyObject *name, PyObject *qualname, PyObject *module_name);
  1597. static int __Pyx_Coroutine_clear(PyObject *self);
  1598. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
  1599. static PyObject *__Pyx_Coroutine_Close(PyObject *self);
  1600. static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
  1601. #define __Pyx_Coroutine_SwapException(self) {\
  1602. __Pyx_ExceptionSwap(&(self)->exc_type, &(self)->exc_value, &(self)->exc_traceback);\
  1603. __Pyx_Coroutine_ResetFrameBackpointer(self);\
  1604. }
  1605. #define __Pyx_Coroutine_ResetAndClearException(self) {\
  1606. __Pyx_ExceptionReset((self)->exc_type, (self)->exc_value, (self)->exc_traceback);\
  1607. (self)->exc_type = (self)->exc_value = (self)->exc_traceback = NULL;\
  1608. }
  1609. #if CYTHON_FAST_THREAD_STATE
  1610. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  1611. __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
  1612. #else
  1613. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  1614. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
  1615. #endif
  1616. static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
  1617. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self);
  1618. /* PatchModuleWithCoroutine.proto */
  1619. static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);
  1620. /* PatchGeneratorABC.proto */
  1621. static int __Pyx_patch_abc(void);
  1622. /* Generator.proto */
  1623. #define __Pyx_Generator_USED
  1624. static PyTypeObject *__pyx_GeneratorType = 0;
  1625. #define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
  1626. #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
  1627. __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
  1628. static PyObject *__Pyx_Generator_Next(PyObject *self);
  1629. static int __pyx_Generator_init(void);
  1630. /* CheckBinaryVersion.proto */
  1631. static int __Pyx_check_binary_version(void);
  1632. /* VoidPtrExport.proto */
  1633. static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
  1634. /* FunctionExport.proto */
  1635. static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
  1636. /* InitStrings.proto */
  1637. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  1638. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__clear_stale_readers(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto*/
  1639. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis *__pyx_optional_args); /* proto*/
  1640. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env *__pyx_optional_args); /* proto*/
  1641. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy *__pyx_optional_args); /* proto*/
  1642. static CYTHON_INLINE int __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, unsigned char *__pyx_v_key, unsigned char __pyx_v_klen, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists *__pyx_optional_args); /* proto*/
  1643. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, unsigned char *__pyx_v_key, size_t __pyx_v_key_size, unsigned char *__pyx_v_data, size_t __pyx_v_data_size, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put *__pyx_optional_args); /* proto*/
  1644. static PyObject *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_key, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data *__pyx_optional_args); /* proto*/
  1645. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, unsigned char *__pyx_v_key, CYTHON_UNUSED size_t __pyx_v_klen, struct MDB_val *__pyx_v_rv, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data *__pyx_optional_args); /* proto*/
  1646. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, unsigned char *__pyx_v_key, size_t __pyx_v_klen, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete *__pyx_optional_args); /* proto*/
  1647. static PyObject *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
  1648. static PyObject *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto*/
  1649. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin *__pyx_optional_args); /* proto*/
  1650. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_commit(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto*/
  1651. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_abort(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto*/
  1652. static int __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_txn_id(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
  1653. static size_t __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_id(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto*/
  1654. static MDB_dbi __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi *__pyx_optional_args); /* proto*/
  1655. static MDB_cursor *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open *__pyx_optional_args); /* proto*/
  1656. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_close(CYTHON_UNUSED struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, MDB_cursor *__pyx_v_cur); /* proto*/
  1657. /* Module declarations from 'libc.stdint' */
  1658. /* Module declarations from 'posix.types' */
  1659. /* Module declarations from 'lakesuperior.cy_include.cylmdb' */
  1660. /* Module declarations from 'lakesuperior.cy_include' */
  1661. /* Module declarations from 'libc' */
  1662. /* Module declarations from 'libc.errno' */
  1663. /* Module declarations from 'cpython.mem' */
  1664. /* Module declarations from 'lakesuperior.store.base_lmdb_store' */
  1665. static PyTypeObject *__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = 0;
  1666. static PyTypeObject *__pyx_ptype_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = 0;
  1667. static int __pyx_v_12lakesuperior_5store_15base_lmdb_store_rc;
  1668. static size_t __pyx_v_12lakesuperior_5store_15base_lmdb_store_i;
  1669. static struct MDB_val __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v;
  1670. static struct MDB_val __pyx_v_12lakesuperior_5store_15base_lmdb_store_data_v;
  1671. static MDB_dbi __pyx_v_12lakesuperior_5store_15base_lmdb_store_dbi;
  1672. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(int, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check *__pyx_optional_args); /*proto*/
  1673. #define __Pyx_MODULE_NAME "lakesuperior.store.base_lmdb_store"
  1674. extern int __pyx_module_is_main_lakesuperior__store__base_lmdb_store;
  1675. int __pyx_module_is_main_lakesuperior__store__base_lmdb_store = 0;
  1676. /* Implementation of 'lakesuperior.store.base_lmdb_store' */
  1677. static PyObject *__pyx_builtin_MemoryError;
  1678. static PyObject *__pyx_builtin_enumerate;
  1679. static PyObject *__pyx_builtin_RuntimeError;
  1680. static PyObject *__pyx_builtin_TypeError;
  1681. static const char __pyx_k_[] = "";
  1682. static const char __pyx_k_i[] = "i";
  1683. static const char __pyx_k_x[] = "{:x}";
  1684. static const char __pyx_k_RO[] = "RO";
  1685. static const char __pyx_k_RW[] = "RW";
  1686. static const char __pyx_k__4[] = ".";
  1687. static const char __pyx_k__6[] = ": ";
  1688. static const char __pyx_k_os[] = "os";
  1689. static const char __pyx_k_rc[] = "rc";
  1690. static const char __pyx_k_DBI[] = " (DBI ";
  1691. static const char __pyx_k__20[] = ")...";
  1692. static const char __pyx_k_dbi[] = "dbi";
  1693. static const char __pyx_k_doc[] = "__doc__";
  1694. static const char __pyx_k_env[] = "env";
  1695. static const char __pyx_k_get[] = "get";
  1696. static const char __pyx_k_key[] = "key";
  1697. static const char __pyx_k_pid[] = "pid";
  1698. static const char __pyx_k_None[] = "None";
  1699. static const char __pyx_k_args[] = "args";
  1700. static const char __pyx_k_data[] = "data";
  1701. static const char __pyx_k_exit[] = "__exit__";
  1702. static const char __pyx_k_info[] = "info";
  1703. static const char __pyx_k_lock[] = "-lock";
  1704. static const char __pyx_k_main[] = "__main__";
  1705. static const char __pyx_k_mode[] = "mode";
  1706. static const char __pyx_k_name[] = "__name__";
  1707. static const char __pyx_k_path[] = "path";
  1708. static const char __pyx_k_send[] = "send";
  1709. static const char __pyx_k_stat[] = "stat";
  1710. static const char __pyx_k_test[] = "__test__";
  1711. static const char __pyx_k_wsgi[] = "wsgi";
  1712. static const char __pyx_k_abort[] = "abort";
  1713. static const char __pyx_k_close[] = "close";
  1714. static const char __pyx_k_debug[] = "debug";
  1715. static const char __pyx_k_enter[] = "__enter__";
  1716. static const char __pyx_k_flags[] = "flags";
  1717. static const char __pyx_k_index[] = "index";
  1718. static const char __pyx_k_key_v[] = "key_v";
  1719. static const char __pyx_k_stats[] = "stats";
  1720. static const char __pyx_k_throw[] = "throw";
  1721. static const char __pyx_k_write[] = "write";
  1722. static const char __pyx_k_create[] = "create";
  1723. static const char __pyx_k_data_v[] = "data_v";
  1724. static const char __pyx_k_encode[] = "encode";
  1725. static const char __pyx_k_exists[] = "exists";
  1726. static const char __pyx_k_format[] = "format";
  1727. static const char __pyx_k_import[] = "__import__";
  1728. static const char __pyx_k_logger[] = "logger";
  1729. static const char __pyx_k_module[] = "__module__";
  1730. static const char __pyx_k_path_2[] = "_path";
  1731. static const char __pyx_k_reduce[] = "__reduce__";
  1732. static const char __pyx_k_rmtree[] = "rmtree";
  1733. static const char __pyx_k_shutil[] = "shutil";
  1734. static const char __pyx_k_txn_id[] = "txn_id";
  1735. static const char __pyx_k_unlink[] = "unlink";
  1736. static const char __pyx_k_dblabel[] = "dblabel";
  1737. static const char __pyx_k_destroy[] = "destroy";
  1738. static const char __pyx_k_dirname[] = "dirname";
  1739. static const char __pyx_k_getName[] = "getName";
  1740. static const char __pyx_k_is_open[] = "is_open";
  1741. static const char __pyx_k_logging[] = "logging";
  1742. static const char __pyx_k_max_dbs[] = "max_dbs";
  1743. static const char __pyx_k_new_txn[] = "new_txn";
  1744. static const char __pyx_k_options[] = "options";
  1745. static const char __pyx_k_prepare[] = "__prepare__";
  1746. static const char __pyx_k_st_size[] = "st_size";
  1747. static const char __pyx_k_txn_ctx[] = "txn_ctx";
  1748. static const char __pyx_k_warning[] = "warning";
  1749. static const char __pyx_k_workers[] = "workers";
  1750. static const char __pyx_k_db_stats[] = "db_stats";
  1751. static const char __pyx_k_env_path[] = "env_path";
  1752. static const char __pyx_k_env_size[] = "env_size";
  1753. static const char __pyx_k_exist_ok[] = "exist_ok";
  1754. static const char __pyx_k_get_data[] = "get_data";
  1755. static const char __pyx_k_getstate[] = "__getstate__";
  1756. static const char __pyx_k_makedirs[] = "makedirs";
  1757. static const char __pyx_k_map_size[] = "map_size";
  1758. static const char __pyx_k_ms_depth[] = "ms_depth";
  1759. static const char __pyx_k_ms_psize[] = "ms_psize";
  1760. static const char __pyx_k_open_env[] = "open_env";
  1761. static const char __pyx_k_opened_x[] = "...opened @ {:x}.";
  1762. static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
  1763. static const char __pyx_k_qualname[] = "__qualname__";
  1764. static const char __pyx_k_setstate[] = "__setstate__";
  1765. static const char __pyx_k_LmdbError[] = "LmdbError";
  1766. static const char __pyx_k_TypeError[] = "TypeError";
  1767. static const char __pyx_k_close_env[] = "close_env";
  1768. static const char __pyx_k_dbi_flags[] = "dbi_flags";
  1769. static const char __pyx_k_enumerate[] = "enumerate";
  1770. static const char __pyx_k_env_flags[] = "env_flags";
  1771. static const char __pyx_k_env_perms[] = "env_perms";
  1772. static const char __pyx_k_env_stats[] = "env_stats";
  1773. static const char __pyx_k_getLogger[] = "getLogger";
  1774. static const char __pyx_k_is_txn_rw[] = "is_txn_rw";
  1775. static const char __pyx_k_metaclass[] = "__metaclass__";
  1776. static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
  1777. static const char __pyx_k_threading[] = "threading";
  1778. static const char __pyx_k_Created_DB[] = "Created DB ";
  1779. static const char __pyx_k_LMDB_Error[] = "LMDB Error ({}): ";
  1780. static const char __pyx_k_contextlib[] = "contextlib";
  1781. static const char __pyx_k_dbi_labels[] = "dbi_labels";
  1782. static const char __pyx_k_ms_entries[] = "ms_entries";
  1783. static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
  1784. static const char __pyx_k_Max_readers[] = "Max. readers: {}";
  1785. static const char __pyx_k_MemoryError[] = "MemoryError";
  1786. static const char __pyx_k_txn_is_open[] = "txn is open: {}";
  1787. static const char __pyx_k_Creating_DBs[] = "Creating DBs.";
  1788. static const char __pyx_k_RuntimeError[] = "RuntimeError";
  1789. static const char __pyx_k_lakesuperior[] = "lakesuperior";
  1790. static const char __pyx_k_readers_mult[] = "readers_mult";
  1791. static const char __pyx_k_currentThread[] = "currentThread";
  1792. static const char __pyx_k_ms_leaf_pages[] = "ms_leaf_pages";
  1793. static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
  1794. static const char __pyx_k_Internal_error[] = "\nInternal error ({}): ";
  1795. static const char __pyx_k_KeyExistsError[] = "KeyExistsError";
  1796. static const char __pyx_k_contextmanager[] = "contextmanager";
  1797. static const char __pyx_k_max_spare_txns[] = "max_spare_txns";
  1798. static const char __pyx_k_Created_DBenv_x[] = "Created DBenv @ {:x}";
  1799. static const char __pyx_k_DBenv_address_x[] = "DBenv address: {:x}";
  1800. static const char __pyx_k_current_process[] = "current_process";
  1801. static const char __pyx_k_ms_branch_pages[] = "ms_branch_pages";
  1802. static const char __pyx_k_multiprocessing[] = "multiprocessing";
  1803. static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
  1804. static const char __pyx_k_KeyNotFoundError[] = "KeyNotFoundError";
  1805. static const char __pyx_k_Closing_store_env[] = "Closing store env.";
  1806. static const char __pyx_k_FileNotFoundError[] = "FileNotFoundError";
  1807. static const char __pyx_k_Store_is_not_open[] = "Store is not open.";
  1808. static const char __pyx_k_ms_overflow_pages[] = "ms_overflow_pages";
  1809. static const char __pyx_k_Error_putting_data[] = "Error putting data: {}, {}";
  1810. static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
  1811. static const char __pyx_k_Transaction_aborted[] = "Transaction @ {} aborted.";
  1812. static const char __pyx_k_Error_opening_cursor[] = "Error opening cursor: ";
  1813. static const char __pyx_k_Opened_transaction_x[] = "Opened transaction @ {:x}";
  1814. static const char __pyx_k_BaseLmdbStore_txn_ctx[] = "BaseLmdbStore.txn_ctx";
  1815. static const char __pyx_k_Cleaning_up_store_env[] = "Cleaning up store env.";
  1816. static const char __pyx_k_Cleared_stale_readers[] = "Cleared {} stale readers.";
  1817. static const char __pyx_k_Opening_cursor_for_DB[] = "Opening cursor for DB ";
  1818. static const char __pyx_k_Transaction_committed[] = "Transaction @ {} committed.";
  1819. static const char __pyx_k_Error_setting_map_size[] = "Error setting map size: {}";
  1820. static const char __pyx_k_Opening_environment_at[] = "Opening environment at {}.";
  1821. static const char __pyx_k_Environment_already_open[] = "Environment already open.";
  1822. static const char __pyx_k_Error_opening_transaction[] = "Error opening transaction.";
  1823. static const char __pyx_k_Error_setting_max_readers[] = "Error setting max. readers: {}";
  1824. static const char __pyx_k_Getting_DBI_without_label[] = "Getting DBI without label.";
  1825. static const char __pyx_k_Error_getting_data_for_key[] = "Error getting data for key '{}'.";
  1826. static const char __pyx_k_Store_must_be_opened_first[] = "Store must be opened first.";
  1827. static const char __pyx_k_commit_pending_transaction[] = "commit_pending_transaction";
  1828. static const char __pyx_k_Error_getting_datbase_stats[] = "Error getting datbase stats: {}";
  1829. static const char __pyx_k_Error_setting_max_databases[] = "Error setting max. databases: {}";
  1830. static const char __pyx_k_Could_not_create_store_at_Error[] = "Could not create store at {}. Error: {}";
  1831. static const char __pyx_k_Error_creating_DB_environment_ha[] = "Error creating DB environment handle: {}";
  1832. static const char __pyx_k_Error_opening_the_database_envir[] = "Error opening the database environment: ";
  1833. static const char __pyx_k_Opening_transaction_in_PID_threa[] = "Opening {} transaction in PID {}, thread {}";
  1834. static const char __pyx_k_Transaction_is_already_active_No[] = "Transaction is already active. Not opening another one.";
  1835. static const char __pyx_k_lakesuperior_store_base_lmdb_sto[] = "lakesuperior.store.base_lmdb_store";
  1836. static const char __pyx_k_self_curs_self_dbenv_self_dbis_s[] = "self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling";
  1837. static PyObject *__pyx_kp_u_;
  1838. static PyObject *__pyx_n_s_BaseLmdbStore_txn_ctx;
  1839. static PyObject *__pyx_kp_u_Cleaning_up_store_env;
  1840. static PyObject *__pyx_kp_u_Cleared_stale_readers;
  1841. static PyObject *__pyx_kp_u_Closing_store_env;
  1842. static PyObject *__pyx_kp_u_Could_not_create_store_at_Error;
  1843. static PyObject *__pyx_kp_u_Created_DB;
  1844. static PyObject *__pyx_kp_u_Created_DBenv_x;
  1845. static PyObject *__pyx_kp_u_Creating_DBs;
  1846. static PyObject *__pyx_kp_u_DBI;
  1847. static PyObject *__pyx_kp_u_DBenv_address_x;
  1848. static PyObject *__pyx_kp_u_Environment_already_open;
  1849. static PyObject *__pyx_kp_u_Error_creating_DB_environment_ha;
  1850. static PyObject *__pyx_kp_u_Error_getting_data_for_key;
  1851. static PyObject *__pyx_kp_u_Error_getting_datbase_stats;
  1852. static PyObject *__pyx_kp_u_Error_opening_cursor;
  1853. static PyObject *__pyx_kp_u_Error_opening_the_database_envir;
  1854. static PyObject *__pyx_kp_u_Error_opening_transaction;
  1855. static PyObject *__pyx_kp_u_Error_putting_data;
  1856. static PyObject *__pyx_kp_u_Error_setting_map_size;
  1857. static PyObject *__pyx_kp_u_Error_setting_max_databases;
  1858. static PyObject *__pyx_kp_u_Error_setting_max_readers;
  1859. static PyObject *__pyx_n_s_FileNotFoundError;
  1860. static PyObject *__pyx_kp_u_Getting_DBI_without_label;
  1861. static PyObject *__pyx_kp_u_Internal_error;
  1862. static PyObject *__pyx_n_s_KeyExistsError;
  1863. static PyObject *__pyx_n_s_KeyNotFoundError;
  1864. static PyObject *__pyx_kp_u_LMDB_Error;
  1865. static PyObject *__pyx_n_s_LmdbError;
  1866. static PyObject *__pyx_kp_u_Max_readers;
  1867. static PyObject *__pyx_n_s_MemoryError;
  1868. static PyObject *__pyx_kp_u_None;
  1869. static PyObject *__pyx_kp_u_Opened_transaction_x;
  1870. static PyObject *__pyx_kp_u_Opening_cursor_for_DB;
  1871. static PyObject *__pyx_kp_u_Opening_environment_at;
  1872. static PyObject *__pyx_kp_u_Opening_transaction_in_PID_threa;
  1873. static PyObject *__pyx_n_u_RO;
  1874. static PyObject *__pyx_n_u_RW;
  1875. static PyObject *__pyx_n_s_RuntimeError;
  1876. static PyObject *__pyx_kp_u_Store_is_not_open;
  1877. static PyObject *__pyx_kp_u_Store_must_be_opened_first;
  1878. static PyObject *__pyx_kp_u_Transaction_aborted;
  1879. static PyObject *__pyx_kp_u_Transaction_committed;
  1880. static PyObject *__pyx_kp_u_Transaction_is_already_active_No;
  1881. static PyObject *__pyx_n_s_TypeError;
  1882. static PyObject *__pyx_kp_u__20;
  1883. static PyObject *__pyx_kp_u__4;
  1884. static PyObject *__pyx_kp_u__6;
  1885. static PyObject *__pyx_n_s_abort;
  1886. static PyObject *__pyx_n_s_args;
  1887. static PyObject *__pyx_n_s_cline_in_traceback;
  1888. static PyObject *__pyx_n_s_close;
  1889. static PyObject *__pyx_n_s_close_env;
  1890. static PyObject *__pyx_n_s_commit_pending_transaction;
  1891. static PyObject *__pyx_n_s_contextlib;
  1892. static PyObject *__pyx_n_s_contextmanager;
  1893. static PyObject *__pyx_n_s_create;
  1894. static PyObject *__pyx_n_s_currentThread;
  1895. static PyObject *__pyx_n_s_current_process;
  1896. static PyObject *__pyx_n_s_data;
  1897. static PyObject *__pyx_n_s_data_v;
  1898. static PyObject *__pyx_n_u_db_stats;
  1899. static PyObject *__pyx_n_s_dbi;
  1900. static PyObject *__pyx_n_s_dbi_flags;
  1901. static PyObject *__pyx_n_s_dbi_labels;
  1902. static PyObject *__pyx_n_s_dblabel;
  1903. static PyObject *__pyx_n_s_debug;
  1904. static PyObject *__pyx_n_s_destroy;
  1905. static PyObject *__pyx_n_s_dirname;
  1906. static PyObject *__pyx_n_s_doc;
  1907. static PyObject *__pyx_n_s_encode;
  1908. static PyObject *__pyx_n_s_enter;
  1909. static PyObject *__pyx_n_s_enumerate;
  1910. static PyObject *__pyx_n_s_env;
  1911. static PyObject *__pyx_n_s_env_flags;
  1912. static PyObject *__pyx_n_s_env_path;
  1913. static PyObject *__pyx_n_s_env_perms;
  1914. static PyObject *__pyx_n_u_env_size;
  1915. static PyObject *__pyx_n_u_env_stats;
  1916. static PyObject *__pyx_n_s_exist_ok;
  1917. static PyObject *__pyx_n_s_exists;
  1918. static PyObject *__pyx_n_s_exit;
  1919. static PyObject *__pyx_n_s_flags;
  1920. static PyObject *__pyx_n_s_format;
  1921. static PyObject *__pyx_n_s_get;
  1922. static PyObject *__pyx_n_s_getLogger;
  1923. static PyObject *__pyx_n_s_getName;
  1924. static PyObject *__pyx_n_s_get_data;
  1925. static PyObject *__pyx_n_s_getstate;
  1926. static PyObject *__pyx_n_s_i;
  1927. static PyObject *__pyx_n_s_import;
  1928. static PyObject *__pyx_n_s_index;
  1929. static PyObject *__pyx_n_s_info;
  1930. static PyObject *__pyx_n_s_is_open;
  1931. static PyObject *__pyx_n_s_is_txn_rw;
  1932. static PyObject *__pyx_n_s_key;
  1933. static PyObject *__pyx_n_s_key_v;
  1934. static PyObject *__pyx_n_s_lakesuperior;
  1935. static PyObject *__pyx_n_s_lakesuperior_store_base_lmdb_sto;
  1936. static PyObject *__pyx_kp_u_lock;
  1937. static PyObject *__pyx_n_s_logger;
  1938. static PyObject *__pyx_n_s_logging;
  1939. static PyObject *__pyx_n_s_main;
  1940. static PyObject *__pyx_n_s_makedirs;
  1941. static PyObject *__pyx_n_u_map_size;
  1942. static PyObject *__pyx_n_u_max_dbs;
  1943. static PyObject *__pyx_n_u_max_spare_txns;
  1944. static PyObject *__pyx_n_s_metaclass;
  1945. static PyObject *__pyx_n_s_mode;
  1946. static PyObject *__pyx_n_s_module;
  1947. static PyObject *__pyx_n_s_ms_branch_pages;
  1948. static PyObject *__pyx_n_s_ms_depth;
  1949. static PyObject *__pyx_n_s_ms_entries;
  1950. static PyObject *__pyx_n_s_ms_leaf_pages;
  1951. static PyObject *__pyx_n_s_ms_overflow_pages;
  1952. static PyObject *__pyx_n_s_ms_psize;
  1953. static PyObject *__pyx_n_s_multiprocessing;
  1954. static PyObject *__pyx_n_s_name;
  1955. static PyObject *__pyx_n_s_new_txn;
  1956. static PyObject *__pyx_n_s_open_env;
  1957. static PyObject *__pyx_kp_u_opened_x;
  1958. static PyObject *__pyx_n_s_options;
  1959. static PyObject *__pyx_n_s_os;
  1960. static PyObject *__pyx_n_s_path;
  1961. static PyObject *__pyx_n_s_path_2;
  1962. static PyObject *__pyx_n_s_pid;
  1963. static PyObject *__pyx_n_s_prepare;
  1964. static PyObject *__pyx_n_s_pyx_capi;
  1965. static PyObject *__pyx_n_s_pyx_vtable;
  1966. static PyObject *__pyx_n_s_qualname;
  1967. static PyObject *__pyx_n_s_rc;
  1968. static PyObject *__pyx_n_s_readers_mult;
  1969. static PyObject *__pyx_n_s_reduce;
  1970. static PyObject *__pyx_n_s_reduce_cython;
  1971. static PyObject *__pyx_n_s_reduce_ex;
  1972. static PyObject *__pyx_n_s_rmtree;
  1973. static PyObject *__pyx_kp_s_self_curs_self_dbenv_self_dbis_s;
  1974. static PyObject *__pyx_n_s_send;
  1975. static PyObject *__pyx_n_s_setstate;
  1976. static PyObject *__pyx_n_s_setstate_cython;
  1977. static PyObject *__pyx_n_s_shutil;
  1978. static PyObject *__pyx_n_s_st_size;
  1979. static PyObject *__pyx_n_s_stat;
  1980. static PyObject *__pyx_n_s_stats;
  1981. static PyObject *__pyx_n_s_test;
  1982. static PyObject *__pyx_n_s_threading;
  1983. static PyObject *__pyx_n_s_throw;
  1984. static PyObject *__pyx_n_s_txn_ctx;
  1985. static PyObject *__pyx_n_s_txn_id;
  1986. static PyObject *__pyx_kp_u_txn_is_open;
  1987. static PyObject *__pyx_n_s_unlink;
  1988. static PyObject *__pyx_n_s_warning;
  1989. static PyObject *__pyx_n_s_workers;
  1990. static PyObject *__pyx_n_s_write;
  1991. static PyObject *__pyx_n_s_wsgi;
  1992. static PyObject *__pyx_kp_u_x;
  1993. static int __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_env_path, PyObject *__pyx_v_open_env, PyObject *__pyx_v_create); /* proto */
  1994. static void __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_2__dealloc__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  1995. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  1996. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  1997. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_4open_env(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_create); /* proto */
  1998. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_6close_env(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, int __pyx_v_commit_pending_transaction); /* proto */
  1999. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8destroy(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v__path); /* proto */
  2000. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_10txn_ctx(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_write); /* proto */
  2001. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_13begin(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_write); /* proto */
  2002. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2003. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2004. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2005. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_21key_exists(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_dblabel, PyObject *__pyx_v_new_txn); /* proto */
  2006. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_23put(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_data, PyObject *__pyx_v_dblabel, PyObject *__pyx_v_flags); /* proto */
  2007. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_25get_data(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_dblabel); /* proto */
  2008. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_27delete(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_dblabel); /* proto */
  2009. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2010. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_31txn_id(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2011. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2012. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2013. static int __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_2__set__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
  2014. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2015. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_33__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2016. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_35__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
  2017. static PyObject *__pyx_tp_new_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2018. static PyObject *__pyx_tp_new_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2019. static PyObject *__pyx_int_0;
  2020. static PyObject *__pyx_int_1;
  2021. static PyObject *__pyx_int_4;
  2022. static PyObject *__pyx_int_416;
  2023. static PyObject *__pyx_int_488;
  2024. static PyObject *__pyx_int_1073741824;
  2025. static unsigned char *__pyx_k__14;
  2026. static unsigned char *__pyx_k__15;
  2027. static unsigned char *__pyx_k__16;
  2028. static unsigned char *__pyx_k__17;
  2029. static PyObject *__pyx_tuple__2;
  2030. static PyObject *__pyx_tuple__3;
  2031. static PyObject *__pyx_tuple__5;
  2032. static PyObject *__pyx_tuple__7;
  2033. static PyObject *__pyx_tuple__8;
  2034. static PyObject *__pyx_tuple__9;
  2035. static PyObject *__pyx_tuple__10;
  2036. static PyObject *__pyx_tuple__11;
  2037. static PyObject *__pyx_tuple__12;
  2038. static PyObject *__pyx_tuple__13;
  2039. static PyObject *__pyx_tuple__18;
  2040. static PyObject *__pyx_tuple__19;
  2041. static PyObject *__pyx_tuple__21;
  2042. static PyObject *__pyx_tuple__22;
  2043. /* Late includes */
  2044. /* "lakesuperior/store/base_lmdb_store.pyx":22
  2045. *
  2046. *
  2047. * cdef void _check(int rc, str message='') except *: # <<<<<<<<<<<<<<
  2048. * """
  2049. * Check return code.
  2050. */
  2051. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(int __pyx_v_rc, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check *__pyx_optional_args) {
  2052. PyObject *__pyx_v_message = ((PyObject*)__pyx_kp_u_);
  2053. PyObject *__pyx_v_out_msg = NULL;
  2054. __Pyx_TraceDeclarations
  2055. __Pyx_RefNannyDeclarations
  2056. int __pyx_t_1;
  2057. PyObject *__pyx_t_2 = NULL;
  2058. PyObject *__pyx_t_3 = NULL;
  2059. PyObject *__pyx_t_4 = NULL;
  2060. Py_ssize_t __pyx_t_5;
  2061. PyObject *__pyx_t_6 = NULL;
  2062. PyObject *__pyx_t_7 = NULL;
  2063. PyObject *__pyx_t_8 = NULL;
  2064. char *__pyx_t_9;
  2065. __Pyx_RefNannySetupContext("_check", 0);
  2066. __Pyx_TraceCall("_check", __pyx_f[0], 22, 0, __PYX_ERR(0, 22, __pyx_L1_error));
  2067. if (__pyx_optional_args) {
  2068. if (__pyx_optional_args->__pyx_n > 0) {
  2069. __pyx_v_message = __pyx_optional_args->message;
  2070. }
  2071. }
  2072. /* "lakesuperior/store/base_lmdb_store.pyx":26
  2073. * Check return code.
  2074. * """
  2075. * if rc == lmdb.MDB_NOTFOUND: # <<<<<<<<<<<<<<
  2076. * raise KeyNotFoundError()
  2077. * if rc == lmdb.MDB_KEYEXIST:
  2078. */
  2079. __pyx_t_1 = ((__pyx_v_rc == MDB_NOTFOUND) != 0);
  2080. if (unlikely(__pyx_t_1)) {
  2081. /* "lakesuperior/store/base_lmdb_store.pyx":27
  2082. * """
  2083. * if rc == lmdb.MDB_NOTFOUND:
  2084. * raise KeyNotFoundError() # <<<<<<<<<<<<<<
  2085. * if rc == lmdb.MDB_KEYEXIST:
  2086. * raise KeyExistsError()
  2087. */
  2088. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error)
  2089. __Pyx_GOTREF(__pyx_t_3);
  2090. __pyx_t_4 = NULL;
  2091. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  2092. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  2093. if (likely(__pyx_t_4)) {
  2094. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2095. __Pyx_INCREF(__pyx_t_4);
  2096. __Pyx_INCREF(function);
  2097. __Pyx_DECREF_SET(__pyx_t_3, function);
  2098. }
  2099. }
  2100. if (__pyx_t_4) {
  2101. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
  2102. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2103. } else {
  2104. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
  2105. }
  2106. __Pyx_GOTREF(__pyx_t_2);
  2107. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2108. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  2109. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2110. __PYX_ERR(0, 27, __pyx_L1_error)
  2111. /* "lakesuperior/store/base_lmdb_store.pyx":26
  2112. * Check return code.
  2113. * """
  2114. * if rc == lmdb.MDB_NOTFOUND: # <<<<<<<<<<<<<<
  2115. * raise KeyNotFoundError()
  2116. * if rc == lmdb.MDB_KEYEXIST:
  2117. */
  2118. }
  2119. /* "lakesuperior/store/base_lmdb_store.pyx":28
  2120. * if rc == lmdb.MDB_NOTFOUND:
  2121. * raise KeyNotFoundError()
  2122. * if rc == lmdb.MDB_KEYEXIST: # <<<<<<<<<<<<<<
  2123. * raise KeyExistsError()
  2124. * if rc != lmdb.MDB_SUCCESS:
  2125. */
  2126. __pyx_t_1 = ((__pyx_v_rc == MDB_KEYEXIST) != 0);
  2127. if (unlikely(__pyx_t_1)) {
  2128. /* "lakesuperior/store/base_lmdb_store.pyx":29
  2129. * raise KeyNotFoundError()
  2130. * if rc == lmdb.MDB_KEYEXIST:
  2131. * raise KeyExistsError() # <<<<<<<<<<<<<<
  2132. * if rc != lmdb.MDB_SUCCESS:
  2133. * out_msg = (
  2134. */
  2135. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyExistsError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error)
  2136. __Pyx_GOTREF(__pyx_t_3);
  2137. __pyx_t_4 = NULL;
  2138. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  2139. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  2140. if (likely(__pyx_t_4)) {
  2141. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2142. __Pyx_INCREF(__pyx_t_4);
  2143. __Pyx_INCREF(function);
  2144. __Pyx_DECREF_SET(__pyx_t_3, function);
  2145. }
  2146. }
  2147. if (__pyx_t_4) {
  2148. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  2149. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2150. } else {
  2151. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  2152. }
  2153. __Pyx_GOTREF(__pyx_t_2);
  2154. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2155. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  2156. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2157. __PYX_ERR(0, 29, __pyx_L1_error)
  2158. /* "lakesuperior/store/base_lmdb_store.pyx":28
  2159. * if rc == lmdb.MDB_NOTFOUND:
  2160. * raise KeyNotFoundError()
  2161. * if rc == lmdb.MDB_KEYEXIST: # <<<<<<<<<<<<<<
  2162. * raise KeyExistsError()
  2163. * if rc != lmdb.MDB_SUCCESS:
  2164. */
  2165. }
  2166. /* "lakesuperior/store/base_lmdb_store.pyx":30
  2167. * if rc == lmdb.MDB_KEYEXIST:
  2168. * raise KeyExistsError()
  2169. * if rc != lmdb.MDB_SUCCESS: # <<<<<<<<<<<<<<
  2170. * out_msg = (
  2171. * message + '\nInternal error ({}): '.format(rc)
  2172. */
  2173. __pyx_t_1 = ((__pyx_v_rc != MDB_SUCCESS) != 0);
  2174. if (unlikely(__pyx_t_1)) {
  2175. /* "lakesuperior/store/base_lmdb_store.pyx":33
  2176. * out_msg = (
  2177. * message + '\nInternal error ({}): '.format(rc)
  2178. * if len(message) else 'LMDB Error ({}): '.format(rc)) # <<<<<<<<<<<<<<
  2179. * out_msg += lmdb.mdb_strerror(rc).decode()
  2180. * raise LmdbError(out_msg)
  2181. */
  2182. if (unlikely(__pyx_v_message == Py_None)) {
  2183. PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
  2184. __PYX_ERR(0, 33, __pyx_L1_error)
  2185. }
  2186. __pyx_t_5 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_message); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 33, __pyx_L1_error)
  2187. if ((__pyx_t_5 != 0)) {
  2188. /* "lakesuperior/store/base_lmdb_store.pyx":32
  2189. * if rc != lmdb.MDB_SUCCESS:
  2190. * out_msg = (
  2191. * message + '\nInternal error ({}): '.format(rc) # <<<<<<<<<<<<<<
  2192. * if len(message) else 'LMDB Error ({}): '.format(rc))
  2193. * out_msg += lmdb.mdb_strerror(rc).decode()
  2194. */
  2195. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Internal_error, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 32, __pyx_L1_error)
  2196. __Pyx_GOTREF(__pyx_t_4);
  2197. __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 32, __pyx_L1_error)
  2198. __Pyx_GOTREF(__pyx_t_6);
  2199. __pyx_t_7 = NULL;
  2200. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  2201. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
  2202. if (likely(__pyx_t_7)) {
  2203. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2204. __Pyx_INCREF(__pyx_t_7);
  2205. __Pyx_INCREF(function);
  2206. __Pyx_DECREF_SET(__pyx_t_4, function);
  2207. }
  2208. }
  2209. if (!__pyx_t_7) {
  2210. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error)
  2211. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2212. __Pyx_GOTREF(__pyx_t_3);
  2213. } else {
  2214. #if CYTHON_FAST_PYCALL
  2215. if (PyFunction_Check(__pyx_t_4)) {
  2216. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  2217. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error)
  2218. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  2219. __Pyx_GOTREF(__pyx_t_3);
  2220. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2221. } else
  2222. #endif
  2223. #if CYTHON_FAST_PYCCALL
  2224. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  2225. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  2226. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error)
  2227. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  2228. __Pyx_GOTREF(__pyx_t_3);
  2229. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2230. } else
  2231. #endif
  2232. {
  2233. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 32, __pyx_L1_error)
  2234. __Pyx_GOTREF(__pyx_t_8);
  2235. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  2236. __Pyx_GIVEREF(__pyx_t_6);
  2237. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
  2238. __pyx_t_6 = 0;
  2239. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error)
  2240. __Pyx_GOTREF(__pyx_t_3);
  2241. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2242. }
  2243. }
  2244. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2245. __pyx_t_4 = PyNumber_Add(__pyx_v_message, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 32, __pyx_L1_error)
  2246. __Pyx_GOTREF(__pyx_t_4);
  2247. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2248. __pyx_t_2 = __pyx_t_4;
  2249. __pyx_t_4 = 0;
  2250. } else {
  2251. /* "lakesuperior/store/base_lmdb_store.pyx":33
  2252. * out_msg = (
  2253. * message + '\nInternal error ({}): '.format(rc)
  2254. * if len(message) else 'LMDB Error ({}): '.format(rc)) # <<<<<<<<<<<<<<
  2255. * out_msg += lmdb.mdb_strerror(rc).decode()
  2256. * raise LmdbError(out_msg)
  2257. */
  2258. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_LMDB_Error, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 33, __pyx_L1_error)
  2259. __Pyx_GOTREF(__pyx_t_3);
  2260. __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 33, __pyx_L1_error)
  2261. __Pyx_GOTREF(__pyx_t_8);
  2262. __pyx_t_6 = NULL;
  2263. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  2264. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
  2265. if (likely(__pyx_t_6)) {
  2266. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2267. __Pyx_INCREF(__pyx_t_6);
  2268. __Pyx_INCREF(function);
  2269. __Pyx_DECREF_SET(__pyx_t_3, function);
  2270. }
  2271. }
  2272. if (!__pyx_t_6) {
  2273. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error)
  2274. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2275. __Pyx_GOTREF(__pyx_t_4);
  2276. } else {
  2277. #if CYTHON_FAST_PYCALL
  2278. if (PyFunction_Check(__pyx_t_3)) {
  2279. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_8};
  2280. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error)
  2281. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2282. __Pyx_GOTREF(__pyx_t_4);
  2283. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2284. } else
  2285. #endif
  2286. #if CYTHON_FAST_PYCCALL
  2287. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  2288. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_8};
  2289. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error)
  2290. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2291. __Pyx_GOTREF(__pyx_t_4);
  2292. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2293. } else
  2294. #endif
  2295. {
  2296. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 33, __pyx_L1_error)
  2297. __Pyx_GOTREF(__pyx_t_7);
  2298. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
  2299. __Pyx_GIVEREF(__pyx_t_8);
  2300. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_8);
  2301. __pyx_t_8 = 0;
  2302. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error)
  2303. __Pyx_GOTREF(__pyx_t_4);
  2304. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2305. }
  2306. }
  2307. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2308. __pyx_t_2 = __pyx_t_4;
  2309. __pyx_t_4 = 0;
  2310. }
  2311. __pyx_v_out_msg = __pyx_t_2;
  2312. __pyx_t_2 = 0;
  2313. /* "lakesuperior/store/base_lmdb_store.pyx":34
  2314. * message + '\nInternal error ({}): '.format(rc)
  2315. * if len(message) else 'LMDB Error ({}): '.format(rc))
  2316. * out_msg += lmdb.mdb_strerror(rc).decode() # <<<<<<<<<<<<<<
  2317. * raise LmdbError(out_msg)
  2318. *
  2319. */
  2320. __pyx_t_9 = mdb_strerror(__pyx_v_rc);
  2321. __pyx_t_2 = __Pyx_decode_c_string(__pyx_t_9, 0, strlen(__pyx_t_9), NULL, NULL, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error)
  2322. __Pyx_GOTREF(__pyx_t_2);
  2323. __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_out_msg, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error)
  2324. __Pyx_GOTREF(__pyx_t_4);
  2325. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2326. __Pyx_DECREF_SET(__pyx_v_out_msg, __pyx_t_4);
  2327. __pyx_t_4 = 0;
  2328. /* "lakesuperior/store/base_lmdb_store.pyx":35
  2329. * if len(message) else 'LMDB Error ({}): '.format(rc))
  2330. * out_msg += lmdb.mdb_strerror(rc).decode()
  2331. * raise LmdbError(out_msg) # <<<<<<<<<<<<<<
  2332. *
  2333. *
  2334. */
  2335. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
  2336. __Pyx_GOTREF(__pyx_t_2);
  2337. __pyx_t_3 = NULL;
  2338. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  2339. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  2340. if (likely(__pyx_t_3)) {
  2341. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  2342. __Pyx_INCREF(__pyx_t_3);
  2343. __Pyx_INCREF(function);
  2344. __Pyx_DECREF_SET(__pyx_t_2, function);
  2345. }
  2346. }
  2347. if (!__pyx_t_3) {
  2348. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_out_msg); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 35, __pyx_L1_error)
  2349. __Pyx_GOTREF(__pyx_t_4);
  2350. } else {
  2351. #if CYTHON_FAST_PYCALL
  2352. if (PyFunction_Check(__pyx_t_2)) {
  2353. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_out_msg};
  2354. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 35, __pyx_L1_error)
  2355. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2356. __Pyx_GOTREF(__pyx_t_4);
  2357. } else
  2358. #endif
  2359. #if CYTHON_FAST_PYCCALL
  2360. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  2361. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_out_msg};
  2362. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 35, __pyx_L1_error)
  2363. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2364. __Pyx_GOTREF(__pyx_t_4);
  2365. } else
  2366. #endif
  2367. {
  2368. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 35, __pyx_L1_error)
  2369. __Pyx_GOTREF(__pyx_t_7);
  2370. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
  2371. __Pyx_INCREF(__pyx_v_out_msg);
  2372. __Pyx_GIVEREF(__pyx_v_out_msg);
  2373. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_out_msg);
  2374. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 35, __pyx_L1_error)
  2375. __Pyx_GOTREF(__pyx_t_4);
  2376. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2377. }
  2378. }
  2379. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2380. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  2381. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2382. __PYX_ERR(0, 35, __pyx_L1_error)
  2383. /* "lakesuperior/store/base_lmdb_store.pyx":30
  2384. * if rc == lmdb.MDB_KEYEXIST:
  2385. * raise KeyExistsError()
  2386. * if rc != lmdb.MDB_SUCCESS: # <<<<<<<<<<<<<<
  2387. * out_msg = (
  2388. * message + '\nInternal error ({}): '.format(rc)
  2389. */
  2390. }
  2391. /* "lakesuperior/store/base_lmdb_store.pyx":22
  2392. *
  2393. *
  2394. * cdef void _check(int rc, str message='') except *: # <<<<<<<<<<<<<<
  2395. * """
  2396. * Check return code.
  2397. */
  2398. /* function exit code */
  2399. goto __pyx_L0;
  2400. __pyx_L1_error:;
  2401. __Pyx_XDECREF(__pyx_t_2);
  2402. __Pyx_XDECREF(__pyx_t_3);
  2403. __Pyx_XDECREF(__pyx_t_4);
  2404. __Pyx_XDECREF(__pyx_t_6);
  2405. __Pyx_XDECREF(__pyx_t_7);
  2406. __Pyx_XDECREF(__pyx_t_8);
  2407. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store._check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2408. __pyx_L0:;
  2409. __Pyx_XDECREF(__pyx_v_out_msg);
  2410. __Pyx_TraceReturn(Py_None, 0);
  2411. __Pyx_RefNannyFinishContext();
  2412. }
  2413. /* "lakesuperior/store/base_lmdb_store.pyx":129
  2414. * ### INIT & TEARDOWN ###
  2415. *
  2416. * def __init__(self, env_path, open_env=True, create=True): # <<<<<<<<<<<<<<
  2417. * """
  2418. * Initialize DB environment and databases.
  2419. */
  2420. /* Python wrapper */
  2421. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2422. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__[] = "\n Initialize DB environment and databases.\n\n :param str env_path: The file path of the store.\n :param bool open: Whether to open the store immediately. If ``False``\n the store can be manually opened with :py:meth:`opn_env`.\n :param bool create: Whether the file and directory structure should\n be created if the store is opened immediately.\n ";
  2423. #if CYTHON_COMPILING_IN_CPYTHON
  2424. struct wrapperbase __pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__;
  2425. #endif
  2426. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2427. PyObject *__pyx_v_env_path = 0;
  2428. PyObject *__pyx_v_open_env = 0;
  2429. PyObject *__pyx_v_create = 0;
  2430. int __pyx_r;
  2431. __Pyx_RefNannyDeclarations
  2432. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  2433. {
  2434. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_env_path,&__pyx_n_s_open_env,&__pyx_n_s_create,0};
  2435. PyObject* values[3] = {0,0,0};
  2436. values[1] = ((PyObject *)Py_True);
  2437. values[2] = ((PyObject *)Py_True);
  2438. if (unlikely(__pyx_kwds)) {
  2439. Py_ssize_t kw_args;
  2440. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2441. switch (pos_args) {
  2442. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2443. CYTHON_FALLTHROUGH;
  2444. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2445. CYTHON_FALLTHROUGH;
  2446. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2447. CYTHON_FALLTHROUGH;
  2448. case 0: break;
  2449. default: goto __pyx_L5_argtuple_error;
  2450. }
  2451. kw_args = PyDict_Size(__pyx_kwds);
  2452. switch (pos_args) {
  2453. case 0:
  2454. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_env_path)) != 0)) kw_args--;
  2455. else goto __pyx_L5_argtuple_error;
  2456. CYTHON_FALLTHROUGH;
  2457. case 1:
  2458. if (kw_args > 0) {
  2459. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_open_env);
  2460. if (value) { values[1] = value; kw_args--; }
  2461. }
  2462. CYTHON_FALLTHROUGH;
  2463. case 2:
  2464. if (kw_args > 0) {
  2465. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_create);
  2466. if (value) { values[2] = value; kw_args--; }
  2467. }
  2468. }
  2469. if (unlikely(kw_args > 0)) {
  2470. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 129, __pyx_L3_error)
  2471. }
  2472. } else {
  2473. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2474. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2475. CYTHON_FALLTHROUGH;
  2476. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2477. CYTHON_FALLTHROUGH;
  2478. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2479. break;
  2480. default: goto __pyx_L5_argtuple_error;
  2481. }
  2482. }
  2483. __pyx_v_env_path = values[0];
  2484. __pyx_v_open_env = values[1];
  2485. __pyx_v_create = values[2];
  2486. }
  2487. goto __pyx_L4_argument_unpacking_done;
  2488. __pyx_L5_argtuple_error:;
  2489. __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 129, __pyx_L3_error)
  2490. __pyx_L3_error:;
  2491. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2492. __Pyx_RefNannyFinishContext();
  2493. return -1;
  2494. __pyx_L4_argument_unpacking_done:;
  2495. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), __pyx_v_env_path, __pyx_v_open_env, __pyx_v_create);
  2496. /* function exit code */
  2497. __Pyx_RefNannyFinishContext();
  2498. return __pyx_r;
  2499. }
  2500. static int __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_env_path, PyObject *__pyx_v_open_env, PyObject *__pyx_v_create) {
  2501. int __pyx_r;
  2502. __Pyx_TraceDeclarations
  2503. __Pyx_RefNannyDeclarations
  2504. PyObject *__pyx_t_1 = NULL;
  2505. int __pyx_t_2;
  2506. PyObject *__pyx_t_3 = NULL;
  2507. PyObject *__pyx_t_4 = NULL;
  2508. PyObject *__pyx_t_5 = NULL;
  2509. __Pyx_RefNannySetupContext("__init__", 0);
  2510. __Pyx_TraceCall("__init__", __pyx_f[0], 129, 0, __PYX_ERR(0, 129, __pyx_L1_error));
  2511. /* "lakesuperior/store/base_lmdb_store.pyx":139
  2512. * be created if the store is opened immediately.
  2513. * """
  2514. * self._open = False # <<<<<<<<<<<<<<
  2515. * self.is_txn_open = False
  2516. * self.env_path = env_path
  2517. */
  2518. __pyx_v_self->_open = 0;
  2519. /* "lakesuperior/store/base_lmdb_store.pyx":140
  2520. * """
  2521. * self._open = False
  2522. * self.is_txn_open = False # <<<<<<<<<<<<<<
  2523. * self.env_path = env_path
  2524. * if open_env:
  2525. */
  2526. __pyx_v_self->is_txn_open = 0;
  2527. /* "lakesuperior/store/base_lmdb_store.pyx":141
  2528. * self._open = False
  2529. * self.is_txn_open = False
  2530. * self.env_path = env_path # <<<<<<<<<<<<<<
  2531. * if open_env:
  2532. * self.open_env(create)
  2533. */
  2534. if (!(likely(PyUnicode_CheckExact(__pyx_v_env_path))||((__pyx_v_env_path) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_env_path)->tp_name), 0))) __PYX_ERR(0, 141, __pyx_L1_error)
  2535. __pyx_t_1 = __pyx_v_env_path;
  2536. __Pyx_INCREF(__pyx_t_1);
  2537. __Pyx_GIVEREF(__pyx_t_1);
  2538. __Pyx_GOTREF(__pyx_v_self->env_path);
  2539. __Pyx_DECREF(__pyx_v_self->env_path);
  2540. __pyx_v_self->env_path = ((PyObject*)__pyx_t_1);
  2541. __pyx_t_1 = 0;
  2542. /* "lakesuperior/store/base_lmdb_store.pyx":142
  2543. * self.is_txn_open = False
  2544. * self.env_path = env_path
  2545. * if open_env: # <<<<<<<<<<<<<<
  2546. * self.open_env(create)
  2547. * #logger.info('Init DB with path: {}'.format(self.env_path))
  2548. */
  2549. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_open_env); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 142, __pyx_L1_error)
  2550. if (__pyx_t_2) {
  2551. /* "lakesuperior/store/base_lmdb_store.pyx":143
  2552. * self.env_path = env_path
  2553. * if open_env:
  2554. * self.open_env(create) # <<<<<<<<<<<<<<
  2555. * #logger.info('Init DB with path: {}'.format(self.env_path))
  2556. *
  2557. */
  2558. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_env); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 143, __pyx_L1_error)
  2559. __Pyx_GOTREF(__pyx_t_3);
  2560. __pyx_t_4 = NULL;
  2561. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  2562. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  2563. if (likely(__pyx_t_4)) {
  2564. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2565. __Pyx_INCREF(__pyx_t_4);
  2566. __Pyx_INCREF(function);
  2567. __Pyx_DECREF_SET(__pyx_t_3, function);
  2568. }
  2569. }
  2570. if (!__pyx_t_4) {
  2571. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_create); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
  2572. __Pyx_GOTREF(__pyx_t_1);
  2573. } else {
  2574. #if CYTHON_FAST_PYCALL
  2575. if (PyFunction_Check(__pyx_t_3)) {
  2576. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_create};
  2577. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
  2578. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2579. __Pyx_GOTREF(__pyx_t_1);
  2580. } else
  2581. #endif
  2582. #if CYTHON_FAST_PYCCALL
  2583. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  2584. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_create};
  2585. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
  2586. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2587. __Pyx_GOTREF(__pyx_t_1);
  2588. } else
  2589. #endif
  2590. {
  2591. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error)
  2592. __Pyx_GOTREF(__pyx_t_5);
  2593. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  2594. __Pyx_INCREF(__pyx_v_create);
  2595. __Pyx_GIVEREF(__pyx_v_create);
  2596. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_create);
  2597. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
  2598. __Pyx_GOTREF(__pyx_t_1);
  2599. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2600. }
  2601. }
  2602. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2603. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2604. /* "lakesuperior/store/base_lmdb_store.pyx":142
  2605. * self.is_txn_open = False
  2606. * self.env_path = env_path
  2607. * if open_env: # <<<<<<<<<<<<<<
  2608. * self.open_env(create)
  2609. * #logger.info('Init DB with path: {}'.format(self.env_path))
  2610. */
  2611. }
  2612. /* "lakesuperior/store/base_lmdb_store.pyx":129
  2613. * ### INIT & TEARDOWN ###
  2614. *
  2615. * def __init__(self, env_path, open_env=True, create=True): # <<<<<<<<<<<<<<
  2616. * """
  2617. * Initialize DB environment and databases.
  2618. */
  2619. /* function exit code */
  2620. __pyx_r = 0;
  2621. goto __pyx_L0;
  2622. __pyx_L1_error:;
  2623. __Pyx_XDECREF(__pyx_t_1);
  2624. __Pyx_XDECREF(__pyx_t_3);
  2625. __Pyx_XDECREF(__pyx_t_4);
  2626. __Pyx_XDECREF(__pyx_t_5);
  2627. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2628. __pyx_r = -1;
  2629. __pyx_L0:;
  2630. __Pyx_TraceReturn(Py_None, 0);
  2631. __Pyx_RefNannyFinishContext();
  2632. return __pyx_r;
  2633. }
  2634. /* "lakesuperior/store/base_lmdb_store.pyx":147
  2635. *
  2636. *
  2637. * def __dealloc__(self): # <<<<<<<<<<<<<<
  2638. * self.close_env()
  2639. *
  2640. */
  2641. /* Python wrapper */
  2642. static void __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
  2643. static void __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_3__dealloc__(PyObject *__pyx_v_self) {
  2644. __Pyx_RefNannyDeclarations
  2645. __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  2646. __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_2__dealloc__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  2647. /* function exit code */
  2648. __Pyx_RefNannyFinishContext();
  2649. }
  2650. static void __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_2__dealloc__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  2651. __Pyx_TraceDeclarations
  2652. __Pyx_RefNannyDeclarations
  2653. __Pyx_RefNannySetupContext("__dealloc__", 0);
  2654. __Pyx_TraceCall("__dealloc__", __pyx_f[0], 147, 0, __PYX_ERR(0, 147, __pyx_L1_error));
  2655. /* "lakesuperior/store/base_lmdb_store.pyx":148
  2656. *
  2657. * def __dealloc__(self):
  2658. * self.close_env() # <<<<<<<<<<<<<<
  2659. *
  2660. *
  2661. */
  2662. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->close_env(__pyx_v_self, 0, NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 148, __pyx_L1_error)
  2663. /* "lakesuperior/store/base_lmdb_store.pyx":147
  2664. *
  2665. *
  2666. * def __dealloc__(self): # <<<<<<<<<<<<<<
  2667. * self.close_env()
  2668. *
  2669. */
  2670. /* function exit code */
  2671. goto __pyx_L0;
  2672. __pyx_L1_error:;
  2673. __Pyx_WriteUnraisable("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  2674. __pyx_L0:;
  2675. __Pyx_TraceReturn(Py_None, 0);
  2676. __Pyx_RefNannyFinishContext();
  2677. }
  2678. /* "lakesuperior/store/base_lmdb_store.pyx":152
  2679. *
  2680. * @property
  2681. * def is_open(self): # <<<<<<<<<<<<<<
  2682. * return self._open
  2683. *
  2684. */
  2685. /* Python wrapper */
  2686. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open_1__get__(PyObject *__pyx_v_self); /*proto*/
  2687. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open_1__get__(PyObject *__pyx_v_self) {
  2688. PyObject *__pyx_r = 0;
  2689. __Pyx_RefNannyDeclarations
  2690. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  2691. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open___get__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  2692. /* function exit code */
  2693. __Pyx_RefNannyFinishContext();
  2694. return __pyx_r;
  2695. }
  2696. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  2697. PyObject *__pyx_r = NULL;
  2698. __Pyx_TraceDeclarations
  2699. __Pyx_RefNannyDeclarations
  2700. PyObject *__pyx_t_1 = NULL;
  2701. __Pyx_RefNannySetupContext("__get__", 0);
  2702. __Pyx_TraceCall("__get__", __pyx_f[0], 152, 0, __PYX_ERR(0, 152, __pyx_L1_error));
  2703. /* "lakesuperior/store/base_lmdb_store.pyx":153
  2704. * @property
  2705. * def is_open(self):
  2706. * return self._open # <<<<<<<<<<<<<<
  2707. *
  2708. *
  2709. */
  2710. __Pyx_XDECREF(__pyx_r);
  2711. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
  2712. __Pyx_GOTREF(__pyx_t_1);
  2713. __pyx_r = __pyx_t_1;
  2714. __pyx_t_1 = 0;
  2715. goto __pyx_L0;
  2716. /* "lakesuperior/store/base_lmdb_store.pyx":152
  2717. *
  2718. * @property
  2719. * def is_open(self): # <<<<<<<<<<<<<<
  2720. * return self._open
  2721. *
  2722. */
  2723. /* function exit code */
  2724. __pyx_L1_error:;
  2725. __Pyx_XDECREF(__pyx_t_1);
  2726. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.is_open.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2727. __pyx_r = NULL;
  2728. __pyx_L0:;
  2729. __Pyx_XGIVEREF(__pyx_r);
  2730. __Pyx_TraceReturn(__pyx_r, 0);
  2731. __Pyx_RefNannyFinishContext();
  2732. return __pyx_r;
  2733. }
  2734. /* "lakesuperior/store/base_lmdb_store.pyx":157
  2735. *
  2736. * @property
  2737. * def readers(self): # <<<<<<<<<<<<<<
  2738. * return self._readers
  2739. *
  2740. */
  2741. /* Python wrapper */
  2742. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers_1__get__(PyObject *__pyx_v_self); /*proto*/
  2743. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers_1__get__(PyObject *__pyx_v_self) {
  2744. PyObject *__pyx_r = 0;
  2745. __Pyx_RefNannyDeclarations
  2746. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  2747. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers___get__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  2748. /* function exit code */
  2749. __Pyx_RefNannyFinishContext();
  2750. return __pyx_r;
  2751. }
  2752. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  2753. PyObject *__pyx_r = NULL;
  2754. __Pyx_TraceDeclarations
  2755. __Pyx_RefNannyDeclarations
  2756. PyObject *__pyx_t_1 = NULL;
  2757. __Pyx_RefNannySetupContext("__get__", 0);
  2758. __Pyx_TraceCall("__get__", __pyx_f[0], 157, 0, __PYX_ERR(0, 157, __pyx_L1_error));
  2759. /* "lakesuperior/store/base_lmdb_store.pyx":158
  2760. * @property
  2761. * def readers(self):
  2762. * return self._readers # <<<<<<<<<<<<<<
  2763. *
  2764. *
  2765. */
  2766. __Pyx_XDECREF(__pyx_r);
  2767. __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->_readers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error)
  2768. __Pyx_GOTREF(__pyx_t_1);
  2769. __pyx_r = __pyx_t_1;
  2770. __pyx_t_1 = 0;
  2771. goto __pyx_L0;
  2772. /* "lakesuperior/store/base_lmdb_store.pyx":157
  2773. *
  2774. * @property
  2775. * def readers(self): # <<<<<<<<<<<<<<
  2776. * return self._readers
  2777. *
  2778. */
  2779. /* function exit code */
  2780. __pyx_L1_error:;
  2781. __Pyx_XDECREF(__pyx_t_1);
  2782. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.readers.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2783. __pyx_r = NULL;
  2784. __pyx_L0:;
  2785. __Pyx_XGIVEREF(__pyx_r);
  2786. __Pyx_TraceReturn(__pyx_r, 0);
  2787. __Pyx_RefNannyFinishContext();
  2788. return __pyx_r;
  2789. }
  2790. /* "lakesuperior/store/base_lmdb_store.pyx":161
  2791. *
  2792. *
  2793. * def open_env(self, create): # <<<<<<<<<<<<<<
  2794. * """
  2795. * Open, and optionally create, store environment.
  2796. */
  2797. /* Python wrapper */
  2798. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5open_env(PyObject *__pyx_v_self, PyObject *__pyx_v_create); /*proto*/
  2799. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_4open_env[] = "\n Open, and optionally create, store environment.\n ";
  2800. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5open_env(PyObject *__pyx_v_self, PyObject *__pyx_v_create) {
  2801. PyObject *__pyx_r = 0;
  2802. __Pyx_RefNannyDeclarations
  2803. __Pyx_RefNannySetupContext("open_env (wrapper)", 0);
  2804. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_4open_env(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), ((PyObject *)__pyx_v_create));
  2805. /* function exit code */
  2806. __Pyx_RefNannyFinishContext();
  2807. return __pyx_r;
  2808. }
  2809. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_4open_env(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_create) {
  2810. PyObject *__pyx_v_parent_path = NULL;
  2811. PyObject *__pyx_v_e = NULL;
  2812. PyObject *__pyx_v_max_dbs = NULL;
  2813. PyObject *__pyx_r = NULL;
  2814. __Pyx_TraceDeclarations
  2815. __Pyx_RefNannyDeclarations
  2816. PyObject *__pyx_t_1 = NULL;
  2817. int __pyx_t_2;
  2818. PyObject *__pyx_t_3 = NULL;
  2819. PyObject *__pyx_t_4 = NULL;
  2820. PyObject *__pyx_t_5 = NULL;
  2821. PyObject *__pyx_t_6 = NULL;
  2822. PyObject *__pyx_t_7 = NULL;
  2823. int __pyx_t_8;
  2824. PyObject *__pyx_t_9 = NULL;
  2825. PyObject *__pyx_t_10 = NULL;
  2826. PyObject *__pyx_t_11 = NULL;
  2827. int __pyx_t_12;
  2828. PyObject *__pyx_t_13 = NULL;
  2829. PyObject *__pyx_t_14 = NULL;
  2830. PyObject *__pyx_t_15 = NULL;
  2831. int __pyx_t_16;
  2832. char const *__pyx_t_17;
  2833. PyObject *__pyx_t_18 = NULL;
  2834. PyObject *__pyx_t_19 = NULL;
  2835. PyObject *__pyx_t_20 = NULL;
  2836. PyObject *__pyx_t_21 = NULL;
  2837. PyObject *__pyx_t_22 = NULL;
  2838. PyObject *__pyx_t_23 = NULL;
  2839. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_24;
  2840. size_t __pyx_t_25;
  2841. Py_ssize_t __pyx_t_26;
  2842. MDB_dbi __pyx_t_27;
  2843. unsigned int __pyx_t_28;
  2844. char const *__pyx_t_29;
  2845. mdb_mode_t __pyx_t_30;
  2846. Py_UCS4 __pyx_t_31;
  2847. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis __pyx_t_32;
  2848. __Pyx_RefNannySetupContext("open_env", 0);
  2849. __Pyx_TraceCall("open_env", __pyx_f[0], 161, 0, __PYX_ERR(0, 161, __pyx_L1_error));
  2850. /* "lakesuperior/store/base_lmdb_store.pyx":165
  2851. * Open, and optionally create, store environment.
  2852. * """
  2853. * if self.is_open: # <<<<<<<<<<<<<<
  2854. * logger.warning('Environment already open.')
  2855. * return
  2856. */
  2857. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error)
  2858. __Pyx_GOTREF(__pyx_t_1);
  2859. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 165, __pyx_L1_error)
  2860. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2861. if (__pyx_t_2) {
  2862. /* "lakesuperior/store/base_lmdb_store.pyx":166
  2863. * """
  2864. * if self.is_open:
  2865. * logger.warning('Environment already open.') # <<<<<<<<<<<<<<
  2866. * return
  2867. *
  2868. */
  2869. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
  2870. __Pyx_GOTREF(__pyx_t_1);
  2871. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warning); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error)
  2872. __Pyx_GOTREF(__pyx_t_3);
  2873. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2874. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
  2875. __Pyx_GOTREF(__pyx_t_1);
  2876. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2877. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2878. /* "lakesuperior/store/base_lmdb_store.pyx":167
  2879. * if self.is_open:
  2880. * logger.warning('Environment already open.')
  2881. * return # <<<<<<<<<<<<<<
  2882. *
  2883. * logger.debug('Opening environment at {}.'.format(self.env_path))
  2884. */
  2885. __Pyx_XDECREF(__pyx_r);
  2886. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2887. goto __pyx_L0;
  2888. /* "lakesuperior/store/base_lmdb_store.pyx":165
  2889. * Open, and optionally create, store environment.
  2890. * """
  2891. * if self.is_open: # <<<<<<<<<<<<<<
  2892. * logger.warning('Environment already open.')
  2893. * return
  2894. */
  2895. }
  2896. /* "lakesuperior/store/base_lmdb_store.pyx":169
  2897. * return
  2898. *
  2899. * logger.debug('Opening environment at {}.'.format(self.env_path)) # <<<<<<<<<<<<<<
  2900. * if create:
  2901. * #logger.info('Creating db env at {}'.format(self.env_path))
  2902. */
  2903. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
  2904. __Pyx_GOTREF(__pyx_t_3);
  2905. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error)
  2906. __Pyx_GOTREF(__pyx_t_4);
  2907. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2908. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Opening_environment_at, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 169, __pyx_L1_error)
  2909. __Pyx_GOTREF(__pyx_t_5);
  2910. __pyx_t_6 = NULL;
  2911. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  2912. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
  2913. if (likely(__pyx_t_6)) {
  2914. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  2915. __Pyx_INCREF(__pyx_t_6);
  2916. __Pyx_INCREF(function);
  2917. __Pyx_DECREF_SET(__pyx_t_5, function);
  2918. }
  2919. }
  2920. if (!__pyx_t_6) {
  2921. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_self->env_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
  2922. __Pyx_GOTREF(__pyx_t_3);
  2923. } else {
  2924. #if CYTHON_FAST_PYCALL
  2925. if (PyFunction_Check(__pyx_t_5)) {
  2926. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->env_path};
  2927. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
  2928. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2929. __Pyx_GOTREF(__pyx_t_3);
  2930. } else
  2931. #endif
  2932. #if CYTHON_FAST_PYCCALL
  2933. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  2934. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->env_path};
  2935. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
  2936. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2937. __Pyx_GOTREF(__pyx_t_3);
  2938. } else
  2939. #endif
  2940. {
  2941. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 169, __pyx_L1_error)
  2942. __Pyx_GOTREF(__pyx_t_7);
  2943. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
  2944. __Pyx_INCREF(__pyx_v_self->env_path);
  2945. __Pyx_GIVEREF(__pyx_v_self->env_path);
  2946. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_self->env_path);
  2947. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
  2948. __Pyx_GOTREF(__pyx_t_3);
  2949. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2950. }
  2951. }
  2952. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2953. __pyx_t_5 = NULL;
  2954. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  2955. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  2956. if (likely(__pyx_t_5)) {
  2957. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2958. __Pyx_INCREF(__pyx_t_5);
  2959. __Pyx_INCREF(function);
  2960. __Pyx_DECREF_SET(__pyx_t_4, function);
  2961. }
  2962. }
  2963. if (!__pyx_t_5) {
  2964. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
  2965. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2966. __Pyx_GOTREF(__pyx_t_1);
  2967. } else {
  2968. #if CYTHON_FAST_PYCALL
  2969. if (PyFunction_Check(__pyx_t_4)) {
  2970. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  2971. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
  2972. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2973. __Pyx_GOTREF(__pyx_t_1);
  2974. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2975. } else
  2976. #endif
  2977. #if CYTHON_FAST_PYCCALL
  2978. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  2979. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  2980. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
  2981. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2982. __Pyx_GOTREF(__pyx_t_1);
  2983. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2984. } else
  2985. #endif
  2986. {
  2987. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 169, __pyx_L1_error)
  2988. __Pyx_GOTREF(__pyx_t_7);
  2989. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  2990. __Pyx_GIVEREF(__pyx_t_3);
  2991. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3);
  2992. __pyx_t_3 = 0;
  2993. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
  2994. __Pyx_GOTREF(__pyx_t_1);
  2995. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2996. }
  2997. }
  2998. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2999. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3000. /* "lakesuperior/store/base_lmdb_store.pyx":170
  3001. *
  3002. * logger.debug('Opening environment at {}.'.format(self.env_path))
  3003. * if create: # <<<<<<<<<<<<<<
  3004. * #logger.info('Creating db env at {}'.format(self.env_path))
  3005. * parent_path = (
  3006. */
  3007. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_create); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 170, __pyx_L1_error)
  3008. if (__pyx_t_2) {
  3009. /* "lakesuperior/store/base_lmdb_store.pyx":174
  3010. * parent_path = (
  3011. * path.dirname(self.env_path)
  3012. * if lmdb.MDB_NOSUBDIR & self.flags # <<<<<<<<<<<<<<
  3013. * else self.env_path)
  3014. *
  3015. */
  3016. __pyx_t_4 = __Pyx_PyInt_From_int(MDB_NOSUBDIR); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
  3017. __Pyx_GOTREF(__pyx_t_4);
  3018. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_flags); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 174, __pyx_L1_error)
  3019. __Pyx_GOTREF(__pyx_t_7);
  3020. __pyx_t_3 = PyNumber_And(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
  3021. __Pyx_GOTREF(__pyx_t_3);
  3022. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3023. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3024. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 174, __pyx_L1_error)
  3025. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3026. if (__pyx_t_2) {
  3027. /* "lakesuperior/store/base_lmdb_store.pyx":173
  3028. * #logger.info('Creating db env at {}'.format(self.env_path))
  3029. * parent_path = (
  3030. * path.dirname(self.env_path) # <<<<<<<<<<<<<<
  3031. * if lmdb.MDB_NOSUBDIR & self.flags
  3032. * else self.env_path)
  3033. */
  3034. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 173, __pyx_L1_error)
  3035. __Pyx_GOTREF(__pyx_t_7);
  3036. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dirname); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 173, __pyx_L1_error)
  3037. __Pyx_GOTREF(__pyx_t_4);
  3038. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3039. __pyx_t_7 = NULL;
  3040. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  3041. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
  3042. if (likely(__pyx_t_7)) {
  3043. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  3044. __Pyx_INCREF(__pyx_t_7);
  3045. __Pyx_INCREF(function);
  3046. __Pyx_DECREF_SET(__pyx_t_4, function);
  3047. }
  3048. }
  3049. if (!__pyx_t_7) {
  3050. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self->env_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L1_error)
  3051. __Pyx_GOTREF(__pyx_t_3);
  3052. } else {
  3053. #if CYTHON_FAST_PYCALL
  3054. if (PyFunction_Check(__pyx_t_4)) {
  3055. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_self->env_path};
  3056. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L1_error)
  3057. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3058. __Pyx_GOTREF(__pyx_t_3);
  3059. } else
  3060. #endif
  3061. #if CYTHON_FAST_PYCCALL
  3062. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  3063. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_self->env_path};
  3064. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L1_error)
  3065. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3066. __Pyx_GOTREF(__pyx_t_3);
  3067. } else
  3068. #endif
  3069. {
  3070. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 173, __pyx_L1_error)
  3071. __Pyx_GOTREF(__pyx_t_5);
  3072. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
  3073. __Pyx_INCREF(__pyx_v_self->env_path);
  3074. __Pyx_GIVEREF(__pyx_v_self->env_path);
  3075. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_self->env_path);
  3076. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L1_error)
  3077. __Pyx_GOTREF(__pyx_t_3);
  3078. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3079. }
  3080. }
  3081. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3082. __pyx_t_1 = __pyx_t_3;
  3083. __pyx_t_3 = 0;
  3084. } else {
  3085. /* "lakesuperior/store/base_lmdb_store.pyx":175
  3086. * path.dirname(self.env_path)
  3087. * if lmdb.MDB_NOSUBDIR & self.flags
  3088. * else self.env_path) # <<<<<<<<<<<<<<
  3089. *
  3090. * if not path.exists(parent_path):
  3091. */
  3092. __Pyx_INCREF(__pyx_v_self->env_path);
  3093. __pyx_t_1 = __pyx_v_self->env_path;
  3094. }
  3095. __pyx_v_parent_path = __pyx_t_1;
  3096. __pyx_t_1 = 0;
  3097. /* "lakesuperior/store/base_lmdb_store.pyx":177
  3098. * else self.env_path)
  3099. *
  3100. * if not path.exists(parent_path): # <<<<<<<<<<<<<<
  3101. * #logger.info(
  3102. * # 'Creating store directory at {}'.format(parent_path))
  3103. */
  3104. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
  3105. __Pyx_GOTREF(__pyx_t_3);
  3106. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exists); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 177, __pyx_L1_error)
  3107. __Pyx_GOTREF(__pyx_t_4);
  3108. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3109. __pyx_t_3 = NULL;
  3110. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  3111. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
  3112. if (likely(__pyx_t_3)) {
  3113. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  3114. __Pyx_INCREF(__pyx_t_3);
  3115. __Pyx_INCREF(function);
  3116. __Pyx_DECREF_SET(__pyx_t_4, function);
  3117. }
  3118. }
  3119. if (!__pyx_t_3) {
  3120. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_parent_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
  3121. __Pyx_GOTREF(__pyx_t_1);
  3122. } else {
  3123. #if CYTHON_FAST_PYCALL
  3124. if (PyFunction_Check(__pyx_t_4)) {
  3125. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_parent_path};
  3126. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
  3127. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3128. __Pyx_GOTREF(__pyx_t_1);
  3129. } else
  3130. #endif
  3131. #if CYTHON_FAST_PYCCALL
  3132. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  3133. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_parent_path};
  3134. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
  3135. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3136. __Pyx_GOTREF(__pyx_t_1);
  3137. } else
  3138. #endif
  3139. {
  3140. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 177, __pyx_L1_error)
  3141. __Pyx_GOTREF(__pyx_t_5);
  3142. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  3143. __Pyx_INCREF(__pyx_v_parent_path);
  3144. __Pyx_GIVEREF(__pyx_v_parent_path);
  3145. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_parent_path);
  3146. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
  3147. __Pyx_GOTREF(__pyx_t_1);
  3148. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3149. }
  3150. }
  3151. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3152. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 177, __pyx_L1_error)
  3153. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3154. __pyx_t_8 = ((!__pyx_t_2) != 0);
  3155. if (__pyx_t_8) {
  3156. /* "lakesuperior/store/base_lmdb_store.pyx":180
  3157. * #logger.info(
  3158. * # 'Creating store directory at {}'.format(parent_path))
  3159. * try: # <<<<<<<<<<<<<<
  3160. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3161. * except Exception as e:
  3162. */
  3163. {
  3164. __Pyx_PyThreadState_declare
  3165. __Pyx_PyThreadState_assign
  3166. __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
  3167. __Pyx_XGOTREF(__pyx_t_9);
  3168. __Pyx_XGOTREF(__pyx_t_10);
  3169. __Pyx_XGOTREF(__pyx_t_11);
  3170. /*try:*/ {
  3171. /* "lakesuperior/store/base_lmdb_store.pyx":181
  3172. * # 'Creating store directory at {}'.format(parent_path))
  3173. * try:
  3174. * makedirs(parent_path, mode=0o750, exist_ok=True) # <<<<<<<<<<<<<<
  3175. * except Exception as e:
  3176. * raise LmdbError(
  3177. */
  3178. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_makedirs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L6_error)
  3179. __Pyx_GOTREF(__pyx_t_1);
  3180. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L6_error)
  3181. __Pyx_GOTREF(__pyx_t_4);
  3182. __Pyx_INCREF(__pyx_v_parent_path);
  3183. __Pyx_GIVEREF(__pyx_v_parent_path);
  3184. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_parent_path);
  3185. __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L6_error)
  3186. __Pyx_GOTREF(__pyx_t_5);
  3187. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_mode, __pyx_int_488) < 0) __PYX_ERR(0, 181, __pyx_L6_error)
  3188. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_exist_ok, Py_True) < 0) __PYX_ERR(0, 181, __pyx_L6_error)
  3189. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L6_error)
  3190. __Pyx_GOTREF(__pyx_t_3);
  3191. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3192. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3193. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3194. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3195. /* "lakesuperior/store/base_lmdb_store.pyx":180
  3196. * #logger.info(
  3197. * # 'Creating store directory at {}'.format(parent_path))
  3198. * try: # <<<<<<<<<<<<<<
  3199. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3200. * except Exception as e:
  3201. */
  3202. }
  3203. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3204. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3205. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  3206. goto __pyx_L11_try_end;
  3207. __pyx_L6_error:;
  3208. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3209. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3210. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3211. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  3212. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3213. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3214. /* "lakesuperior/store/base_lmdb_store.pyx":182
  3215. * try:
  3216. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3217. * except Exception as e: # <<<<<<<<<<<<<<
  3218. * raise LmdbError(
  3219. * 'Could not create store at {}. Error: {}'.format(
  3220. */
  3221. __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  3222. if (__pyx_t_12) {
  3223. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.open_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3224. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(0, 182, __pyx_L8_except_error)
  3225. __Pyx_GOTREF(__pyx_t_3);
  3226. __Pyx_GOTREF(__pyx_t_5);
  3227. __Pyx_GOTREF(__pyx_t_4);
  3228. __Pyx_INCREF(__pyx_t_5);
  3229. __pyx_v_e = __pyx_t_5;
  3230. /*try:*/ {
  3231. /* "lakesuperior/store/base_lmdb_store.pyx":183
  3232. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3233. * except Exception as e:
  3234. * raise LmdbError( # <<<<<<<<<<<<<<
  3235. * 'Could not create store at {}. Error: {}'.format(
  3236. * self.env_path, e))
  3237. */
  3238. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 183, __pyx_L17_error)
  3239. __Pyx_GOTREF(__pyx_t_7);
  3240. /* "lakesuperior/store/base_lmdb_store.pyx":184
  3241. * except Exception as e:
  3242. * raise LmdbError(
  3243. * 'Could not create store at {}. Error: {}'.format( # <<<<<<<<<<<<<<
  3244. * self.env_path, e))
  3245. *
  3246. */
  3247. __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Could_not_create_store_at_Error, __pyx_n_s_format); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 184, __pyx_L17_error)
  3248. __Pyx_GOTREF(__pyx_t_13);
  3249. /* "lakesuperior/store/base_lmdb_store.pyx":185
  3250. * raise LmdbError(
  3251. * 'Could not create store at {}. Error: {}'.format(
  3252. * self.env_path, e)) # <<<<<<<<<<<<<<
  3253. *
  3254. * # Create environment handle.
  3255. */
  3256. __pyx_t_14 = NULL;
  3257. __pyx_t_12 = 0;
  3258. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  3259. __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
  3260. if (likely(__pyx_t_14)) {
  3261. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  3262. __Pyx_INCREF(__pyx_t_14);
  3263. __Pyx_INCREF(function);
  3264. __Pyx_DECREF_SET(__pyx_t_13, function);
  3265. __pyx_t_12 = 1;
  3266. }
  3267. }
  3268. #if CYTHON_FAST_PYCALL
  3269. if (PyFunction_Check(__pyx_t_13)) {
  3270. PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_self->env_path, __pyx_v_e};
  3271. __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 184, __pyx_L17_error)
  3272. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  3273. __Pyx_GOTREF(__pyx_t_6);
  3274. } else
  3275. #endif
  3276. #if CYTHON_FAST_PYCCALL
  3277. if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
  3278. PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_self->env_path, __pyx_v_e};
  3279. __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 184, __pyx_L17_error)
  3280. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  3281. __Pyx_GOTREF(__pyx_t_6);
  3282. } else
  3283. #endif
  3284. {
  3285. __pyx_t_15 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 184, __pyx_L17_error)
  3286. __Pyx_GOTREF(__pyx_t_15);
  3287. if (__pyx_t_14) {
  3288. __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
  3289. }
  3290. __Pyx_INCREF(__pyx_v_self->env_path);
  3291. __Pyx_GIVEREF(__pyx_v_self->env_path);
  3292. PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_12, __pyx_v_self->env_path);
  3293. __Pyx_INCREF(__pyx_v_e);
  3294. __Pyx_GIVEREF(__pyx_v_e);
  3295. PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_12, __pyx_v_e);
  3296. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 184, __pyx_L17_error)
  3297. __Pyx_GOTREF(__pyx_t_6);
  3298. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3299. }
  3300. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3301. __pyx_t_13 = NULL;
  3302. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
  3303. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
  3304. if (likely(__pyx_t_13)) {
  3305. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  3306. __Pyx_INCREF(__pyx_t_13);
  3307. __Pyx_INCREF(function);
  3308. __Pyx_DECREF_SET(__pyx_t_7, function);
  3309. }
  3310. }
  3311. if (!__pyx_t_13) {
  3312. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L17_error)
  3313. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3314. __Pyx_GOTREF(__pyx_t_1);
  3315. } else {
  3316. #if CYTHON_FAST_PYCALL
  3317. if (PyFunction_Check(__pyx_t_7)) {
  3318. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  3319. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L17_error)
  3320. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3321. __Pyx_GOTREF(__pyx_t_1);
  3322. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3323. } else
  3324. #endif
  3325. #if CYTHON_FAST_PYCCALL
  3326. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  3327. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  3328. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L17_error)
  3329. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3330. __Pyx_GOTREF(__pyx_t_1);
  3331. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3332. } else
  3333. #endif
  3334. {
  3335. __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 183, __pyx_L17_error)
  3336. __Pyx_GOTREF(__pyx_t_15);
  3337. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
  3338. __Pyx_GIVEREF(__pyx_t_6);
  3339. PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_6);
  3340. __pyx_t_6 = 0;
  3341. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L17_error)
  3342. __Pyx_GOTREF(__pyx_t_1);
  3343. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3344. }
  3345. }
  3346. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3347. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  3348. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3349. __PYX_ERR(0, 183, __pyx_L17_error)
  3350. }
  3351. /* "lakesuperior/store/base_lmdb_store.pyx":182
  3352. * try:
  3353. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3354. * except Exception as e: # <<<<<<<<<<<<<<
  3355. * raise LmdbError(
  3356. * 'Could not create store at {}. Error: {}'.format(
  3357. */
  3358. /*finally:*/ {
  3359. __pyx_L17_error:;
  3360. /*exception exit:*/{
  3361. __Pyx_PyThreadState_declare
  3362. __Pyx_PyThreadState_assign
  3363. __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
  3364. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  3365. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3366. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3367. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  3368. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3369. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3370. if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
  3371. if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
  3372. __Pyx_XGOTREF(__pyx_t_18);
  3373. __Pyx_XGOTREF(__pyx_t_19);
  3374. __Pyx_XGOTREF(__pyx_t_20);
  3375. __Pyx_XGOTREF(__pyx_t_21);
  3376. __Pyx_XGOTREF(__pyx_t_22);
  3377. __Pyx_XGOTREF(__pyx_t_23);
  3378. __pyx_t_12 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
  3379. {
  3380. __Pyx_DECREF(__pyx_v_e);
  3381. __pyx_v_e = NULL;
  3382. }
  3383. if (PY_MAJOR_VERSION >= 3) {
  3384. __Pyx_XGIVEREF(__pyx_t_21);
  3385. __Pyx_XGIVEREF(__pyx_t_22);
  3386. __Pyx_XGIVEREF(__pyx_t_23);
  3387. __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
  3388. }
  3389. __Pyx_XGIVEREF(__pyx_t_18);
  3390. __Pyx_XGIVEREF(__pyx_t_19);
  3391. __Pyx_XGIVEREF(__pyx_t_20);
  3392. __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
  3393. __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
  3394. __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
  3395. goto __pyx_L8_except_error;
  3396. }
  3397. }
  3398. }
  3399. goto __pyx_L8_except_error;
  3400. __pyx_L8_except_error:;
  3401. /* "lakesuperior/store/base_lmdb_store.pyx":180
  3402. * #logger.info(
  3403. * # 'Creating store directory at {}'.format(parent_path))
  3404. * try: # <<<<<<<<<<<<<<
  3405. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3406. * except Exception as e:
  3407. */
  3408. __Pyx_XGIVEREF(__pyx_t_9);
  3409. __Pyx_XGIVEREF(__pyx_t_10);
  3410. __Pyx_XGIVEREF(__pyx_t_11);
  3411. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
  3412. goto __pyx_L1_error;
  3413. __pyx_L11_try_end:;
  3414. }
  3415. /* "lakesuperior/store/base_lmdb_store.pyx":177
  3416. * else self.env_path)
  3417. *
  3418. * if not path.exists(parent_path): # <<<<<<<<<<<<<<
  3419. * #logger.info(
  3420. * # 'Creating store directory at {}'.format(parent_path))
  3421. */
  3422. }
  3423. /* "lakesuperior/store/base_lmdb_store.pyx":170
  3424. *
  3425. * logger.debug('Opening environment at {}.'.format(self.env_path))
  3426. * if create: # <<<<<<<<<<<<<<
  3427. * #logger.info('Creating db env at {}'.format(self.env_path))
  3428. * parent_path = (
  3429. */
  3430. }
  3431. /* "lakesuperior/store/base_lmdb_store.pyx":188
  3432. *
  3433. * # Create environment handle.
  3434. * _check( # <<<<<<<<<<<<<<
  3435. * lmdb.mdb_env_create(&self.dbenv),
  3436. * 'Error creating DB environment handle: {}')
  3437. */
  3438. __pyx_t_24.__pyx_n = 1;
  3439. __pyx_t_24.message = __pyx_kp_u_Error_creating_DB_environment_ha;
  3440. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_env_create((&__pyx_v_self->dbenv)), &__pyx_t_24); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 188, __pyx_L1_error)
  3441. /* "lakesuperior/store/base_lmdb_store.pyx":191
  3442. * lmdb.mdb_env_create(&self.dbenv),
  3443. * 'Error creating DB environment handle: {}')
  3444. * logger.debug('Created DBenv @ {:x}'.format(<unsigned long>self.dbenv)) # <<<<<<<<<<<<<<
  3445. *
  3446. * # Set map size.
  3447. */
  3448. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error)
  3449. __Pyx_GOTREF(__pyx_t_5);
  3450. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error)
  3451. __Pyx_GOTREF(__pyx_t_3);
  3452. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3453. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Created_DBenv_x, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error)
  3454. __Pyx_GOTREF(__pyx_t_1);
  3455. __pyx_t_7 = __Pyx_PyInt_From_unsigned_long(((unsigned long)__pyx_v_self->dbenv)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 191, __pyx_L1_error)
  3456. __Pyx_GOTREF(__pyx_t_7);
  3457. __pyx_t_15 = NULL;
  3458. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  3459. __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
  3460. if (likely(__pyx_t_15)) {
  3461. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  3462. __Pyx_INCREF(__pyx_t_15);
  3463. __Pyx_INCREF(function);
  3464. __Pyx_DECREF_SET(__pyx_t_1, function);
  3465. }
  3466. }
  3467. if (!__pyx_t_15) {
  3468. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error)
  3469. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3470. __Pyx_GOTREF(__pyx_t_5);
  3471. } else {
  3472. #if CYTHON_FAST_PYCALL
  3473. if (PyFunction_Check(__pyx_t_1)) {
  3474. PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_7};
  3475. __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error)
  3476. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  3477. __Pyx_GOTREF(__pyx_t_5);
  3478. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3479. } else
  3480. #endif
  3481. #if CYTHON_FAST_PYCCALL
  3482. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  3483. PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_7};
  3484. __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error)
  3485. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  3486. __Pyx_GOTREF(__pyx_t_5);
  3487. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3488. } else
  3489. #endif
  3490. {
  3491. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 191, __pyx_L1_error)
  3492. __Pyx_GOTREF(__pyx_t_6);
  3493. __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_15); __pyx_t_15 = NULL;
  3494. __Pyx_GIVEREF(__pyx_t_7);
  3495. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_7);
  3496. __pyx_t_7 = 0;
  3497. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error)
  3498. __Pyx_GOTREF(__pyx_t_5);
  3499. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3500. }
  3501. }
  3502. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3503. __pyx_t_1 = NULL;
  3504. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  3505. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
  3506. if (likely(__pyx_t_1)) {
  3507. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  3508. __Pyx_INCREF(__pyx_t_1);
  3509. __Pyx_INCREF(function);
  3510. __Pyx_DECREF_SET(__pyx_t_3, function);
  3511. }
  3512. }
  3513. if (!__pyx_t_1) {
  3514. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 191, __pyx_L1_error)
  3515. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3516. __Pyx_GOTREF(__pyx_t_4);
  3517. } else {
  3518. #if CYTHON_FAST_PYCALL
  3519. if (PyFunction_Check(__pyx_t_3)) {
  3520. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
  3521. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 191, __pyx_L1_error)
  3522. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3523. __Pyx_GOTREF(__pyx_t_4);
  3524. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3525. } else
  3526. #endif
  3527. #if CYTHON_FAST_PYCCALL
  3528. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  3529. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
  3530. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 191, __pyx_L1_error)
  3531. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3532. __Pyx_GOTREF(__pyx_t_4);
  3533. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3534. } else
  3535. #endif
  3536. {
  3537. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 191, __pyx_L1_error)
  3538. __Pyx_GOTREF(__pyx_t_6);
  3539. __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
  3540. __Pyx_GIVEREF(__pyx_t_5);
  3541. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
  3542. __pyx_t_5 = 0;
  3543. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 191, __pyx_L1_error)
  3544. __Pyx_GOTREF(__pyx_t_4);
  3545. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3546. }
  3547. }
  3548. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3549. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3550. /* "lakesuperior/store/base_lmdb_store.pyx":195
  3551. * # Set map size.
  3552. * _check(
  3553. * lmdb.mdb_env_set_mapsize(self.dbenv, self.options.get( # <<<<<<<<<<<<<<
  3554. * 'map_size', 1024 ** 3)),
  3555. * 'Error setting map size: {}')
  3556. */
  3557. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_options); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 195, __pyx_L1_error)
  3558. __Pyx_GOTREF(__pyx_t_4);
  3559. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error)
  3560. __Pyx_GOTREF(__pyx_t_3);
  3561. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3562. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 195, __pyx_L1_error)
  3563. __Pyx_GOTREF(__pyx_t_4);
  3564. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3565. __pyx_t_25 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_25 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 195, __pyx_L1_error)
  3566. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3567. /* "lakesuperior/store/base_lmdb_store.pyx":194
  3568. *
  3569. * # Set map size.
  3570. * _check( # <<<<<<<<<<<<<<
  3571. * lmdb.mdb_env_set_mapsize(self.dbenv, self.options.get(
  3572. * 'map_size', 1024 ** 3)),
  3573. */
  3574. __pyx_t_24.__pyx_n = 1;
  3575. __pyx_t_24.message = __pyx_kp_u_Error_setting_map_size;
  3576. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_env_set_mapsize(__pyx_v_self->dbenv, __pyx_t_25), &__pyx_t_24); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 194, __pyx_L1_error)
  3577. /* "lakesuperior/store/base_lmdb_store.pyx":200
  3578. *
  3579. * # Set max databases.
  3580. * max_dbs = self.options.get('max_dbs', len(self.dbi_labels)) # <<<<<<<<<<<<<<
  3581. * _check(
  3582. * lmdb.mdb_env_set_maxdbs(self.dbenv, max_dbs),
  3583. */
  3584. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_options); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
  3585. __Pyx_GOTREF(__pyx_t_3);
  3586. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 200, __pyx_L1_error)
  3587. __Pyx_GOTREF(__pyx_t_6);
  3588. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3589. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dbi_labels); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
  3590. __Pyx_GOTREF(__pyx_t_3);
  3591. __pyx_t_26 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_26 == ((Py_ssize_t)-1))) __PYX_ERR(0, 200, __pyx_L1_error)
  3592. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3593. __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_26); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
  3594. __Pyx_GOTREF(__pyx_t_3);
  3595. __pyx_t_5 = NULL;
  3596. __pyx_t_16 = 0;
  3597. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  3598. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
  3599. if (likely(__pyx_t_5)) {
  3600. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  3601. __Pyx_INCREF(__pyx_t_5);
  3602. __Pyx_INCREF(function);
  3603. __Pyx_DECREF_SET(__pyx_t_6, function);
  3604. __pyx_t_16 = 1;
  3605. }
  3606. }
  3607. #if CYTHON_FAST_PYCALL
  3608. if (PyFunction_Check(__pyx_t_6)) {
  3609. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_n_u_max_dbs, __pyx_t_3};
  3610. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error)
  3611. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3612. __Pyx_GOTREF(__pyx_t_4);
  3613. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3614. } else
  3615. #endif
  3616. #if CYTHON_FAST_PYCCALL
  3617. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  3618. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_n_u_max_dbs, __pyx_t_3};
  3619. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error)
  3620. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3621. __Pyx_GOTREF(__pyx_t_4);
  3622. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3623. } else
  3624. #endif
  3625. {
  3626. __pyx_t_1 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
  3627. __Pyx_GOTREF(__pyx_t_1);
  3628. if (__pyx_t_5) {
  3629. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL;
  3630. }
  3631. __Pyx_INCREF(__pyx_n_u_max_dbs);
  3632. __Pyx_GIVEREF(__pyx_n_u_max_dbs);
  3633. PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_16, __pyx_n_u_max_dbs);
  3634. __Pyx_GIVEREF(__pyx_t_3);
  3635. PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_16, __pyx_t_3);
  3636. __pyx_t_3 = 0;
  3637. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error)
  3638. __Pyx_GOTREF(__pyx_t_4);
  3639. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3640. }
  3641. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3642. __pyx_v_max_dbs = __pyx_t_4;
  3643. __pyx_t_4 = 0;
  3644. /* "lakesuperior/store/base_lmdb_store.pyx":202
  3645. * max_dbs = self.options.get('max_dbs', len(self.dbi_labels))
  3646. * _check(
  3647. * lmdb.mdb_env_set_maxdbs(self.dbenv, max_dbs), # <<<<<<<<<<<<<<
  3648. * 'Error setting max. databases: {}')
  3649. *
  3650. */
  3651. __pyx_t_27 = __Pyx_PyInt_As_MDB_dbi(__pyx_v_max_dbs); if (unlikely((__pyx_t_27 == ((MDB_dbi)-1)) && PyErr_Occurred())) __PYX_ERR(0, 202, __pyx_L1_error)
  3652. /* "lakesuperior/store/base_lmdb_store.pyx":201
  3653. * # Set max databases.
  3654. * max_dbs = self.options.get('max_dbs', len(self.dbi_labels))
  3655. * _check( # <<<<<<<<<<<<<<
  3656. * lmdb.mdb_env_set_maxdbs(self.dbenv, max_dbs),
  3657. * 'Error setting max. databases: {}')
  3658. */
  3659. __pyx_t_24.__pyx_n = 1;
  3660. __pyx_t_24.message = __pyx_kp_u_Error_setting_max_databases;
  3661. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_env_set_maxdbs(__pyx_v_self->dbenv, __pyx_t_27), &__pyx_t_24); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 201, __pyx_L1_error)
  3662. /* "lakesuperior/store/base_lmdb_store.pyx":206
  3663. *
  3664. * # Set max readers.
  3665. * self._readers = self.options.get( # <<<<<<<<<<<<<<
  3666. * 'max_spare_txns', wsgi.workers * self.readers_mult)
  3667. * _check(
  3668. */
  3669. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_options); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 206, __pyx_L1_error)
  3670. __Pyx_GOTREF(__pyx_t_6);
  3671. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error)
  3672. __Pyx_GOTREF(__pyx_t_1);
  3673. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3674. /* "lakesuperior/store/base_lmdb_store.pyx":207
  3675. * # Set max readers.
  3676. * self._readers = self.options.get(
  3677. * 'max_spare_txns', wsgi.workers * self.readers_mult) # <<<<<<<<<<<<<<
  3678. * _check(
  3679. * lmdb.mdb_env_set_maxreaders(self.dbenv, self._readers),
  3680. */
  3681. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_wsgi); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 207, __pyx_L1_error)
  3682. __Pyx_GOTREF(__pyx_t_6);
  3683. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_workers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 207, __pyx_L1_error)
  3684. __Pyx_GOTREF(__pyx_t_3);
  3685. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3686. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_readers_mult); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 207, __pyx_L1_error)
  3687. __Pyx_GOTREF(__pyx_t_6);
  3688. __pyx_t_5 = PyNumber_Multiply(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error)
  3689. __Pyx_GOTREF(__pyx_t_5);
  3690. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3691. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3692. __pyx_t_6 = NULL;
  3693. __pyx_t_16 = 0;
  3694. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  3695. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
  3696. if (likely(__pyx_t_6)) {
  3697. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  3698. __Pyx_INCREF(__pyx_t_6);
  3699. __Pyx_INCREF(function);
  3700. __Pyx_DECREF_SET(__pyx_t_1, function);
  3701. __pyx_t_16 = 1;
  3702. }
  3703. }
  3704. #if CYTHON_FAST_PYCALL
  3705. if (PyFunction_Check(__pyx_t_1)) {
  3706. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_n_u_max_spare_txns, __pyx_t_5};
  3707. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 206, __pyx_L1_error)
  3708. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3709. __Pyx_GOTREF(__pyx_t_4);
  3710. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3711. } else
  3712. #endif
  3713. #if CYTHON_FAST_PYCCALL
  3714. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  3715. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_n_u_max_spare_txns, __pyx_t_5};
  3716. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 206, __pyx_L1_error)
  3717. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3718. __Pyx_GOTREF(__pyx_t_4);
  3719. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3720. } else
  3721. #endif
  3722. {
  3723. __pyx_t_3 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 206, __pyx_L1_error)
  3724. __Pyx_GOTREF(__pyx_t_3);
  3725. if (__pyx_t_6) {
  3726. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
  3727. }
  3728. __Pyx_INCREF(__pyx_n_u_max_spare_txns);
  3729. __Pyx_GIVEREF(__pyx_n_u_max_spare_txns);
  3730. PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_16, __pyx_n_u_max_spare_txns);
  3731. __Pyx_GIVEREF(__pyx_t_5);
  3732. PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_16, __pyx_t_5);
  3733. __pyx_t_5 = 0;
  3734. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 206, __pyx_L1_error)
  3735. __Pyx_GOTREF(__pyx_t_4);
  3736. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3737. }
  3738. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3739. /* "lakesuperior/store/base_lmdb_store.pyx":206
  3740. *
  3741. * # Set max readers.
  3742. * self._readers = self.options.get( # <<<<<<<<<<<<<<
  3743. * 'max_spare_txns', wsgi.workers * self.readers_mult)
  3744. * _check(
  3745. */
  3746. __pyx_t_28 = __Pyx_PyInt_As_unsigned_int(__pyx_t_4); if (unlikely((__pyx_t_28 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 206, __pyx_L1_error)
  3747. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3748. __pyx_v_self->_readers = __pyx_t_28;
  3749. /* "lakesuperior/store/base_lmdb_store.pyx":208
  3750. * self._readers = self.options.get(
  3751. * 'max_spare_txns', wsgi.workers * self.readers_mult)
  3752. * _check( # <<<<<<<<<<<<<<
  3753. * lmdb.mdb_env_set_maxreaders(self.dbenv, self._readers),
  3754. * 'Error setting max. readers: {}')
  3755. */
  3756. __pyx_t_24.__pyx_n = 1;
  3757. __pyx_t_24.message = __pyx_kp_u_Error_setting_max_readers;
  3758. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_env_set_maxreaders(__pyx_v_self->dbenv, __pyx_v_self->_readers), &__pyx_t_24); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 208, __pyx_L1_error)
  3759. /* "lakesuperior/store/base_lmdb_store.pyx":211
  3760. * lmdb.mdb_env_set_maxreaders(self.dbenv, self._readers),
  3761. * 'Error setting max. readers: {}')
  3762. * logger.debug('Max. readers: {}'.format(self._readers)) # <<<<<<<<<<<<<<
  3763. *
  3764. * # Clear stale readers.
  3765. */
  3766. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
  3767. __Pyx_GOTREF(__pyx_t_1);
  3768. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error)
  3769. __Pyx_GOTREF(__pyx_t_3);
  3770. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3771. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Max_readers, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 211, __pyx_L1_error)
  3772. __Pyx_GOTREF(__pyx_t_5);
  3773. __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->_readers); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 211, __pyx_L1_error)
  3774. __Pyx_GOTREF(__pyx_t_6);
  3775. __pyx_t_7 = NULL;
  3776. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  3777. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  3778. if (likely(__pyx_t_7)) {
  3779. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  3780. __Pyx_INCREF(__pyx_t_7);
  3781. __Pyx_INCREF(function);
  3782. __Pyx_DECREF_SET(__pyx_t_5, function);
  3783. }
  3784. }
  3785. if (!__pyx_t_7) {
  3786. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
  3787. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3788. __Pyx_GOTREF(__pyx_t_1);
  3789. } else {
  3790. #if CYTHON_FAST_PYCALL
  3791. if (PyFunction_Check(__pyx_t_5)) {
  3792. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  3793. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
  3794. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3795. __Pyx_GOTREF(__pyx_t_1);
  3796. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3797. } else
  3798. #endif
  3799. #if CYTHON_FAST_PYCCALL
  3800. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  3801. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  3802. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
  3803. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3804. __Pyx_GOTREF(__pyx_t_1);
  3805. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3806. } else
  3807. #endif
  3808. {
  3809. __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 211, __pyx_L1_error)
  3810. __Pyx_GOTREF(__pyx_t_15);
  3811. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_7); __pyx_t_7 = NULL;
  3812. __Pyx_GIVEREF(__pyx_t_6);
  3813. PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_6);
  3814. __pyx_t_6 = 0;
  3815. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
  3816. __Pyx_GOTREF(__pyx_t_1);
  3817. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3818. }
  3819. }
  3820. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3821. __pyx_t_5 = NULL;
  3822. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  3823. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
  3824. if (likely(__pyx_t_5)) {
  3825. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  3826. __Pyx_INCREF(__pyx_t_5);
  3827. __Pyx_INCREF(function);
  3828. __Pyx_DECREF_SET(__pyx_t_3, function);
  3829. }
  3830. }
  3831. if (!__pyx_t_5) {
  3832. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 211, __pyx_L1_error)
  3833. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3834. __Pyx_GOTREF(__pyx_t_4);
  3835. } else {
  3836. #if CYTHON_FAST_PYCALL
  3837. if (PyFunction_Check(__pyx_t_3)) {
  3838. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1};
  3839. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 211, __pyx_L1_error)
  3840. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3841. __Pyx_GOTREF(__pyx_t_4);
  3842. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3843. } else
  3844. #endif
  3845. #if CYTHON_FAST_PYCCALL
  3846. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  3847. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1};
  3848. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 211, __pyx_L1_error)
  3849. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3850. __Pyx_GOTREF(__pyx_t_4);
  3851. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3852. } else
  3853. #endif
  3854. {
  3855. __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 211, __pyx_L1_error)
  3856. __Pyx_GOTREF(__pyx_t_15);
  3857. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_5); __pyx_t_5 = NULL;
  3858. __Pyx_GIVEREF(__pyx_t_1);
  3859. PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_1);
  3860. __pyx_t_1 = 0;
  3861. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_15, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 211, __pyx_L1_error)
  3862. __Pyx_GOTREF(__pyx_t_4);
  3863. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3864. }
  3865. }
  3866. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3867. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3868. /* "lakesuperior/store/base_lmdb_store.pyx":214
  3869. *
  3870. * # Clear stale readers.
  3871. * self._clear_stale_readers() # <<<<<<<<<<<<<<
  3872. *
  3873. * # Open DB environment.
  3874. */
  3875. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_clear_stale_readers(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 214, __pyx_L1_error)
  3876. /* "lakesuperior/store/base_lmdb_store.pyx":217
  3877. *
  3878. * # Open DB environment.
  3879. * logger.debug('DBenv address: {:x}'.format(<unsigned long>self.dbenv)) # <<<<<<<<<<<<<<
  3880. * _check(
  3881. * lmdb.mdb_env_open(
  3882. */
  3883. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  3884. __Pyx_GOTREF(__pyx_t_3);
  3885. __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 217, __pyx_L1_error)
  3886. __Pyx_GOTREF(__pyx_t_15);
  3887. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3888. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_DBenv_address_x, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error)
  3889. __Pyx_GOTREF(__pyx_t_1);
  3890. __pyx_t_5 = __Pyx_PyInt_From_unsigned_long(((unsigned long)__pyx_v_self->dbenv)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 217, __pyx_L1_error)
  3891. __Pyx_GOTREF(__pyx_t_5);
  3892. __pyx_t_6 = NULL;
  3893. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  3894. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
  3895. if (likely(__pyx_t_6)) {
  3896. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  3897. __Pyx_INCREF(__pyx_t_6);
  3898. __Pyx_INCREF(function);
  3899. __Pyx_DECREF_SET(__pyx_t_1, function);
  3900. }
  3901. }
  3902. if (!__pyx_t_6) {
  3903. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  3904. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3905. __Pyx_GOTREF(__pyx_t_3);
  3906. } else {
  3907. #if CYTHON_FAST_PYCALL
  3908. if (PyFunction_Check(__pyx_t_1)) {
  3909. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
  3910. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  3911. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3912. __Pyx_GOTREF(__pyx_t_3);
  3913. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3914. } else
  3915. #endif
  3916. #if CYTHON_FAST_PYCCALL
  3917. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  3918. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
  3919. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  3920. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3921. __Pyx_GOTREF(__pyx_t_3);
  3922. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3923. } else
  3924. #endif
  3925. {
  3926. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 217, __pyx_L1_error)
  3927. __Pyx_GOTREF(__pyx_t_7);
  3928. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
  3929. __Pyx_GIVEREF(__pyx_t_5);
  3930. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
  3931. __pyx_t_5 = 0;
  3932. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  3933. __Pyx_GOTREF(__pyx_t_3);
  3934. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3935. }
  3936. }
  3937. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3938. __pyx_t_1 = NULL;
  3939. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
  3940. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
  3941. if (likely(__pyx_t_1)) {
  3942. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
  3943. __Pyx_INCREF(__pyx_t_1);
  3944. __Pyx_INCREF(function);
  3945. __Pyx_DECREF_SET(__pyx_t_15, function);
  3946. }
  3947. }
  3948. if (!__pyx_t_1) {
  3949. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 217, __pyx_L1_error)
  3950. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3951. __Pyx_GOTREF(__pyx_t_4);
  3952. } else {
  3953. #if CYTHON_FAST_PYCALL
  3954. if (PyFunction_Check(__pyx_t_15)) {
  3955. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
  3956. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 217, __pyx_L1_error)
  3957. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3958. __Pyx_GOTREF(__pyx_t_4);
  3959. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3960. } else
  3961. #endif
  3962. #if CYTHON_FAST_PYCCALL
  3963. if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
  3964. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
  3965. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 217, __pyx_L1_error)
  3966. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3967. __Pyx_GOTREF(__pyx_t_4);
  3968. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3969. } else
  3970. #endif
  3971. {
  3972. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 217, __pyx_L1_error)
  3973. __Pyx_GOTREF(__pyx_t_7);
  3974. __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
  3975. __Pyx_GIVEREF(__pyx_t_3);
  3976. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3);
  3977. __pyx_t_3 = 0;
  3978. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 217, __pyx_L1_error)
  3979. __Pyx_GOTREF(__pyx_t_4);
  3980. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3981. }
  3982. }
  3983. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3984. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3985. /* "lakesuperior/store/base_lmdb_store.pyx":220
  3986. * _check(
  3987. * lmdb.mdb_env_open(
  3988. * self.dbenv, self.env_path.encode(), # <<<<<<<<<<<<<<
  3989. * self.env_flags, self.env_perms),
  3990. * f'Error opening the database environment: {self.env_path}.')
  3991. */
  3992. if (unlikely(__pyx_v_self->env_path == Py_None)) {
  3993. PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
  3994. __PYX_ERR(0, 220, __pyx_L1_error)
  3995. }
  3996. __pyx_t_4 = PyUnicode_AsEncodedString(__pyx_v_self->env_path, NULL, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 220, __pyx_L1_error)
  3997. __Pyx_GOTREF(__pyx_t_4);
  3998. __pyx_t_29 = __Pyx_PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_29) && PyErr_Occurred())) __PYX_ERR(0, 220, __pyx_L1_error)
  3999. /* "lakesuperior/store/base_lmdb_store.pyx":221
  4000. * lmdb.mdb_env_open(
  4001. * self.dbenv, self.env_path.encode(),
  4002. * self.env_flags, self.env_perms), # <<<<<<<<<<<<<<
  4003. * f'Error opening the database environment: {self.env_path}.')
  4004. *
  4005. */
  4006. __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_env_flags); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 221, __pyx_L1_error)
  4007. __Pyx_GOTREF(__pyx_t_15);
  4008. __pyx_t_28 = __Pyx_PyInt_As_unsigned_int(__pyx_t_15); if (unlikely((__pyx_t_28 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 221, __pyx_L1_error)
  4009. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4010. __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_env_perms); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 221, __pyx_L1_error)
  4011. __Pyx_GOTREF(__pyx_t_15);
  4012. __pyx_t_30 = __Pyx_PyInt_As_mode_t(__pyx_t_15); if (unlikely((__pyx_t_30 == ((mdb_mode_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 221, __pyx_L1_error)
  4013. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4014. /* "lakesuperior/store/base_lmdb_store.pyx":222
  4015. * self.dbenv, self.env_path.encode(),
  4016. * self.env_flags, self.env_perms),
  4017. * f'Error opening the database environment: {self.env_path}.') # <<<<<<<<<<<<<<
  4018. *
  4019. * self._init_dbis(create)
  4020. */
  4021. __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 222, __pyx_L1_error)
  4022. __Pyx_GOTREF(__pyx_t_15);
  4023. __pyx_t_26 = 0;
  4024. __pyx_t_31 = 127;
  4025. __Pyx_INCREF(__pyx_kp_u_Error_opening_the_database_envir);
  4026. __pyx_t_26 += 40;
  4027. __Pyx_GIVEREF(__pyx_kp_u_Error_opening_the_database_envir);
  4028. PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_opening_the_database_envir);
  4029. __pyx_t_7 = __Pyx_PyUnicode_Unicode(__pyx_v_self->env_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 222, __pyx_L1_error)
  4030. __Pyx_GOTREF(__pyx_t_7);
  4031. __pyx_t_31 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_31) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_31;
  4032. __pyx_t_26 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
  4033. __Pyx_GIVEREF(__pyx_t_7);
  4034. PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_7);
  4035. __pyx_t_7 = 0;
  4036. __Pyx_INCREF(__pyx_kp_u__4);
  4037. __pyx_t_26 += 1;
  4038. __Pyx_GIVEREF(__pyx_kp_u__4);
  4039. PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_kp_u__4);
  4040. __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_15, 3, __pyx_t_26, __pyx_t_31); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 222, __pyx_L1_error)
  4041. __Pyx_GOTREF(__pyx_t_7);
  4042. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4043. /* "lakesuperior/store/base_lmdb_store.pyx":218
  4044. * # Open DB environment.
  4045. * logger.debug('DBenv address: {:x}'.format(<unsigned long>self.dbenv))
  4046. * _check( # <<<<<<<<<<<<<<
  4047. * lmdb.mdb_env_open(
  4048. * self.dbenv, self.env_path.encode(),
  4049. */
  4050. __pyx_t_24.__pyx_n = 1;
  4051. __pyx_t_24.message = ((PyObject*)__pyx_t_7);
  4052. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_env_open(__pyx_v_self->dbenv, __pyx_t_29, __pyx_t_28, __pyx_t_30), &__pyx_t_24); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L1_error)
  4053. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4054. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4055. /* "lakesuperior/store/base_lmdb_store.pyx":224
  4056. * f'Error opening the database environment: {self.env_path}.')
  4057. *
  4058. * self._init_dbis(create) # <<<<<<<<<<<<<<
  4059. * self._open = True
  4060. *
  4061. */
  4062. __pyx_t_32.__pyx_n = 1;
  4063. __pyx_t_32.create = __pyx_v_create;
  4064. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_init_dbis(__pyx_v_self, &__pyx_t_32); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 224, __pyx_L1_error)
  4065. /* "lakesuperior/store/base_lmdb_store.pyx":225
  4066. *
  4067. * self._init_dbis(create)
  4068. * self._open = True # <<<<<<<<<<<<<<
  4069. *
  4070. *
  4071. */
  4072. __pyx_v_self->_open = 1;
  4073. /* "lakesuperior/store/base_lmdb_store.pyx":161
  4074. *
  4075. *
  4076. * def open_env(self, create): # <<<<<<<<<<<<<<
  4077. * """
  4078. * Open, and optionally create, store environment.
  4079. */
  4080. /* function exit code */
  4081. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4082. goto __pyx_L0;
  4083. __pyx_L1_error:;
  4084. __Pyx_XDECREF(__pyx_t_1);
  4085. __Pyx_XDECREF(__pyx_t_3);
  4086. __Pyx_XDECREF(__pyx_t_4);
  4087. __Pyx_XDECREF(__pyx_t_5);
  4088. __Pyx_XDECREF(__pyx_t_6);
  4089. __Pyx_XDECREF(__pyx_t_7);
  4090. __Pyx_XDECREF(__pyx_t_13);
  4091. __Pyx_XDECREF(__pyx_t_14);
  4092. __Pyx_XDECREF(__pyx_t_15);
  4093. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.open_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4094. __pyx_r = NULL;
  4095. __pyx_L0:;
  4096. __Pyx_XDECREF(__pyx_v_parent_path);
  4097. __Pyx_XDECREF(__pyx_v_e);
  4098. __Pyx_XDECREF(__pyx_v_max_dbs);
  4099. __Pyx_XGIVEREF(__pyx_r);
  4100. __Pyx_TraceReturn(__pyx_r, 0);
  4101. __Pyx_RefNannyFinishContext();
  4102. return __pyx_r;
  4103. }
  4104. /* "lakesuperior/store/base_lmdb_store.pyx":228
  4105. *
  4106. *
  4107. * cdef void _clear_stale_readers(self) except *: # <<<<<<<<<<<<<<
  4108. * """
  4109. * Clear stale readers.
  4110. */
  4111. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__clear_stale_readers(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  4112. int __pyx_v_stale_readers;
  4113. __Pyx_TraceDeclarations
  4114. __Pyx_RefNannyDeclarations
  4115. int __pyx_t_1;
  4116. PyObject *__pyx_t_2 = NULL;
  4117. PyObject *__pyx_t_3 = NULL;
  4118. PyObject *__pyx_t_4 = NULL;
  4119. PyObject *__pyx_t_5 = NULL;
  4120. PyObject *__pyx_t_6 = NULL;
  4121. PyObject *__pyx_t_7 = NULL;
  4122. PyObject *__pyx_t_8 = NULL;
  4123. __Pyx_RefNannySetupContext("_clear_stale_readers", 0);
  4124. __Pyx_TraceCall("_clear_stale_readers", __pyx_f[0], 228, 0, __PYX_ERR(0, 228, __pyx_L1_error));
  4125. /* "lakesuperior/store/base_lmdb_store.pyx":234
  4126. * cdef int stale_readers
  4127. *
  4128. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers)) # <<<<<<<<<<<<<<
  4129. * if stale_readers > 0:
  4130. * logger.debug('Cleared {} stale readers.'.format(stale_readers))
  4131. */
  4132. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_reader_check(__pyx_v_self->dbenv, (&__pyx_v_stale_readers)), NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 234, __pyx_L1_error)
  4133. /* "lakesuperior/store/base_lmdb_store.pyx":235
  4134. *
  4135. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers))
  4136. * if stale_readers > 0: # <<<<<<<<<<<<<<
  4137. * logger.debug('Cleared {} stale readers.'.format(stale_readers))
  4138. *
  4139. */
  4140. __pyx_t_1 = ((__pyx_v_stale_readers > 0) != 0);
  4141. if (__pyx_t_1) {
  4142. /* "lakesuperior/store/base_lmdb_store.pyx":236
  4143. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers))
  4144. * if stale_readers > 0:
  4145. * logger.debug('Cleared {} stale readers.'.format(stale_readers)) # <<<<<<<<<<<<<<
  4146. *
  4147. *
  4148. */
  4149. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
  4150. __Pyx_GOTREF(__pyx_t_3);
  4151. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 236, __pyx_L1_error)
  4152. __Pyx_GOTREF(__pyx_t_4);
  4153. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4154. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Cleared_stale_readers, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 236, __pyx_L1_error)
  4155. __Pyx_GOTREF(__pyx_t_5);
  4156. __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_stale_readers); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 236, __pyx_L1_error)
  4157. __Pyx_GOTREF(__pyx_t_6);
  4158. __pyx_t_7 = NULL;
  4159. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  4160. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  4161. if (likely(__pyx_t_7)) {
  4162. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  4163. __Pyx_INCREF(__pyx_t_7);
  4164. __Pyx_INCREF(function);
  4165. __Pyx_DECREF_SET(__pyx_t_5, function);
  4166. }
  4167. }
  4168. if (!__pyx_t_7) {
  4169. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
  4170. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4171. __Pyx_GOTREF(__pyx_t_3);
  4172. } else {
  4173. #if CYTHON_FAST_PYCALL
  4174. if (PyFunction_Check(__pyx_t_5)) {
  4175. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  4176. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
  4177. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4178. __Pyx_GOTREF(__pyx_t_3);
  4179. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4180. } else
  4181. #endif
  4182. #if CYTHON_FAST_PYCCALL
  4183. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  4184. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  4185. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
  4186. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4187. __Pyx_GOTREF(__pyx_t_3);
  4188. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4189. } else
  4190. #endif
  4191. {
  4192. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 236, __pyx_L1_error)
  4193. __Pyx_GOTREF(__pyx_t_8);
  4194. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  4195. __Pyx_GIVEREF(__pyx_t_6);
  4196. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
  4197. __pyx_t_6 = 0;
  4198. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
  4199. __Pyx_GOTREF(__pyx_t_3);
  4200. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4201. }
  4202. }
  4203. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4204. __pyx_t_5 = NULL;
  4205. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  4206. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  4207. if (likely(__pyx_t_5)) {
  4208. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  4209. __Pyx_INCREF(__pyx_t_5);
  4210. __Pyx_INCREF(function);
  4211. __Pyx_DECREF_SET(__pyx_t_4, function);
  4212. }
  4213. }
  4214. if (!__pyx_t_5) {
  4215. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error)
  4216. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4217. __Pyx_GOTREF(__pyx_t_2);
  4218. } else {
  4219. #if CYTHON_FAST_PYCALL
  4220. if (PyFunction_Check(__pyx_t_4)) {
  4221. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4222. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error)
  4223. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4224. __Pyx_GOTREF(__pyx_t_2);
  4225. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4226. } else
  4227. #endif
  4228. #if CYTHON_FAST_PYCCALL
  4229. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  4230. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4231. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error)
  4232. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4233. __Pyx_GOTREF(__pyx_t_2);
  4234. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4235. } else
  4236. #endif
  4237. {
  4238. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 236, __pyx_L1_error)
  4239. __Pyx_GOTREF(__pyx_t_8);
  4240. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
  4241. __Pyx_GIVEREF(__pyx_t_3);
  4242. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_3);
  4243. __pyx_t_3 = 0;
  4244. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error)
  4245. __Pyx_GOTREF(__pyx_t_2);
  4246. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4247. }
  4248. }
  4249. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4250. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4251. /* "lakesuperior/store/base_lmdb_store.pyx":235
  4252. *
  4253. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers))
  4254. * if stale_readers > 0: # <<<<<<<<<<<<<<
  4255. * logger.debug('Cleared {} stale readers.'.format(stale_readers))
  4256. *
  4257. */
  4258. }
  4259. /* "lakesuperior/store/base_lmdb_store.pyx":228
  4260. *
  4261. *
  4262. * cdef void _clear_stale_readers(self) except *: # <<<<<<<<<<<<<<
  4263. * """
  4264. * Clear stale readers.
  4265. */
  4266. /* function exit code */
  4267. goto __pyx_L0;
  4268. __pyx_L1_error:;
  4269. __Pyx_XDECREF(__pyx_t_2);
  4270. __Pyx_XDECREF(__pyx_t_3);
  4271. __Pyx_XDECREF(__pyx_t_4);
  4272. __Pyx_XDECREF(__pyx_t_5);
  4273. __Pyx_XDECREF(__pyx_t_6);
  4274. __Pyx_XDECREF(__pyx_t_7);
  4275. __Pyx_XDECREF(__pyx_t_8);
  4276. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._clear_stale_readers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4277. __pyx_L0:;
  4278. __Pyx_TraceReturn(Py_None, 0);
  4279. __Pyx_RefNannyFinishContext();
  4280. }
  4281. /* "lakesuperior/store/base_lmdb_store.pyx":239
  4282. *
  4283. *
  4284. * cdef void _init_dbis(self, create=True) except *: # <<<<<<<<<<<<<<
  4285. * """
  4286. * Initialize databases and cursors.
  4287. */
  4288. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis *__pyx_optional_args) {
  4289. PyObject *__pyx_v_create = ((PyObject *)Py_True);
  4290. size_t __pyx_v_i;
  4291. MDB_txn *__pyx_v_txn;
  4292. MDB_dbi __pyx_v_dbi;
  4293. long __pyx_v_create_flag;
  4294. long __pyx_v_txn_flags;
  4295. CYTHON_UNUSED int __pyx_v_rc;
  4296. PyObject *__pyx_v_dblabel = NULL;
  4297. PyObject *__pyx_v_flags = NULL;
  4298. __Pyx_TraceDeclarations
  4299. __Pyx_RefNannyDeclarations
  4300. long __pyx_t_1;
  4301. PyObject *__pyx_t_2 = NULL;
  4302. Py_ssize_t __pyx_t_3;
  4303. Py_ssize_t __pyx_t_4;
  4304. int __pyx_t_5;
  4305. PyObject *__pyx_t_6 = NULL;
  4306. PyObject *__pyx_t_7 = NULL;
  4307. PyObject *__pyx_t_8 = NULL;
  4308. PyObject *__pyx_t_9 = NULL;
  4309. size_t __pyx_t_10;
  4310. PyObject *(*__pyx_t_11)(PyObject *);
  4311. PyObject *__pyx_t_12 = NULL;
  4312. PyObject *__pyx_t_13 = NULL;
  4313. int __pyx_t_14;
  4314. PyObject *__pyx_t_15 = NULL;
  4315. char const *__pyx_t_16;
  4316. unsigned int __pyx_t_17;
  4317. Py_UCS4 __pyx_t_18;
  4318. PyObject *__pyx_t_19 = NULL;
  4319. __Pyx_RefNannySetupContext("_init_dbis", 0);
  4320. __Pyx_TraceCall("_init_dbis", __pyx_f[0], 239, 0, __PYX_ERR(0, 239, __pyx_L1_error));
  4321. if (__pyx_optional_args) {
  4322. if (__pyx_optional_args->__pyx_n > 0) {
  4323. __pyx_v_create = __pyx_optional_args->create;
  4324. }
  4325. }
  4326. /* "lakesuperior/store/base_lmdb_store.pyx":249
  4327. *
  4328. * # At least one slot (for environments without a database)
  4329. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc( # <<<<<<<<<<<<<<
  4330. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4331. * if not self.dbis:
  4332. */
  4333. __pyx_t_1 = 1;
  4334. /* "lakesuperior/store/base_lmdb_store.pyx":250
  4335. * # At least one slot (for environments without a database)
  4336. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc(
  4337. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi)) # <<<<<<<<<<<<<<
  4338. * if not self.dbis:
  4339. * raise MemoryError()
  4340. */
  4341. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dbi_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error)
  4342. __Pyx_GOTREF(__pyx_t_2);
  4343. __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 250, __pyx_L1_error)
  4344. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4345. if (((__pyx_t_1 > __pyx_t_3) != 0)) {
  4346. __pyx_t_4 = __pyx_t_1;
  4347. } else {
  4348. __pyx_t_4 = __pyx_t_3;
  4349. }
  4350. /* "lakesuperior/store/base_lmdb_store.pyx":249
  4351. *
  4352. * # At least one slot (for environments without a database)
  4353. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc( # <<<<<<<<<<<<<<
  4354. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4355. * if not self.dbis:
  4356. */
  4357. __pyx_v_self->dbis = ((MDB_dbi *)PyMem_Malloc((__pyx_t_4 * (sizeof(MDB_dbi)))));
  4358. /* "lakesuperior/store/base_lmdb_store.pyx":251
  4359. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc(
  4360. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4361. * if not self.dbis: # <<<<<<<<<<<<<<
  4362. * raise MemoryError()
  4363. *
  4364. */
  4365. __pyx_t_5 = ((!(__pyx_v_self->dbis != 0)) != 0);
  4366. if (unlikely(__pyx_t_5)) {
  4367. /* "lakesuperior/store/base_lmdb_store.pyx":252
  4368. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4369. * if not self.dbis:
  4370. * raise MemoryError() # <<<<<<<<<<<<<<
  4371. *
  4372. * # DBIs seem to start from 2. We want to map cursor pointers in the
  4373. */
  4374. PyErr_NoMemory(); __PYX_ERR(0, 252, __pyx_L1_error)
  4375. /* "lakesuperior/store/base_lmdb_store.pyx":251
  4376. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc(
  4377. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4378. * if not self.dbis: # <<<<<<<<<<<<<<
  4379. * raise MemoryError()
  4380. *
  4381. */
  4382. }
  4383. /* "lakesuperior/store/base_lmdb_store.pyx":257
  4384. * # array to DBIs, so we need an extra slot.
  4385. * self.curs = <lmdb.MDB_cursor **>PyMem_Malloc(
  4386. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*)) # <<<<<<<<<<<<<<
  4387. * if not self.curs:
  4388. * raise MemoryError()
  4389. */
  4390. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dbi_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error)
  4391. __Pyx_GOTREF(__pyx_t_2);
  4392. __pyx_t_4 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 257, __pyx_L1_error)
  4393. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4394. /* "lakesuperior/store/base_lmdb_store.pyx":256
  4395. * # DBIs seem to start from 2. We want to map cursor pointers in the
  4396. * # array to DBIs, so we need an extra slot.
  4397. * self.curs = <lmdb.MDB_cursor **>PyMem_Malloc( # <<<<<<<<<<<<<<
  4398. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4399. * if not self.curs:
  4400. */
  4401. __pyx_v_self->curs = ((MDB_cursor **)PyMem_Malloc(((__pyx_t_4 + 2) * (sizeof(MDB_cursor *)))));
  4402. /* "lakesuperior/store/base_lmdb_store.pyx":258
  4403. * self.curs = <lmdb.MDB_cursor **>PyMem_Malloc(
  4404. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4405. * if not self.curs: # <<<<<<<<<<<<<<
  4406. * raise MemoryError()
  4407. *
  4408. */
  4409. __pyx_t_5 = ((!(__pyx_v_self->curs != 0)) != 0);
  4410. if (unlikely(__pyx_t_5)) {
  4411. /* "lakesuperior/store/base_lmdb_store.pyx":259
  4412. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4413. * if not self.curs:
  4414. * raise MemoryError() # <<<<<<<<<<<<<<
  4415. *
  4416. * create_flag = lmdb.MDB_CREATE if create is True else 0
  4417. */
  4418. PyErr_NoMemory(); __PYX_ERR(0, 259, __pyx_L1_error)
  4419. /* "lakesuperior/store/base_lmdb_store.pyx":258
  4420. * self.curs = <lmdb.MDB_cursor **>PyMem_Malloc(
  4421. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4422. * if not self.curs: # <<<<<<<<<<<<<<
  4423. * raise MemoryError()
  4424. *
  4425. */
  4426. }
  4427. /* "lakesuperior/store/base_lmdb_store.pyx":261
  4428. * raise MemoryError()
  4429. *
  4430. * create_flag = lmdb.MDB_CREATE if create is True else 0 # <<<<<<<<<<<<<<
  4431. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  4432. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4433. */
  4434. __pyx_t_5 = (__pyx_v_create == Py_True);
  4435. if ((__pyx_t_5 != 0)) {
  4436. __pyx_t_1 = MDB_CREATE;
  4437. } else {
  4438. __pyx_t_1 = 0;
  4439. }
  4440. __pyx_v_create_flag = __pyx_t_1;
  4441. /* "lakesuperior/store/base_lmdb_store.pyx":262
  4442. *
  4443. * create_flag = lmdb.MDB_CREATE if create is True else 0
  4444. * txn_flags = 0 if create else lmdb.MDB_RDONLY # <<<<<<<<<<<<<<
  4445. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4446. * logger.info(f'Creating DBs.')
  4447. */
  4448. __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_create); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 262, __pyx_L1_error)
  4449. if (__pyx_t_5) {
  4450. __pyx_t_1 = 0;
  4451. } else {
  4452. __pyx_t_1 = MDB_RDONLY;
  4453. }
  4454. __pyx_v_txn_flags = __pyx_t_1;
  4455. /* "lakesuperior/store/base_lmdb_store.pyx":263
  4456. * create_flag = lmdb.MDB_CREATE if create is True else 0
  4457. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  4458. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn) # <<<<<<<<<<<<<<
  4459. * logger.info(f'Creating DBs.')
  4460. * try:
  4461. */
  4462. __pyx_v_rc = mdb_txn_begin(__pyx_v_self->dbenv, NULL, __pyx_v_txn_flags, (&__pyx_v_txn));
  4463. /* "lakesuperior/store/base_lmdb_store.pyx":264
  4464. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  4465. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4466. * logger.info(f'Creating DBs.') # <<<<<<<<<<<<<<
  4467. * try:
  4468. * if len(self.dbi_labels):
  4469. */
  4470. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error)
  4471. __Pyx_GOTREF(__pyx_t_2);
  4472. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 264, __pyx_L1_error)
  4473. __Pyx_GOTREF(__pyx_t_6);
  4474. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4475. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error)
  4476. __Pyx_GOTREF(__pyx_t_2);
  4477. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4478. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4479. /* "lakesuperior/store/base_lmdb_store.pyx":265
  4480. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4481. * logger.info(f'Creating DBs.')
  4482. * try: # <<<<<<<<<<<<<<
  4483. * if len(self.dbi_labels):
  4484. * for i, dblabel in enumerate(self.dbi_labels):
  4485. */
  4486. {
  4487. __Pyx_PyThreadState_declare
  4488. __Pyx_PyThreadState_assign
  4489. __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
  4490. __Pyx_XGOTREF(__pyx_t_7);
  4491. __Pyx_XGOTREF(__pyx_t_8);
  4492. __Pyx_XGOTREF(__pyx_t_9);
  4493. /*try:*/ {
  4494. /* "lakesuperior/store/base_lmdb_store.pyx":266
  4495. * logger.info(f'Creating DBs.')
  4496. * try:
  4497. * if len(self.dbi_labels): # <<<<<<<<<<<<<<
  4498. * for i, dblabel in enumerate(self.dbi_labels):
  4499. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4500. */
  4501. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dbi_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L5_error)
  4502. __Pyx_GOTREF(__pyx_t_2);
  4503. __pyx_t_4 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 266, __pyx_L5_error)
  4504. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4505. __pyx_t_5 = (__pyx_t_4 != 0);
  4506. if (__pyx_t_5) {
  4507. /* "lakesuperior/store/base_lmdb_store.pyx":267
  4508. * try:
  4509. * if len(self.dbi_labels):
  4510. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  4511. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4512. * _check(lmdb.mdb_dbi_open(
  4513. */
  4514. __pyx_t_10 = 0;
  4515. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dbi_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L5_error)
  4516. __Pyx_GOTREF(__pyx_t_2);
  4517. if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
  4518. __pyx_t_6 = __pyx_t_2; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = 0;
  4519. __pyx_t_11 = NULL;
  4520. } else {
  4521. __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 267, __pyx_L5_error)
  4522. __Pyx_GOTREF(__pyx_t_6);
  4523. __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 267, __pyx_L5_error)
  4524. }
  4525. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4526. for (;;) {
  4527. if (likely(!__pyx_t_11)) {
  4528. if (likely(PyList_CheckExact(__pyx_t_6))) {
  4529. if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_6)) break;
  4530. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4531. __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 267, __pyx_L5_error)
  4532. #else
  4533. __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L5_error)
  4534. __Pyx_GOTREF(__pyx_t_2);
  4535. #endif
  4536. } else {
  4537. if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
  4538. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4539. __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 267, __pyx_L5_error)
  4540. #else
  4541. __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L5_error)
  4542. __Pyx_GOTREF(__pyx_t_2);
  4543. #endif
  4544. }
  4545. } else {
  4546. __pyx_t_2 = __pyx_t_11(__pyx_t_6);
  4547. if (unlikely(!__pyx_t_2)) {
  4548. PyObject* exc_type = PyErr_Occurred();
  4549. if (exc_type) {
  4550. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  4551. else __PYX_ERR(0, 267, __pyx_L5_error)
  4552. }
  4553. break;
  4554. }
  4555. __Pyx_GOTREF(__pyx_t_2);
  4556. }
  4557. __Pyx_XDECREF_SET(__pyx_v_dblabel, __pyx_t_2);
  4558. __pyx_t_2 = 0;
  4559. __pyx_v_i = __pyx_t_10;
  4560. __pyx_t_10 = (__pyx_t_10 + 1);
  4561. /* "lakesuperior/store/base_lmdb_store.pyx":268
  4562. * if len(self.dbi_labels):
  4563. * for i, dblabel in enumerate(self.dbi_labels):
  4564. * flags = self.dbi_flags.get(dblabel, 0) | create_flag # <<<<<<<<<<<<<<
  4565. * _check(lmdb.mdb_dbi_open(
  4566. * txn, dblabel.encode(), flags, self.dbis + i))
  4567. */
  4568. __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dbi_flags); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 268, __pyx_L5_error)
  4569. __Pyx_GOTREF(__pyx_t_12);
  4570. __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_get); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 268, __pyx_L5_error)
  4571. __Pyx_GOTREF(__pyx_t_13);
  4572. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4573. __pyx_t_12 = NULL;
  4574. __pyx_t_14 = 0;
  4575. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  4576. __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
  4577. if (likely(__pyx_t_12)) {
  4578. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  4579. __Pyx_INCREF(__pyx_t_12);
  4580. __Pyx_INCREF(function);
  4581. __Pyx_DECREF_SET(__pyx_t_13, function);
  4582. __pyx_t_14 = 1;
  4583. }
  4584. }
  4585. #if CYTHON_FAST_PYCALL
  4586. if (PyFunction_Check(__pyx_t_13)) {
  4587. PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_dblabel, __pyx_int_0};
  4588. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L5_error)
  4589. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4590. __Pyx_GOTREF(__pyx_t_2);
  4591. } else
  4592. #endif
  4593. #if CYTHON_FAST_PYCCALL
  4594. if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
  4595. PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_dblabel, __pyx_int_0};
  4596. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L5_error)
  4597. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4598. __Pyx_GOTREF(__pyx_t_2);
  4599. } else
  4600. #endif
  4601. {
  4602. __pyx_t_15 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 268, __pyx_L5_error)
  4603. __Pyx_GOTREF(__pyx_t_15);
  4604. if (__pyx_t_12) {
  4605. __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_12); __pyx_t_12 = NULL;
  4606. }
  4607. __Pyx_INCREF(__pyx_v_dblabel);
  4608. __Pyx_GIVEREF(__pyx_v_dblabel);
  4609. PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_v_dblabel);
  4610. __Pyx_INCREF(__pyx_int_0);
  4611. __Pyx_GIVEREF(__pyx_int_0);
  4612. PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_int_0);
  4613. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L5_error)
  4614. __Pyx_GOTREF(__pyx_t_2);
  4615. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4616. }
  4617. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4618. __pyx_t_13 = __Pyx_PyInt_From_long(__pyx_v_create_flag); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 268, __pyx_L5_error)
  4619. __Pyx_GOTREF(__pyx_t_13);
  4620. __pyx_t_15 = PyNumber_Or(__pyx_t_2, __pyx_t_13); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 268, __pyx_L5_error)
  4621. __Pyx_GOTREF(__pyx_t_15);
  4622. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4623. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4624. __Pyx_XDECREF_SET(__pyx_v_flags, __pyx_t_15);
  4625. __pyx_t_15 = 0;
  4626. /* "lakesuperior/store/base_lmdb_store.pyx":270
  4627. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4628. * _check(lmdb.mdb_dbi_open(
  4629. * txn, dblabel.encode(), flags, self.dbis + i)) # <<<<<<<<<<<<<<
  4630. * dbi = self.dbis[i]
  4631. * logger.info(f'Created DB {dblabel}: {dbi}')
  4632. */
  4633. __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_dblabel, __pyx_n_s_encode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 270, __pyx_L5_error)
  4634. __Pyx_GOTREF(__pyx_t_13);
  4635. __pyx_t_2 = NULL;
  4636. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  4637. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_13);
  4638. if (likely(__pyx_t_2)) {
  4639. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  4640. __Pyx_INCREF(__pyx_t_2);
  4641. __Pyx_INCREF(function);
  4642. __Pyx_DECREF_SET(__pyx_t_13, function);
  4643. }
  4644. }
  4645. if (__pyx_t_2) {
  4646. __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 270, __pyx_L5_error)
  4647. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4648. } else {
  4649. __pyx_t_15 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 270, __pyx_L5_error)
  4650. }
  4651. __Pyx_GOTREF(__pyx_t_15);
  4652. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4653. __pyx_t_16 = __Pyx_PyObject_AsString(__pyx_t_15); if (unlikely((!__pyx_t_16) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L5_error)
  4654. __pyx_t_17 = __Pyx_PyInt_As_unsigned_int(__pyx_v_flags); if (unlikely((__pyx_t_17 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L5_error)
  4655. /* "lakesuperior/store/base_lmdb_store.pyx":269
  4656. * for i, dblabel in enumerate(self.dbi_labels):
  4657. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4658. * _check(lmdb.mdb_dbi_open( # <<<<<<<<<<<<<<
  4659. * txn, dblabel.encode(), flags, self.dbis + i))
  4660. * dbi = self.dbis[i]
  4661. */
  4662. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_dbi_open(__pyx_v_txn, __pyx_t_16, __pyx_t_17, (__pyx_v_self->dbis + __pyx_v_i)), NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 269, __pyx_L5_error)
  4663. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4664. /* "lakesuperior/store/base_lmdb_store.pyx":271
  4665. * _check(lmdb.mdb_dbi_open(
  4666. * txn, dblabel.encode(), flags, self.dbis + i))
  4667. * dbi = self.dbis[i] # <<<<<<<<<<<<<<
  4668. * logger.info(f'Created DB {dblabel}: {dbi}')
  4669. * # Open and close cursor to initialize the memory slot.
  4670. */
  4671. __pyx_v_dbi = (__pyx_v_self->dbis[__pyx_v_i]);
  4672. /* "lakesuperior/store/base_lmdb_store.pyx":272
  4673. * txn, dblabel.encode(), flags, self.dbis + i))
  4674. * dbi = self.dbis[i]
  4675. * logger.info(f'Created DB {dblabel}: {dbi}') # <<<<<<<<<<<<<<
  4676. * # Open and close cursor to initialize the memory slot.
  4677. * _check(lmdb.mdb_cursor_open(
  4678. */
  4679. __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 272, __pyx_L5_error)
  4680. __Pyx_GOTREF(__pyx_t_13);
  4681. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L5_error)
  4682. __Pyx_GOTREF(__pyx_t_2);
  4683. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4684. __pyx_t_13 = PyTuple_New(4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 272, __pyx_L5_error)
  4685. __Pyx_GOTREF(__pyx_t_13);
  4686. __pyx_t_3 = 0;
  4687. __pyx_t_18 = 127;
  4688. __Pyx_INCREF(__pyx_kp_u_Created_DB);
  4689. __pyx_t_3 += 11;
  4690. __Pyx_GIVEREF(__pyx_kp_u_Created_DB);
  4691. PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_kp_u_Created_DB);
  4692. __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_v_dblabel, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L5_error)
  4693. __Pyx_GOTREF(__pyx_t_12);
  4694. __pyx_t_18 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_18) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_18;
  4695. __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12);
  4696. __Pyx_GIVEREF(__pyx_t_12);
  4697. PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12);
  4698. __pyx_t_12 = 0;
  4699. __Pyx_INCREF(__pyx_kp_u__6);
  4700. __pyx_t_3 += 2;
  4701. __Pyx_GIVEREF(__pyx_kp_u__6);
  4702. PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_kp_u__6);
  4703. __pyx_t_12 = __Pyx_PyInt_From_MDB_dbi(__pyx_v_dbi); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L5_error)
  4704. __Pyx_GOTREF(__pyx_t_12);
  4705. __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_t_12, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 272, __pyx_L5_error)
  4706. __Pyx_GOTREF(__pyx_t_19);
  4707. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4708. __pyx_t_18 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_18) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_18;
  4709. __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19);
  4710. __Pyx_GIVEREF(__pyx_t_19);
  4711. PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_19);
  4712. __pyx_t_19 = 0;
  4713. __pyx_t_19 = __Pyx_PyUnicode_Join(__pyx_t_13, 4, __pyx_t_3, __pyx_t_18); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 272, __pyx_L5_error)
  4714. __Pyx_GOTREF(__pyx_t_19);
  4715. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4716. __pyx_t_13 = NULL;
  4717. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  4718. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
  4719. if (likely(__pyx_t_13)) {
  4720. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  4721. __Pyx_INCREF(__pyx_t_13);
  4722. __Pyx_INCREF(function);
  4723. __Pyx_DECREF_SET(__pyx_t_2, function);
  4724. }
  4725. }
  4726. if (!__pyx_t_13) {
  4727. __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_19); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 272, __pyx_L5_error)
  4728. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  4729. __Pyx_GOTREF(__pyx_t_15);
  4730. } else {
  4731. #if CYTHON_FAST_PYCALL
  4732. if (PyFunction_Check(__pyx_t_2)) {
  4733. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_19};
  4734. __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 272, __pyx_L5_error)
  4735. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4736. __Pyx_GOTREF(__pyx_t_15);
  4737. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  4738. } else
  4739. #endif
  4740. #if CYTHON_FAST_PYCCALL
  4741. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  4742. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_19};
  4743. __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 272, __pyx_L5_error)
  4744. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4745. __Pyx_GOTREF(__pyx_t_15);
  4746. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  4747. } else
  4748. #endif
  4749. {
  4750. __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L5_error)
  4751. __Pyx_GOTREF(__pyx_t_12);
  4752. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL;
  4753. __Pyx_GIVEREF(__pyx_t_19);
  4754. PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_19);
  4755. __pyx_t_19 = 0;
  4756. __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 272, __pyx_L5_error)
  4757. __Pyx_GOTREF(__pyx_t_15);
  4758. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4759. }
  4760. }
  4761. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4762. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4763. /* "lakesuperior/store/base_lmdb_store.pyx":274
  4764. * logger.info(f'Created DB {dblabel}: {dbi}')
  4765. * # Open and close cursor to initialize the memory slot.
  4766. * _check(lmdb.mdb_cursor_open( # <<<<<<<<<<<<<<
  4767. * txn, dbi, self.curs + dbi))
  4768. * #lmdb.mdb_cursor_close(self.curs[dbi])
  4769. */
  4770. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_cursor_open(__pyx_v_txn, __pyx_v_dbi, (__pyx_v_self->curs + __pyx_v_dbi)), NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 274, __pyx_L5_error)
  4771. /* "lakesuperior/store/base_lmdb_store.pyx":267
  4772. * try:
  4773. * if len(self.dbi_labels):
  4774. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  4775. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4776. * _check(lmdb.mdb_dbi_open(
  4777. */
  4778. }
  4779. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4780. /* "lakesuperior/store/base_lmdb_store.pyx":266
  4781. * logger.info(f'Creating DBs.')
  4782. * try:
  4783. * if len(self.dbi_labels): # <<<<<<<<<<<<<<
  4784. * for i, dblabel in enumerate(self.dbi_labels):
  4785. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4786. */
  4787. goto __pyx_L11;
  4788. }
  4789. /* "lakesuperior/store/base_lmdb_store.pyx":278
  4790. * #lmdb.mdb_cursor_close(self.curs[dbi])
  4791. * else:
  4792. * _check(lmdb.mdb_dbi_open(txn, NULL, 0, self.dbis)) # <<<<<<<<<<<<<<
  4793. * _check(lmdb.mdb_cursor_open(txn, self.dbis[0], self.curs))
  4794. * #lmdb.mdb_cursor_close(self.curs[self.dbis[0]])
  4795. */
  4796. /*else*/ {
  4797. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_dbi_open(__pyx_v_txn, NULL, 0, __pyx_v_self->dbis), NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 278, __pyx_L5_error)
  4798. /* "lakesuperior/store/base_lmdb_store.pyx":279
  4799. * else:
  4800. * _check(lmdb.mdb_dbi_open(txn, NULL, 0, self.dbis))
  4801. * _check(lmdb.mdb_cursor_open(txn, self.dbis[0], self.curs)) # <<<<<<<<<<<<<<
  4802. * #lmdb.mdb_cursor_close(self.curs[self.dbis[0]])
  4803. *
  4804. */
  4805. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_cursor_open(__pyx_v_txn, (__pyx_v_self->dbis[0]), __pyx_v_self->curs), NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 279, __pyx_L5_error)
  4806. }
  4807. __pyx_L11:;
  4808. /* "lakesuperior/store/base_lmdb_store.pyx":282
  4809. * #lmdb.mdb_cursor_close(self.curs[self.dbis[0]])
  4810. *
  4811. * _check(lmdb.mdb_txn_commit(txn)) # <<<<<<<<<<<<<<
  4812. * except:
  4813. * lmdb.mdb_txn_abort(txn)
  4814. */
  4815. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_txn_commit(__pyx_v_txn), NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 282, __pyx_L5_error)
  4816. /* "lakesuperior/store/base_lmdb_store.pyx":265
  4817. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4818. * logger.info(f'Creating DBs.')
  4819. * try: # <<<<<<<<<<<<<<
  4820. * if len(self.dbi_labels):
  4821. * for i, dblabel in enumerate(self.dbi_labels):
  4822. */
  4823. }
  4824. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4825. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  4826. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  4827. goto __pyx_L10_try_end;
  4828. __pyx_L5_error:;
  4829. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4830. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  4831. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4832. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  4833. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  4834. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4835. /* "lakesuperior/store/base_lmdb_store.pyx":283
  4836. *
  4837. * _check(lmdb.mdb_txn_commit(txn))
  4838. * except: # <<<<<<<<<<<<<<
  4839. * lmdb.mdb_txn_abort(txn)
  4840. * raise
  4841. */
  4842. /*except:*/ {
  4843. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._init_dbis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4844. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_15, &__pyx_t_2) < 0) __PYX_ERR(0, 283, __pyx_L7_except_error)
  4845. __Pyx_GOTREF(__pyx_t_6);
  4846. __Pyx_GOTREF(__pyx_t_15);
  4847. __Pyx_GOTREF(__pyx_t_2);
  4848. /* "lakesuperior/store/base_lmdb_store.pyx":284
  4849. * _check(lmdb.mdb_txn_commit(txn))
  4850. * except:
  4851. * lmdb.mdb_txn_abort(txn) # <<<<<<<<<<<<<<
  4852. * raise
  4853. *
  4854. */
  4855. mdb_txn_abort(__pyx_v_txn);
  4856. /* "lakesuperior/store/base_lmdb_store.pyx":285
  4857. * except:
  4858. * lmdb.mdb_txn_abort(txn)
  4859. * raise # <<<<<<<<<<<<<<
  4860. *
  4861. *
  4862. */
  4863. __Pyx_GIVEREF(__pyx_t_6);
  4864. __Pyx_GIVEREF(__pyx_t_15);
  4865. __Pyx_XGIVEREF(__pyx_t_2);
  4866. __Pyx_ErrRestoreWithState(__pyx_t_6, __pyx_t_15, __pyx_t_2);
  4867. __pyx_t_6 = 0; __pyx_t_15 = 0; __pyx_t_2 = 0;
  4868. __PYX_ERR(0, 285, __pyx_L7_except_error)
  4869. }
  4870. __pyx_L7_except_error:;
  4871. /* "lakesuperior/store/base_lmdb_store.pyx":265
  4872. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4873. * logger.info(f'Creating DBs.')
  4874. * try: # <<<<<<<<<<<<<<
  4875. * if len(self.dbi_labels):
  4876. * for i, dblabel in enumerate(self.dbi_labels):
  4877. */
  4878. __Pyx_XGIVEREF(__pyx_t_7);
  4879. __Pyx_XGIVEREF(__pyx_t_8);
  4880. __Pyx_XGIVEREF(__pyx_t_9);
  4881. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  4882. goto __pyx_L1_error;
  4883. __pyx_L10_try_end:;
  4884. }
  4885. /* "lakesuperior/store/base_lmdb_store.pyx":239
  4886. *
  4887. *
  4888. * cdef void _init_dbis(self, create=True) except *: # <<<<<<<<<<<<<<
  4889. * """
  4890. * Initialize databases and cursors.
  4891. */
  4892. /* function exit code */
  4893. goto __pyx_L0;
  4894. __pyx_L1_error:;
  4895. __Pyx_XDECREF(__pyx_t_2);
  4896. __Pyx_XDECREF(__pyx_t_6);
  4897. __Pyx_XDECREF(__pyx_t_12);
  4898. __Pyx_XDECREF(__pyx_t_13);
  4899. __Pyx_XDECREF(__pyx_t_15);
  4900. __Pyx_XDECREF(__pyx_t_19);
  4901. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._init_dbis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4902. __pyx_L0:;
  4903. __Pyx_XDECREF(__pyx_v_dblabel);
  4904. __Pyx_XDECREF(__pyx_v_flags);
  4905. __Pyx_TraceReturn(Py_None, 0);
  4906. __Pyx_RefNannyFinishContext();
  4907. }
  4908. /* "lakesuperior/store/base_lmdb_store.pyx":288
  4909. *
  4910. *
  4911. * cpdef void close_env(self, bint commit_pending_transaction=False) except *: # <<<<<<<<<<<<<<
  4912. * logger.debug('Cleaning up store env.')
  4913. * if self.is_open:
  4914. */
  4915. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4916. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env *__pyx_optional_args) {
  4917. int __pyx_v_commit_pending_transaction = ((int)0);
  4918. __Pyx_TraceDeclarations
  4919. __Pyx_RefNannyDeclarations
  4920. PyObject *__pyx_t_1 = NULL;
  4921. PyObject *__pyx_t_2 = NULL;
  4922. PyObject *__pyx_t_3 = NULL;
  4923. PyObject *__pyx_t_4 = NULL;
  4924. PyObject *__pyx_t_5 = NULL;
  4925. PyObject *__pyx_t_6 = NULL;
  4926. int __pyx_t_7;
  4927. __Pyx_RefNannySetupContext("close_env", 0);
  4928. __Pyx_TraceCall("close_env", __pyx_f[0], 288, 0, __PYX_ERR(0, 288, __pyx_L1_error));
  4929. if (__pyx_optional_args) {
  4930. if (__pyx_optional_args->__pyx_n > 0) {
  4931. __pyx_v_commit_pending_transaction = __pyx_optional_args->commit_pending_transaction;
  4932. }
  4933. }
  4934. /* Check if called by wrapper */
  4935. if (unlikely(__pyx_skip_dispatch)) ;
  4936. /* Check if overridden in Python */
  4937. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  4938. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_close_env); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error)
  4939. __Pyx_GOTREF(__pyx_t_1);
  4940. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env)) {
  4941. __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_commit_pending_transaction); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error)
  4942. __Pyx_GOTREF(__pyx_t_3);
  4943. __Pyx_INCREF(__pyx_t_1);
  4944. __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
  4945. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  4946. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  4947. if (likely(__pyx_t_5)) {
  4948. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  4949. __Pyx_INCREF(__pyx_t_5);
  4950. __Pyx_INCREF(function);
  4951. __Pyx_DECREF_SET(__pyx_t_4, function);
  4952. }
  4953. }
  4954. if (!__pyx_t_5) {
  4955. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
  4956. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4957. __Pyx_GOTREF(__pyx_t_2);
  4958. } else {
  4959. #if CYTHON_FAST_PYCALL
  4960. if (PyFunction_Check(__pyx_t_4)) {
  4961. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4962. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
  4963. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4964. __Pyx_GOTREF(__pyx_t_2);
  4965. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4966. } else
  4967. #endif
  4968. #if CYTHON_FAST_PYCCALL
  4969. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  4970. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4971. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
  4972. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4973. __Pyx_GOTREF(__pyx_t_2);
  4974. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4975. } else
  4976. #endif
  4977. {
  4978. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error)
  4979. __Pyx_GOTREF(__pyx_t_6);
  4980. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
  4981. __Pyx_GIVEREF(__pyx_t_3);
  4982. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
  4983. __pyx_t_3 = 0;
  4984. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
  4985. __Pyx_GOTREF(__pyx_t_2);
  4986. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4987. }
  4988. }
  4989. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4990. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4991. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4992. goto __pyx_L0;
  4993. }
  4994. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4995. }
  4996. /* "lakesuperior/store/base_lmdb_store.pyx":289
  4997. *
  4998. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  4999. * logger.debug('Cleaning up store env.') # <<<<<<<<<<<<<<
  5000. * if self.is_open:
  5001. * logger.debug('Closing store env.')
  5002. */
  5003. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error)
  5004. __Pyx_GOTREF(__pyx_t_1);
  5005. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error)
  5006. __Pyx_GOTREF(__pyx_t_2);
  5007. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5008. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error)
  5009. __Pyx_GOTREF(__pyx_t_1);
  5010. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5011. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5012. /* "lakesuperior/store/base_lmdb_store.pyx":290
  5013. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  5014. * logger.debug('Cleaning up store env.')
  5015. * if self.is_open: # <<<<<<<<<<<<<<
  5016. * logger.debug('Closing store env.')
  5017. * if self.is_txn_open is True:
  5018. */
  5019. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L1_error)
  5020. __Pyx_GOTREF(__pyx_t_1);
  5021. __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 290, __pyx_L1_error)
  5022. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5023. if (__pyx_t_7) {
  5024. /* "lakesuperior/store/base_lmdb_store.pyx":291
  5025. * logger.debug('Cleaning up store env.')
  5026. * if self.is_open:
  5027. * logger.debug('Closing store env.') # <<<<<<<<<<<<<<
  5028. * if self.is_txn_open is True:
  5029. * if commit_pending_transaction:
  5030. */
  5031. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error)
  5032. __Pyx_GOTREF(__pyx_t_1);
  5033. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 291, __pyx_L1_error)
  5034. __Pyx_GOTREF(__pyx_t_2);
  5035. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5036. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error)
  5037. __Pyx_GOTREF(__pyx_t_1);
  5038. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5039. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5040. /* "lakesuperior/store/base_lmdb_store.pyx":292
  5041. * if self.is_open:
  5042. * logger.debug('Closing store env.')
  5043. * if self.is_txn_open is True: # <<<<<<<<<<<<<<
  5044. * if commit_pending_transaction:
  5045. * self._txn_commit()
  5046. */
  5047. __pyx_t_7 = ((__pyx_v_self->is_txn_open == 1) != 0);
  5048. if (__pyx_t_7) {
  5049. /* "lakesuperior/store/base_lmdb_store.pyx":293
  5050. * logger.debug('Closing store env.')
  5051. * if self.is_txn_open is True:
  5052. * if commit_pending_transaction: # <<<<<<<<<<<<<<
  5053. * self._txn_commit()
  5054. * else:
  5055. */
  5056. __pyx_t_7 = (__pyx_v_commit_pending_transaction != 0);
  5057. if (__pyx_t_7) {
  5058. /* "lakesuperior/store/base_lmdb_store.pyx":294
  5059. * if self.is_txn_open is True:
  5060. * if commit_pending_transaction:
  5061. * self._txn_commit() # <<<<<<<<<<<<<<
  5062. * else:
  5063. * self._txn_abort()
  5064. */
  5065. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_txn_commit(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 294, __pyx_L1_error)
  5066. /* "lakesuperior/store/base_lmdb_store.pyx":293
  5067. * logger.debug('Closing store env.')
  5068. * if self.is_txn_open is True:
  5069. * if commit_pending_transaction: # <<<<<<<<<<<<<<
  5070. * self._txn_commit()
  5071. * else:
  5072. */
  5073. goto __pyx_L5;
  5074. }
  5075. /* "lakesuperior/store/base_lmdb_store.pyx":296
  5076. * self._txn_commit()
  5077. * else:
  5078. * self._txn_abort() # <<<<<<<<<<<<<<
  5079. *
  5080. * self._clear_stale_readers()
  5081. */
  5082. /*else*/ {
  5083. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_txn_abort(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 296, __pyx_L1_error)
  5084. }
  5085. __pyx_L5:;
  5086. /* "lakesuperior/store/base_lmdb_store.pyx":292
  5087. * if self.is_open:
  5088. * logger.debug('Closing store env.')
  5089. * if self.is_txn_open is True: # <<<<<<<<<<<<<<
  5090. * if commit_pending_transaction:
  5091. * self._txn_commit()
  5092. */
  5093. }
  5094. /* "lakesuperior/store/base_lmdb_store.pyx":298
  5095. * self._txn_abort()
  5096. *
  5097. * self._clear_stale_readers() # <<<<<<<<<<<<<<
  5098. *
  5099. * PyMem_Free(self.dbis)
  5100. */
  5101. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_clear_stale_readers(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 298, __pyx_L1_error)
  5102. /* "lakesuperior/store/base_lmdb_store.pyx":300
  5103. * self._clear_stale_readers()
  5104. *
  5105. * PyMem_Free(self.dbis) # <<<<<<<<<<<<<<
  5106. * PyMem_Free(self.curs)
  5107. * lmdb.mdb_env_close(self.dbenv)
  5108. */
  5109. PyMem_Free(__pyx_v_self->dbis);
  5110. /* "lakesuperior/store/base_lmdb_store.pyx":301
  5111. *
  5112. * PyMem_Free(self.dbis)
  5113. * PyMem_Free(self.curs) # <<<<<<<<<<<<<<
  5114. * lmdb.mdb_env_close(self.dbenv)
  5115. *
  5116. */
  5117. PyMem_Free(__pyx_v_self->curs);
  5118. /* "lakesuperior/store/base_lmdb_store.pyx":302
  5119. * PyMem_Free(self.dbis)
  5120. * PyMem_Free(self.curs)
  5121. * lmdb.mdb_env_close(self.dbenv) # <<<<<<<<<<<<<<
  5122. *
  5123. * self._open = False
  5124. */
  5125. mdb_env_close(__pyx_v_self->dbenv);
  5126. /* "lakesuperior/store/base_lmdb_store.pyx":290
  5127. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  5128. * logger.debug('Cleaning up store env.')
  5129. * if self.is_open: # <<<<<<<<<<<<<<
  5130. * logger.debug('Closing store env.')
  5131. * if self.is_txn_open is True:
  5132. */
  5133. }
  5134. /* "lakesuperior/store/base_lmdb_store.pyx":304
  5135. * lmdb.mdb_env_close(self.dbenv)
  5136. *
  5137. * self._open = False # <<<<<<<<<<<<<<
  5138. *
  5139. *
  5140. */
  5141. __pyx_v_self->_open = 0;
  5142. /* "lakesuperior/store/base_lmdb_store.pyx":288
  5143. *
  5144. *
  5145. * cpdef void close_env(self, bint commit_pending_transaction=False) except *: # <<<<<<<<<<<<<<
  5146. * logger.debug('Cleaning up store env.')
  5147. * if self.is_open:
  5148. */
  5149. /* function exit code */
  5150. goto __pyx_L0;
  5151. __pyx_L1_error:;
  5152. __Pyx_XDECREF(__pyx_t_1);
  5153. __Pyx_XDECREF(__pyx_t_2);
  5154. __Pyx_XDECREF(__pyx_t_3);
  5155. __Pyx_XDECREF(__pyx_t_4);
  5156. __Pyx_XDECREF(__pyx_t_5);
  5157. __Pyx_XDECREF(__pyx_t_6);
  5158. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.close_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5159. __pyx_L0:;
  5160. __Pyx_TraceReturn(Py_None, 0);
  5161. __Pyx_RefNannyFinishContext();
  5162. }
  5163. /* Python wrapper */
  5164. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5165. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5166. int __pyx_v_commit_pending_transaction;
  5167. PyObject *__pyx_r = 0;
  5168. __Pyx_RefNannyDeclarations
  5169. __Pyx_RefNannySetupContext("close_env (wrapper)", 0);
  5170. {
  5171. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_commit_pending_transaction,0};
  5172. PyObject* values[1] = {0};
  5173. if (unlikely(__pyx_kwds)) {
  5174. Py_ssize_t kw_args;
  5175. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5176. switch (pos_args) {
  5177. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5178. CYTHON_FALLTHROUGH;
  5179. case 0: break;
  5180. default: goto __pyx_L5_argtuple_error;
  5181. }
  5182. kw_args = PyDict_Size(__pyx_kwds);
  5183. switch (pos_args) {
  5184. case 0:
  5185. if (kw_args > 0) {
  5186. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_commit_pending_transaction);
  5187. if (value) { values[0] = value; kw_args--; }
  5188. }
  5189. }
  5190. if (unlikely(kw_args > 0)) {
  5191. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "close_env") < 0)) __PYX_ERR(0, 288, __pyx_L3_error)
  5192. }
  5193. } else {
  5194. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5195. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5196. CYTHON_FALLTHROUGH;
  5197. case 0: break;
  5198. default: goto __pyx_L5_argtuple_error;
  5199. }
  5200. }
  5201. if (values[0]) {
  5202. __pyx_v_commit_pending_transaction = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_commit_pending_transaction == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error)
  5203. } else {
  5204. __pyx_v_commit_pending_transaction = ((int)0);
  5205. }
  5206. }
  5207. goto __pyx_L4_argument_unpacking_done;
  5208. __pyx_L5_argtuple_error:;
  5209. __Pyx_RaiseArgtupleInvalid("close_env", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 288, __pyx_L3_error)
  5210. __pyx_L3_error:;
  5211. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.close_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5212. __Pyx_RefNannyFinishContext();
  5213. return NULL;
  5214. __pyx_L4_argument_unpacking_done:;
  5215. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_6close_env(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), __pyx_v_commit_pending_transaction);
  5216. /* function exit code */
  5217. __Pyx_RefNannyFinishContext();
  5218. return __pyx_r;
  5219. }
  5220. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_6close_env(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, int __pyx_v_commit_pending_transaction) {
  5221. PyObject *__pyx_r = NULL;
  5222. __Pyx_TraceDeclarations
  5223. __Pyx_RefNannyDeclarations
  5224. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env __pyx_t_1;
  5225. PyObject *__pyx_t_2 = NULL;
  5226. __Pyx_RefNannySetupContext("close_env", 0);
  5227. __Pyx_TraceCall("close_env (wrapper)", __pyx_f[0], 288, 0, __PYX_ERR(0, 288, __pyx_L1_error));
  5228. __Pyx_XDECREF(__pyx_r);
  5229. __pyx_t_1.__pyx_n = 1;
  5230. __pyx_t_1.commit_pending_transaction = __pyx_v_commit_pending_transaction;
  5231. __pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore->close_env(__pyx_v_self, 1, &__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L1_error)
  5232. __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
  5233. __Pyx_GOTREF(__pyx_t_2);
  5234. __pyx_r = __pyx_t_2;
  5235. __pyx_t_2 = 0;
  5236. goto __pyx_L0;
  5237. /* function exit code */
  5238. __pyx_L1_error:;
  5239. __Pyx_XDECREF(__pyx_t_2);
  5240. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.close_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5241. __pyx_r = NULL;
  5242. __pyx_L0:;
  5243. __Pyx_XGIVEREF(__pyx_r);
  5244. __Pyx_TraceReturn(__pyx_r, 0);
  5245. __Pyx_RefNannyFinishContext();
  5246. return __pyx_r;
  5247. }
  5248. /* "lakesuperior/store/base_lmdb_store.pyx":307
  5249. *
  5250. *
  5251. * cpdef void destroy(self, _path='') except *: # <<<<<<<<<<<<<<
  5252. * """
  5253. * Destroy the store.
  5254. */
  5255. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5256. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy *__pyx_optional_args) {
  5257. PyObject *__pyx_v__path = ((PyObject *)__pyx_kp_u_);
  5258. __Pyx_TraceDeclarations
  5259. __Pyx_RefNannyDeclarations
  5260. PyObject *__pyx_t_1 = NULL;
  5261. PyObject *__pyx_t_2 = NULL;
  5262. PyObject *__pyx_t_3 = NULL;
  5263. PyObject *__pyx_t_4 = NULL;
  5264. PyObject *__pyx_t_5 = NULL;
  5265. int __pyx_t_6;
  5266. PyObject *__pyx_t_7 = NULL;
  5267. PyObject *__pyx_t_8 = NULL;
  5268. PyObject *__pyx_t_9 = NULL;
  5269. int __pyx_t_10;
  5270. __Pyx_RefNannySetupContext("destroy", 0);
  5271. __Pyx_TraceCall("destroy", __pyx_f[0], 307, 0, __PYX_ERR(0, 307, __pyx_L1_error));
  5272. if (__pyx_optional_args) {
  5273. if (__pyx_optional_args->__pyx_n > 0) {
  5274. __pyx_v__path = __pyx_optional_args->_path;
  5275. }
  5276. }
  5277. /* Check if called by wrapper */
  5278. if (unlikely(__pyx_skip_dispatch)) ;
  5279. /* Check if overridden in Python */
  5280. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  5281. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error)
  5282. __Pyx_GOTREF(__pyx_t_1);
  5283. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy)) {
  5284. __Pyx_INCREF(__pyx_t_1);
  5285. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  5286. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  5287. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  5288. if (likely(__pyx_t_4)) {
  5289. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  5290. __Pyx_INCREF(__pyx_t_4);
  5291. __Pyx_INCREF(function);
  5292. __Pyx_DECREF_SET(__pyx_t_3, function);
  5293. }
  5294. }
  5295. if (!__pyx_t_4) {
  5296. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v__path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
  5297. __Pyx_GOTREF(__pyx_t_2);
  5298. } else {
  5299. #if CYTHON_FAST_PYCALL
  5300. if (PyFunction_Check(__pyx_t_3)) {
  5301. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v__path};
  5302. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
  5303. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5304. __Pyx_GOTREF(__pyx_t_2);
  5305. } else
  5306. #endif
  5307. #if CYTHON_FAST_PYCCALL
  5308. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  5309. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v__path};
  5310. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
  5311. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5312. __Pyx_GOTREF(__pyx_t_2);
  5313. } else
  5314. #endif
  5315. {
  5316. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 307, __pyx_L1_error)
  5317. __Pyx_GOTREF(__pyx_t_5);
  5318. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  5319. __Pyx_INCREF(__pyx_v__path);
  5320. __Pyx_GIVEREF(__pyx_v__path);
  5321. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v__path);
  5322. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
  5323. __Pyx_GOTREF(__pyx_t_2);
  5324. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5325. }
  5326. }
  5327. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5328. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5329. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5330. goto __pyx_L0;
  5331. }
  5332. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5333. }
  5334. /* "lakesuperior/store/base_lmdb_store.pyx":317
  5335. * general-purpose recursive file and folder delete method!)
  5336. * """
  5337. * if path.exists(self.env_path): # <<<<<<<<<<<<<<
  5338. * if lmdb.MDB_NOSUBDIR & self.flags:
  5339. * try:
  5340. */
  5341. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error)
  5342. __Pyx_GOTREF(__pyx_t_2);
  5343. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_exists); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __pyx_L1_error)
  5344. __Pyx_GOTREF(__pyx_t_3);
  5345. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5346. __pyx_t_2 = NULL;
  5347. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  5348. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
  5349. if (likely(__pyx_t_2)) {
  5350. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  5351. __Pyx_INCREF(__pyx_t_2);
  5352. __Pyx_INCREF(function);
  5353. __Pyx_DECREF_SET(__pyx_t_3, function);
  5354. }
  5355. }
  5356. if (!__pyx_t_2) {
  5357. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->env_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
  5358. __Pyx_GOTREF(__pyx_t_1);
  5359. } else {
  5360. #if CYTHON_FAST_PYCALL
  5361. if (PyFunction_Check(__pyx_t_3)) {
  5362. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5363. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
  5364. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5365. __Pyx_GOTREF(__pyx_t_1);
  5366. } else
  5367. #endif
  5368. #if CYTHON_FAST_PYCCALL
  5369. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  5370. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5371. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
  5372. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5373. __Pyx_GOTREF(__pyx_t_1);
  5374. } else
  5375. #endif
  5376. {
  5377. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 317, __pyx_L1_error)
  5378. __Pyx_GOTREF(__pyx_t_5);
  5379. __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
  5380. __Pyx_INCREF(__pyx_v_self->env_path);
  5381. __Pyx_GIVEREF(__pyx_v_self->env_path);
  5382. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_self->env_path);
  5383. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
  5384. __Pyx_GOTREF(__pyx_t_1);
  5385. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5386. }
  5387. }
  5388. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5389. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 317, __pyx_L1_error)
  5390. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5391. if (__pyx_t_6) {
  5392. /* "lakesuperior/store/base_lmdb_store.pyx":318
  5393. * """
  5394. * if path.exists(self.env_path):
  5395. * if lmdb.MDB_NOSUBDIR & self.flags: # <<<<<<<<<<<<<<
  5396. * try:
  5397. * os.unlink(self.env_path)
  5398. */
  5399. __pyx_t_1 = __Pyx_PyInt_From_int(MDB_NOSUBDIR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error)
  5400. __Pyx_GOTREF(__pyx_t_1);
  5401. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error)
  5402. __Pyx_GOTREF(__pyx_t_3);
  5403. __pyx_t_5 = PyNumber_And(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 318, __pyx_L1_error)
  5404. __Pyx_GOTREF(__pyx_t_5);
  5405. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5406. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5407. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 318, __pyx_L1_error)
  5408. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5409. if (__pyx_t_6) {
  5410. /* "lakesuperior/store/base_lmdb_store.pyx":319
  5411. * if path.exists(self.env_path):
  5412. * if lmdb.MDB_NOSUBDIR & self.flags:
  5413. * try: # <<<<<<<<<<<<<<
  5414. * os.unlink(self.env_path)
  5415. * except FileNotFoundError:
  5416. */
  5417. {
  5418. __Pyx_PyThreadState_declare
  5419. __Pyx_PyThreadState_assign
  5420. __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
  5421. __Pyx_XGOTREF(__pyx_t_7);
  5422. __Pyx_XGOTREF(__pyx_t_8);
  5423. __Pyx_XGOTREF(__pyx_t_9);
  5424. /*try:*/ {
  5425. /* "lakesuperior/store/base_lmdb_store.pyx":320
  5426. * if lmdb.MDB_NOSUBDIR & self.flags:
  5427. * try:
  5428. * os.unlink(self.env_path) # <<<<<<<<<<<<<<
  5429. * except FileNotFoundError:
  5430. * pass
  5431. */
  5432. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L5_error)
  5433. __Pyx_GOTREF(__pyx_t_3);
  5434. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_unlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L5_error)
  5435. __Pyx_GOTREF(__pyx_t_1);
  5436. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5437. __pyx_t_3 = NULL;
  5438. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  5439. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
  5440. if (likely(__pyx_t_3)) {
  5441. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  5442. __Pyx_INCREF(__pyx_t_3);
  5443. __Pyx_INCREF(function);
  5444. __Pyx_DECREF_SET(__pyx_t_1, function);
  5445. }
  5446. }
  5447. if (!__pyx_t_3) {
  5448. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_self->env_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 320, __pyx_L5_error)
  5449. __Pyx_GOTREF(__pyx_t_5);
  5450. } else {
  5451. #if CYTHON_FAST_PYCALL
  5452. if (PyFunction_Check(__pyx_t_1)) {
  5453. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->env_path};
  5454. __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 320, __pyx_L5_error)
  5455. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5456. __Pyx_GOTREF(__pyx_t_5);
  5457. } else
  5458. #endif
  5459. #if CYTHON_FAST_PYCCALL
  5460. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  5461. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->env_path};
  5462. __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 320, __pyx_L5_error)
  5463. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5464. __Pyx_GOTREF(__pyx_t_5);
  5465. } else
  5466. #endif
  5467. {
  5468. __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L5_error)
  5469. __Pyx_GOTREF(__pyx_t_2);
  5470. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
  5471. __Pyx_INCREF(__pyx_v_self->env_path);
  5472. __Pyx_GIVEREF(__pyx_v_self->env_path);
  5473. PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_self->env_path);
  5474. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 320, __pyx_L5_error)
  5475. __Pyx_GOTREF(__pyx_t_5);
  5476. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5477. }
  5478. }
  5479. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5480. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5481. /* "lakesuperior/store/base_lmdb_store.pyx":319
  5482. * if path.exists(self.env_path):
  5483. * if lmdb.MDB_NOSUBDIR & self.flags:
  5484. * try: # <<<<<<<<<<<<<<
  5485. * os.unlink(self.env_path)
  5486. * except FileNotFoundError:
  5487. */
  5488. }
  5489. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5490. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  5491. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  5492. goto __pyx_L10_try_end;
  5493. __pyx_L5_error:;
  5494. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5495. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5496. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5497. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5498. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5499. /* "lakesuperior/store/base_lmdb_store.pyx":321
  5500. * try:
  5501. * os.unlink(self.env_path)
  5502. * except FileNotFoundError: # <<<<<<<<<<<<<<
  5503. * pass
  5504. * try:
  5505. */
  5506. __Pyx_ErrFetch(&__pyx_t_5, &__pyx_t_1, &__pyx_t_2);
  5507. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_FileNotFoundError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L7_except_error)
  5508. __Pyx_GOTREF(__pyx_t_3);
  5509. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_5, __pyx_t_3);
  5510. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5511. __Pyx_ErrRestore(__pyx_t_5, __pyx_t_1, __pyx_t_2);
  5512. __pyx_t_5 = 0; __pyx_t_1 = 0; __pyx_t_2 = 0;
  5513. if (__pyx_t_10) {
  5514. __Pyx_ErrRestore(0,0,0);
  5515. goto __pyx_L6_exception_handled;
  5516. }
  5517. goto __pyx_L7_except_error;
  5518. __pyx_L7_except_error:;
  5519. /* "lakesuperior/store/base_lmdb_store.pyx":319
  5520. * if path.exists(self.env_path):
  5521. * if lmdb.MDB_NOSUBDIR & self.flags:
  5522. * try: # <<<<<<<<<<<<<<
  5523. * os.unlink(self.env_path)
  5524. * except FileNotFoundError:
  5525. */
  5526. __Pyx_XGIVEREF(__pyx_t_7);
  5527. __Pyx_XGIVEREF(__pyx_t_8);
  5528. __Pyx_XGIVEREF(__pyx_t_9);
  5529. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  5530. goto __pyx_L1_error;
  5531. __pyx_L6_exception_handled:;
  5532. __Pyx_XGIVEREF(__pyx_t_7);
  5533. __Pyx_XGIVEREF(__pyx_t_8);
  5534. __Pyx_XGIVEREF(__pyx_t_9);
  5535. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  5536. __pyx_L10_try_end:;
  5537. }
  5538. /* "lakesuperior/store/base_lmdb_store.pyx":323
  5539. * except FileNotFoundError:
  5540. * pass
  5541. * try: # <<<<<<<<<<<<<<
  5542. * os.unlink(self.env_path + '-lock')
  5543. * except FileNotFoundError:
  5544. */
  5545. {
  5546. __Pyx_PyThreadState_declare
  5547. __Pyx_PyThreadState_assign
  5548. __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
  5549. __Pyx_XGOTREF(__pyx_t_9);
  5550. __Pyx_XGOTREF(__pyx_t_8);
  5551. __Pyx_XGOTREF(__pyx_t_7);
  5552. /*try:*/ {
  5553. /* "lakesuperior/store/base_lmdb_store.pyx":324
  5554. * pass
  5555. * try:
  5556. * os.unlink(self.env_path + '-lock') # <<<<<<<<<<<<<<
  5557. * except FileNotFoundError:
  5558. * pass
  5559. */
  5560. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L11_error)
  5561. __Pyx_GOTREF(__pyx_t_1);
  5562. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_unlink); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 324, __pyx_L11_error)
  5563. __Pyx_GOTREF(__pyx_t_5);
  5564. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5565. __pyx_t_1 = __Pyx_PyUnicode_ConcatSafe(__pyx_v_self->env_path, __pyx_kp_u_lock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L11_error)
  5566. __Pyx_GOTREF(__pyx_t_1);
  5567. __pyx_t_3 = NULL;
  5568. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  5569. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
  5570. if (likely(__pyx_t_3)) {
  5571. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  5572. __Pyx_INCREF(__pyx_t_3);
  5573. __Pyx_INCREF(function);
  5574. __Pyx_DECREF_SET(__pyx_t_5, function);
  5575. }
  5576. }
  5577. if (!__pyx_t_3) {
  5578. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L11_error)
  5579. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5580. __Pyx_GOTREF(__pyx_t_2);
  5581. } else {
  5582. #if CYTHON_FAST_PYCALL
  5583. if (PyFunction_Check(__pyx_t_5)) {
  5584. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
  5585. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L11_error)
  5586. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5587. __Pyx_GOTREF(__pyx_t_2);
  5588. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5589. } else
  5590. #endif
  5591. #if CYTHON_FAST_PYCCALL
  5592. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  5593. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
  5594. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L11_error)
  5595. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5596. __Pyx_GOTREF(__pyx_t_2);
  5597. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5598. } else
  5599. #endif
  5600. {
  5601. __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 324, __pyx_L11_error)
  5602. __Pyx_GOTREF(__pyx_t_4);
  5603. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
  5604. __Pyx_GIVEREF(__pyx_t_1);
  5605. PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_1);
  5606. __pyx_t_1 = 0;
  5607. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L11_error)
  5608. __Pyx_GOTREF(__pyx_t_2);
  5609. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5610. }
  5611. }
  5612. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5613. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5614. /* "lakesuperior/store/base_lmdb_store.pyx":323
  5615. * except FileNotFoundError:
  5616. * pass
  5617. * try: # <<<<<<<<<<<<<<
  5618. * os.unlink(self.env_path + '-lock')
  5619. * except FileNotFoundError:
  5620. */
  5621. }
  5622. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  5623. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  5624. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5625. goto __pyx_L16_try_end;
  5626. __pyx_L11_error:;
  5627. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5628. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5629. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5630. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5631. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5632. /* "lakesuperior/store/base_lmdb_store.pyx":325
  5633. * try:
  5634. * os.unlink(self.env_path + '-lock')
  5635. * except FileNotFoundError: # <<<<<<<<<<<<<<
  5636. * pass
  5637. * else:
  5638. */
  5639. __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_5, &__pyx_t_4);
  5640. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_FileNotFoundError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L13_except_error)
  5641. __Pyx_GOTREF(__pyx_t_1);
  5642. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_1);
  5643. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5644. __Pyx_ErrRestore(__pyx_t_2, __pyx_t_5, __pyx_t_4);
  5645. __pyx_t_2 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0;
  5646. if (__pyx_t_10) {
  5647. __Pyx_ErrRestore(0,0,0);
  5648. goto __pyx_L12_exception_handled;
  5649. }
  5650. goto __pyx_L13_except_error;
  5651. __pyx_L13_except_error:;
  5652. /* "lakesuperior/store/base_lmdb_store.pyx":323
  5653. * except FileNotFoundError:
  5654. * pass
  5655. * try: # <<<<<<<<<<<<<<
  5656. * os.unlink(self.env_path + '-lock')
  5657. * except FileNotFoundError:
  5658. */
  5659. __Pyx_XGIVEREF(__pyx_t_9);
  5660. __Pyx_XGIVEREF(__pyx_t_8);
  5661. __Pyx_XGIVEREF(__pyx_t_7);
  5662. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7);
  5663. goto __pyx_L1_error;
  5664. __pyx_L12_exception_handled:;
  5665. __Pyx_XGIVEREF(__pyx_t_9);
  5666. __Pyx_XGIVEREF(__pyx_t_8);
  5667. __Pyx_XGIVEREF(__pyx_t_7);
  5668. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7);
  5669. __pyx_L16_try_end:;
  5670. }
  5671. /* "lakesuperior/store/base_lmdb_store.pyx":318
  5672. * """
  5673. * if path.exists(self.env_path):
  5674. * if lmdb.MDB_NOSUBDIR & self.flags: # <<<<<<<<<<<<<<
  5675. * try:
  5676. * os.unlink(self.env_path)
  5677. */
  5678. goto __pyx_L4;
  5679. }
  5680. /* "lakesuperior/store/base_lmdb_store.pyx":328
  5681. * pass
  5682. * else:
  5683. * rmtree(self.env_path) # <<<<<<<<<<<<<<
  5684. *
  5685. *
  5686. */
  5687. /*else*/ {
  5688. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_rmtree); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 328, __pyx_L1_error)
  5689. __Pyx_GOTREF(__pyx_t_5);
  5690. __pyx_t_2 = NULL;
  5691. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  5692. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
  5693. if (likely(__pyx_t_2)) {
  5694. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  5695. __Pyx_INCREF(__pyx_t_2);
  5696. __Pyx_INCREF(function);
  5697. __Pyx_DECREF_SET(__pyx_t_5, function);
  5698. }
  5699. }
  5700. if (!__pyx_t_2) {
  5701. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_self->env_path); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 328, __pyx_L1_error)
  5702. __Pyx_GOTREF(__pyx_t_4);
  5703. } else {
  5704. #if CYTHON_FAST_PYCALL
  5705. if (PyFunction_Check(__pyx_t_5)) {
  5706. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5707. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 328, __pyx_L1_error)
  5708. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5709. __Pyx_GOTREF(__pyx_t_4);
  5710. } else
  5711. #endif
  5712. #if CYTHON_FAST_PYCCALL
  5713. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  5714. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5715. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 328, __pyx_L1_error)
  5716. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5717. __Pyx_GOTREF(__pyx_t_4);
  5718. } else
  5719. #endif
  5720. {
  5721. __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __pyx_L1_error)
  5722. __Pyx_GOTREF(__pyx_t_1);
  5723. __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
  5724. __Pyx_INCREF(__pyx_v_self->env_path);
  5725. __Pyx_GIVEREF(__pyx_v_self->env_path);
  5726. PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_self->env_path);
  5727. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 328, __pyx_L1_error)
  5728. __Pyx_GOTREF(__pyx_t_4);
  5729. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5730. }
  5731. }
  5732. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5733. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5734. }
  5735. __pyx_L4:;
  5736. /* "lakesuperior/store/base_lmdb_store.pyx":317
  5737. * general-purpose recursive file and folder delete method!)
  5738. * """
  5739. * if path.exists(self.env_path): # <<<<<<<<<<<<<<
  5740. * if lmdb.MDB_NOSUBDIR & self.flags:
  5741. * try:
  5742. */
  5743. }
  5744. /* "lakesuperior/store/base_lmdb_store.pyx":307
  5745. *
  5746. *
  5747. * cpdef void destroy(self, _path='') except *: # <<<<<<<<<<<<<<
  5748. * """
  5749. * Destroy the store.
  5750. */
  5751. /* function exit code */
  5752. goto __pyx_L0;
  5753. __pyx_L1_error:;
  5754. __Pyx_XDECREF(__pyx_t_1);
  5755. __Pyx_XDECREF(__pyx_t_2);
  5756. __Pyx_XDECREF(__pyx_t_3);
  5757. __Pyx_XDECREF(__pyx_t_4);
  5758. __Pyx_XDECREF(__pyx_t_5);
  5759. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5760. __pyx_L0:;
  5761. __Pyx_TraceReturn(Py_None, 0);
  5762. __Pyx_RefNannyFinishContext();
  5763. }
  5764. /* Python wrapper */
  5765. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5766. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8destroy[] = "\n Destroy the store.\n\n https://www.youtube.com/watch?v=lIVq7FJnPwg\n\n :param str _path: unused. Left for RDFLib API compatibility. (actually\n quite dangerous if it were used: it could turn into a\n general-purpose recursive file and folder delete method!)\n ";
  5767. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5768. PyObject *__pyx_v__path = 0;
  5769. PyObject *__pyx_r = 0;
  5770. __Pyx_RefNannyDeclarations
  5771. __Pyx_RefNannySetupContext("destroy (wrapper)", 0);
  5772. {
  5773. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path_2,0};
  5774. PyObject* values[1] = {0};
  5775. values[0] = ((PyObject *)__pyx_kp_u_);
  5776. if (unlikely(__pyx_kwds)) {
  5777. Py_ssize_t kw_args;
  5778. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5779. switch (pos_args) {
  5780. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5781. CYTHON_FALLTHROUGH;
  5782. case 0: break;
  5783. default: goto __pyx_L5_argtuple_error;
  5784. }
  5785. kw_args = PyDict_Size(__pyx_kwds);
  5786. switch (pos_args) {
  5787. case 0:
  5788. if (kw_args > 0) {
  5789. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path_2);
  5790. if (value) { values[0] = value; kw_args--; }
  5791. }
  5792. }
  5793. if (unlikely(kw_args > 0)) {
  5794. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "destroy") < 0)) __PYX_ERR(0, 307, __pyx_L3_error)
  5795. }
  5796. } else {
  5797. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5798. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5799. CYTHON_FALLTHROUGH;
  5800. case 0: break;
  5801. default: goto __pyx_L5_argtuple_error;
  5802. }
  5803. }
  5804. __pyx_v__path = values[0];
  5805. }
  5806. goto __pyx_L4_argument_unpacking_done;
  5807. __pyx_L5_argtuple_error:;
  5808. __Pyx_RaiseArgtupleInvalid("destroy", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 307, __pyx_L3_error)
  5809. __pyx_L3_error:;
  5810. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5811. __Pyx_RefNannyFinishContext();
  5812. return NULL;
  5813. __pyx_L4_argument_unpacking_done:;
  5814. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8destroy(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), __pyx_v__path);
  5815. /* function exit code */
  5816. __Pyx_RefNannyFinishContext();
  5817. return __pyx_r;
  5818. }
  5819. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8destroy(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v__path) {
  5820. PyObject *__pyx_r = NULL;
  5821. __Pyx_TraceDeclarations
  5822. __Pyx_RefNannyDeclarations
  5823. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy __pyx_t_1;
  5824. PyObject *__pyx_t_2 = NULL;
  5825. __Pyx_RefNannySetupContext("destroy", 0);
  5826. __Pyx_TraceCall("destroy (wrapper)", __pyx_f[0], 307, 0, __PYX_ERR(0, 307, __pyx_L1_error));
  5827. __Pyx_XDECREF(__pyx_r);
  5828. __pyx_t_1.__pyx_n = 1;
  5829. __pyx_t_1._path = __pyx_v__path;
  5830. __pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore->destroy(__pyx_v_self, 1, &__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 307, __pyx_L1_error)
  5831. __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
  5832. __Pyx_GOTREF(__pyx_t_2);
  5833. __pyx_r = __pyx_t_2;
  5834. __pyx_t_2 = 0;
  5835. goto __pyx_L0;
  5836. /* function exit code */
  5837. __pyx_L1_error:;
  5838. __Pyx_XDECREF(__pyx_t_2);
  5839. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5840. __pyx_r = NULL;
  5841. __pyx_L0:;
  5842. __Pyx_XGIVEREF(__pyx_r);
  5843. __Pyx_TraceReturn(__pyx_r, 0);
  5844. __Pyx_RefNannyFinishContext();
  5845. return __pyx_r;
  5846. }
  5847. static PyObject *__pyx_gb_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_12generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
  5848. /* "lakesuperior/store/base_lmdb_store.pyx":334
  5849. *
  5850. * @contextmanager
  5851. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  5852. * """
  5853. * Transaction context manager.
  5854. */
  5855. /* Python wrapper */
  5856. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11txn_ctx(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5857. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_10txn_ctx[] = "\n Transaction context manager.\n\n :param bool write: Whether a write transaction is to be opened.\n\n :rtype: lmdb.Transaction\n ";
  5858. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11txn_ctx(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5859. PyObject *__pyx_v_write = 0;
  5860. PyObject *__pyx_r = 0;
  5861. __Pyx_RefNannyDeclarations
  5862. __Pyx_RefNannySetupContext("txn_ctx (wrapper)", 0);
  5863. {
  5864. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_write,0};
  5865. PyObject* values[1] = {0};
  5866. values[0] = ((PyObject *)Py_False);
  5867. if (unlikely(__pyx_kwds)) {
  5868. Py_ssize_t kw_args;
  5869. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5870. switch (pos_args) {
  5871. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5872. CYTHON_FALLTHROUGH;
  5873. case 0: break;
  5874. default: goto __pyx_L5_argtuple_error;
  5875. }
  5876. kw_args = PyDict_Size(__pyx_kwds);
  5877. switch (pos_args) {
  5878. case 0:
  5879. if (kw_args > 0) {
  5880. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_write);
  5881. if (value) { values[0] = value; kw_args--; }
  5882. }
  5883. }
  5884. if (unlikely(kw_args > 0)) {
  5885. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "txn_ctx") < 0)) __PYX_ERR(0, 334, __pyx_L3_error)
  5886. }
  5887. } else {
  5888. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5889. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5890. CYTHON_FALLTHROUGH;
  5891. case 0: break;
  5892. default: goto __pyx_L5_argtuple_error;
  5893. }
  5894. }
  5895. __pyx_v_write = values[0];
  5896. }
  5897. goto __pyx_L4_argument_unpacking_done;
  5898. __pyx_L5_argtuple_error:;
  5899. __Pyx_RaiseArgtupleInvalid("txn_ctx", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 334, __pyx_L3_error)
  5900. __pyx_L3_error:;
  5901. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5902. __Pyx_RefNannyFinishContext();
  5903. return NULL;
  5904. __pyx_L4_argument_unpacking_done:;
  5905. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_10txn_ctx(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), __pyx_v_write);
  5906. /* function exit code */
  5907. __Pyx_RefNannyFinishContext();
  5908. return __pyx_r;
  5909. }
  5910. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_10txn_ctx(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_write) {
  5911. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *__pyx_cur_scope;
  5912. PyObject *__pyx_r = NULL;
  5913. __Pyx_RefNannyDeclarations
  5914. __Pyx_RefNannySetupContext("txn_ctx", 0);
  5915. __pyx_cur_scope = (struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *)__pyx_tp_new_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx, __pyx_empty_tuple, NULL);
  5916. if (unlikely(!__pyx_cur_scope)) {
  5917. __pyx_cur_scope = ((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *)Py_None);
  5918. __Pyx_INCREF(Py_None);
  5919. __PYX_ERR(0, 334, __pyx_L1_error)
  5920. } else {
  5921. __Pyx_GOTREF(__pyx_cur_scope);
  5922. }
  5923. __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  5924. __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  5925. __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  5926. __pyx_cur_scope->__pyx_v_write = __pyx_v_write;
  5927. __Pyx_INCREF(__pyx_cur_scope->__pyx_v_write);
  5928. __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_write);
  5929. {
  5930. __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_12generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_txn_ctx, __pyx_n_s_BaseLmdbStore_txn_ctx, __pyx_n_s_lakesuperior_store_base_lmdb_sto); if (unlikely(!gen)) __PYX_ERR(0, 334, __pyx_L1_error)
  5931. __Pyx_DECREF(__pyx_cur_scope);
  5932. __Pyx_RefNannyFinishContext();
  5933. return (PyObject *) gen;
  5934. }
  5935. /* function exit code */
  5936. __pyx_L1_error:;
  5937. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5938. __pyx_r = NULL;
  5939. __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  5940. __Pyx_XGIVEREF(__pyx_r);
  5941. __Pyx_RefNannyFinishContext();
  5942. return __pyx_r;
  5943. }
  5944. static PyObject *__pyx_gb_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_12generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
  5945. {
  5946. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *__pyx_cur_scope = ((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *)__pyx_generator->closure);
  5947. PyObject *__pyx_r = NULL;
  5948. __Pyx_TraceDeclarations
  5949. PyObject *__pyx_t_1 = NULL;
  5950. int __pyx_t_2;
  5951. int __pyx_t_3;
  5952. PyObject *__pyx_t_4 = NULL;
  5953. PyObject *__pyx_t_5 = NULL;
  5954. PyObject *__pyx_t_6 = NULL;
  5955. PyObject *__pyx_t_7 = NULL;
  5956. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin __pyx_t_8;
  5957. PyObject *__pyx_t_9 = NULL;
  5958. __Pyx_RefNannyDeclarations
  5959. __Pyx_RefNannySetupContext("txn_ctx", 0);
  5960. __Pyx_TraceCall("txn_ctx", __pyx_f[0], 334, 0, __PYX_ERR(0, 334, __pyx_L1_error));
  5961. switch (__pyx_generator->resume_label) {
  5962. case 0: goto __pyx_L3_first_run;
  5963. case 1: goto __pyx_L6_resume_from_yield;
  5964. case 2: goto __pyx_L13_resume_from_yield;
  5965. default: /* CPython raises the right error here */
  5966. __Pyx_TraceReturn(Py_None, 0);
  5967. __Pyx_RefNannyFinishContext();
  5968. return NULL;
  5969. }
  5970. __pyx_L3_first_run:;
  5971. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 334, __pyx_L1_error)
  5972. /* "lakesuperior/store/base_lmdb_store.pyx":342
  5973. * :rtype: lmdb.Transaction
  5974. * """
  5975. * if not self.is_open: # <<<<<<<<<<<<<<
  5976. * raise LmdbError('Store is not open.')
  5977. *
  5978. */
  5979. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L1_error)
  5980. __Pyx_GOTREF(__pyx_t_1);
  5981. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 342, __pyx_L1_error)
  5982. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5983. __pyx_t_3 = ((!__pyx_t_2) != 0);
  5984. if (unlikely(__pyx_t_3)) {
  5985. /* "lakesuperior/store/base_lmdb_store.pyx":343
  5986. * """
  5987. * if not self.is_open:
  5988. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  5989. *
  5990. * if self.is_txn_open:
  5991. */
  5992. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
  5993. __Pyx_GOTREF(__pyx_t_1);
  5994. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 343, __pyx_L1_error)
  5995. __Pyx_GOTREF(__pyx_t_4);
  5996. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5997. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  5998. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5999. __PYX_ERR(0, 343, __pyx_L1_error)
  6000. /* "lakesuperior/store/base_lmdb_store.pyx":342
  6001. * :rtype: lmdb.Transaction
  6002. * """
  6003. * if not self.is_open: # <<<<<<<<<<<<<<
  6004. * raise LmdbError('Store is not open.')
  6005. *
  6006. */
  6007. }
  6008. /* "lakesuperior/store/base_lmdb_store.pyx":345
  6009. * raise LmdbError('Store is not open.')
  6010. *
  6011. * if self.is_txn_open: # <<<<<<<<<<<<<<
  6012. * logger.debug(
  6013. * 'Transaction is already active. Not opening another one.')
  6014. */
  6015. __pyx_t_3 = (__pyx_cur_scope->__pyx_v_self->is_txn_open != 0);
  6016. if (__pyx_t_3) {
  6017. /* "lakesuperior/store/base_lmdb_store.pyx":346
  6018. *
  6019. * if self.is_txn_open:
  6020. * logger.debug( # <<<<<<<<<<<<<<
  6021. * 'Transaction is already active. Not opening another one.')
  6022. * #logger.debug('before yield')
  6023. */
  6024. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 346, __pyx_L1_error)
  6025. __Pyx_GOTREF(__pyx_t_4);
  6026. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_debug); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error)
  6027. __Pyx_GOTREF(__pyx_t_1);
  6028. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6029. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 346, __pyx_L1_error)
  6030. __Pyx_GOTREF(__pyx_t_4);
  6031. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6032. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6033. /* "lakesuperior/store/base_lmdb_store.pyx":349
  6034. * 'Transaction is already active. Not opening another one.')
  6035. * #logger.debug('before yield')
  6036. * yield # <<<<<<<<<<<<<<
  6037. * #logger.debug('after yield')
  6038. * else:
  6039. */
  6040. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6041. __Pyx_XGIVEREF(__pyx_r);
  6042. __Pyx_TraceReturn(__pyx_r, 0);
  6043. __Pyx_RefNannyFinishContext();
  6044. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  6045. /* return from generator, yielding value */
  6046. __pyx_generator->resume_label = 1;
  6047. return __pyx_r;
  6048. __pyx_L6_resume_from_yield:;
  6049. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 349, __pyx_L1_error)
  6050. /* "lakesuperior/store/base_lmdb_store.pyx":345
  6051. * raise LmdbError('Store is not open.')
  6052. *
  6053. * if self.is_txn_open: # <<<<<<<<<<<<<<
  6054. * logger.debug(
  6055. * 'Transaction is already active. Not opening another one.')
  6056. */
  6057. goto __pyx_L5;
  6058. }
  6059. /* "lakesuperior/store/base_lmdb_store.pyx":354
  6060. * #logger.debug('Beginning {} transaction.'.format(
  6061. * # 'RW' if write else 'RO'))
  6062. * try: # <<<<<<<<<<<<<<
  6063. * self._txn_begin(write=write)
  6064. * self.is_txn_rw = write
  6065. */
  6066. /*else*/ {
  6067. {
  6068. __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
  6069. __Pyx_XGOTREF(__pyx_t_5);
  6070. __Pyx_XGOTREF(__pyx_t_6);
  6071. __Pyx_XGOTREF(__pyx_t_7);
  6072. /*try:*/ {
  6073. /* "lakesuperior/store/base_lmdb_store.pyx":355
  6074. * # 'RW' if write else 'RO'))
  6075. * try:
  6076. * self._txn_begin(write=write) # <<<<<<<<<<<<<<
  6077. * self.is_txn_rw = write
  6078. * #logger.debug('In txn_ctx, before yield')
  6079. */
  6080. __pyx_t_8.__pyx_n = 1;
  6081. __pyx_t_8.write = __pyx_cur_scope->__pyx_v_write;
  6082. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->_txn_begin(__pyx_cur_scope->__pyx_v_self, &__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 355, __pyx_L7_error)
  6083. /* "lakesuperior/store/base_lmdb_store.pyx":356
  6084. * try:
  6085. * self._txn_begin(write=write)
  6086. * self.is_txn_rw = write # <<<<<<<<<<<<<<
  6087. * #logger.debug('In txn_ctx, before yield')
  6088. * yield
  6089. */
  6090. if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_is_txn_rw, __pyx_cur_scope->__pyx_v_write) < 0) __PYX_ERR(0, 356, __pyx_L7_error)
  6091. /* "lakesuperior/store/base_lmdb_store.pyx":358
  6092. * self.is_txn_rw = write
  6093. * #logger.debug('In txn_ctx, before yield')
  6094. * yield # <<<<<<<<<<<<<<
  6095. * #logger.debug('In txn_ctx, after yield')
  6096. * self._txn_commit()
  6097. */
  6098. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6099. __Pyx_XGIVEREF(__pyx_t_5);
  6100. __pyx_cur_scope->__pyx_t_0 = __pyx_t_5;
  6101. __Pyx_XGIVEREF(__pyx_t_6);
  6102. __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
  6103. __Pyx_XGIVEREF(__pyx_t_7);
  6104. __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
  6105. __Pyx_XGIVEREF(__pyx_r);
  6106. __Pyx_TraceReturn(__pyx_r, 0);
  6107. __Pyx_RefNannyFinishContext();
  6108. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  6109. /* return from generator, yielding value */
  6110. __pyx_generator->resume_label = 2;
  6111. return __pyx_r;
  6112. __pyx_L13_resume_from_yield:;
  6113. __pyx_t_5 = __pyx_cur_scope->__pyx_t_0;
  6114. __pyx_cur_scope->__pyx_t_0 = 0;
  6115. __Pyx_XGOTREF(__pyx_t_5);
  6116. __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
  6117. __pyx_cur_scope->__pyx_t_1 = 0;
  6118. __Pyx_XGOTREF(__pyx_t_6);
  6119. __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
  6120. __pyx_cur_scope->__pyx_t_2 = 0;
  6121. __Pyx_XGOTREF(__pyx_t_7);
  6122. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 358, __pyx_L7_error)
  6123. /* "lakesuperior/store/base_lmdb_store.pyx":360
  6124. * yield
  6125. * #logger.debug('In txn_ctx, after yield')
  6126. * self._txn_commit() # <<<<<<<<<<<<<<
  6127. * #logger.debug('after _txn_commit')
  6128. * except:
  6129. */
  6130. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->_txn_commit(__pyx_cur_scope->__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 360, __pyx_L7_error)
  6131. /* "lakesuperior/store/base_lmdb_store.pyx":354
  6132. * #logger.debug('Beginning {} transaction.'.format(
  6133. * # 'RW' if write else 'RO'))
  6134. * try: # <<<<<<<<<<<<<<
  6135. * self._txn_begin(write=write)
  6136. * self.is_txn_rw = write
  6137. */
  6138. }
  6139. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6140. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6141. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6142. goto __pyx_L12_try_end;
  6143. __pyx_L7_error:;
  6144. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  6145. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  6146. /* "lakesuperior/store/base_lmdb_store.pyx":362
  6147. * self._txn_commit()
  6148. * #logger.debug('after _txn_commit')
  6149. * except: # <<<<<<<<<<<<<<
  6150. * self._txn_abort()
  6151. * raise
  6152. */
  6153. /*except:*/ {
  6154. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6155. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_9) < 0) __PYX_ERR(0, 362, __pyx_L9_except_error)
  6156. __Pyx_GOTREF(__pyx_t_4);
  6157. __Pyx_GOTREF(__pyx_t_1);
  6158. __Pyx_GOTREF(__pyx_t_9);
  6159. /* "lakesuperior/store/base_lmdb_store.pyx":363
  6160. * #logger.debug('after _txn_commit')
  6161. * except:
  6162. * self._txn_abort() # <<<<<<<<<<<<<<
  6163. * raise
  6164. *
  6165. */
  6166. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->_txn_abort(__pyx_cur_scope->__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 363, __pyx_L9_except_error)
  6167. /* "lakesuperior/store/base_lmdb_store.pyx":364
  6168. * except:
  6169. * self._txn_abort()
  6170. * raise # <<<<<<<<<<<<<<
  6171. *
  6172. *
  6173. */
  6174. __Pyx_GIVEREF(__pyx_t_4);
  6175. __Pyx_GIVEREF(__pyx_t_1);
  6176. __Pyx_XGIVEREF(__pyx_t_9);
  6177. __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_1, __pyx_t_9);
  6178. __pyx_t_4 = 0; __pyx_t_1 = 0; __pyx_t_9 = 0;
  6179. __PYX_ERR(0, 364, __pyx_L9_except_error)
  6180. }
  6181. __pyx_L9_except_error:;
  6182. /* "lakesuperior/store/base_lmdb_store.pyx":354
  6183. * #logger.debug('Beginning {} transaction.'.format(
  6184. * # 'RW' if write else 'RO'))
  6185. * try: # <<<<<<<<<<<<<<
  6186. * self._txn_begin(write=write)
  6187. * self.is_txn_rw = write
  6188. */
  6189. __Pyx_XGIVEREF(__pyx_t_5);
  6190. __Pyx_XGIVEREF(__pyx_t_6);
  6191. __Pyx_XGIVEREF(__pyx_t_7);
  6192. __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
  6193. goto __pyx_L1_error;
  6194. __pyx_L12_try_end:;
  6195. }
  6196. }
  6197. __pyx_L5:;
  6198. CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
  6199. /* "lakesuperior/store/base_lmdb_store.pyx":334
  6200. *
  6201. * @contextmanager
  6202. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  6203. * """
  6204. * Transaction context manager.
  6205. */
  6206. /* function exit code */
  6207. PyErr_SetNone(PyExc_StopIteration);
  6208. goto __pyx_L0;
  6209. __pyx_L1_error:;
  6210. __Pyx_XDECREF(__pyx_t_1);
  6211. __Pyx_XDECREF(__pyx_t_4);
  6212. __Pyx_XDECREF(__pyx_t_9);
  6213. __Pyx_AddTraceback("txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6214. __pyx_L0:;
  6215. __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  6216. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  6217. __pyx_generator->resume_label = -1;
  6218. __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  6219. __Pyx_TraceReturn(__pyx_r, 0);
  6220. __Pyx_RefNannyFinishContext();
  6221. return __pyx_r;
  6222. }
  6223. /* "lakesuperior/store/base_lmdb_store.pyx":367
  6224. *
  6225. *
  6226. * def begin(self, write=False): # <<<<<<<<<<<<<<
  6227. * """
  6228. * Begin a transaction manually if not already in a txn context.
  6229. */
  6230. /* Python wrapper */
  6231. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_14begin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6232. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_13begin[] = "\n Begin a transaction manually if not already in a txn context.\n\n The :py:meth:`txn_ctx` context manager should be used whenever\n possible rather than this method.\n ";
  6233. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_14begin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6234. PyObject *__pyx_v_write = 0;
  6235. PyObject *__pyx_r = 0;
  6236. __Pyx_RefNannyDeclarations
  6237. __Pyx_RefNannySetupContext("begin (wrapper)", 0);
  6238. {
  6239. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_write,0};
  6240. PyObject* values[1] = {0};
  6241. values[0] = ((PyObject *)Py_False);
  6242. if (unlikely(__pyx_kwds)) {
  6243. Py_ssize_t kw_args;
  6244. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6245. switch (pos_args) {
  6246. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6247. CYTHON_FALLTHROUGH;
  6248. case 0: break;
  6249. default: goto __pyx_L5_argtuple_error;
  6250. }
  6251. kw_args = PyDict_Size(__pyx_kwds);
  6252. switch (pos_args) {
  6253. case 0:
  6254. if (kw_args > 0) {
  6255. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_write);
  6256. if (value) { values[0] = value; kw_args--; }
  6257. }
  6258. }
  6259. if (unlikely(kw_args > 0)) {
  6260. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "begin") < 0)) __PYX_ERR(0, 367, __pyx_L3_error)
  6261. }
  6262. } else {
  6263. switch (PyTuple_GET_SIZE(__pyx_args)) {
  6264. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6265. CYTHON_FALLTHROUGH;
  6266. case 0: break;
  6267. default: goto __pyx_L5_argtuple_error;
  6268. }
  6269. }
  6270. __pyx_v_write = values[0];
  6271. }
  6272. goto __pyx_L4_argument_unpacking_done;
  6273. __pyx_L5_argtuple_error:;
  6274. __Pyx_RaiseArgtupleInvalid("begin", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 367, __pyx_L3_error)
  6275. __pyx_L3_error:;
  6276. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.begin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6277. __Pyx_RefNannyFinishContext();
  6278. return NULL;
  6279. __pyx_L4_argument_unpacking_done:;
  6280. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_13begin(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), __pyx_v_write);
  6281. /* function exit code */
  6282. __Pyx_RefNannyFinishContext();
  6283. return __pyx_r;
  6284. }
  6285. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_13begin(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_write) {
  6286. PyObject *__pyx_r = NULL;
  6287. __Pyx_TraceDeclarations
  6288. __Pyx_RefNannyDeclarations
  6289. PyObject *__pyx_t_1 = NULL;
  6290. int __pyx_t_2;
  6291. int __pyx_t_3;
  6292. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin __pyx_t_4;
  6293. __Pyx_RefNannySetupContext("begin", 0);
  6294. __Pyx_TraceCall("begin", __pyx_f[0], 367, 0, __PYX_ERR(0, 367, __pyx_L1_error));
  6295. /* "lakesuperior/store/base_lmdb_store.pyx":374
  6296. * possible rather than this method.
  6297. * """
  6298. * if not self.is_open: # <<<<<<<<<<<<<<
  6299. * raise RuntimeError('Store must be opened first.')
  6300. * #logger.debug('Beginning a {} transaction.'.format(
  6301. */
  6302. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error)
  6303. __Pyx_GOTREF(__pyx_t_1);
  6304. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 374, __pyx_L1_error)
  6305. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6306. __pyx_t_3 = ((!__pyx_t_2) != 0);
  6307. if (unlikely(__pyx_t_3)) {
  6308. /* "lakesuperior/store/base_lmdb_store.pyx":375
  6309. * """
  6310. * if not self.is_open:
  6311. * raise RuntimeError('Store must be opened first.') # <<<<<<<<<<<<<<
  6312. * #logger.debug('Beginning a {} transaction.'.format(
  6313. * # 'read/write' if write else 'read-only'))
  6314. */
  6315. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error)
  6316. __Pyx_GOTREF(__pyx_t_1);
  6317. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  6318. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6319. __PYX_ERR(0, 375, __pyx_L1_error)
  6320. /* "lakesuperior/store/base_lmdb_store.pyx":374
  6321. * possible rather than this method.
  6322. * """
  6323. * if not self.is_open: # <<<<<<<<<<<<<<
  6324. * raise RuntimeError('Store must be opened first.')
  6325. * #logger.debug('Beginning a {} transaction.'.format(
  6326. */
  6327. }
  6328. /* "lakesuperior/store/base_lmdb_store.pyx":379
  6329. * # 'read/write' if write else 'read-only'))
  6330. *
  6331. * self._txn_begin(write=write) # <<<<<<<<<<<<<<
  6332. *
  6333. *
  6334. */
  6335. __pyx_t_4.__pyx_n = 1;
  6336. __pyx_t_4.write = __pyx_v_write;
  6337. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_txn_begin(__pyx_v_self, &__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 379, __pyx_L1_error)
  6338. /* "lakesuperior/store/base_lmdb_store.pyx":367
  6339. *
  6340. *
  6341. * def begin(self, write=False): # <<<<<<<<<<<<<<
  6342. * """
  6343. * Begin a transaction manually if not already in a txn context.
  6344. */
  6345. /* function exit code */
  6346. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6347. goto __pyx_L0;
  6348. __pyx_L1_error:;
  6349. __Pyx_XDECREF(__pyx_t_1);
  6350. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.begin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6351. __pyx_r = NULL;
  6352. __pyx_L0:;
  6353. __Pyx_XGIVEREF(__pyx_r);
  6354. __Pyx_TraceReturn(__pyx_r, 0);
  6355. __Pyx_RefNannyFinishContext();
  6356. return __pyx_r;
  6357. }
  6358. /* "lakesuperior/store/base_lmdb_store.pyx":382
  6359. *
  6360. *
  6361. * def commit(self): # <<<<<<<<<<<<<<
  6362. * """Commit main transaction."""
  6363. * #logger.debug('Committing transaction.')
  6364. */
  6365. /* Python wrapper */
  6366. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_16commit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6367. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit[] = "Commit main transaction.";
  6368. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_16commit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  6369. PyObject *__pyx_r = 0;
  6370. __Pyx_RefNannyDeclarations
  6371. __Pyx_RefNannySetupContext("commit (wrapper)", 0);
  6372. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  6373. /* function exit code */
  6374. __Pyx_RefNannyFinishContext();
  6375. return __pyx_r;
  6376. }
  6377. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  6378. PyObject *__pyx_r = NULL;
  6379. __Pyx_TraceDeclarations
  6380. __Pyx_RefNannyDeclarations
  6381. __Pyx_RefNannySetupContext("commit", 0);
  6382. __Pyx_TraceCall("commit", __pyx_f[0], 382, 0, __PYX_ERR(0, 382, __pyx_L1_error));
  6383. /* "lakesuperior/store/base_lmdb_store.pyx":385
  6384. * """Commit main transaction."""
  6385. * #logger.debug('Committing transaction.')
  6386. * self._txn_commit() # <<<<<<<<<<<<<<
  6387. *
  6388. *
  6389. */
  6390. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_txn_commit(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 385, __pyx_L1_error)
  6391. /* "lakesuperior/store/base_lmdb_store.pyx":382
  6392. *
  6393. *
  6394. * def commit(self): # <<<<<<<<<<<<<<
  6395. * """Commit main transaction."""
  6396. * #logger.debug('Committing transaction.')
  6397. */
  6398. /* function exit code */
  6399. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6400. goto __pyx_L0;
  6401. __pyx_L1_error:;
  6402. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.commit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6403. __pyx_r = NULL;
  6404. __pyx_L0:;
  6405. __Pyx_XGIVEREF(__pyx_r);
  6406. __Pyx_TraceReturn(__pyx_r, 0);
  6407. __Pyx_RefNannyFinishContext();
  6408. return __pyx_r;
  6409. }
  6410. /* "lakesuperior/store/base_lmdb_store.pyx":388
  6411. *
  6412. *
  6413. * def abort(self): # <<<<<<<<<<<<<<
  6414. * """Abort main transaction."""
  6415. * #logger.debug('Rolling back transaction.')
  6416. */
  6417. /* Python wrapper */
  6418. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_18abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6419. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort[] = "Abort main transaction.";
  6420. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_18abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  6421. PyObject *__pyx_r = 0;
  6422. __Pyx_RefNannyDeclarations
  6423. __Pyx_RefNannySetupContext("abort (wrapper)", 0);
  6424. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  6425. /* function exit code */
  6426. __Pyx_RefNannyFinishContext();
  6427. return __pyx_r;
  6428. }
  6429. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  6430. PyObject *__pyx_r = NULL;
  6431. __Pyx_TraceDeclarations
  6432. __Pyx_RefNannyDeclarations
  6433. __Pyx_RefNannySetupContext("abort", 0);
  6434. __Pyx_TraceCall("abort", __pyx_f[0], 388, 0, __PYX_ERR(0, 388, __pyx_L1_error));
  6435. /* "lakesuperior/store/base_lmdb_store.pyx":391
  6436. * """Abort main transaction."""
  6437. * #logger.debug('Rolling back transaction.')
  6438. * self._txn_abort() # <<<<<<<<<<<<<<
  6439. *
  6440. *
  6441. */
  6442. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_txn_abort(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 391, __pyx_L1_error)
  6443. /* "lakesuperior/store/base_lmdb_store.pyx":388
  6444. *
  6445. *
  6446. * def abort(self): # <<<<<<<<<<<<<<
  6447. * """Abort main transaction."""
  6448. * #logger.debug('Rolling back transaction.')
  6449. */
  6450. /* function exit code */
  6451. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6452. goto __pyx_L0;
  6453. __pyx_L1_error:;
  6454. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.abort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6455. __pyx_r = NULL;
  6456. __pyx_L0:;
  6457. __Pyx_XGIVEREF(__pyx_r);
  6458. __Pyx_TraceReturn(__pyx_r, 0);
  6459. __Pyx_RefNannyFinishContext();
  6460. return __pyx_r;
  6461. }
  6462. /* "lakesuperior/store/base_lmdb_store.pyx":394
  6463. *
  6464. *
  6465. * def rollback(self): # <<<<<<<<<<<<<<
  6466. * """Alias for :py:meth:`abort`"""
  6467. * self.abort()
  6468. */
  6469. /* Python wrapper */
  6470. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_20rollback(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6471. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback[] = "Alias for :py:meth:`abort`";
  6472. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_20rollback(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  6473. PyObject *__pyx_r = 0;
  6474. __Pyx_RefNannyDeclarations
  6475. __Pyx_RefNannySetupContext("rollback (wrapper)", 0);
  6476. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  6477. /* function exit code */
  6478. __Pyx_RefNannyFinishContext();
  6479. return __pyx_r;
  6480. }
  6481. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  6482. PyObject *__pyx_r = NULL;
  6483. __Pyx_TraceDeclarations
  6484. __Pyx_RefNannyDeclarations
  6485. PyObject *__pyx_t_1 = NULL;
  6486. PyObject *__pyx_t_2 = NULL;
  6487. PyObject *__pyx_t_3 = NULL;
  6488. __Pyx_RefNannySetupContext("rollback", 0);
  6489. __Pyx_TraceCall("rollback", __pyx_f[0], 394, 0, __PYX_ERR(0, 394, __pyx_L1_error));
  6490. /* "lakesuperior/store/base_lmdb_store.pyx":396
  6491. * def rollback(self):
  6492. * """Alias for :py:meth:`abort`"""
  6493. * self.abort() # <<<<<<<<<<<<<<
  6494. *
  6495. *
  6496. */
  6497. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_abort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 396, __pyx_L1_error)
  6498. __Pyx_GOTREF(__pyx_t_2);
  6499. __pyx_t_3 = NULL;
  6500. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6501. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  6502. if (likely(__pyx_t_3)) {
  6503. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6504. __Pyx_INCREF(__pyx_t_3);
  6505. __Pyx_INCREF(function);
  6506. __Pyx_DECREF_SET(__pyx_t_2, function);
  6507. }
  6508. }
  6509. if (__pyx_t_3) {
  6510. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  6511. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6512. } else {
  6513. __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  6514. }
  6515. __Pyx_GOTREF(__pyx_t_1);
  6516. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6517. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6518. /* "lakesuperior/store/base_lmdb_store.pyx":394
  6519. *
  6520. *
  6521. * def rollback(self): # <<<<<<<<<<<<<<
  6522. * """Alias for :py:meth:`abort`"""
  6523. * self.abort()
  6524. */
  6525. /* function exit code */
  6526. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6527. goto __pyx_L0;
  6528. __pyx_L1_error:;
  6529. __Pyx_XDECREF(__pyx_t_1);
  6530. __Pyx_XDECREF(__pyx_t_2);
  6531. __Pyx_XDECREF(__pyx_t_3);
  6532. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.rollback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6533. __pyx_r = NULL;
  6534. __pyx_L0:;
  6535. __Pyx_XGIVEREF(__pyx_r);
  6536. __Pyx_TraceReturn(__pyx_r, 0);
  6537. __Pyx_RefNannyFinishContext();
  6538. return __pyx_r;
  6539. }
  6540. /* "lakesuperior/store/base_lmdb_store.pyx":399
  6541. *
  6542. *
  6543. * def key_exists(self, key, dblabel='', new_txn=True): # <<<<<<<<<<<<<<
  6544. * """
  6545. * Return whether a key exists in a database (Python-facing method).
  6546. */
  6547. /* Python wrapper */
  6548. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_22key_exists(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6549. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_21key_exists[] = "\n Return whether a key exists in a database (Python-facing method).\n\n Wrap in a new transaction. Only use this if a transaction has not been\n opened.\n ";
  6550. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_22key_exists(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6551. PyObject *__pyx_v_key = 0;
  6552. PyObject *__pyx_v_dblabel = 0;
  6553. PyObject *__pyx_v_new_txn = 0;
  6554. PyObject *__pyx_r = 0;
  6555. __Pyx_RefNannyDeclarations
  6556. __Pyx_RefNannySetupContext("key_exists (wrapper)", 0);
  6557. {
  6558. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_dblabel,&__pyx_n_s_new_txn,0};
  6559. PyObject* values[3] = {0,0,0};
  6560. values[1] = ((PyObject *)__pyx_kp_u_);
  6561. values[2] = ((PyObject *)Py_True);
  6562. if (unlikely(__pyx_kwds)) {
  6563. Py_ssize_t kw_args;
  6564. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6565. switch (pos_args) {
  6566. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6567. CYTHON_FALLTHROUGH;
  6568. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6569. CYTHON_FALLTHROUGH;
  6570. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6571. CYTHON_FALLTHROUGH;
  6572. case 0: break;
  6573. default: goto __pyx_L5_argtuple_error;
  6574. }
  6575. kw_args = PyDict_Size(__pyx_kwds);
  6576. switch (pos_args) {
  6577. case 0:
  6578. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  6579. else goto __pyx_L5_argtuple_error;
  6580. CYTHON_FALLTHROUGH;
  6581. case 1:
  6582. if (kw_args > 0) {
  6583. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  6584. if (value) { values[1] = value; kw_args--; }
  6585. }
  6586. CYTHON_FALLTHROUGH;
  6587. case 2:
  6588. if (kw_args > 0) {
  6589. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_new_txn);
  6590. if (value) { values[2] = value; kw_args--; }
  6591. }
  6592. }
  6593. if (unlikely(kw_args > 0)) {
  6594. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "key_exists") < 0)) __PYX_ERR(0, 399, __pyx_L3_error)
  6595. }
  6596. } else {
  6597. switch (PyTuple_GET_SIZE(__pyx_args)) {
  6598. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6599. CYTHON_FALLTHROUGH;
  6600. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6601. CYTHON_FALLTHROUGH;
  6602. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6603. break;
  6604. default: goto __pyx_L5_argtuple_error;
  6605. }
  6606. }
  6607. __pyx_v_key = values[0];
  6608. __pyx_v_dblabel = values[1];
  6609. __pyx_v_new_txn = values[2];
  6610. }
  6611. goto __pyx_L4_argument_unpacking_done;
  6612. __pyx_L5_argtuple_error:;
  6613. __Pyx_RaiseArgtupleInvalid("key_exists", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 399, __pyx_L3_error)
  6614. __pyx_L3_error:;
  6615. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6616. __Pyx_RefNannyFinishContext();
  6617. return NULL;
  6618. __pyx_L4_argument_unpacking_done:;
  6619. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_21key_exists(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), __pyx_v_key, __pyx_v_dblabel, __pyx_v_new_txn);
  6620. /* function exit code */
  6621. __Pyx_RefNannyFinishContext();
  6622. return __pyx_r;
  6623. }
  6624. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_21key_exists(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_dblabel, PyObject *__pyx_v_new_txn) {
  6625. PyObject *__pyx_r = NULL;
  6626. __Pyx_TraceDeclarations
  6627. __Pyx_RefNannyDeclarations
  6628. int __pyx_t_1;
  6629. int __pyx_t_2;
  6630. PyObject *__pyx_t_3 = NULL;
  6631. PyObject *__pyx_t_4 = NULL;
  6632. PyObject *__pyx_t_5 = NULL;
  6633. PyObject *__pyx_t_6 = NULL;
  6634. PyObject *__pyx_t_7 = NULL;
  6635. PyObject *__pyx_t_8 = NULL;
  6636. PyObject *__pyx_t_9 = NULL;
  6637. PyObject *__pyx_t_10 = NULL;
  6638. unsigned char *__pyx_t_11;
  6639. Py_ssize_t __pyx_t_12;
  6640. unsigned char *__pyx_t_13;
  6641. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists __pyx_t_14;
  6642. PyObject *__pyx_t_15 = NULL;
  6643. __Pyx_RefNannySetupContext("key_exists", 0);
  6644. __Pyx_TraceCall("key_exists", __pyx_f[0], 399, 0, __PYX_ERR(0, 399, __pyx_L1_error));
  6645. /* "lakesuperior/store/base_lmdb_store.pyx":406
  6646. * opened.
  6647. * """
  6648. * if new_txn is True: # <<<<<<<<<<<<<<
  6649. * with self.txn_ctx():
  6650. * return self._key_exists(
  6651. */
  6652. __pyx_t_1 = (__pyx_v_new_txn == Py_True);
  6653. __pyx_t_2 = (__pyx_t_1 != 0);
  6654. if (__pyx_t_2) {
  6655. /* "lakesuperior/store/base_lmdb_store.pyx":407
  6656. * """
  6657. * if new_txn is True:
  6658. * with self.txn_ctx(): # <<<<<<<<<<<<<<
  6659. * return self._key_exists(
  6660. * key, len(key), dblabel=dblabel.encode())
  6661. */
  6662. /*with:*/ {
  6663. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_txn_ctx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 407, __pyx_L1_error)
  6664. __Pyx_GOTREF(__pyx_t_4);
  6665. __pyx_t_5 = NULL;
  6666. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  6667. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  6668. if (likely(__pyx_t_5)) {
  6669. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  6670. __Pyx_INCREF(__pyx_t_5);
  6671. __Pyx_INCREF(function);
  6672. __Pyx_DECREF_SET(__pyx_t_4, function);
  6673. }
  6674. }
  6675. if (__pyx_t_5) {
  6676. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error)
  6677. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6678. } else {
  6679. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error)
  6680. }
  6681. __Pyx_GOTREF(__pyx_t_3);
  6682. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6683. __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 407, __pyx_L1_error)
  6684. __Pyx_GOTREF(__pyx_t_6);
  6685. __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 407, __pyx_L4_error)
  6686. __Pyx_GOTREF(__pyx_t_5);
  6687. __pyx_t_7 = NULL;
  6688. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  6689. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  6690. if (likely(__pyx_t_7)) {
  6691. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  6692. __Pyx_INCREF(__pyx_t_7);
  6693. __Pyx_INCREF(function);
  6694. __Pyx_DECREF_SET(__pyx_t_5, function);
  6695. }
  6696. }
  6697. if (__pyx_t_7) {
  6698. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 407, __pyx_L4_error)
  6699. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6700. } else {
  6701. __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 407, __pyx_L4_error)
  6702. }
  6703. __Pyx_GOTREF(__pyx_t_4);
  6704. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6705. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6706. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6707. /*try:*/ {
  6708. {
  6709. __Pyx_PyThreadState_declare
  6710. __Pyx_PyThreadState_assign
  6711. __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
  6712. __Pyx_XGOTREF(__pyx_t_8);
  6713. __Pyx_XGOTREF(__pyx_t_9);
  6714. __Pyx_XGOTREF(__pyx_t_10);
  6715. /*try:*/ {
  6716. /* "lakesuperior/store/base_lmdb_store.pyx":408
  6717. * if new_txn is True:
  6718. * with self.txn_ctx():
  6719. * return self._key_exists( # <<<<<<<<<<<<<<
  6720. * key, len(key), dblabel=dblabel.encode())
  6721. * else:
  6722. */
  6723. __Pyx_XDECREF(__pyx_r);
  6724. /* "lakesuperior/store/base_lmdb_store.pyx":409
  6725. * with self.txn_ctx():
  6726. * return self._key_exists(
  6727. * key, len(key), dblabel=dblabel.encode()) # <<<<<<<<<<<<<<
  6728. * else:
  6729. * return self._key_exists(key, len(key), dblabel=dblabel.encode())
  6730. */
  6731. __pyx_t_11 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 409, __pyx_L8_error)
  6732. __pyx_t_12 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 409, __pyx_L8_error)
  6733. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_dblabel, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 409, __pyx_L8_error)
  6734. __Pyx_GOTREF(__pyx_t_4);
  6735. __pyx_t_5 = NULL;
  6736. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  6737. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  6738. if (likely(__pyx_t_5)) {
  6739. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  6740. __Pyx_INCREF(__pyx_t_5);
  6741. __Pyx_INCREF(function);
  6742. __Pyx_DECREF_SET(__pyx_t_4, function);
  6743. }
  6744. }
  6745. if (__pyx_t_5) {
  6746. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L8_error)
  6747. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6748. } else {
  6749. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L8_error)
  6750. }
  6751. __Pyx_GOTREF(__pyx_t_3);
  6752. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6753. __pyx_t_13 = __Pyx_PyObject_AsWritableUString(__pyx_t_3); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 409, __pyx_L8_error)
  6754. /* "lakesuperior/store/base_lmdb_store.pyx":408
  6755. * if new_txn is True:
  6756. * with self.txn_ctx():
  6757. * return self._key_exists( # <<<<<<<<<<<<<<
  6758. * key, len(key), dblabel=dblabel.encode())
  6759. * else:
  6760. */
  6761. __pyx_t_14.__pyx_n = 1;
  6762. __pyx_t_14.dblabel = __pyx_t_13;
  6763. __pyx_t_2 = __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists(__pyx_v_self, __pyx_t_11, __pyx_t_12, &__pyx_t_14); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 408, __pyx_L8_error)
  6764. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6765. __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 408, __pyx_L8_error)
  6766. __Pyx_GOTREF(__pyx_t_3);
  6767. __pyx_r = __pyx_t_3;
  6768. __pyx_t_3 = 0;
  6769. goto __pyx_L12_try_return;
  6770. /* "lakesuperior/store/base_lmdb_store.pyx":407
  6771. * """
  6772. * if new_txn is True:
  6773. * with self.txn_ctx(): # <<<<<<<<<<<<<<
  6774. * return self._key_exists(
  6775. * key, len(key), dblabel=dblabel.encode())
  6776. */
  6777. }
  6778. __pyx_L8_error:;
  6779. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6780. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6781. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  6782. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6783. /*except:*/ {
  6784. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6785. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5) < 0) __PYX_ERR(0, 407, __pyx_L10_except_error)
  6786. __Pyx_GOTREF(__pyx_t_3);
  6787. __Pyx_GOTREF(__pyx_t_4);
  6788. __Pyx_GOTREF(__pyx_t_5);
  6789. __pyx_t_7 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 407, __pyx_L10_except_error)
  6790. __Pyx_GOTREF(__pyx_t_7);
  6791. __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL);
  6792. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6793. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6794. if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 407, __pyx_L10_except_error)
  6795. __Pyx_GOTREF(__pyx_t_15);
  6796. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_15);
  6797. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  6798. if (__pyx_t_2 < 0) __PYX_ERR(0, 407, __pyx_L10_except_error)
  6799. __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
  6800. if (__pyx_t_1) {
  6801. __Pyx_GIVEREF(__pyx_t_3);
  6802. __Pyx_GIVEREF(__pyx_t_4);
  6803. __Pyx_XGIVEREF(__pyx_t_5);
  6804. __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_4, __pyx_t_5);
  6805. __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0;
  6806. __PYX_ERR(0, 407, __pyx_L10_except_error)
  6807. }
  6808. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6809. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6810. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6811. goto __pyx_L9_exception_handled;
  6812. }
  6813. __pyx_L10_except_error:;
  6814. __Pyx_XGIVEREF(__pyx_t_8);
  6815. __Pyx_XGIVEREF(__pyx_t_9);
  6816. __Pyx_XGIVEREF(__pyx_t_10);
  6817. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  6818. goto __pyx_L1_error;
  6819. __pyx_L12_try_return:;
  6820. __Pyx_XGIVEREF(__pyx_t_8);
  6821. __Pyx_XGIVEREF(__pyx_t_9);
  6822. __Pyx_XGIVEREF(__pyx_t_10);
  6823. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  6824. goto __pyx_L5_return;
  6825. __pyx_L9_exception_handled:;
  6826. __Pyx_XGIVEREF(__pyx_t_8);
  6827. __Pyx_XGIVEREF(__pyx_t_9);
  6828. __Pyx_XGIVEREF(__pyx_t_10);
  6829. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  6830. }
  6831. }
  6832. /*finally:*/ {
  6833. /*normal exit:*/{
  6834. if (__pyx_t_6) {
  6835. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__12, NULL);
  6836. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6837. if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 407, __pyx_L1_error)
  6838. __Pyx_GOTREF(__pyx_t_10);
  6839. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  6840. }
  6841. goto __pyx_L7;
  6842. }
  6843. __pyx_L5_return: {
  6844. __pyx_t_10 = __pyx_r;
  6845. __pyx_r = 0;
  6846. if (__pyx_t_6) {
  6847. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__13, NULL);
  6848. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6849. if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 407, __pyx_L1_error)
  6850. __Pyx_GOTREF(__pyx_t_9);
  6851. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6852. }
  6853. __pyx_r = __pyx_t_10;
  6854. __pyx_t_10 = 0;
  6855. goto __pyx_L0;
  6856. }
  6857. __pyx_L7:;
  6858. }
  6859. goto __pyx_L17;
  6860. __pyx_L4_error:;
  6861. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6862. goto __pyx_L1_error;
  6863. __pyx_L17:;
  6864. }
  6865. /* "lakesuperior/store/base_lmdb_store.pyx":406
  6866. * opened.
  6867. * """
  6868. * if new_txn is True: # <<<<<<<<<<<<<<
  6869. * with self.txn_ctx():
  6870. * return self._key_exists(
  6871. */
  6872. goto __pyx_L3;
  6873. }
  6874. /* "lakesuperior/store/base_lmdb_store.pyx":411
  6875. * key, len(key), dblabel=dblabel.encode())
  6876. * else:
  6877. * return self._key_exists(key, len(key), dblabel=dblabel.encode()) # <<<<<<<<<<<<<<
  6878. *
  6879. *
  6880. */
  6881. /*else*/ {
  6882. __Pyx_XDECREF(__pyx_r);
  6883. __pyx_t_13 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 411, __pyx_L1_error)
  6884. __pyx_t_12 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 411, __pyx_L1_error)
  6885. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_dblabel, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 411, __pyx_L1_error)
  6886. __Pyx_GOTREF(__pyx_t_4);
  6887. __pyx_t_3 = NULL;
  6888. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  6889. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
  6890. if (likely(__pyx_t_3)) {
  6891. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  6892. __Pyx_INCREF(__pyx_t_3);
  6893. __Pyx_INCREF(function);
  6894. __Pyx_DECREF_SET(__pyx_t_4, function);
  6895. }
  6896. }
  6897. if (__pyx_t_3) {
  6898. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 411, __pyx_L1_error)
  6899. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6900. } else {
  6901. __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 411, __pyx_L1_error)
  6902. }
  6903. __Pyx_GOTREF(__pyx_t_5);
  6904. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6905. __pyx_t_11 = __Pyx_PyObject_AsWritableUString(__pyx_t_5); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 411, __pyx_L1_error)
  6906. __pyx_t_14.__pyx_n = 1;
  6907. __pyx_t_14.dblabel = __pyx_t_11;
  6908. __pyx_t_1 = __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists(__pyx_v_self, __pyx_t_13, __pyx_t_12, &__pyx_t_14); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 411, __pyx_L1_error)
  6909. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6910. __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 411, __pyx_L1_error)
  6911. __Pyx_GOTREF(__pyx_t_5);
  6912. __pyx_r = __pyx_t_5;
  6913. __pyx_t_5 = 0;
  6914. goto __pyx_L0;
  6915. }
  6916. __pyx_L3:;
  6917. /* "lakesuperior/store/base_lmdb_store.pyx":399
  6918. *
  6919. *
  6920. * def key_exists(self, key, dblabel='', new_txn=True): # <<<<<<<<<<<<<<
  6921. * """
  6922. * Return whether a key exists in a database (Python-facing method).
  6923. */
  6924. /* function exit code */
  6925. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6926. goto __pyx_L0;
  6927. __pyx_L1_error:;
  6928. __Pyx_XDECREF(__pyx_t_3);
  6929. __Pyx_XDECREF(__pyx_t_4);
  6930. __Pyx_XDECREF(__pyx_t_5);
  6931. __Pyx_XDECREF(__pyx_t_7);
  6932. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6933. __pyx_r = NULL;
  6934. __pyx_L0:;
  6935. __Pyx_XGIVEREF(__pyx_r);
  6936. __Pyx_TraceReturn(__pyx_r, 0);
  6937. __Pyx_RefNannyFinishContext();
  6938. return __pyx_r;
  6939. }
  6940. /* "lakesuperior/store/base_lmdb_store.pyx":414
  6941. *
  6942. *
  6943. * cdef inline bint _key_exists( # <<<<<<<<<<<<<<
  6944. * self, unsigned char *key, unsigned char klen,
  6945. * unsigned char *dblabel=b'') except -1:
  6946. */
  6947. static CYTHON_INLINE int __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, unsigned char *__pyx_v_key, unsigned char __pyx_v_klen, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists *__pyx_optional_args) {
  6948. unsigned char *__pyx_v_dblabel = __pyx_k__14;
  6949. struct MDB_val __pyx_v_key_v;
  6950. struct MDB_val __pyx_v_data_v;
  6951. int __pyx_r;
  6952. __Pyx_TraceDeclarations
  6953. __Pyx_RefNannyDeclarations
  6954. PyObject *__pyx_t_1 = NULL;
  6955. PyObject *__pyx_t_2 = NULL;
  6956. PyObject *__pyx_t_3 = NULL;
  6957. MDB_dbi __pyx_t_4;
  6958. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_5;
  6959. PyObject *__pyx_t_6 = NULL;
  6960. PyObject *__pyx_t_7 = NULL;
  6961. PyObject *__pyx_t_8 = NULL;
  6962. PyObject *__pyx_t_9 = NULL;
  6963. int __pyx_t_10;
  6964. __Pyx_RefNannySetupContext("_key_exists", 0);
  6965. __Pyx_TraceCall("_key_exists", __pyx_f[0], 414, 0, __PYX_ERR(0, 414, __pyx_L1_error));
  6966. if (__pyx_optional_args) {
  6967. if (__pyx_optional_args->__pyx_n > 0) {
  6968. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  6969. }
  6970. }
  6971. /* "lakesuperior/store/base_lmdb_store.pyx":424
  6972. * cdef lmdb.MDB_val key_v, data_v
  6973. *
  6974. * key_v.mv_data = key # <<<<<<<<<<<<<<
  6975. * key_v.mv_size = klen
  6976. * #logger.debug(
  6977. */
  6978. __pyx_v_key_v.mv_data = __pyx_v_key;
  6979. /* "lakesuperior/store/base_lmdb_store.pyx":425
  6980. *
  6981. * key_v.mv_data = key
  6982. * key_v.mv_size = klen # <<<<<<<<<<<<<<
  6983. * #logger.debug(
  6984. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  6985. */
  6986. __pyx_v_key_v.mv_size = __pyx_v_klen;
  6987. /* "lakesuperior/store/base_lmdb_store.pyx":428
  6988. * #logger.debug(
  6989. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  6990. * try: # <<<<<<<<<<<<<<
  6991. * _check(lmdb.mdb_get(
  6992. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  6993. */
  6994. {
  6995. __Pyx_PyThreadState_declare
  6996. __Pyx_PyThreadState_assign
  6997. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  6998. __Pyx_XGOTREF(__pyx_t_1);
  6999. __Pyx_XGOTREF(__pyx_t_2);
  7000. __Pyx_XGOTREF(__pyx_t_3);
  7001. /*try:*/ {
  7002. /* "lakesuperior/store/base_lmdb_store.pyx":430
  7003. * try:
  7004. * _check(lmdb.mdb_get(
  7005. * self.txn, self.get_dbi(dblabel), &key_v, &data_v)) # <<<<<<<<<<<<<<
  7006. * except KeyNotFoundError:
  7007. * #logger.debug('...no.')
  7008. */
  7009. __pyx_t_5.__pyx_n = 1;
  7010. __pyx_t_5.dblabel = __pyx_v_dblabel;
  7011. __pyx_t_4 = ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->get_dbi(__pyx_v_self, &__pyx_t_5);
  7012. /* "lakesuperior/store/base_lmdb_store.pyx":429
  7013. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  7014. * try:
  7015. * _check(lmdb.mdb_get( # <<<<<<<<<<<<<<
  7016. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7017. * except KeyNotFoundError:
  7018. */
  7019. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_get(__pyx_v_self->txn, __pyx_t_4, (&__pyx_v_key_v), (&__pyx_v_data_v)), NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L3_error)
  7020. /* "lakesuperior/store/base_lmdb_store.pyx":428
  7021. * #logger.debug(
  7022. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  7023. * try: # <<<<<<<<<<<<<<
  7024. * _check(lmdb.mdb_get(
  7025. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7026. */
  7027. }
  7028. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  7029. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  7030. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7031. goto __pyx_L8_try_end;
  7032. __pyx_L3_error:;
  7033. /* "lakesuperior/store/base_lmdb_store.pyx":431
  7034. * _check(lmdb.mdb_get(
  7035. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7036. * except KeyNotFoundError: # <<<<<<<<<<<<<<
  7037. * #logger.debug('...no.')
  7038. * return False
  7039. */
  7040. __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
  7041. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 431, __pyx_L5_except_error)
  7042. __Pyx_GOTREF(__pyx_t_9);
  7043. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_6, __pyx_t_9);
  7044. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  7045. __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  7046. __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0;
  7047. if (__pyx_t_10) {
  7048. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7049. if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0) __PYX_ERR(0, 431, __pyx_L5_except_error)
  7050. __Pyx_GOTREF(__pyx_t_8);
  7051. __Pyx_GOTREF(__pyx_t_7);
  7052. __Pyx_GOTREF(__pyx_t_6);
  7053. /* "lakesuperior/store/base_lmdb_store.pyx":433
  7054. * except KeyNotFoundError:
  7055. * #logger.debug('...no.')
  7056. * return False # <<<<<<<<<<<<<<
  7057. * #logger.debug('...yes.')
  7058. * return True
  7059. */
  7060. __pyx_r = 0;
  7061. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7062. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7063. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7064. goto __pyx_L6_except_return;
  7065. }
  7066. goto __pyx_L5_except_error;
  7067. __pyx_L5_except_error:;
  7068. /* "lakesuperior/store/base_lmdb_store.pyx":428
  7069. * #logger.debug(
  7070. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  7071. * try: # <<<<<<<<<<<<<<
  7072. * _check(lmdb.mdb_get(
  7073. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7074. */
  7075. __Pyx_XGIVEREF(__pyx_t_1);
  7076. __Pyx_XGIVEREF(__pyx_t_2);
  7077. __Pyx_XGIVEREF(__pyx_t_3);
  7078. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7079. goto __pyx_L1_error;
  7080. __pyx_L6_except_return:;
  7081. __Pyx_XGIVEREF(__pyx_t_1);
  7082. __Pyx_XGIVEREF(__pyx_t_2);
  7083. __Pyx_XGIVEREF(__pyx_t_3);
  7084. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7085. goto __pyx_L0;
  7086. __pyx_L8_try_end:;
  7087. }
  7088. /* "lakesuperior/store/base_lmdb_store.pyx":435
  7089. * return False
  7090. * #logger.debug('...yes.')
  7091. * return True # <<<<<<<<<<<<<<
  7092. *
  7093. *
  7094. */
  7095. __pyx_r = 1;
  7096. goto __pyx_L0;
  7097. /* "lakesuperior/store/base_lmdb_store.pyx":414
  7098. *
  7099. *
  7100. * cdef inline bint _key_exists( # <<<<<<<<<<<<<<
  7101. * self, unsigned char *key, unsigned char klen,
  7102. * unsigned char *dblabel=b'') except -1:
  7103. */
  7104. /* function exit code */
  7105. __pyx_L1_error:;
  7106. __Pyx_XDECREF(__pyx_t_6);
  7107. __Pyx_XDECREF(__pyx_t_7);
  7108. __Pyx_XDECREF(__pyx_t_8);
  7109. __Pyx_XDECREF(__pyx_t_9);
  7110. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7111. __pyx_r = -1;
  7112. __pyx_L0:;
  7113. __Pyx_TraceReturn(Py_None, 0);
  7114. __Pyx_RefNannyFinishContext();
  7115. return __pyx_r;
  7116. }
  7117. /* "lakesuperior/store/base_lmdb_store.pyx":438
  7118. *
  7119. *
  7120. * def put(self, key, data, dblabel='', flags=0): # <<<<<<<<<<<<<<
  7121. * """
  7122. * Put one key/value pair (Python-facing method).
  7123. */
  7124. /* Python wrapper */
  7125. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_24put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7126. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_23put[] = "\n Put one key/value pair (Python-facing method).\n ";
  7127. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_24put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  7128. PyObject *__pyx_v_key = 0;
  7129. PyObject *__pyx_v_data = 0;
  7130. PyObject *__pyx_v_dblabel = 0;
  7131. PyObject *__pyx_v_flags = 0;
  7132. PyObject *__pyx_r = 0;
  7133. __Pyx_RefNannyDeclarations
  7134. __Pyx_RefNannySetupContext("put (wrapper)", 0);
  7135. {
  7136. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_data,&__pyx_n_s_dblabel,&__pyx_n_s_flags,0};
  7137. PyObject* values[4] = {0,0,0,0};
  7138. values[2] = ((PyObject *)__pyx_kp_u_);
  7139. values[3] = ((PyObject *)__pyx_int_0);
  7140. if (unlikely(__pyx_kwds)) {
  7141. Py_ssize_t kw_args;
  7142. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  7143. switch (pos_args) {
  7144. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  7145. CYTHON_FALLTHROUGH;
  7146. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  7147. CYTHON_FALLTHROUGH;
  7148. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7149. CYTHON_FALLTHROUGH;
  7150. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7151. CYTHON_FALLTHROUGH;
  7152. case 0: break;
  7153. default: goto __pyx_L5_argtuple_error;
  7154. }
  7155. kw_args = PyDict_Size(__pyx_kwds);
  7156. switch (pos_args) {
  7157. case 0:
  7158. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  7159. else goto __pyx_L5_argtuple_error;
  7160. CYTHON_FALLTHROUGH;
  7161. case 1:
  7162. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
  7163. else {
  7164. __Pyx_RaiseArgtupleInvalid("put", 0, 2, 4, 1); __PYX_ERR(0, 438, __pyx_L3_error)
  7165. }
  7166. CYTHON_FALLTHROUGH;
  7167. case 2:
  7168. if (kw_args > 0) {
  7169. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  7170. if (value) { values[2] = value; kw_args--; }
  7171. }
  7172. CYTHON_FALLTHROUGH;
  7173. case 3:
  7174. if (kw_args > 0) {
  7175. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags);
  7176. if (value) { values[3] = value; kw_args--; }
  7177. }
  7178. }
  7179. if (unlikely(kw_args > 0)) {
  7180. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "put") < 0)) __PYX_ERR(0, 438, __pyx_L3_error)
  7181. }
  7182. } else {
  7183. switch (PyTuple_GET_SIZE(__pyx_args)) {
  7184. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  7185. CYTHON_FALLTHROUGH;
  7186. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  7187. CYTHON_FALLTHROUGH;
  7188. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7189. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7190. break;
  7191. default: goto __pyx_L5_argtuple_error;
  7192. }
  7193. }
  7194. __pyx_v_key = values[0];
  7195. __pyx_v_data = values[1];
  7196. __pyx_v_dblabel = values[2];
  7197. __pyx_v_flags = values[3];
  7198. }
  7199. goto __pyx_L4_argument_unpacking_done;
  7200. __pyx_L5_argtuple_error:;
  7201. __Pyx_RaiseArgtupleInvalid("put", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 438, __pyx_L3_error)
  7202. __pyx_L3_error:;
  7203. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7204. __Pyx_RefNannyFinishContext();
  7205. return NULL;
  7206. __pyx_L4_argument_unpacking_done:;
  7207. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_23put(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), __pyx_v_key, __pyx_v_data, __pyx_v_dblabel, __pyx_v_flags);
  7208. /* function exit code */
  7209. __Pyx_RefNannyFinishContext();
  7210. return __pyx_r;
  7211. }
  7212. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_23put(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_data, PyObject *__pyx_v_dblabel, PyObject *__pyx_v_flags) {
  7213. PyObject *__pyx_r = NULL;
  7214. __Pyx_TraceDeclarations
  7215. __Pyx_RefNannyDeclarations
  7216. unsigned char *__pyx_t_1;
  7217. Py_ssize_t __pyx_t_2;
  7218. unsigned char *__pyx_t_3;
  7219. Py_ssize_t __pyx_t_4;
  7220. PyObject *__pyx_t_5 = NULL;
  7221. PyObject *__pyx_t_6 = NULL;
  7222. PyObject *__pyx_t_7 = NULL;
  7223. unsigned char *__pyx_t_8;
  7224. unsigned int __pyx_t_9;
  7225. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put __pyx_t_10;
  7226. __Pyx_RefNannySetupContext("put", 0);
  7227. __Pyx_TraceCall("put", __pyx_f[0], 438, 0, __PYX_ERR(0, 438, __pyx_L1_error));
  7228. /* "lakesuperior/store/base_lmdb_store.pyx":443
  7229. * """
  7230. * self._put(
  7231. * key, len(key), data, len(data), dblabel=dblabel.encode(), # <<<<<<<<<<<<<<
  7232. * txn=self.txn, flags=flags)
  7233. *
  7234. */
  7235. __pyx_t_1 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 443, __pyx_L1_error)
  7236. __pyx_t_2 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 443, __pyx_L1_error)
  7237. __pyx_t_3 = __Pyx_PyObject_AsWritableUString(__pyx_v_data); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 443, __pyx_L1_error)
  7238. __pyx_t_4 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 443, __pyx_L1_error)
  7239. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dblabel, __pyx_n_s_encode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 443, __pyx_L1_error)
  7240. __Pyx_GOTREF(__pyx_t_6);
  7241. __pyx_t_7 = NULL;
  7242. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  7243. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  7244. if (likely(__pyx_t_7)) {
  7245. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  7246. __Pyx_INCREF(__pyx_t_7);
  7247. __Pyx_INCREF(function);
  7248. __Pyx_DECREF_SET(__pyx_t_6, function);
  7249. }
  7250. }
  7251. if (__pyx_t_7) {
  7252. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 443, __pyx_L1_error)
  7253. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7254. } else {
  7255. __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 443, __pyx_L1_error)
  7256. }
  7257. __Pyx_GOTREF(__pyx_t_5);
  7258. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7259. __pyx_t_8 = __Pyx_PyObject_AsWritableUString(__pyx_t_5); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 443, __pyx_L1_error)
  7260. /* "lakesuperior/store/base_lmdb_store.pyx":444
  7261. * self._put(
  7262. * key, len(key), data, len(data), dblabel=dblabel.encode(),
  7263. * txn=self.txn, flags=flags) # <<<<<<<<<<<<<<
  7264. *
  7265. *
  7266. */
  7267. __pyx_t_9 = __Pyx_PyInt_As_unsigned_int(__pyx_v_flags); if (unlikely((__pyx_t_9 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 444, __pyx_L1_error)
  7268. /* "lakesuperior/store/base_lmdb_store.pyx":442
  7269. * Put one key/value pair (Python-facing method).
  7270. * """
  7271. * self._put( # <<<<<<<<<<<<<<
  7272. * key, len(key), data, len(data), dblabel=dblabel.encode(),
  7273. * txn=self.txn, flags=flags)
  7274. */
  7275. __pyx_t_10.__pyx_n = 3;
  7276. __pyx_t_10.dblabel = __pyx_t_8;
  7277. __pyx_t_10.txn = __pyx_v_self->txn;
  7278. __pyx_t_10.flags = __pyx_t_9;
  7279. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_put(__pyx_v_self, __pyx_t_1, __pyx_t_2, __pyx_t_3, __pyx_t_4, &__pyx_t_10); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 442, __pyx_L1_error)
  7280. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7281. /* "lakesuperior/store/base_lmdb_store.pyx":438
  7282. *
  7283. *
  7284. * def put(self, key, data, dblabel='', flags=0): # <<<<<<<<<<<<<<
  7285. * """
  7286. * Put one key/value pair (Python-facing method).
  7287. */
  7288. /* function exit code */
  7289. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7290. goto __pyx_L0;
  7291. __pyx_L1_error:;
  7292. __Pyx_XDECREF(__pyx_t_5);
  7293. __Pyx_XDECREF(__pyx_t_6);
  7294. __Pyx_XDECREF(__pyx_t_7);
  7295. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7296. __pyx_r = NULL;
  7297. __pyx_L0:;
  7298. __Pyx_XGIVEREF(__pyx_r);
  7299. __Pyx_TraceReturn(__pyx_r, 0);
  7300. __Pyx_RefNannyFinishContext();
  7301. return __pyx_r;
  7302. }
  7303. /* "lakesuperior/store/base_lmdb_store.pyx":447
  7304. *
  7305. *
  7306. * cdef void _put( # <<<<<<<<<<<<<<
  7307. * self, unsigned char *key, size_t key_size, unsigned char *data,
  7308. * size_t data_size, unsigned char *dblabel='',
  7309. */
  7310. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, unsigned char *__pyx_v_key, size_t __pyx_v_key_size, unsigned char *__pyx_v_data, size_t __pyx_v_data_size, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put *__pyx_optional_args) {
  7311. unsigned char *__pyx_v_dblabel = __pyx_k__15;
  7312. /* "lakesuperior/store/base_lmdb_store.pyx":450
  7313. * self, unsigned char *key, size_t key_size, unsigned char *data,
  7314. * size_t data_size, unsigned char *dblabel='',
  7315. * lmdb.MDB_txn *txn=NULL, unsigned int flags=0) except *: # <<<<<<<<<<<<<<
  7316. * """
  7317. * Put one key/value pair.
  7318. */
  7319. MDB_txn *__pyx_v_txn = ((MDB_txn *)NULL);
  7320. unsigned int __pyx_v_flags = ((unsigned int)0);
  7321. int __pyx_v_rc;
  7322. __Pyx_TraceDeclarations
  7323. __Pyx_RefNannyDeclarations
  7324. int __pyx_t_1;
  7325. MDB_txn *__pyx_t_2;
  7326. MDB_dbi __pyx_t_3;
  7327. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_4;
  7328. PyObject *__pyx_t_5 = NULL;
  7329. PyObject *__pyx_t_6 = NULL;
  7330. PyObject *__pyx_t_7 = NULL;
  7331. PyObject *__pyx_t_8 = NULL;
  7332. PyObject *__pyx_t_9 = NULL;
  7333. int __pyx_t_10;
  7334. PyObject *__pyx_t_11 = NULL;
  7335. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_12;
  7336. __Pyx_RefNannySetupContext("_put", 0);
  7337. __Pyx_TraceCall("_put", __pyx_f[0], 447, 0, __PYX_ERR(0, 447, __pyx_L1_error));
  7338. if (__pyx_optional_args) {
  7339. if (__pyx_optional_args->__pyx_n > 0) {
  7340. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  7341. if (__pyx_optional_args->__pyx_n > 1) {
  7342. __pyx_v_txn = __pyx_optional_args->txn;
  7343. if (__pyx_optional_args->__pyx_n > 2) {
  7344. __pyx_v_flags = __pyx_optional_args->flags;
  7345. }
  7346. }
  7347. }
  7348. }
  7349. /* "lakesuperior/store/base_lmdb_store.pyx":454
  7350. * Put one key/value pair.
  7351. * """
  7352. * if txn is NULL: # <<<<<<<<<<<<<<
  7353. * txn = self.txn
  7354. *
  7355. */
  7356. __pyx_t_1 = ((__pyx_v_txn == NULL) != 0);
  7357. if (__pyx_t_1) {
  7358. /* "lakesuperior/store/base_lmdb_store.pyx":455
  7359. * """
  7360. * if txn is NULL:
  7361. * txn = self.txn # <<<<<<<<<<<<<<
  7362. *
  7363. * key_v.mv_data = key
  7364. */
  7365. __pyx_t_2 = __pyx_v_self->txn;
  7366. __pyx_v_txn = __pyx_t_2;
  7367. /* "lakesuperior/store/base_lmdb_store.pyx":454
  7368. * Put one key/value pair.
  7369. * """
  7370. * if txn is NULL: # <<<<<<<<<<<<<<
  7371. * txn = self.txn
  7372. *
  7373. */
  7374. }
  7375. /* "lakesuperior/store/base_lmdb_store.pyx":457
  7376. * txn = self.txn
  7377. *
  7378. * key_v.mv_data = key # <<<<<<<<<<<<<<
  7379. * key_v.mv_size = key_size
  7380. * data_v.mv_data = data
  7381. */
  7382. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_data = __pyx_v_key;
  7383. /* "lakesuperior/store/base_lmdb_store.pyx":458
  7384. *
  7385. * key_v.mv_data = key
  7386. * key_v.mv_size = key_size # <<<<<<<<<<<<<<
  7387. * data_v.mv_data = data
  7388. * data_v.mv_size = data_size
  7389. */
  7390. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_size = __pyx_v_key_size;
  7391. /* "lakesuperior/store/base_lmdb_store.pyx":459
  7392. * key_v.mv_data = key
  7393. * key_v.mv_size = key_size
  7394. * data_v.mv_data = data # <<<<<<<<<<<<<<
  7395. * data_v.mv_size = data_size
  7396. *
  7397. */
  7398. __pyx_v_12lakesuperior_5store_15base_lmdb_store_data_v.mv_data = __pyx_v_data;
  7399. /* "lakesuperior/store/base_lmdb_store.pyx":460
  7400. * key_v.mv_size = key_size
  7401. * data_v.mv_data = data
  7402. * data_v.mv_size = data_size # <<<<<<<<<<<<<<
  7403. *
  7404. * #logger.debug('Putting: {}, {} into DB {}'.format(key[: key_size],
  7405. */
  7406. __pyx_v_12lakesuperior_5store_15base_lmdb_store_data_v.mv_size = __pyx_v_data_size;
  7407. /* "lakesuperior/store/base_lmdb_store.pyx":464
  7408. * #logger.debug('Putting: {}, {} into DB {}'.format(key[: key_size],
  7409. * # data[: data_size], dblabel))
  7410. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags) # <<<<<<<<<<<<<<
  7411. * _check(rc, 'Error putting data: {}, {}'.format(
  7412. * key[: key_size], data[: data_size]))
  7413. */
  7414. __pyx_t_4.__pyx_n = 1;
  7415. __pyx_t_4.dblabel = __pyx_v_dblabel;
  7416. __pyx_t_3 = ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->get_dbi(__pyx_v_self, &__pyx_t_4);
  7417. __pyx_v_rc = mdb_put(__pyx_v_txn, __pyx_t_3, (&__pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v), (&__pyx_v_12lakesuperior_5store_15base_lmdb_store_data_v), __pyx_v_flags);
  7418. /* "lakesuperior/store/base_lmdb_store.pyx":465
  7419. * # data[: data_size], dblabel))
  7420. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags)
  7421. * _check(rc, 'Error putting data: {}, {}'.format( # <<<<<<<<<<<<<<
  7422. * key[: key_size], data[: data_size]))
  7423. *
  7424. */
  7425. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Error_putting_data, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 465, __pyx_L1_error)
  7426. __Pyx_GOTREF(__pyx_t_6);
  7427. /* "lakesuperior/store/base_lmdb_store.pyx":466
  7428. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags)
  7429. * _check(rc, 'Error putting data: {}, {}'.format(
  7430. * key[: key_size], data[: data_size])) # <<<<<<<<<<<<<<
  7431. *
  7432. *
  7433. */
  7434. __pyx_t_7 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_key) + 0, __pyx_v_key_size - 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 466, __pyx_L1_error)
  7435. __Pyx_GOTREF(__pyx_t_7);
  7436. __pyx_t_8 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_data) + 0, __pyx_v_data_size - 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 466, __pyx_L1_error)
  7437. __Pyx_GOTREF(__pyx_t_8);
  7438. __pyx_t_9 = NULL;
  7439. __pyx_t_10 = 0;
  7440. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  7441. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
  7442. if (likely(__pyx_t_9)) {
  7443. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  7444. __Pyx_INCREF(__pyx_t_9);
  7445. __Pyx_INCREF(function);
  7446. __Pyx_DECREF_SET(__pyx_t_6, function);
  7447. __pyx_t_10 = 1;
  7448. }
  7449. }
  7450. #if CYTHON_FAST_PYCALL
  7451. if (PyFunction_Check(__pyx_t_6)) {
  7452. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_7, __pyx_t_8};
  7453. __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 465, __pyx_L1_error)
  7454. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  7455. __Pyx_GOTREF(__pyx_t_5);
  7456. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7457. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7458. } else
  7459. #endif
  7460. #if CYTHON_FAST_PYCCALL
  7461. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  7462. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_7, __pyx_t_8};
  7463. __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 465, __pyx_L1_error)
  7464. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  7465. __Pyx_GOTREF(__pyx_t_5);
  7466. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7467. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7468. } else
  7469. #endif
  7470. {
  7471. __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 465, __pyx_L1_error)
  7472. __Pyx_GOTREF(__pyx_t_11);
  7473. if (__pyx_t_9) {
  7474. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
  7475. }
  7476. __Pyx_GIVEREF(__pyx_t_7);
  7477. PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_7);
  7478. __Pyx_GIVEREF(__pyx_t_8);
  7479. PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_8);
  7480. __pyx_t_7 = 0;
  7481. __pyx_t_8 = 0;
  7482. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 465, __pyx_L1_error)
  7483. __Pyx_GOTREF(__pyx_t_5);
  7484. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  7485. }
  7486. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7487. /* "lakesuperior/store/base_lmdb_store.pyx":465
  7488. * # data[: data_size], dblabel))
  7489. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags)
  7490. * _check(rc, 'Error putting data: {}, {}'.format( # <<<<<<<<<<<<<<
  7491. * key[: key_size], data[: data_size]))
  7492. *
  7493. */
  7494. if (!(likely(PyUnicode_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(0, 465, __pyx_L1_error)
  7495. __pyx_t_12.__pyx_n = 1;
  7496. __pyx_t_12.message = ((PyObject*)__pyx_t_5);
  7497. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(__pyx_v_rc, &__pyx_t_12); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 465, __pyx_L1_error)
  7498. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7499. /* "lakesuperior/store/base_lmdb_store.pyx":447
  7500. *
  7501. *
  7502. * cdef void _put( # <<<<<<<<<<<<<<
  7503. * self, unsigned char *key, size_t key_size, unsigned char *data,
  7504. * size_t data_size, unsigned char *dblabel='',
  7505. */
  7506. /* function exit code */
  7507. goto __pyx_L0;
  7508. __pyx_L1_error:;
  7509. __Pyx_XDECREF(__pyx_t_5);
  7510. __Pyx_XDECREF(__pyx_t_6);
  7511. __Pyx_XDECREF(__pyx_t_7);
  7512. __Pyx_XDECREF(__pyx_t_8);
  7513. __Pyx_XDECREF(__pyx_t_9);
  7514. __Pyx_XDECREF(__pyx_t_11);
  7515. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7516. __pyx_L0:;
  7517. __Pyx_TraceReturn(Py_None, 0);
  7518. __Pyx_RefNannyFinishContext();
  7519. }
  7520. /* "lakesuperior/store/base_lmdb_store.pyx":469
  7521. *
  7522. *
  7523. * cpdef bytes get_data(self, key, dblabel=''): # <<<<<<<<<<<<<<
  7524. * """
  7525. * Get a single value (non-dup) for a key (Python-facing method).
  7526. */
  7527. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7528. static PyObject *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_key, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data *__pyx_optional_args) {
  7529. PyObject *__pyx_v_dblabel = ((PyObject *)__pyx_kp_u_);
  7530. struct MDB_val __pyx_v_rv;
  7531. PyObject *__pyx_r = NULL;
  7532. __Pyx_TraceDeclarations
  7533. __Pyx_RefNannyDeclarations
  7534. PyObject *__pyx_t_1 = NULL;
  7535. PyObject *__pyx_t_2 = NULL;
  7536. PyObject *__pyx_t_3 = NULL;
  7537. PyObject *__pyx_t_4 = NULL;
  7538. int __pyx_t_5;
  7539. PyObject *__pyx_t_6 = NULL;
  7540. PyObject *__pyx_t_7 = NULL;
  7541. PyObject *__pyx_t_8 = NULL;
  7542. PyObject *__pyx_t_9 = NULL;
  7543. unsigned char *__pyx_t_10;
  7544. Py_ssize_t __pyx_t_11;
  7545. unsigned char *__pyx_t_12;
  7546. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data __pyx_t_13;
  7547. __Pyx_RefNannySetupContext("get_data", 0);
  7548. __Pyx_TraceCall("get_data", __pyx_f[0], 469, 0, __PYX_ERR(0, 469, __pyx_L1_error));
  7549. if (__pyx_optional_args) {
  7550. if (__pyx_optional_args->__pyx_n > 0) {
  7551. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  7552. }
  7553. }
  7554. /* Check if called by wrapper */
  7555. if (unlikely(__pyx_skip_dispatch)) ;
  7556. /* Check if overridden in Python */
  7557. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  7558. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 469, __pyx_L1_error)
  7559. __Pyx_GOTREF(__pyx_t_1);
  7560. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data)) {
  7561. __Pyx_XDECREF(__pyx_r);
  7562. __Pyx_INCREF(__pyx_t_1);
  7563. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  7564. __pyx_t_5 = 0;
  7565. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  7566. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  7567. if (likely(__pyx_t_4)) {
  7568. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  7569. __Pyx_INCREF(__pyx_t_4);
  7570. __Pyx_INCREF(function);
  7571. __Pyx_DECREF_SET(__pyx_t_3, function);
  7572. __pyx_t_5 = 1;
  7573. }
  7574. }
  7575. #if CYTHON_FAST_PYCALL
  7576. if (PyFunction_Check(__pyx_t_3)) {
  7577. PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_key, __pyx_v_dblabel};
  7578. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 469, __pyx_L1_error)
  7579. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7580. __Pyx_GOTREF(__pyx_t_2);
  7581. } else
  7582. #endif
  7583. #if CYTHON_FAST_PYCCALL
  7584. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  7585. PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_key, __pyx_v_dblabel};
  7586. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 469, __pyx_L1_error)
  7587. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7588. __Pyx_GOTREF(__pyx_t_2);
  7589. } else
  7590. #endif
  7591. {
  7592. __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L1_error)
  7593. __Pyx_GOTREF(__pyx_t_6);
  7594. if (__pyx_t_4) {
  7595. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  7596. }
  7597. __Pyx_INCREF(__pyx_v_key);
  7598. __Pyx_GIVEREF(__pyx_v_key);
  7599. PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_key);
  7600. __Pyx_INCREF(__pyx_v_dblabel);
  7601. __Pyx_GIVEREF(__pyx_v_dblabel);
  7602. PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_dblabel);
  7603. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 469, __pyx_L1_error)
  7604. __Pyx_GOTREF(__pyx_t_2);
  7605. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7606. }
  7607. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7608. if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 469, __pyx_L1_error)
  7609. __pyx_r = ((PyObject*)__pyx_t_2);
  7610. __pyx_t_2 = 0;
  7611. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7612. goto __pyx_L0;
  7613. }
  7614. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7615. }
  7616. /* "lakesuperior/store/base_lmdb_store.pyx":474
  7617. * """
  7618. * cdef lmdb.MDB_val rv
  7619. * try: # <<<<<<<<<<<<<<
  7620. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7621. *
  7622. */
  7623. {
  7624. __Pyx_PyThreadState_declare
  7625. __Pyx_PyThreadState_assign
  7626. __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
  7627. __Pyx_XGOTREF(__pyx_t_7);
  7628. __Pyx_XGOTREF(__pyx_t_8);
  7629. __Pyx_XGOTREF(__pyx_t_9);
  7630. /*try:*/ {
  7631. /* "lakesuperior/store/base_lmdb_store.pyx":475
  7632. * cdef lmdb.MDB_val rv
  7633. * try:
  7634. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode()) # <<<<<<<<<<<<<<
  7635. *
  7636. * return (<unsigned char *>rv.mv_data)[: rv.mv_size]
  7637. */
  7638. __pyx_t_10 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) __PYX_ERR(0, 475, __pyx_L3_error)
  7639. __pyx_t_11 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 475, __pyx_L3_error)
  7640. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_dblabel, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 475, __pyx_L3_error)
  7641. __Pyx_GOTREF(__pyx_t_2);
  7642. __pyx_t_3 = NULL;
  7643. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  7644. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  7645. if (likely(__pyx_t_3)) {
  7646. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  7647. __Pyx_INCREF(__pyx_t_3);
  7648. __Pyx_INCREF(function);
  7649. __Pyx_DECREF_SET(__pyx_t_2, function);
  7650. }
  7651. }
  7652. if (__pyx_t_3) {
  7653. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 475, __pyx_L3_error)
  7654. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7655. } else {
  7656. __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 475, __pyx_L3_error)
  7657. }
  7658. __Pyx_GOTREF(__pyx_t_1);
  7659. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7660. __pyx_t_12 = __Pyx_PyObject_AsWritableUString(__pyx_t_1); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 475, __pyx_L3_error)
  7661. __pyx_t_13.__pyx_n = 1;
  7662. __pyx_t_13.dblabel = __pyx_t_12;
  7663. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_get_data(__pyx_v_self, __pyx_t_10, __pyx_t_11, (&__pyx_v_rv), &__pyx_t_13); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 475, __pyx_L3_error)
  7664. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7665. /* "lakesuperior/store/base_lmdb_store.pyx":477
  7666. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7667. *
  7668. * return (<unsigned char *>rv.mv_data)[: rv.mv_size] # <<<<<<<<<<<<<<
  7669. * except KeyNotFoundError:
  7670. * return None
  7671. */
  7672. __Pyx_XDECREF(__pyx_r);
  7673. __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(((const char*)((unsigned char *)__pyx_v_rv.mv_data)) + 0, __pyx_v_rv.mv_size - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 477, __pyx_L3_error)
  7674. __Pyx_GOTREF(__pyx_t_1);
  7675. __pyx_r = ((PyObject*)__pyx_t_1);
  7676. __pyx_t_1 = 0;
  7677. goto __pyx_L7_try_return;
  7678. /* "lakesuperior/store/base_lmdb_store.pyx":474
  7679. * """
  7680. * cdef lmdb.MDB_val rv
  7681. * try: # <<<<<<<<<<<<<<
  7682. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7683. *
  7684. */
  7685. }
  7686. __pyx_L3_error:;
  7687. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7688. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  7689. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7690. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  7691. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  7692. /* "lakesuperior/store/base_lmdb_store.pyx":478
  7693. *
  7694. * return (<unsigned char *>rv.mv_data)[: rv.mv_size]
  7695. * except KeyNotFoundError: # <<<<<<<<<<<<<<
  7696. * return None
  7697. *
  7698. */
  7699. __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  7700. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 478, __pyx_L5_except_error)
  7701. __Pyx_GOTREF(__pyx_t_6);
  7702. __pyx_t_5 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
  7703. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7704. __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7705. __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0;
  7706. if (__pyx_t_5) {
  7707. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7708. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 478, __pyx_L5_except_error)
  7709. __Pyx_GOTREF(__pyx_t_3);
  7710. __Pyx_GOTREF(__pyx_t_2);
  7711. __Pyx_GOTREF(__pyx_t_1);
  7712. /* "lakesuperior/store/base_lmdb_store.pyx":479
  7713. * return (<unsigned char *>rv.mv_data)[: rv.mv_size]
  7714. * except KeyNotFoundError:
  7715. * return None # <<<<<<<<<<<<<<
  7716. *
  7717. *
  7718. */
  7719. __Pyx_XDECREF(__pyx_r);
  7720. __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  7721. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7722. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7723. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7724. goto __pyx_L6_except_return;
  7725. }
  7726. goto __pyx_L5_except_error;
  7727. __pyx_L5_except_error:;
  7728. /* "lakesuperior/store/base_lmdb_store.pyx":474
  7729. * """
  7730. * cdef lmdb.MDB_val rv
  7731. * try: # <<<<<<<<<<<<<<
  7732. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7733. *
  7734. */
  7735. __Pyx_XGIVEREF(__pyx_t_7);
  7736. __Pyx_XGIVEREF(__pyx_t_8);
  7737. __Pyx_XGIVEREF(__pyx_t_9);
  7738. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  7739. goto __pyx_L1_error;
  7740. __pyx_L7_try_return:;
  7741. __Pyx_XGIVEREF(__pyx_t_7);
  7742. __Pyx_XGIVEREF(__pyx_t_8);
  7743. __Pyx_XGIVEREF(__pyx_t_9);
  7744. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  7745. goto __pyx_L0;
  7746. __pyx_L6_except_return:;
  7747. __Pyx_XGIVEREF(__pyx_t_7);
  7748. __Pyx_XGIVEREF(__pyx_t_8);
  7749. __Pyx_XGIVEREF(__pyx_t_9);
  7750. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  7751. goto __pyx_L0;
  7752. }
  7753. /* "lakesuperior/store/base_lmdb_store.pyx":469
  7754. *
  7755. *
  7756. * cpdef bytes get_data(self, key, dblabel=''): # <<<<<<<<<<<<<<
  7757. * """
  7758. * Get a single value (non-dup) for a key (Python-facing method).
  7759. */
  7760. /* function exit code */
  7761. __pyx_L1_error:;
  7762. __Pyx_XDECREF(__pyx_t_1);
  7763. __Pyx_XDECREF(__pyx_t_2);
  7764. __Pyx_XDECREF(__pyx_t_3);
  7765. __Pyx_XDECREF(__pyx_t_4);
  7766. __Pyx_XDECREF(__pyx_t_6);
  7767. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7768. __pyx_r = 0;
  7769. __pyx_L0:;
  7770. __Pyx_XGIVEREF(__pyx_r);
  7771. __Pyx_TraceReturn(__pyx_r, 0);
  7772. __Pyx_RefNannyFinishContext();
  7773. return __pyx_r;
  7774. }
  7775. /* Python wrapper */
  7776. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7777. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_25get_data[] = "\n Get a single value (non-dup) for a key (Python-facing method).\n ";
  7778. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  7779. PyObject *__pyx_v_key = 0;
  7780. PyObject *__pyx_v_dblabel = 0;
  7781. PyObject *__pyx_r = 0;
  7782. __Pyx_RefNannyDeclarations
  7783. __Pyx_RefNannySetupContext("get_data (wrapper)", 0);
  7784. {
  7785. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_dblabel,0};
  7786. PyObject* values[2] = {0,0};
  7787. values[1] = ((PyObject *)__pyx_kp_u_);
  7788. if (unlikely(__pyx_kwds)) {
  7789. Py_ssize_t kw_args;
  7790. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  7791. switch (pos_args) {
  7792. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7793. CYTHON_FALLTHROUGH;
  7794. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7795. CYTHON_FALLTHROUGH;
  7796. case 0: break;
  7797. default: goto __pyx_L5_argtuple_error;
  7798. }
  7799. kw_args = PyDict_Size(__pyx_kwds);
  7800. switch (pos_args) {
  7801. case 0:
  7802. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  7803. else goto __pyx_L5_argtuple_error;
  7804. CYTHON_FALLTHROUGH;
  7805. case 1:
  7806. if (kw_args > 0) {
  7807. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  7808. if (value) { values[1] = value; kw_args--; }
  7809. }
  7810. }
  7811. if (unlikely(kw_args > 0)) {
  7812. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_data") < 0)) __PYX_ERR(0, 469, __pyx_L3_error)
  7813. }
  7814. } else {
  7815. switch (PyTuple_GET_SIZE(__pyx_args)) {
  7816. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7817. CYTHON_FALLTHROUGH;
  7818. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7819. break;
  7820. default: goto __pyx_L5_argtuple_error;
  7821. }
  7822. }
  7823. __pyx_v_key = values[0];
  7824. __pyx_v_dblabel = values[1];
  7825. }
  7826. goto __pyx_L4_argument_unpacking_done;
  7827. __pyx_L5_argtuple_error:;
  7828. __Pyx_RaiseArgtupleInvalid("get_data", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 469, __pyx_L3_error)
  7829. __pyx_L3_error:;
  7830. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7831. __Pyx_RefNannyFinishContext();
  7832. return NULL;
  7833. __pyx_L4_argument_unpacking_done:;
  7834. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_25get_data(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), __pyx_v_key, __pyx_v_dblabel);
  7835. /* function exit code */
  7836. __Pyx_RefNannyFinishContext();
  7837. return __pyx_r;
  7838. }
  7839. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_25get_data(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_dblabel) {
  7840. PyObject *__pyx_r = NULL;
  7841. __Pyx_TraceDeclarations
  7842. __Pyx_RefNannyDeclarations
  7843. PyObject *__pyx_t_1 = NULL;
  7844. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data __pyx_t_2;
  7845. __Pyx_RefNannySetupContext("get_data", 0);
  7846. __Pyx_TraceCall("get_data (wrapper)", __pyx_f[0], 469, 0, __PYX_ERR(0, 469, __pyx_L1_error));
  7847. __Pyx_XDECREF(__pyx_r);
  7848. __pyx_t_2.__pyx_n = 1;
  7849. __pyx_t_2.dblabel = __pyx_v_dblabel;
  7850. __pyx_t_1 = __pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore->get_data(__pyx_v_self, __pyx_v_key, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 469, __pyx_L1_error)
  7851. __Pyx_GOTREF(__pyx_t_1);
  7852. __pyx_r = __pyx_t_1;
  7853. __pyx_t_1 = 0;
  7854. goto __pyx_L0;
  7855. /* function exit code */
  7856. __pyx_L1_error:;
  7857. __Pyx_XDECREF(__pyx_t_1);
  7858. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7859. __pyx_r = NULL;
  7860. __pyx_L0:;
  7861. __Pyx_XGIVEREF(__pyx_r);
  7862. __Pyx_TraceReturn(__pyx_r, 0);
  7863. __Pyx_RefNannyFinishContext();
  7864. return __pyx_r;
  7865. }
  7866. /* "lakesuperior/store/base_lmdb_store.pyx":482
  7867. *
  7868. *
  7869. * cdef void _get_data( # <<<<<<<<<<<<<<
  7870. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  7871. * unsigned char *dblabel='') except *:
  7872. */
  7873. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, unsigned char *__pyx_v_key, CYTHON_UNUSED size_t __pyx_v_klen, struct MDB_val *__pyx_v_rv, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data *__pyx_optional_args) {
  7874. unsigned char *__pyx_v_dblabel = __pyx_k__16;
  7875. __Pyx_TraceDeclarations
  7876. __Pyx_RefNannyDeclarations
  7877. size_t __pyx_t_1;
  7878. MDB_dbi __pyx_t_2;
  7879. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_3;
  7880. PyObject *__pyx_t_4 = NULL;
  7881. PyObject *__pyx_t_5 = NULL;
  7882. PyObject *__pyx_t_6 = NULL;
  7883. PyObject *__pyx_t_7 = NULL;
  7884. PyObject *__pyx_t_8 = NULL;
  7885. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_9;
  7886. __Pyx_RefNannySetupContext("_get_data", 0);
  7887. __Pyx_TraceCall("_get_data", __pyx_f[0], 482, 0, __PYX_ERR(0, 482, __pyx_L1_error));
  7888. if (__pyx_optional_args) {
  7889. if (__pyx_optional_args->__pyx_n > 0) {
  7890. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  7891. }
  7892. }
  7893. /* "lakesuperior/store/base_lmdb_store.pyx":491
  7894. * unsigned char *ret
  7895. *
  7896. * key_v.mv_data = key # <<<<<<<<<<<<<<
  7897. * key_v.mv_size = len(key)
  7898. *
  7899. */
  7900. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_data = __pyx_v_key;
  7901. /* "lakesuperior/store/base_lmdb_store.pyx":492
  7902. *
  7903. * key_v.mv_data = key
  7904. * key_v.mv_size = len(key) # <<<<<<<<<<<<<<
  7905. *
  7906. * _check(
  7907. */
  7908. __pyx_t_1 = strlen(((char const *)__pyx_v_key));
  7909. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_size = __pyx_t_1;
  7910. /* "lakesuperior/store/base_lmdb_store.pyx":495
  7911. *
  7912. * _check(
  7913. * lmdb.mdb_get(self.txn, self.get_dbi(dblabel), &key_v, rv), # <<<<<<<<<<<<<<
  7914. * 'Error getting data for key \'{}\'.'.format(key.decode()))
  7915. *
  7916. */
  7917. __pyx_t_3.__pyx_n = 1;
  7918. __pyx_t_3.dblabel = __pyx_v_dblabel;
  7919. __pyx_t_2 = ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->get_dbi(__pyx_v_self, &__pyx_t_3);
  7920. /* "lakesuperior/store/base_lmdb_store.pyx":496
  7921. * _check(
  7922. * lmdb.mdb_get(self.txn, self.get_dbi(dblabel), &key_v, rv),
  7923. * 'Error getting data for key \'{}\'.'.format(key.decode())) # <<<<<<<<<<<<<<
  7924. *
  7925. *
  7926. */
  7927. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Error_getting_data_for_key, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 496, __pyx_L1_error)
  7928. __Pyx_GOTREF(__pyx_t_5);
  7929. __pyx_t_6 = __Pyx_decode_c_string(((char const *)__pyx_v_key), 0, strlen(((char const *)__pyx_v_key)), NULL, NULL, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 496, __pyx_L1_error)
  7930. __Pyx_GOTREF(__pyx_t_6);
  7931. __pyx_t_7 = NULL;
  7932. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  7933. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  7934. if (likely(__pyx_t_7)) {
  7935. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  7936. __Pyx_INCREF(__pyx_t_7);
  7937. __Pyx_INCREF(function);
  7938. __Pyx_DECREF_SET(__pyx_t_5, function);
  7939. }
  7940. }
  7941. if (!__pyx_t_7) {
  7942. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 496, __pyx_L1_error)
  7943. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7944. __Pyx_GOTREF(__pyx_t_4);
  7945. } else {
  7946. #if CYTHON_FAST_PYCALL
  7947. if (PyFunction_Check(__pyx_t_5)) {
  7948. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  7949. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 496, __pyx_L1_error)
  7950. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7951. __Pyx_GOTREF(__pyx_t_4);
  7952. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7953. } else
  7954. #endif
  7955. #if CYTHON_FAST_PYCCALL
  7956. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  7957. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  7958. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 496, __pyx_L1_error)
  7959. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7960. __Pyx_GOTREF(__pyx_t_4);
  7961. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7962. } else
  7963. #endif
  7964. {
  7965. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 496, __pyx_L1_error)
  7966. __Pyx_GOTREF(__pyx_t_8);
  7967. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  7968. __Pyx_GIVEREF(__pyx_t_6);
  7969. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
  7970. __pyx_t_6 = 0;
  7971. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 496, __pyx_L1_error)
  7972. __Pyx_GOTREF(__pyx_t_4);
  7973. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7974. }
  7975. }
  7976. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7977. if (!(likely(PyUnicode_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 496, __pyx_L1_error)
  7978. /* "lakesuperior/store/base_lmdb_store.pyx":494
  7979. * key_v.mv_size = len(key)
  7980. *
  7981. * _check( # <<<<<<<<<<<<<<
  7982. * lmdb.mdb_get(self.txn, self.get_dbi(dblabel), &key_v, rv),
  7983. * 'Error getting data for key \'{}\'.'.format(key.decode()))
  7984. */
  7985. __pyx_t_9.__pyx_n = 1;
  7986. __pyx_t_9.message = ((PyObject*)__pyx_t_4);
  7987. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_get(__pyx_v_self->txn, __pyx_t_2, (&__pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v), __pyx_v_rv), &__pyx_t_9); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 494, __pyx_L1_error)
  7988. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7989. /* "lakesuperior/store/base_lmdb_store.pyx":482
  7990. *
  7991. *
  7992. * cdef void _get_data( # <<<<<<<<<<<<<<
  7993. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  7994. * unsigned char *dblabel='') except *:
  7995. */
  7996. /* function exit code */
  7997. goto __pyx_L0;
  7998. __pyx_L1_error:;
  7999. __Pyx_XDECREF(__pyx_t_4);
  8000. __Pyx_XDECREF(__pyx_t_5);
  8001. __Pyx_XDECREF(__pyx_t_6);
  8002. __Pyx_XDECREF(__pyx_t_7);
  8003. __Pyx_XDECREF(__pyx_t_8);
  8004. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8005. __pyx_L0:;
  8006. __Pyx_TraceReturn(Py_None, 0);
  8007. __Pyx_RefNannyFinishContext();
  8008. }
  8009. /* "lakesuperior/store/base_lmdb_store.pyx":499
  8010. *
  8011. *
  8012. * def delete(self, key, dblabel=''): # <<<<<<<<<<<<<<
  8013. * """
  8014. * Delete one single value by key. Python-facing method.
  8015. */
  8016. /* Python wrapper */
  8017. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_28delete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  8018. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_27delete[] = "\n Delete one single value by key. Python-facing method.\n ";
  8019. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_28delete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  8020. PyObject *__pyx_v_key = 0;
  8021. PyObject *__pyx_v_dblabel = 0;
  8022. PyObject *__pyx_r = 0;
  8023. __Pyx_RefNannyDeclarations
  8024. __Pyx_RefNannySetupContext("delete (wrapper)", 0);
  8025. {
  8026. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_dblabel,0};
  8027. PyObject* values[2] = {0,0};
  8028. values[1] = ((PyObject *)__pyx_kp_u_);
  8029. if (unlikely(__pyx_kwds)) {
  8030. Py_ssize_t kw_args;
  8031. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  8032. switch (pos_args) {
  8033. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  8034. CYTHON_FALLTHROUGH;
  8035. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8036. CYTHON_FALLTHROUGH;
  8037. case 0: break;
  8038. default: goto __pyx_L5_argtuple_error;
  8039. }
  8040. kw_args = PyDict_Size(__pyx_kwds);
  8041. switch (pos_args) {
  8042. case 0:
  8043. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  8044. else goto __pyx_L5_argtuple_error;
  8045. CYTHON_FALLTHROUGH;
  8046. case 1:
  8047. if (kw_args > 0) {
  8048. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  8049. if (value) { values[1] = value; kw_args--; }
  8050. }
  8051. }
  8052. if (unlikely(kw_args > 0)) {
  8053. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "delete") < 0)) __PYX_ERR(0, 499, __pyx_L3_error)
  8054. }
  8055. } else {
  8056. switch (PyTuple_GET_SIZE(__pyx_args)) {
  8057. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  8058. CYTHON_FALLTHROUGH;
  8059. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8060. break;
  8061. default: goto __pyx_L5_argtuple_error;
  8062. }
  8063. }
  8064. __pyx_v_key = values[0];
  8065. __pyx_v_dblabel = values[1];
  8066. }
  8067. goto __pyx_L4_argument_unpacking_done;
  8068. __pyx_L5_argtuple_error:;
  8069. __Pyx_RaiseArgtupleInvalid("delete", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 499, __pyx_L3_error)
  8070. __pyx_L3_error:;
  8071. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8072. __Pyx_RefNannyFinishContext();
  8073. return NULL;
  8074. __pyx_L4_argument_unpacking_done:;
  8075. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_27delete(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), __pyx_v_key, __pyx_v_dblabel);
  8076. /* function exit code */
  8077. __Pyx_RefNannyFinishContext();
  8078. return __pyx_r;
  8079. }
  8080. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_27delete(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_dblabel) {
  8081. PyObject *__pyx_r = NULL;
  8082. __Pyx_TraceDeclarations
  8083. __Pyx_RefNannyDeclarations
  8084. unsigned char *__pyx_t_1;
  8085. Py_ssize_t __pyx_t_2;
  8086. PyObject *__pyx_t_3 = NULL;
  8087. PyObject *__pyx_t_4 = NULL;
  8088. PyObject *__pyx_t_5 = NULL;
  8089. unsigned char *__pyx_t_6;
  8090. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete __pyx_t_7;
  8091. __Pyx_RefNannySetupContext("delete", 0);
  8092. __Pyx_TraceCall("delete", __pyx_f[0], 499, 0, __PYX_ERR(0, 499, __pyx_L1_error));
  8093. /* "lakesuperior/store/base_lmdb_store.pyx":503
  8094. * Delete one single value by key. Python-facing method.
  8095. * """
  8096. * self._delete(key, len(key), dblabel.encode()) # <<<<<<<<<<<<<<
  8097. *
  8098. *
  8099. */
  8100. __pyx_t_1 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 503, __pyx_L1_error)
  8101. __pyx_t_2 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 503, __pyx_L1_error)
  8102. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_dblabel, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 503, __pyx_L1_error)
  8103. __Pyx_GOTREF(__pyx_t_4);
  8104. __pyx_t_5 = NULL;
  8105. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  8106. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  8107. if (likely(__pyx_t_5)) {
  8108. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  8109. __Pyx_INCREF(__pyx_t_5);
  8110. __Pyx_INCREF(function);
  8111. __Pyx_DECREF_SET(__pyx_t_4, function);
  8112. }
  8113. }
  8114. if (__pyx_t_5) {
  8115. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __pyx_L1_error)
  8116. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8117. } else {
  8118. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __pyx_L1_error)
  8119. }
  8120. __Pyx_GOTREF(__pyx_t_3);
  8121. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8122. __pyx_t_6 = __Pyx_PyObject_AsWritableUString(__pyx_t_3); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 503, __pyx_L1_error)
  8123. __pyx_t_7.__pyx_n = 1;
  8124. __pyx_t_7.dblabel = __pyx_t_6;
  8125. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_delete(__pyx_v_self, __pyx_t_1, __pyx_t_2, &__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 503, __pyx_L1_error)
  8126. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8127. /* "lakesuperior/store/base_lmdb_store.pyx":499
  8128. *
  8129. *
  8130. * def delete(self, key, dblabel=''): # <<<<<<<<<<<<<<
  8131. * """
  8132. * Delete one single value by key. Python-facing method.
  8133. */
  8134. /* function exit code */
  8135. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  8136. goto __pyx_L0;
  8137. __pyx_L1_error:;
  8138. __Pyx_XDECREF(__pyx_t_3);
  8139. __Pyx_XDECREF(__pyx_t_4);
  8140. __Pyx_XDECREF(__pyx_t_5);
  8141. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8142. __pyx_r = NULL;
  8143. __pyx_L0:;
  8144. __Pyx_XGIVEREF(__pyx_r);
  8145. __Pyx_TraceReturn(__pyx_r, 0);
  8146. __Pyx_RefNannyFinishContext();
  8147. return __pyx_r;
  8148. }
  8149. /* "lakesuperior/store/base_lmdb_store.pyx":506
  8150. *
  8151. *
  8152. * cdef void _delete( # <<<<<<<<<<<<<<
  8153. * self, unsigned char *key, size_t klen,
  8154. * unsigned char *dblabel=b'') except *:
  8155. */
  8156. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, unsigned char *__pyx_v_key, size_t __pyx_v_klen, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete *__pyx_optional_args) {
  8157. unsigned char *__pyx_v_dblabel = __pyx_k__17;
  8158. __Pyx_TraceDeclarations
  8159. __Pyx_RefNannyDeclarations
  8160. PyObject *__pyx_t_1 = NULL;
  8161. PyObject *__pyx_t_2 = NULL;
  8162. PyObject *__pyx_t_3 = NULL;
  8163. MDB_dbi __pyx_t_4;
  8164. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_5;
  8165. PyObject *__pyx_t_6 = NULL;
  8166. PyObject *__pyx_t_7 = NULL;
  8167. PyObject *__pyx_t_8 = NULL;
  8168. PyObject *__pyx_t_9 = NULL;
  8169. int __pyx_t_10;
  8170. __Pyx_RefNannySetupContext("_delete", 0);
  8171. __Pyx_TraceCall("_delete", __pyx_f[0], 506, 0, __PYX_ERR(0, 506, __pyx_L1_error));
  8172. if (__pyx_optional_args) {
  8173. if (__pyx_optional_args->__pyx_n > 0) {
  8174. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  8175. }
  8176. }
  8177. /* "lakesuperior/store/base_lmdb_store.pyx":514
  8178. * TODO Allow deleting duplicate keys.
  8179. * """
  8180. * key_v.mv_data = key # <<<<<<<<<<<<<<
  8181. * key_v.mv_size = klen
  8182. * try:
  8183. */
  8184. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_data = __pyx_v_key;
  8185. /* "lakesuperior/store/base_lmdb_store.pyx":515
  8186. * """
  8187. * key_v.mv_data = key
  8188. * key_v.mv_size = klen # <<<<<<<<<<<<<<
  8189. * try:
  8190. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8191. */
  8192. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_size = __pyx_v_klen;
  8193. /* "lakesuperior/store/base_lmdb_store.pyx":516
  8194. * key_v.mv_data = key
  8195. * key_v.mv_size = klen
  8196. * try: # <<<<<<<<<<<<<<
  8197. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8198. * except KeyNotFoundError:
  8199. */
  8200. {
  8201. __Pyx_PyThreadState_declare
  8202. __Pyx_PyThreadState_assign
  8203. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  8204. __Pyx_XGOTREF(__pyx_t_1);
  8205. __Pyx_XGOTREF(__pyx_t_2);
  8206. __Pyx_XGOTREF(__pyx_t_3);
  8207. /*try:*/ {
  8208. /* "lakesuperior/store/base_lmdb_store.pyx":517
  8209. * key_v.mv_size = klen
  8210. * try:
  8211. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL)) # <<<<<<<<<<<<<<
  8212. * except KeyNotFoundError:
  8213. * pass
  8214. */
  8215. __pyx_t_5.__pyx_n = 1;
  8216. __pyx_t_5.dblabel = __pyx_v_dblabel;
  8217. __pyx_t_4 = ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->get_dbi(__pyx_v_self, &__pyx_t_5);
  8218. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_del(__pyx_v_self->txn, __pyx_t_4, (&__pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v), NULL), NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 517, __pyx_L3_error)
  8219. /* "lakesuperior/store/base_lmdb_store.pyx":516
  8220. * key_v.mv_data = key
  8221. * key_v.mv_size = klen
  8222. * try: # <<<<<<<<<<<<<<
  8223. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8224. * except KeyNotFoundError:
  8225. */
  8226. }
  8227. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  8228. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  8229. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  8230. goto __pyx_L8_try_end;
  8231. __pyx_L3_error:;
  8232. /* "lakesuperior/store/base_lmdb_store.pyx":518
  8233. * try:
  8234. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8235. * except KeyNotFoundError: # <<<<<<<<<<<<<<
  8236. * pass
  8237. *
  8238. */
  8239. __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
  8240. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 518, __pyx_L5_except_error)
  8241. __Pyx_GOTREF(__pyx_t_9);
  8242. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_6, __pyx_t_9);
  8243. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8244. __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  8245. __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0;
  8246. if (__pyx_t_10) {
  8247. __Pyx_ErrRestore(0,0,0);
  8248. goto __pyx_L4_exception_handled;
  8249. }
  8250. goto __pyx_L5_except_error;
  8251. __pyx_L5_except_error:;
  8252. /* "lakesuperior/store/base_lmdb_store.pyx":516
  8253. * key_v.mv_data = key
  8254. * key_v.mv_size = klen
  8255. * try: # <<<<<<<<<<<<<<
  8256. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8257. * except KeyNotFoundError:
  8258. */
  8259. __Pyx_XGIVEREF(__pyx_t_1);
  8260. __Pyx_XGIVEREF(__pyx_t_2);
  8261. __Pyx_XGIVEREF(__pyx_t_3);
  8262. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8263. goto __pyx_L1_error;
  8264. __pyx_L4_exception_handled:;
  8265. __Pyx_XGIVEREF(__pyx_t_1);
  8266. __Pyx_XGIVEREF(__pyx_t_2);
  8267. __Pyx_XGIVEREF(__pyx_t_3);
  8268. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8269. __pyx_L8_try_end:;
  8270. }
  8271. /* "lakesuperior/store/base_lmdb_store.pyx":506
  8272. *
  8273. *
  8274. * cdef void _delete( # <<<<<<<<<<<<<<
  8275. * self, unsigned char *key, size_t klen,
  8276. * unsigned char *dblabel=b'') except *:
  8277. */
  8278. /* function exit code */
  8279. goto __pyx_L0;
  8280. __pyx_L1_error:;
  8281. __Pyx_XDECREF(__pyx_t_6);
  8282. __Pyx_XDECREF(__pyx_t_7);
  8283. __Pyx_XDECREF(__pyx_t_8);
  8284. __Pyx_XDECREF(__pyx_t_9);
  8285. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8286. __pyx_L0:;
  8287. __Pyx_TraceReturn(Py_None, 0);
  8288. __Pyx_RefNannyFinishContext();
  8289. }
  8290. /* "lakesuperior/store/base_lmdb_store.pyx":522
  8291. *
  8292. *
  8293. * cpdef dict stats(self): # <<<<<<<<<<<<<<
  8294. * """Gather statistics about the database."""
  8295. * return self._stats()
  8296. */
  8297. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  8298. static PyObject *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, int __pyx_skip_dispatch) {
  8299. PyObject *__pyx_r = NULL;
  8300. __Pyx_TraceDeclarations
  8301. __Pyx_RefNannyDeclarations
  8302. PyObject *__pyx_t_1 = NULL;
  8303. PyObject *__pyx_t_2 = NULL;
  8304. PyObject *__pyx_t_3 = NULL;
  8305. PyObject *__pyx_t_4 = NULL;
  8306. __Pyx_RefNannySetupContext("stats", 0);
  8307. __Pyx_TraceCall("stats", __pyx_f[0], 522, 0, __PYX_ERR(0, 522, __pyx_L1_error));
  8308. /* Check if called by wrapper */
  8309. if (unlikely(__pyx_skip_dispatch)) ;
  8310. /* Check if overridden in Python */
  8311. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  8312. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 522, __pyx_L1_error)
  8313. __Pyx_GOTREF(__pyx_t_1);
  8314. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats)) {
  8315. __Pyx_XDECREF(__pyx_r);
  8316. __Pyx_INCREF(__pyx_t_1);
  8317. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  8318. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  8319. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  8320. if (likely(__pyx_t_4)) {
  8321. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  8322. __Pyx_INCREF(__pyx_t_4);
  8323. __Pyx_INCREF(function);
  8324. __Pyx_DECREF_SET(__pyx_t_3, function);
  8325. }
  8326. }
  8327. if (__pyx_t_4) {
  8328. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 522, __pyx_L1_error)
  8329. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8330. } else {
  8331. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 522, __pyx_L1_error)
  8332. }
  8333. __Pyx_GOTREF(__pyx_t_2);
  8334. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8335. if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 522, __pyx_L1_error)
  8336. __pyx_r = ((PyObject*)__pyx_t_2);
  8337. __pyx_t_2 = 0;
  8338. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8339. goto __pyx_L0;
  8340. }
  8341. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8342. }
  8343. /* "lakesuperior/store/base_lmdb_store.pyx":524
  8344. * cpdef dict stats(self):
  8345. * """Gather statistics about the database."""
  8346. * return self._stats() # <<<<<<<<<<<<<<
  8347. *
  8348. *
  8349. */
  8350. __Pyx_XDECREF(__pyx_r);
  8351. __pyx_t_1 = ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_stats(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
  8352. __Pyx_GOTREF(__pyx_t_1);
  8353. __pyx_r = ((PyObject*)__pyx_t_1);
  8354. __pyx_t_1 = 0;
  8355. goto __pyx_L0;
  8356. /* "lakesuperior/store/base_lmdb_store.pyx":522
  8357. *
  8358. *
  8359. * cpdef dict stats(self): # <<<<<<<<<<<<<<
  8360. * """Gather statistics about the database."""
  8361. * return self._stats()
  8362. */
  8363. /* function exit code */
  8364. __pyx_L1_error:;
  8365. __Pyx_XDECREF(__pyx_t_1);
  8366. __Pyx_XDECREF(__pyx_t_2);
  8367. __Pyx_XDECREF(__pyx_t_3);
  8368. __Pyx_XDECREF(__pyx_t_4);
  8369. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8370. __pyx_r = 0;
  8371. __pyx_L0:;
  8372. __Pyx_XGIVEREF(__pyx_r);
  8373. __Pyx_TraceReturn(__pyx_r, 0);
  8374. __Pyx_RefNannyFinishContext();
  8375. return __pyx_r;
  8376. }
  8377. /* Python wrapper */
  8378. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  8379. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats[] = "Gather statistics about the database.";
  8380. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  8381. PyObject *__pyx_r = 0;
  8382. __Pyx_RefNannyDeclarations
  8383. __Pyx_RefNannySetupContext("stats (wrapper)", 0);
  8384. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  8385. /* function exit code */
  8386. __Pyx_RefNannyFinishContext();
  8387. return __pyx_r;
  8388. }
  8389. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  8390. PyObject *__pyx_r = NULL;
  8391. __Pyx_TraceDeclarations
  8392. __Pyx_RefNannyDeclarations
  8393. PyObject *__pyx_t_1 = NULL;
  8394. __Pyx_RefNannySetupContext("stats", 0);
  8395. __Pyx_TraceCall("stats (wrapper)", __pyx_f[0], 522, 0, __PYX_ERR(0, 522, __pyx_L1_error));
  8396. __Pyx_XDECREF(__pyx_r);
  8397. __pyx_t_1 = __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 522, __pyx_L1_error)
  8398. __Pyx_GOTREF(__pyx_t_1);
  8399. __pyx_r = __pyx_t_1;
  8400. __pyx_t_1 = 0;
  8401. goto __pyx_L0;
  8402. /* function exit code */
  8403. __pyx_L1_error:;
  8404. __Pyx_XDECREF(__pyx_t_1);
  8405. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8406. __pyx_r = NULL;
  8407. __pyx_L0:;
  8408. __Pyx_XGIVEREF(__pyx_r);
  8409. __Pyx_TraceReturn(__pyx_r, 0);
  8410. __Pyx_RefNannyFinishContext();
  8411. return __pyx_r;
  8412. }
  8413. /* "lakesuperior/store/base_lmdb_store.pyx":527
  8414. *
  8415. *
  8416. * cdef dict _stats(self): # <<<<<<<<<<<<<<
  8417. * """
  8418. * Gather statistics about the database.
  8419. */
  8420. static PyObject *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  8421. struct MDB_stat __pyx_v_stat;
  8422. CYTHON_UNUSED size_t __pyx_v_entries;
  8423. PyObject *__pyx_v_env_stats = NULL;
  8424. PyObject *__pyx_v_db_stats = NULL;
  8425. PyObject *__pyx_v_i = NULL;
  8426. PyObject *__pyx_v_dblabel = NULL;
  8427. PyObject *__pyx_7genexpr__pyx_v_db_label = NULL;
  8428. PyObject *__pyx_r = NULL;
  8429. __Pyx_TraceDeclarations
  8430. __Pyx_RefNannyDeclarations
  8431. PyObject *__pyx_t_1 = NULL;
  8432. PyObject *__pyx_t_2 = NULL;
  8433. PyObject *__pyx_t_3 = NULL;
  8434. Py_ssize_t __pyx_t_4;
  8435. PyObject *(*__pyx_t_5)(PyObject *);
  8436. Py_ssize_t __pyx_t_6;
  8437. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_7;
  8438. size_t __pyx_t_8;
  8439. PyObject *__pyx_t_9 = NULL;
  8440. PyObject *__pyx_t_10 = NULL;
  8441. PyObject *__pyx_t_11 = NULL;
  8442. __Pyx_RefNannySetupContext("_stats", 0);
  8443. __Pyx_TraceCall("_stats", __pyx_f[0], 527, 0, __PYX_ERR(0, 527, __pyx_L1_error));
  8444. /* "lakesuperior/store/base_lmdb_store.pyx":537
  8445. * size_t entries
  8446. *
  8447. * lmdb.mdb_env_stat(self.dbenv, &stat) # <<<<<<<<<<<<<<
  8448. * env_stats = <dict>stat
  8449. *
  8450. */
  8451. (void)(mdb_env_stat(__pyx_v_self->dbenv, (&__pyx_v_stat)));
  8452. /* "lakesuperior/store/base_lmdb_store.pyx":538
  8453. *
  8454. * lmdb.mdb_env_stat(self.dbenv, &stat)
  8455. * env_stats = <dict>stat # <<<<<<<<<<<<<<
  8456. *
  8457. * db_stats = {}
  8458. */
  8459. __pyx_t_1 = __pyx_convert__to_py_struct__MDB_stat(__pyx_v_stat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error)
  8460. __Pyx_GOTREF(__pyx_t_1);
  8461. if (!(likely(PyDict_CheckExact(__pyx_t_1))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 538, __pyx_L1_error)
  8462. __pyx_t_2 = __pyx_t_1;
  8463. __Pyx_INCREF(__pyx_t_2);
  8464. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8465. __pyx_v_env_stats = ((PyObject*)__pyx_t_2);
  8466. __pyx_t_2 = 0;
  8467. /* "lakesuperior/store/base_lmdb_store.pyx":540
  8468. * env_stats = <dict>stat
  8469. *
  8470. * db_stats = {} # <<<<<<<<<<<<<<
  8471. * for i, dblabel in enumerate(self.dbi_labels):
  8472. * _check(
  8473. */
  8474. __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 540, __pyx_L1_error)
  8475. __Pyx_GOTREF(__pyx_t_2);
  8476. __pyx_v_db_stats = ((PyObject*)__pyx_t_2);
  8477. __pyx_t_2 = 0;
  8478. /* "lakesuperior/store/base_lmdb_store.pyx":541
  8479. *
  8480. * db_stats = {}
  8481. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  8482. * _check(
  8483. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8484. */
  8485. __Pyx_INCREF(__pyx_int_0);
  8486. __pyx_t_2 = __pyx_int_0;
  8487. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dbi_labels); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
  8488. __Pyx_GOTREF(__pyx_t_1);
  8489. if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
  8490. __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  8491. __pyx_t_5 = NULL;
  8492. } else {
  8493. __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 541, __pyx_L1_error)
  8494. __Pyx_GOTREF(__pyx_t_3);
  8495. __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 541, __pyx_L1_error)
  8496. }
  8497. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8498. for (;;) {
  8499. if (likely(!__pyx_t_5)) {
  8500. if (likely(PyList_CheckExact(__pyx_t_3))) {
  8501. if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
  8502. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8503. __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 541, __pyx_L1_error)
  8504. #else
  8505. __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
  8506. __Pyx_GOTREF(__pyx_t_1);
  8507. #endif
  8508. } else {
  8509. if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
  8510. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8511. __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 541, __pyx_L1_error)
  8512. #else
  8513. __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
  8514. __Pyx_GOTREF(__pyx_t_1);
  8515. #endif
  8516. }
  8517. } else {
  8518. __pyx_t_1 = __pyx_t_5(__pyx_t_3);
  8519. if (unlikely(!__pyx_t_1)) {
  8520. PyObject* exc_type = PyErr_Occurred();
  8521. if (exc_type) {
  8522. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  8523. else __PYX_ERR(0, 541, __pyx_L1_error)
  8524. }
  8525. break;
  8526. }
  8527. __Pyx_GOTREF(__pyx_t_1);
  8528. }
  8529. __Pyx_XDECREF_SET(__pyx_v_dblabel, __pyx_t_1);
  8530. __pyx_t_1 = 0;
  8531. __Pyx_INCREF(__pyx_t_2);
  8532. __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
  8533. __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
  8534. __Pyx_GOTREF(__pyx_t_1);
  8535. __Pyx_DECREF(__pyx_t_2);
  8536. __pyx_t_2 = __pyx_t_1;
  8537. __pyx_t_1 = 0;
  8538. /* "lakesuperior/store/base_lmdb_store.pyx":543
  8539. * for i, dblabel in enumerate(self.dbi_labels):
  8540. * _check(
  8541. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat), # <<<<<<<<<<<<<<
  8542. * 'Error getting datbase stats: {}')
  8543. * entries = stat.ms_entries
  8544. */
  8545. __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 543, __pyx_L1_error)
  8546. /* "lakesuperior/store/base_lmdb_store.pyx":542
  8547. * db_stats = {}
  8548. * for i, dblabel in enumerate(self.dbi_labels):
  8549. * _check( # <<<<<<<<<<<<<<
  8550. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8551. * 'Error getting datbase stats: {}')
  8552. */
  8553. __pyx_t_7.__pyx_n = 1;
  8554. __pyx_t_7.message = __pyx_kp_u_Error_getting_datbase_stats;
  8555. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_stat(__pyx_v_self->txn, (__pyx_v_self->dbis[__pyx_t_6]), (&__pyx_v_stat)), &__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 542, __pyx_L1_error)
  8556. /* "lakesuperior/store/base_lmdb_store.pyx":545
  8557. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8558. * 'Error getting datbase stats: {}')
  8559. * entries = stat.ms_entries # <<<<<<<<<<<<<<
  8560. * db_stats[dblabel.encode()] = <dict>stat
  8561. *
  8562. */
  8563. __pyx_t_8 = __pyx_v_stat.ms_entries;
  8564. __pyx_v_entries = __pyx_t_8;
  8565. /* "lakesuperior/store/base_lmdb_store.pyx":546
  8566. * 'Error getting datbase stats: {}')
  8567. * entries = stat.ms_entries
  8568. * db_stats[dblabel.encode()] = <dict>stat # <<<<<<<<<<<<<<
  8569. *
  8570. * return {
  8571. */
  8572. __pyx_t_1 = __pyx_convert__to_py_struct__MDB_stat(__pyx_v_stat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error)
  8573. __Pyx_GOTREF(__pyx_t_1);
  8574. if (!(likely(PyDict_CheckExact(__pyx_t_1))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 546, __pyx_L1_error)
  8575. __pyx_t_9 = __pyx_t_1;
  8576. __Pyx_INCREF(__pyx_t_9);
  8577. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8578. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_dblabel, __pyx_n_s_encode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 546, __pyx_L1_error)
  8579. __Pyx_GOTREF(__pyx_t_10);
  8580. __pyx_t_11 = NULL;
  8581. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
  8582. __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
  8583. if (likely(__pyx_t_11)) {
  8584. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  8585. __Pyx_INCREF(__pyx_t_11);
  8586. __Pyx_INCREF(function);
  8587. __Pyx_DECREF_SET(__pyx_t_10, function);
  8588. }
  8589. }
  8590. if (__pyx_t_11) {
  8591. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error)
  8592. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  8593. } else {
  8594. __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error)
  8595. }
  8596. __Pyx_GOTREF(__pyx_t_1);
  8597. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8598. if (unlikely(PyDict_SetItem(__pyx_v_db_stats, __pyx_t_1, __pyx_t_9) < 0)) __PYX_ERR(0, 546, __pyx_L1_error)
  8599. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8600. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8601. /* "lakesuperior/store/base_lmdb_store.pyx":541
  8602. *
  8603. * db_stats = {}
  8604. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  8605. * _check(
  8606. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8607. */
  8608. }
  8609. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8610. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8611. /* "lakesuperior/store/base_lmdb_store.pyx":548
  8612. * db_stats[dblabel.encode()] = <dict>stat
  8613. *
  8614. * return { # <<<<<<<<<<<<<<
  8615. * 'env_stats': env_stats,
  8616. * 'env_size': os.stat(self.env_path).st_size,
  8617. */
  8618. __Pyx_XDECREF(__pyx_r);
  8619. /* "lakesuperior/store/base_lmdb_store.pyx":549
  8620. *
  8621. * return {
  8622. * 'env_stats': env_stats, # <<<<<<<<<<<<<<
  8623. * 'env_size': os.stat(self.env_path).st_size,
  8624. * 'db_stats': {
  8625. */
  8626. __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 549, __pyx_L1_error)
  8627. __Pyx_GOTREF(__pyx_t_2);
  8628. if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_env_stats, __pyx_v_env_stats) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  8629. /* "lakesuperior/store/base_lmdb_store.pyx":550
  8630. * return {
  8631. * 'env_stats': env_stats,
  8632. * 'env_size': os.stat(self.env_path).st_size, # <<<<<<<<<<<<<<
  8633. * 'db_stats': {
  8634. * db_label: db_stats[db_label.encode()]
  8635. */
  8636. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 550, __pyx_L1_error)
  8637. __Pyx_GOTREF(__pyx_t_9);
  8638. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_stat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 550, __pyx_L1_error)
  8639. __Pyx_GOTREF(__pyx_t_1);
  8640. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8641. __pyx_t_9 = NULL;
  8642. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  8643. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
  8644. if (likely(__pyx_t_9)) {
  8645. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  8646. __Pyx_INCREF(__pyx_t_9);
  8647. __Pyx_INCREF(function);
  8648. __Pyx_DECREF_SET(__pyx_t_1, function);
  8649. }
  8650. }
  8651. if (!__pyx_t_9) {
  8652. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_self->env_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 550, __pyx_L1_error)
  8653. __Pyx_GOTREF(__pyx_t_3);
  8654. } else {
  8655. #if CYTHON_FAST_PYCALL
  8656. if (PyFunction_Check(__pyx_t_1)) {
  8657. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_self->env_path};
  8658. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 550, __pyx_L1_error)
  8659. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  8660. __Pyx_GOTREF(__pyx_t_3);
  8661. } else
  8662. #endif
  8663. #if CYTHON_FAST_PYCCALL
  8664. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  8665. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_self->env_path};
  8666. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 550, __pyx_L1_error)
  8667. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  8668. __Pyx_GOTREF(__pyx_t_3);
  8669. } else
  8670. #endif
  8671. {
  8672. __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 550, __pyx_L1_error)
  8673. __Pyx_GOTREF(__pyx_t_10);
  8674. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
  8675. __Pyx_INCREF(__pyx_v_self->env_path);
  8676. __Pyx_GIVEREF(__pyx_v_self->env_path);
  8677. PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_self->env_path);
  8678. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 550, __pyx_L1_error)
  8679. __Pyx_GOTREF(__pyx_t_3);
  8680. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8681. }
  8682. }
  8683. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8684. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_st_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 550, __pyx_L1_error)
  8685. __Pyx_GOTREF(__pyx_t_1);
  8686. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8687. if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_env_size, __pyx_t_1) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  8688. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8689. { /* enter inner scope */
  8690. /* "lakesuperior/store/base_lmdb_store.pyx":551
  8691. * 'env_stats': env_stats,
  8692. * 'env_size': os.stat(self.env_path).st_size,
  8693. * 'db_stats': { # <<<<<<<<<<<<<<
  8694. * db_label: db_stats[db_label.encode()]
  8695. * for db_label in self.dbi_labels
  8696. */
  8697. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 551, __pyx_L7_error)
  8698. __Pyx_GOTREF(__pyx_t_1);
  8699. /* "lakesuperior/store/base_lmdb_store.pyx":553
  8700. * 'db_stats': {
  8701. * db_label: db_stats[db_label.encode()]
  8702. * for db_label in self.dbi_labels # <<<<<<<<<<<<<<
  8703. * },
  8704. * }
  8705. */
  8706. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dbi_labels); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 553, __pyx_L7_error)
  8707. __Pyx_GOTREF(__pyx_t_3);
  8708. if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
  8709. __pyx_t_10 = __pyx_t_3; __Pyx_INCREF(__pyx_t_10); __pyx_t_4 = 0;
  8710. __pyx_t_5 = NULL;
  8711. } else {
  8712. __pyx_t_4 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 553, __pyx_L7_error)
  8713. __Pyx_GOTREF(__pyx_t_10);
  8714. __pyx_t_5 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 553, __pyx_L7_error)
  8715. }
  8716. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8717. for (;;) {
  8718. if (likely(!__pyx_t_5)) {
  8719. if (likely(PyList_CheckExact(__pyx_t_10))) {
  8720. if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_10)) break;
  8721. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8722. __pyx_t_3 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 553, __pyx_L7_error)
  8723. #else
  8724. __pyx_t_3 = PySequence_ITEM(__pyx_t_10, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 553, __pyx_L7_error)
  8725. __Pyx_GOTREF(__pyx_t_3);
  8726. #endif
  8727. } else {
  8728. if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
  8729. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8730. __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 553, __pyx_L7_error)
  8731. #else
  8732. __pyx_t_3 = PySequence_ITEM(__pyx_t_10, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 553, __pyx_L7_error)
  8733. __Pyx_GOTREF(__pyx_t_3);
  8734. #endif
  8735. }
  8736. } else {
  8737. __pyx_t_3 = __pyx_t_5(__pyx_t_10);
  8738. if (unlikely(!__pyx_t_3)) {
  8739. PyObject* exc_type = PyErr_Occurred();
  8740. if (exc_type) {
  8741. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  8742. else __PYX_ERR(0, 553, __pyx_L7_error)
  8743. }
  8744. break;
  8745. }
  8746. __Pyx_GOTREF(__pyx_t_3);
  8747. }
  8748. __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_db_label, __pyx_t_3);
  8749. __pyx_t_3 = 0;
  8750. /* "lakesuperior/store/base_lmdb_store.pyx":552
  8751. * 'env_size': os.stat(self.env_path).st_size,
  8752. * 'db_stats': {
  8753. * db_label: db_stats[db_label.encode()] # <<<<<<<<<<<<<<
  8754. * for db_label in self.dbi_labels
  8755. * },
  8756. */
  8757. __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_7genexpr__pyx_v_db_label, __pyx_n_s_encode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 552, __pyx_L7_error)
  8758. __Pyx_GOTREF(__pyx_t_9);
  8759. __pyx_t_11 = NULL;
  8760. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
  8761. __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
  8762. if (likely(__pyx_t_11)) {
  8763. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
  8764. __Pyx_INCREF(__pyx_t_11);
  8765. __Pyx_INCREF(function);
  8766. __Pyx_DECREF_SET(__pyx_t_9, function);
  8767. }
  8768. }
  8769. if (__pyx_t_11) {
  8770. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L7_error)
  8771. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  8772. } else {
  8773. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L7_error)
  8774. }
  8775. __Pyx_GOTREF(__pyx_t_3);
  8776. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8777. __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_db_stats, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 552, __pyx_L7_error)
  8778. __Pyx_GOTREF(__pyx_t_9);
  8779. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8780. if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_7genexpr__pyx_v_db_label, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 552, __pyx_L7_error)
  8781. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8782. /* "lakesuperior/store/base_lmdb_store.pyx":553
  8783. * 'db_stats': {
  8784. * db_label: db_stats[db_label.encode()]
  8785. * for db_label in self.dbi_labels # <<<<<<<<<<<<<<
  8786. * },
  8787. * }
  8788. */
  8789. }
  8790. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8791. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_db_label); __pyx_7genexpr__pyx_v_db_label = 0;
  8792. goto __pyx_L10_exit_scope;
  8793. __pyx_L7_error:;
  8794. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_db_label); __pyx_7genexpr__pyx_v_db_label = 0;
  8795. goto __pyx_L1_error;
  8796. __pyx_L10_exit_scope:;
  8797. } /* exit inner scope */
  8798. if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_db_stats, __pyx_t_1) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  8799. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8800. __pyx_r = ((PyObject*)__pyx_t_2);
  8801. __pyx_t_2 = 0;
  8802. goto __pyx_L0;
  8803. /* "lakesuperior/store/base_lmdb_store.pyx":527
  8804. *
  8805. *
  8806. * cdef dict _stats(self): # <<<<<<<<<<<<<<
  8807. * """
  8808. * Gather statistics about the database.
  8809. */
  8810. /* function exit code */
  8811. __pyx_L1_error:;
  8812. __Pyx_XDECREF(__pyx_t_1);
  8813. __Pyx_XDECREF(__pyx_t_2);
  8814. __Pyx_XDECREF(__pyx_t_3);
  8815. __Pyx_XDECREF(__pyx_t_9);
  8816. __Pyx_XDECREF(__pyx_t_10);
  8817. __Pyx_XDECREF(__pyx_t_11);
  8818. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8819. __pyx_r = 0;
  8820. __pyx_L0:;
  8821. __Pyx_XDECREF(__pyx_v_env_stats);
  8822. __Pyx_XDECREF(__pyx_v_db_stats);
  8823. __Pyx_XDECREF(__pyx_v_i);
  8824. __Pyx_XDECREF(__pyx_v_dblabel);
  8825. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_db_label);
  8826. __Pyx_XGIVEREF(__pyx_r);
  8827. __Pyx_TraceReturn(__pyx_r, 0);
  8828. __Pyx_RefNannyFinishContext();
  8829. return __pyx_r;
  8830. }
  8831. /* "lakesuperior/store/base_lmdb_store.pyx":606
  8832. * ### CYTHON METHODS ###
  8833. *
  8834. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *: # <<<<<<<<<<<<<<
  8835. * if not self.is_open:
  8836. * raise LmdbError('Store is not open.')
  8837. */
  8838. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin *__pyx_optional_args) {
  8839. PyObject *__pyx_v_write = ((PyObject *)Py_True);
  8840. MDB_txn *__pyx_v_parent = ((MDB_txn *)NULL);
  8841. unsigned int __pyx_v_flags;
  8842. int __pyx_v_rc;
  8843. __Pyx_TraceDeclarations
  8844. __Pyx_RefNannyDeclarations
  8845. PyObject *__pyx_t_1 = NULL;
  8846. int __pyx_t_2;
  8847. int __pyx_t_3;
  8848. PyObject *__pyx_t_4 = NULL;
  8849. unsigned int __pyx_t_5;
  8850. PyObject *__pyx_t_6 = NULL;
  8851. PyObject *__pyx_t_7 = NULL;
  8852. PyObject *__pyx_t_8 = NULL;
  8853. PyObject *__pyx_t_9 = NULL;
  8854. PyObject *__pyx_t_10 = NULL;
  8855. PyObject *__pyx_t_11 = NULL;
  8856. PyObject *__pyx_t_12 = NULL;
  8857. PyObject *__pyx_t_13 = NULL;
  8858. int __pyx_t_14;
  8859. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_15;
  8860. __Pyx_RefNannySetupContext("_txn_begin", 0);
  8861. __Pyx_TraceCall("_txn_begin", __pyx_f[0], 606, 0, __PYX_ERR(0, 606, __pyx_L1_error));
  8862. if (__pyx_optional_args) {
  8863. if (__pyx_optional_args->__pyx_n > 0) {
  8864. __pyx_v_write = __pyx_optional_args->write;
  8865. if (__pyx_optional_args->__pyx_n > 1) {
  8866. __pyx_v_parent = __pyx_optional_args->parent;
  8867. }
  8868. }
  8869. }
  8870. /* "lakesuperior/store/base_lmdb_store.pyx":607
  8871. *
  8872. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  8873. * if not self.is_open: # <<<<<<<<<<<<<<
  8874. * raise LmdbError('Store is not open.')
  8875. *
  8876. */
  8877. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 607, __pyx_L1_error)
  8878. __Pyx_GOTREF(__pyx_t_1);
  8879. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 607, __pyx_L1_error)
  8880. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8881. __pyx_t_3 = ((!__pyx_t_2) != 0);
  8882. if (unlikely(__pyx_t_3)) {
  8883. /* "lakesuperior/store/base_lmdb_store.pyx":608
  8884. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  8885. * if not self.is_open:
  8886. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  8887. *
  8888. * cdef:
  8889. */
  8890. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
  8891. __Pyx_GOTREF(__pyx_t_1);
  8892. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 608, __pyx_L1_error)
  8893. __Pyx_GOTREF(__pyx_t_4);
  8894. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8895. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  8896. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8897. __PYX_ERR(0, 608, __pyx_L1_error)
  8898. /* "lakesuperior/store/base_lmdb_store.pyx":607
  8899. *
  8900. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  8901. * if not self.is_open: # <<<<<<<<<<<<<<
  8902. * raise LmdbError('Store is not open.')
  8903. *
  8904. */
  8905. }
  8906. /* "lakesuperior/store/base_lmdb_store.pyx":613
  8907. * unsigned int flags
  8908. *
  8909. * flags = 0 if write else lmdb.MDB_RDONLY # <<<<<<<<<<<<<<
  8910. *
  8911. * logger.debug('Opening {} transaction in PID {}, thread {}'.format(
  8912. */
  8913. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_write); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 613, __pyx_L1_error)
  8914. if (__pyx_t_3) {
  8915. __pyx_t_5 = 0;
  8916. } else {
  8917. __pyx_t_5 = MDB_RDONLY;
  8918. }
  8919. __pyx_v_flags = __pyx_t_5;
  8920. /* "lakesuperior/store/base_lmdb_store.pyx":615
  8921. * flags = 0 if write else lmdb.MDB_RDONLY
  8922. *
  8923. * logger.debug('Opening {} transaction in PID {}, thread {}'.format( # <<<<<<<<<<<<<<
  8924. * 'RW' if write else 'RO',
  8925. * multiprocessing.current_process().pid,
  8926. */
  8927. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 615, __pyx_L1_error)
  8928. __Pyx_GOTREF(__pyx_t_1);
  8929. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_debug); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 615, __pyx_L1_error)
  8930. __Pyx_GOTREF(__pyx_t_6);
  8931. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8932. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Opening_transaction_in_PID_threa, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 615, __pyx_L1_error)
  8933. __Pyx_GOTREF(__pyx_t_7);
  8934. /* "lakesuperior/store/base_lmdb_store.pyx":616
  8935. *
  8936. * logger.debug('Opening {} transaction in PID {}, thread {}'.format(
  8937. * 'RW' if write else 'RO', # <<<<<<<<<<<<<<
  8938. * multiprocessing.current_process().pid,
  8939. * threading.currentThread().getName()))
  8940. */
  8941. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_write); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 616, __pyx_L1_error)
  8942. if (__pyx_t_3) {
  8943. __Pyx_INCREF(__pyx_n_u_RW);
  8944. __pyx_t_8 = __pyx_n_u_RW;
  8945. } else {
  8946. __Pyx_INCREF(__pyx_n_u_RO);
  8947. __pyx_t_8 = __pyx_n_u_RO;
  8948. }
  8949. /* "lakesuperior/store/base_lmdb_store.pyx":617
  8950. * logger.debug('Opening {} transaction in PID {}, thread {}'.format(
  8951. * 'RW' if write else 'RO',
  8952. * multiprocessing.current_process().pid, # <<<<<<<<<<<<<<
  8953. * threading.currentThread().getName()))
  8954. * #logger.debug('Readers: {}'.format(self.reader_list()))
  8955. */
  8956. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiprocessing); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 617, __pyx_L1_error)
  8957. __Pyx_GOTREF(__pyx_t_10);
  8958. __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_current_process); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 617, __pyx_L1_error)
  8959. __Pyx_GOTREF(__pyx_t_11);
  8960. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8961. __pyx_t_10 = NULL;
  8962. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
  8963. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
  8964. if (likely(__pyx_t_10)) {
  8965. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
  8966. __Pyx_INCREF(__pyx_t_10);
  8967. __Pyx_INCREF(function);
  8968. __Pyx_DECREF_SET(__pyx_t_11, function);
  8969. }
  8970. }
  8971. if (__pyx_t_10) {
  8972. __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 617, __pyx_L1_error)
  8973. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8974. } else {
  8975. __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 617, __pyx_L1_error)
  8976. }
  8977. __Pyx_GOTREF(__pyx_t_9);
  8978. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  8979. __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_pid); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 617, __pyx_L1_error)
  8980. __Pyx_GOTREF(__pyx_t_11);
  8981. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8982. /* "lakesuperior/store/base_lmdb_store.pyx":618
  8983. * 'RW' if write else 'RO',
  8984. * multiprocessing.current_process().pid,
  8985. * threading.currentThread().getName())) # <<<<<<<<<<<<<<
  8986. * #logger.debug('Readers: {}'.format(self.reader_list()))
  8987. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn)
  8988. */
  8989. __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 618, __pyx_L1_error)
  8990. __Pyx_GOTREF(__pyx_t_12);
  8991. __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_currentThread); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 618, __pyx_L1_error)
  8992. __Pyx_GOTREF(__pyx_t_13);
  8993. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  8994. __pyx_t_12 = NULL;
  8995. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
  8996. __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
  8997. if (likely(__pyx_t_12)) {
  8998. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  8999. __Pyx_INCREF(__pyx_t_12);
  9000. __Pyx_INCREF(function);
  9001. __Pyx_DECREF_SET(__pyx_t_13, function);
  9002. }
  9003. }
  9004. if (__pyx_t_12) {
  9005. __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 618, __pyx_L1_error)
  9006. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  9007. } else {
  9008. __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 618, __pyx_L1_error)
  9009. }
  9010. __Pyx_GOTREF(__pyx_t_10);
  9011. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  9012. __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_getName); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 618, __pyx_L1_error)
  9013. __Pyx_GOTREF(__pyx_t_13);
  9014. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9015. __pyx_t_10 = NULL;
  9016. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  9017. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_13);
  9018. if (likely(__pyx_t_10)) {
  9019. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  9020. __Pyx_INCREF(__pyx_t_10);
  9021. __Pyx_INCREF(function);
  9022. __Pyx_DECREF_SET(__pyx_t_13, function);
  9023. }
  9024. }
  9025. if (__pyx_t_10) {
  9026. __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 618, __pyx_L1_error)
  9027. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9028. } else {
  9029. __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 618, __pyx_L1_error)
  9030. }
  9031. __Pyx_GOTREF(__pyx_t_9);
  9032. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  9033. __pyx_t_13 = NULL;
  9034. __pyx_t_14 = 0;
  9035. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
  9036. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
  9037. if (likely(__pyx_t_13)) {
  9038. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  9039. __Pyx_INCREF(__pyx_t_13);
  9040. __Pyx_INCREF(function);
  9041. __Pyx_DECREF_SET(__pyx_t_7, function);
  9042. __pyx_t_14 = 1;
  9043. }
  9044. }
  9045. #if CYTHON_FAST_PYCALL
  9046. if (PyFunction_Check(__pyx_t_7)) {
  9047. PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_8, __pyx_t_11, __pyx_t_9};
  9048. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 3+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 615, __pyx_L1_error)
  9049. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  9050. __Pyx_GOTREF(__pyx_t_1);
  9051. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  9052. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9053. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9054. } else
  9055. #endif
  9056. #if CYTHON_FAST_PYCCALL
  9057. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  9058. PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_8, __pyx_t_11, __pyx_t_9};
  9059. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 3+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 615, __pyx_L1_error)
  9060. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  9061. __Pyx_GOTREF(__pyx_t_1);
  9062. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  9063. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9064. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9065. } else
  9066. #endif
  9067. {
  9068. __pyx_t_10 = PyTuple_New(3+__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 615, __pyx_L1_error)
  9069. __Pyx_GOTREF(__pyx_t_10);
  9070. if (__pyx_t_13) {
  9071. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_13); __pyx_t_13 = NULL;
  9072. }
  9073. __Pyx_GIVEREF(__pyx_t_8);
  9074. PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_14, __pyx_t_8);
  9075. __Pyx_GIVEREF(__pyx_t_11);
  9076. PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_14, __pyx_t_11);
  9077. __Pyx_GIVEREF(__pyx_t_9);
  9078. PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_14, __pyx_t_9);
  9079. __pyx_t_8 = 0;
  9080. __pyx_t_11 = 0;
  9081. __pyx_t_9 = 0;
  9082. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 615, __pyx_L1_error)
  9083. __Pyx_GOTREF(__pyx_t_1);
  9084. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9085. }
  9086. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9087. __pyx_t_7 = NULL;
  9088. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
  9089. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  9090. if (likely(__pyx_t_7)) {
  9091. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  9092. __Pyx_INCREF(__pyx_t_7);
  9093. __Pyx_INCREF(function);
  9094. __Pyx_DECREF_SET(__pyx_t_6, function);
  9095. }
  9096. }
  9097. if (!__pyx_t_7) {
  9098. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error)
  9099. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9100. __Pyx_GOTREF(__pyx_t_4);
  9101. } else {
  9102. #if CYTHON_FAST_PYCALL
  9103. if (PyFunction_Check(__pyx_t_6)) {
  9104. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9105. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error)
  9106. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9107. __Pyx_GOTREF(__pyx_t_4);
  9108. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9109. } else
  9110. #endif
  9111. #if CYTHON_FAST_PYCCALL
  9112. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  9113. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9114. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error)
  9115. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9116. __Pyx_GOTREF(__pyx_t_4);
  9117. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9118. } else
  9119. #endif
  9120. {
  9121. __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 615, __pyx_L1_error)
  9122. __Pyx_GOTREF(__pyx_t_10);
  9123. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
  9124. __Pyx_GIVEREF(__pyx_t_1);
  9125. PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_1);
  9126. __pyx_t_1 = 0;
  9127. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error)
  9128. __Pyx_GOTREF(__pyx_t_4);
  9129. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9130. }
  9131. }
  9132. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9133. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9134. /* "lakesuperior/store/base_lmdb_store.pyx":620
  9135. * threading.currentThread().getName()))
  9136. * #logger.debug('Readers: {}'.format(self.reader_list()))
  9137. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn) # <<<<<<<<<<<<<<
  9138. * _check(rc, 'Error opening transaction.')
  9139. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn))
  9140. */
  9141. __pyx_v_rc = mdb_txn_begin(__pyx_v_self->dbenv, __pyx_v_parent, __pyx_v_flags, (&__pyx_v_self->txn));
  9142. /* "lakesuperior/store/base_lmdb_store.pyx":621
  9143. * #logger.debug('Readers: {}'.format(self.reader_list()))
  9144. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn)
  9145. * _check(rc, 'Error opening transaction.') # <<<<<<<<<<<<<<
  9146. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn))
  9147. *
  9148. */
  9149. __pyx_t_15.__pyx_n = 1;
  9150. __pyx_t_15.message = __pyx_kp_u_Error_opening_transaction;
  9151. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(__pyx_v_rc, &__pyx_t_15); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 621, __pyx_L1_error)
  9152. /* "lakesuperior/store/base_lmdb_store.pyx":622
  9153. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn)
  9154. * _check(rc, 'Error opening transaction.')
  9155. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn)) # <<<<<<<<<<<<<<
  9156. *
  9157. * self.is_txn_open = True
  9158. */
  9159. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 622, __pyx_L1_error)
  9160. __Pyx_GOTREF(__pyx_t_6);
  9161. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_debug); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 622, __pyx_L1_error)
  9162. __Pyx_GOTREF(__pyx_t_10);
  9163. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9164. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Opened_transaction_x, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 622, __pyx_L1_error)
  9165. __Pyx_GOTREF(__pyx_t_1);
  9166. __pyx_t_7 = __Pyx_PyInt_From_unsigned_long(((unsigned long)__pyx_v_self->txn)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 622, __pyx_L1_error)
  9167. __Pyx_GOTREF(__pyx_t_7);
  9168. __pyx_t_9 = NULL;
  9169. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  9170. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
  9171. if (likely(__pyx_t_9)) {
  9172. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  9173. __Pyx_INCREF(__pyx_t_9);
  9174. __Pyx_INCREF(function);
  9175. __Pyx_DECREF_SET(__pyx_t_1, function);
  9176. }
  9177. }
  9178. if (!__pyx_t_9) {
  9179. __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 622, __pyx_L1_error)
  9180. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9181. __Pyx_GOTREF(__pyx_t_6);
  9182. } else {
  9183. #if CYTHON_FAST_PYCALL
  9184. if (PyFunction_Check(__pyx_t_1)) {
  9185. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
  9186. __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 622, __pyx_L1_error)
  9187. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  9188. __Pyx_GOTREF(__pyx_t_6);
  9189. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9190. } else
  9191. #endif
  9192. #if CYTHON_FAST_PYCCALL
  9193. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  9194. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
  9195. __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 622, __pyx_L1_error)
  9196. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  9197. __Pyx_GOTREF(__pyx_t_6);
  9198. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9199. } else
  9200. #endif
  9201. {
  9202. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 622, __pyx_L1_error)
  9203. __Pyx_GOTREF(__pyx_t_11);
  9204. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
  9205. __Pyx_GIVEREF(__pyx_t_7);
  9206. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_7);
  9207. __pyx_t_7 = 0;
  9208. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 622, __pyx_L1_error)
  9209. __Pyx_GOTREF(__pyx_t_6);
  9210. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9211. }
  9212. }
  9213. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9214. __pyx_t_1 = NULL;
  9215. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
  9216. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
  9217. if (likely(__pyx_t_1)) {
  9218. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  9219. __Pyx_INCREF(__pyx_t_1);
  9220. __Pyx_INCREF(function);
  9221. __Pyx_DECREF_SET(__pyx_t_10, function);
  9222. }
  9223. }
  9224. if (!__pyx_t_1) {
  9225. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 622, __pyx_L1_error)
  9226. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9227. __Pyx_GOTREF(__pyx_t_4);
  9228. } else {
  9229. #if CYTHON_FAST_PYCALL
  9230. if (PyFunction_Check(__pyx_t_10)) {
  9231. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6};
  9232. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 622, __pyx_L1_error)
  9233. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9234. __Pyx_GOTREF(__pyx_t_4);
  9235. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9236. } else
  9237. #endif
  9238. #if CYTHON_FAST_PYCCALL
  9239. if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
  9240. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6};
  9241. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 622, __pyx_L1_error)
  9242. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9243. __Pyx_GOTREF(__pyx_t_4);
  9244. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9245. } else
  9246. #endif
  9247. {
  9248. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 622, __pyx_L1_error)
  9249. __Pyx_GOTREF(__pyx_t_11);
  9250. __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL;
  9251. __Pyx_GIVEREF(__pyx_t_6);
  9252. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_6);
  9253. __pyx_t_6 = 0;
  9254. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 622, __pyx_L1_error)
  9255. __Pyx_GOTREF(__pyx_t_4);
  9256. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9257. }
  9258. }
  9259. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9260. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9261. /* "lakesuperior/store/base_lmdb_store.pyx":624
  9262. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn))
  9263. *
  9264. * self.is_txn_open = True # <<<<<<<<<<<<<<
  9265. * self.is_txn_rw = write
  9266. * logger.debug('txn is open: {}'.format(self.is_txn_open))
  9267. */
  9268. __pyx_v_self->is_txn_open = 1;
  9269. /* "lakesuperior/store/base_lmdb_store.pyx":625
  9270. *
  9271. * self.is_txn_open = True
  9272. * self.is_txn_rw = write # <<<<<<<<<<<<<<
  9273. * logger.debug('txn is open: {}'.format(self.is_txn_open))
  9274. *
  9275. */
  9276. if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_txn_rw, __pyx_v_write) < 0) __PYX_ERR(0, 625, __pyx_L1_error)
  9277. /* "lakesuperior/store/base_lmdb_store.pyx":626
  9278. * self.is_txn_open = True
  9279. * self.is_txn_rw = write
  9280. * logger.debug('txn is open: {}'.format(self.is_txn_open)) # <<<<<<<<<<<<<<
  9281. *
  9282. *
  9283. */
  9284. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 626, __pyx_L1_error)
  9285. __Pyx_GOTREF(__pyx_t_10);
  9286. __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_debug); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 626, __pyx_L1_error)
  9287. __Pyx_GOTREF(__pyx_t_11);
  9288. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9289. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_txn_is_open, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 626, __pyx_L1_error)
  9290. __Pyx_GOTREF(__pyx_t_6);
  9291. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_txn_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L1_error)
  9292. __Pyx_GOTREF(__pyx_t_1);
  9293. __pyx_t_7 = NULL;
  9294. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  9295. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  9296. if (likely(__pyx_t_7)) {
  9297. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  9298. __Pyx_INCREF(__pyx_t_7);
  9299. __Pyx_INCREF(function);
  9300. __Pyx_DECREF_SET(__pyx_t_6, function);
  9301. }
  9302. }
  9303. if (!__pyx_t_7) {
  9304. __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 626, __pyx_L1_error)
  9305. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9306. __Pyx_GOTREF(__pyx_t_10);
  9307. } else {
  9308. #if CYTHON_FAST_PYCALL
  9309. if (PyFunction_Check(__pyx_t_6)) {
  9310. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9311. __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 626, __pyx_L1_error)
  9312. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9313. __Pyx_GOTREF(__pyx_t_10);
  9314. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9315. } else
  9316. #endif
  9317. #if CYTHON_FAST_PYCCALL
  9318. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  9319. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9320. __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 626, __pyx_L1_error)
  9321. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9322. __Pyx_GOTREF(__pyx_t_10);
  9323. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9324. } else
  9325. #endif
  9326. {
  9327. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 626, __pyx_L1_error)
  9328. __Pyx_GOTREF(__pyx_t_9);
  9329. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
  9330. __Pyx_GIVEREF(__pyx_t_1);
  9331. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_1);
  9332. __pyx_t_1 = 0;
  9333. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 626, __pyx_L1_error)
  9334. __Pyx_GOTREF(__pyx_t_10);
  9335. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9336. }
  9337. }
  9338. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9339. __pyx_t_6 = NULL;
  9340. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
  9341. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11);
  9342. if (likely(__pyx_t_6)) {
  9343. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
  9344. __Pyx_INCREF(__pyx_t_6);
  9345. __Pyx_INCREF(function);
  9346. __Pyx_DECREF_SET(__pyx_t_11, function);
  9347. }
  9348. }
  9349. if (!__pyx_t_6) {
  9350. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 626, __pyx_L1_error)
  9351. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9352. __Pyx_GOTREF(__pyx_t_4);
  9353. } else {
  9354. #if CYTHON_FAST_PYCALL
  9355. if (PyFunction_Check(__pyx_t_11)) {
  9356. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  9357. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 626, __pyx_L1_error)
  9358. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  9359. __Pyx_GOTREF(__pyx_t_4);
  9360. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9361. } else
  9362. #endif
  9363. #if CYTHON_FAST_PYCCALL
  9364. if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
  9365. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  9366. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 626, __pyx_L1_error)
  9367. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  9368. __Pyx_GOTREF(__pyx_t_4);
  9369. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9370. } else
  9371. #endif
  9372. {
  9373. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 626, __pyx_L1_error)
  9374. __Pyx_GOTREF(__pyx_t_9);
  9375. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
  9376. __Pyx_GIVEREF(__pyx_t_10);
  9377. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_10);
  9378. __pyx_t_10 = 0;
  9379. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 626, __pyx_L1_error)
  9380. __Pyx_GOTREF(__pyx_t_4);
  9381. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9382. }
  9383. }
  9384. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9385. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9386. /* "lakesuperior/store/base_lmdb_store.pyx":606
  9387. * ### CYTHON METHODS ###
  9388. *
  9389. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *: # <<<<<<<<<<<<<<
  9390. * if not self.is_open:
  9391. * raise LmdbError('Store is not open.')
  9392. */
  9393. /* function exit code */
  9394. goto __pyx_L0;
  9395. __pyx_L1_error:;
  9396. __Pyx_XDECREF(__pyx_t_1);
  9397. __Pyx_XDECREF(__pyx_t_4);
  9398. __Pyx_XDECREF(__pyx_t_6);
  9399. __Pyx_XDECREF(__pyx_t_7);
  9400. __Pyx_XDECREF(__pyx_t_8);
  9401. __Pyx_XDECREF(__pyx_t_9);
  9402. __Pyx_XDECREF(__pyx_t_10);
  9403. __Pyx_XDECREF(__pyx_t_11);
  9404. __Pyx_XDECREF(__pyx_t_12);
  9405. __Pyx_XDECREF(__pyx_t_13);
  9406. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_begin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9407. __pyx_L0:;
  9408. __Pyx_TraceReturn(Py_None, 0);
  9409. __Pyx_RefNannyFinishContext();
  9410. }
  9411. /* "lakesuperior/store/base_lmdb_store.pyx":629
  9412. *
  9413. *
  9414. * cdef void _txn_commit(self) except *: # <<<<<<<<<<<<<<
  9415. * txid = '{:x}'.format(<unsigned long>self.txn)
  9416. * try:
  9417. */
  9418. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_commit(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  9419. PyObject *__pyx_v_txid = NULL;
  9420. __Pyx_TraceDeclarations
  9421. __Pyx_RefNannyDeclarations
  9422. PyObject *__pyx_t_1 = NULL;
  9423. PyObject *__pyx_t_2 = NULL;
  9424. PyObject *__pyx_t_3 = NULL;
  9425. PyObject *__pyx_t_4 = NULL;
  9426. PyObject *__pyx_t_5 = NULL;
  9427. PyObject *__pyx_t_6 = NULL;
  9428. PyObject *__pyx_t_7 = NULL;
  9429. PyObject *__pyx_t_8 = NULL;
  9430. PyObject *__pyx_t_9 = NULL;
  9431. __Pyx_RefNannySetupContext("_txn_commit", 0);
  9432. __Pyx_TraceCall("_txn_commit", __pyx_f[0], 629, 0, __PYX_ERR(0, 629, __pyx_L1_error));
  9433. /* "lakesuperior/store/base_lmdb_store.pyx":630
  9434. *
  9435. * cdef void _txn_commit(self) except *:
  9436. * txid = '{:x}'.format(<unsigned long>self.txn) # <<<<<<<<<<<<<<
  9437. * try:
  9438. * _check(lmdb.mdb_txn_commit(self.txn))
  9439. */
  9440. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_x, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 630, __pyx_L1_error)
  9441. __Pyx_GOTREF(__pyx_t_2);
  9442. __pyx_t_3 = __Pyx_PyInt_From_unsigned_long(((unsigned long)__pyx_v_self->txn)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 630, __pyx_L1_error)
  9443. __Pyx_GOTREF(__pyx_t_3);
  9444. __pyx_t_4 = NULL;
  9445. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  9446. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
  9447. if (likely(__pyx_t_4)) {
  9448. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  9449. __Pyx_INCREF(__pyx_t_4);
  9450. __Pyx_INCREF(function);
  9451. __Pyx_DECREF_SET(__pyx_t_2, function);
  9452. }
  9453. }
  9454. if (!__pyx_t_4) {
  9455. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error)
  9456. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9457. __Pyx_GOTREF(__pyx_t_1);
  9458. } else {
  9459. #if CYTHON_FAST_PYCALL
  9460. if (PyFunction_Check(__pyx_t_2)) {
  9461. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9462. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error)
  9463. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9464. __Pyx_GOTREF(__pyx_t_1);
  9465. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9466. } else
  9467. #endif
  9468. #if CYTHON_FAST_PYCCALL
  9469. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  9470. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9471. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error)
  9472. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9473. __Pyx_GOTREF(__pyx_t_1);
  9474. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9475. } else
  9476. #endif
  9477. {
  9478. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 630, __pyx_L1_error)
  9479. __Pyx_GOTREF(__pyx_t_5);
  9480. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9481. __Pyx_GIVEREF(__pyx_t_3);
  9482. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
  9483. __pyx_t_3 = 0;
  9484. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error)
  9485. __Pyx_GOTREF(__pyx_t_1);
  9486. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  9487. }
  9488. }
  9489. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9490. __pyx_v_txid = __pyx_t_1;
  9491. __pyx_t_1 = 0;
  9492. /* "lakesuperior/store/base_lmdb_store.pyx":631
  9493. * cdef void _txn_commit(self) except *:
  9494. * txid = '{:x}'.format(<unsigned long>self.txn)
  9495. * try: # <<<<<<<<<<<<<<
  9496. * _check(lmdb.mdb_txn_commit(self.txn))
  9497. * logger.debug('Transaction @ {} committed.'.format(txid))
  9498. */
  9499. {
  9500. __Pyx_PyThreadState_declare
  9501. __Pyx_PyThreadState_assign
  9502. __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
  9503. __Pyx_XGOTREF(__pyx_t_6);
  9504. __Pyx_XGOTREF(__pyx_t_7);
  9505. __Pyx_XGOTREF(__pyx_t_8);
  9506. /*try:*/ {
  9507. /* "lakesuperior/store/base_lmdb_store.pyx":632
  9508. * txid = '{:x}'.format(<unsigned long>self.txn)
  9509. * try:
  9510. * _check(lmdb.mdb_txn_commit(self.txn)) # <<<<<<<<<<<<<<
  9511. * logger.debug('Transaction @ {} committed.'.format(txid))
  9512. * self.is_txn_open = False
  9513. */
  9514. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_txn_commit(__pyx_v_self->txn), NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 632, __pyx_L3_error)
  9515. /* "lakesuperior/store/base_lmdb_store.pyx":633
  9516. * try:
  9517. * _check(lmdb.mdb_txn_commit(self.txn))
  9518. * logger.debug('Transaction @ {} committed.'.format(txid)) # <<<<<<<<<<<<<<
  9519. * self.is_txn_open = False
  9520. * self.is_txn_rw = False
  9521. */
  9522. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L3_error)
  9523. __Pyx_GOTREF(__pyx_t_2);
  9524. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 633, __pyx_L3_error)
  9525. __Pyx_GOTREF(__pyx_t_5);
  9526. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9527. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Transaction_committed, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 633, __pyx_L3_error)
  9528. __Pyx_GOTREF(__pyx_t_3);
  9529. __pyx_t_4 = NULL;
  9530. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  9531. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  9532. if (likely(__pyx_t_4)) {
  9533. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  9534. __Pyx_INCREF(__pyx_t_4);
  9535. __Pyx_INCREF(function);
  9536. __Pyx_DECREF_SET(__pyx_t_3, function);
  9537. }
  9538. }
  9539. if (!__pyx_t_4) {
  9540. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_txid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L3_error)
  9541. __Pyx_GOTREF(__pyx_t_2);
  9542. } else {
  9543. #if CYTHON_FAST_PYCALL
  9544. if (PyFunction_Check(__pyx_t_3)) {
  9545. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9546. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L3_error)
  9547. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9548. __Pyx_GOTREF(__pyx_t_2);
  9549. } else
  9550. #endif
  9551. #if CYTHON_FAST_PYCCALL
  9552. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  9553. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9554. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L3_error)
  9555. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9556. __Pyx_GOTREF(__pyx_t_2);
  9557. } else
  9558. #endif
  9559. {
  9560. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 633, __pyx_L3_error)
  9561. __Pyx_GOTREF(__pyx_t_9);
  9562. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9563. __Pyx_INCREF(__pyx_v_txid);
  9564. __Pyx_GIVEREF(__pyx_v_txid);
  9565. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_txid);
  9566. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L3_error)
  9567. __Pyx_GOTREF(__pyx_t_2);
  9568. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9569. }
  9570. }
  9571. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9572. __pyx_t_3 = NULL;
  9573. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  9574. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
  9575. if (likely(__pyx_t_3)) {
  9576. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  9577. __Pyx_INCREF(__pyx_t_3);
  9578. __Pyx_INCREF(function);
  9579. __Pyx_DECREF_SET(__pyx_t_5, function);
  9580. }
  9581. }
  9582. if (!__pyx_t_3) {
  9583. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L3_error)
  9584. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9585. __Pyx_GOTREF(__pyx_t_1);
  9586. } else {
  9587. #if CYTHON_FAST_PYCALL
  9588. if (PyFunction_Check(__pyx_t_5)) {
  9589. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  9590. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L3_error)
  9591. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9592. __Pyx_GOTREF(__pyx_t_1);
  9593. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9594. } else
  9595. #endif
  9596. #if CYTHON_FAST_PYCCALL
  9597. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  9598. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  9599. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L3_error)
  9600. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9601. __Pyx_GOTREF(__pyx_t_1);
  9602. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9603. } else
  9604. #endif
  9605. {
  9606. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 633, __pyx_L3_error)
  9607. __Pyx_GOTREF(__pyx_t_9);
  9608. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = NULL;
  9609. __Pyx_GIVEREF(__pyx_t_2);
  9610. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_2);
  9611. __pyx_t_2 = 0;
  9612. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L3_error)
  9613. __Pyx_GOTREF(__pyx_t_1);
  9614. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9615. }
  9616. }
  9617. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  9618. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9619. /* "lakesuperior/store/base_lmdb_store.pyx":634
  9620. * _check(lmdb.mdb_txn_commit(self.txn))
  9621. * logger.debug('Transaction @ {} committed.'.format(txid))
  9622. * self.is_txn_open = False # <<<<<<<<<<<<<<
  9623. * self.is_txn_rw = False
  9624. * except:
  9625. */
  9626. __pyx_v_self->is_txn_open = 0;
  9627. /* "lakesuperior/store/base_lmdb_store.pyx":635
  9628. * logger.debug('Transaction @ {} committed.'.format(txid))
  9629. * self.is_txn_open = False
  9630. * self.is_txn_rw = False # <<<<<<<<<<<<<<
  9631. * except:
  9632. * self._txn_abort()
  9633. */
  9634. if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_txn_rw, Py_False) < 0) __PYX_ERR(0, 635, __pyx_L3_error)
  9635. /* "lakesuperior/store/base_lmdb_store.pyx":631
  9636. * cdef void _txn_commit(self) except *:
  9637. * txid = '{:x}'.format(<unsigned long>self.txn)
  9638. * try: # <<<<<<<<<<<<<<
  9639. * _check(lmdb.mdb_txn_commit(self.txn))
  9640. * logger.debug('Transaction @ {} committed.'.format(txid))
  9641. */
  9642. }
  9643. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  9644. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9645. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  9646. goto __pyx_L8_try_end;
  9647. __pyx_L3_error:;
  9648. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9649. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9650. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  9651. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  9652. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  9653. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9654. /* "lakesuperior/store/base_lmdb_store.pyx":636
  9655. * self.is_txn_open = False
  9656. * self.is_txn_rw = False
  9657. * except: # <<<<<<<<<<<<<<
  9658. * self._txn_abort()
  9659. * raise
  9660. */
  9661. /*except:*/ {
  9662. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_commit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9663. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) __PYX_ERR(0, 636, __pyx_L5_except_error)
  9664. __Pyx_GOTREF(__pyx_t_1);
  9665. __Pyx_GOTREF(__pyx_t_5);
  9666. __Pyx_GOTREF(__pyx_t_9);
  9667. /* "lakesuperior/store/base_lmdb_store.pyx":637
  9668. * self.is_txn_rw = False
  9669. * except:
  9670. * self._txn_abort() # <<<<<<<<<<<<<<
  9671. * raise
  9672. *
  9673. */
  9674. ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_txn_abort(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 637, __pyx_L5_except_error)
  9675. /* "lakesuperior/store/base_lmdb_store.pyx":638
  9676. * except:
  9677. * self._txn_abort()
  9678. * raise # <<<<<<<<<<<<<<
  9679. *
  9680. *
  9681. */
  9682. __Pyx_GIVEREF(__pyx_t_1);
  9683. __Pyx_GIVEREF(__pyx_t_5);
  9684. __Pyx_XGIVEREF(__pyx_t_9);
  9685. __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_5, __pyx_t_9);
  9686. __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
  9687. __PYX_ERR(0, 638, __pyx_L5_except_error)
  9688. }
  9689. __pyx_L5_except_error:;
  9690. /* "lakesuperior/store/base_lmdb_store.pyx":631
  9691. * cdef void _txn_commit(self) except *:
  9692. * txid = '{:x}'.format(<unsigned long>self.txn)
  9693. * try: # <<<<<<<<<<<<<<
  9694. * _check(lmdb.mdb_txn_commit(self.txn))
  9695. * logger.debug('Transaction @ {} committed.'.format(txid))
  9696. */
  9697. __Pyx_XGIVEREF(__pyx_t_6);
  9698. __Pyx_XGIVEREF(__pyx_t_7);
  9699. __Pyx_XGIVEREF(__pyx_t_8);
  9700. __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  9701. goto __pyx_L1_error;
  9702. __pyx_L8_try_end:;
  9703. }
  9704. /* "lakesuperior/store/base_lmdb_store.pyx":629
  9705. *
  9706. *
  9707. * cdef void _txn_commit(self) except *: # <<<<<<<<<<<<<<
  9708. * txid = '{:x}'.format(<unsigned long>self.txn)
  9709. * try:
  9710. */
  9711. /* function exit code */
  9712. goto __pyx_L0;
  9713. __pyx_L1_error:;
  9714. __Pyx_XDECREF(__pyx_t_1);
  9715. __Pyx_XDECREF(__pyx_t_2);
  9716. __Pyx_XDECREF(__pyx_t_3);
  9717. __Pyx_XDECREF(__pyx_t_4);
  9718. __Pyx_XDECREF(__pyx_t_5);
  9719. __Pyx_XDECREF(__pyx_t_9);
  9720. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_commit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9721. __pyx_L0:;
  9722. __Pyx_XDECREF(__pyx_v_txid);
  9723. __Pyx_TraceReturn(Py_None, 0);
  9724. __Pyx_RefNannyFinishContext();
  9725. }
  9726. /* "lakesuperior/store/base_lmdb_store.pyx":641
  9727. *
  9728. *
  9729. * cdef void _txn_abort(self) except *: # <<<<<<<<<<<<<<
  9730. * txid = '{:x}'.format(<unsigned long>self.txn)
  9731. * lmdb.mdb_txn_abort(self.txn)
  9732. */
  9733. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_abort(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  9734. PyObject *__pyx_v_txid = NULL;
  9735. __Pyx_TraceDeclarations
  9736. __Pyx_RefNannyDeclarations
  9737. PyObject *__pyx_t_1 = NULL;
  9738. PyObject *__pyx_t_2 = NULL;
  9739. PyObject *__pyx_t_3 = NULL;
  9740. PyObject *__pyx_t_4 = NULL;
  9741. PyObject *__pyx_t_5 = NULL;
  9742. PyObject *__pyx_t_6 = NULL;
  9743. __Pyx_RefNannySetupContext("_txn_abort", 0);
  9744. __Pyx_TraceCall("_txn_abort", __pyx_f[0], 641, 0, __PYX_ERR(0, 641, __pyx_L1_error));
  9745. /* "lakesuperior/store/base_lmdb_store.pyx":642
  9746. *
  9747. * cdef void _txn_abort(self) except *:
  9748. * txid = '{:x}'.format(<unsigned long>self.txn) # <<<<<<<<<<<<<<
  9749. * lmdb.mdb_txn_abort(self.txn)
  9750. * self.is_txn_open = False
  9751. */
  9752. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_x, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 642, __pyx_L1_error)
  9753. __Pyx_GOTREF(__pyx_t_2);
  9754. __pyx_t_3 = __Pyx_PyInt_From_unsigned_long(((unsigned long)__pyx_v_self->txn)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 642, __pyx_L1_error)
  9755. __Pyx_GOTREF(__pyx_t_3);
  9756. __pyx_t_4 = NULL;
  9757. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  9758. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
  9759. if (likely(__pyx_t_4)) {
  9760. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  9761. __Pyx_INCREF(__pyx_t_4);
  9762. __Pyx_INCREF(function);
  9763. __Pyx_DECREF_SET(__pyx_t_2, function);
  9764. }
  9765. }
  9766. if (!__pyx_t_4) {
  9767. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error)
  9768. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9769. __Pyx_GOTREF(__pyx_t_1);
  9770. } else {
  9771. #if CYTHON_FAST_PYCALL
  9772. if (PyFunction_Check(__pyx_t_2)) {
  9773. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9774. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error)
  9775. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9776. __Pyx_GOTREF(__pyx_t_1);
  9777. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9778. } else
  9779. #endif
  9780. #if CYTHON_FAST_PYCCALL
  9781. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  9782. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9783. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error)
  9784. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9785. __Pyx_GOTREF(__pyx_t_1);
  9786. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9787. } else
  9788. #endif
  9789. {
  9790. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 642, __pyx_L1_error)
  9791. __Pyx_GOTREF(__pyx_t_5);
  9792. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9793. __Pyx_GIVEREF(__pyx_t_3);
  9794. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
  9795. __pyx_t_3 = 0;
  9796. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error)
  9797. __Pyx_GOTREF(__pyx_t_1);
  9798. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  9799. }
  9800. }
  9801. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9802. __pyx_v_txid = __pyx_t_1;
  9803. __pyx_t_1 = 0;
  9804. /* "lakesuperior/store/base_lmdb_store.pyx":643
  9805. * cdef void _txn_abort(self) except *:
  9806. * txid = '{:x}'.format(<unsigned long>self.txn)
  9807. * lmdb.mdb_txn_abort(self.txn) # <<<<<<<<<<<<<<
  9808. * self.is_txn_open = False
  9809. * self.is_txn_rw = False
  9810. */
  9811. mdb_txn_abort(__pyx_v_self->txn);
  9812. /* "lakesuperior/store/base_lmdb_store.pyx":644
  9813. * txid = '{:x}'.format(<unsigned long>self.txn)
  9814. * lmdb.mdb_txn_abort(self.txn)
  9815. * self.is_txn_open = False # <<<<<<<<<<<<<<
  9816. * self.is_txn_rw = False
  9817. * logger.info('Transaction @ {} aborted.'.format(txid))
  9818. */
  9819. __pyx_v_self->is_txn_open = 0;
  9820. /* "lakesuperior/store/base_lmdb_store.pyx":645
  9821. * lmdb.mdb_txn_abort(self.txn)
  9822. * self.is_txn_open = False
  9823. * self.is_txn_rw = False # <<<<<<<<<<<<<<
  9824. * logger.info('Transaction @ {} aborted.'.format(txid))
  9825. *
  9826. */
  9827. if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_txn_rw, Py_False) < 0) __PYX_ERR(0, 645, __pyx_L1_error)
  9828. /* "lakesuperior/store/base_lmdb_store.pyx":646
  9829. * self.is_txn_open = False
  9830. * self.is_txn_rw = False
  9831. * logger.info('Transaction @ {} aborted.'.format(txid)) # <<<<<<<<<<<<<<
  9832. *
  9833. *
  9834. */
  9835. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
  9836. __Pyx_GOTREF(__pyx_t_2);
  9837. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 646, __pyx_L1_error)
  9838. __Pyx_GOTREF(__pyx_t_5);
  9839. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9840. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Transaction_aborted, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 646, __pyx_L1_error)
  9841. __Pyx_GOTREF(__pyx_t_3);
  9842. __pyx_t_4 = NULL;
  9843. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  9844. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  9845. if (likely(__pyx_t_4)) {
  9846. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  9847. __Pyx_INCREF(__pyx_t_4);
  9848. __Pyx_INCREF(function);
  9849. __Pyx_DECREF_SET(__pyx_t_3, function);
  9850. }
  9851. }
  9852. if (!__pyx_t_4) {
  9853. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_txid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
  9854. __Pyx_GOTREF(__pyx_t_2);
  9855. } else {
  9856. #if CYTHON_FAST_PYCALL
  9857. if (PyFunction_Check(__pyx_t_3)) {
  9858. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9859. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
  9860. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9861. __Pyx_GOTREF(__pyx_t_2);
  9862. } else
  9863. #endif
  9864. #if CYTHON_FAST_PYCCALL
  9865. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  9866. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9867. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
  9868. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9869. __Pyx_GOTREF(__pyx_t_2);
  9870. } else
  9871. #endif
  9872. {
  9873. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 646, __pyx_L1_error)
  9874. __Pyx_GOTREF(__pyx_t_6);
  9875. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9876. __Pyx_INCREF(__pyx_v_txid);
  9877. __Pyx_GIVEREF(__pyx_v_txid);
  9878. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_txid);
  9879. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
  9880. __Pyx_GOTREF(__pyx_t_2);
  9881. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9882. }
  9883. }
  9884. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9885. __pyx_t_3 = NULL;
  9886. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  9887. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
  9888. if (likely(__pyx_t_3)) {
  9889. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  9890. __Pyx_INCREF(__pyx_t_3);
  9891. __Pyx_INCREF(function);
  9892. __Pyx_DECREF_SET(__pyx_t_5, function);
  9893. }
  9894. }
  9895. if (!__pyx_t_3) {
  9896. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
  9897. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9898. __Pyx_GOTREF(__pyx_t_1);
  9899. } else {
  9900. #if CYTHON_FAST_PYCALL
  9901. if (PyFunction_Check(__pyx_t_5)) {
  9902. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  9903. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
  9904. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9905. __Pyx_GOTREF(__pyx_t_1);
  9906. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9907. } else
  9908. #endif
  9909. #if CYTHON_FAST_PYCCALL
  9910. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  9911. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  9912. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
  9913. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9914. __Pyx_GOTREF(__pyx_t_1);
  9915. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9916. } else
  9917. #endif
  9918. {
  9919. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 646, __pyx_L1_error)
  9920. __Pyx_GOTREF(__pyx_t_6);
  9921. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
  9922. __Pyx_GIVEREF(__pyx_t_2);
  9923. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_2);
  9924. __pyx_t_2 = 0;
  9925. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
  9926. __Pyx_GOTREF(__pyx_t_1);
  9927. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9928. }
  9929. }
  9930. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  9931. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9932. /* "lakesuperior/store/base_lmdb_store.pyx":641
  9933. *
  9934. *
  9935. * cdef void _txn_abort(self) except *: # <<<<<<<<<<<<<<
  9936. * txid = '{:x}'.format(<unsigned long>self.txn)
  9937. * lmdb.mdb_txn_abort(self.txn)
  9938. */
  9939. /* function exit code */
  9940. goto __pyx_L0;
  9941. __pyx_L1_error:;
  9942. __Pyx_XDECREF(__pyx_t_1);
  9943. __Pyx_XDECREF(__pyx_t_2);
  9944. __Pyx_XDECREF(__pyx_t_3);
  9945. __Pyx_XDECREF(__pyx_t_4);
  9946. __Pyx_XDECREF(__pyx_t_5);
  9947. __Pyx_XDECREF(__pyx_t_6);
  9948. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_abort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9949. __pyx_L0:;
  9950. __Pyx_XDECREF(__pyx_v_txid);
  9951. __Pyx_TraceReturn(Py_None, 0);
  9952. __Pyx_RefNannyFinishContext();
  9953. }
  9954. /* "lakesuperior/store/base_lmdb_store.pyx":649
  9955. *
  9956. *
  9957. * cpdef int txn_id(self): # <<<<<<<<<<<<<<
  9958. * return self._txn_id()
  9959. *
  9960. */
  9961. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  9962. static int __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_txn_id(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, int __pyx_skip_dispatch) {
  9963. int __pyx_r;
  9964. __Pyx_TraceDeclarations
  9965. __Pyx_RefNannyDeclarations
  9966. PyObject *__pyx_t_1 = NULL;
  9967. PyObject *__pyx_t_2 = NULL;
  9968. PyObject *__pyx_t_3 = NULL;
  9969. PyObject *__pyx_t_4 = NULL;
  9970. int __pyx_t_5;
  9971. size_t __pyx_t_6;
  9972. __Pyx_RefNannySetupContext("txn_id", 0);
  9973. __Pyx_TraceCall("txn_id", __pyx_f[0], 649, 0, __PYX_ERR(0, 649, __pyx_L1_error));
  9974. /* Check if called by wrapper */
  9975. if (unlikely(__pyx_skip_dispatch)) ;
  9976. /* Check if overridden in Python */
  9977. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  9978. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_txn_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
  9979. __Pyx_GOTREF(__pyx_t_1);
  9980. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id)) {
  9981. __Pyx_INCREF(__pyx_t_1);
  9982. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  9983. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  9984. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  9985. if (likely(__pyx_t_4)) {
  9986. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  9987. __Pyx_INCREF(__pyx_t_4);
  9988. __Pyx_INCREF(function);
  9989. __Pyx_DECREF_SET(__pyx_t_3, function);
  9990. }
  9991. }
  9992. if (__pyx_t_4) {
  9993. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error)
  9994. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9995. } else {
  9996. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error)
  9997. }
  9998. __Pyx_GOTREF(__pyx_t_2);
  9999. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  10000. __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 649, __pyx_L1_error)
  10001. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  10002. __pyx_r = __pyx_t_5;
  10003. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10004. goto __pyx_L0;
  10005. }
  10006. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10007. }
  10008. /* "lakesuperior/store/base_lmdb_store.pyx":650
  10009. *
  10010. * cpdef int txn_id(self):
  10011. * return self._txn_id() # <<<<<<<<<<<<<<
  10012. *
  10013. *
  10014. */
  10015. __pyx_t_6 = ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->_txn_id(__pyx_v_self); if (unlikely(__pyx_t_6 == ((size_t)-1L))) __PYX_ERR(0, 650, __pyx_L1_error)
  10016. __pyx_r = __pyx_t_6;
  10017. goto __pyx_L0;
  10018. /* "lakesuperior/store/base_lmdb_store.pyx":649
  10019. *
  10020. *
  10021. * cpdef int txn_id(self): # <<<<<<<<<<<<<<
  10022. * return self._txn_id()
  10023. *
  10024. */
  10025. /* function exit code */
  10026. __pyx_L1_error:;
  10027. __Pyx_XDECREF(__pyx_t_1);
  10028. __Pyx_XDECREF(__pyx_t_2);
  10029. __Pyx_XDECREF(__pyx_t_3);
  10030. __Pyx_XDECREF(__pyx_t_4);
  10031. __Pyx_WriteUnraisable("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_id", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  10032. __pyx_r = 0;
  10033. __pyx_L0:;
  10034. __Pyx_TraceReturn(Py_None, 0);
  10035. __Pyx_RefNannyFinishContext();
  10036. return __pyx_r;
  10037. }
  10038. /* Python wrapper */
  10039. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  10040. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  10041. PyObject *__pyx_r = 0;
  10042. __Pyx_RefNannyDeclarations
  10043. __Pyx_RefNannySetupContext("txn_id (wrapper)", 0);
  10044. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_31txn_id(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  10045. /* function exit code */
  10046. __Pyx_RefNannyFinishContext();
  10047. return __pyx_r;
  10048. }
  10049. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_31txn_id(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  10050. PyObject *__pyx_r = NULL;
  10051. __Pyx_TraceDeclarations
  10052. __Pyx_RefNannyDeclarations
  10053. PyObject *__pyx_t_1 = NULL;
  10054. __Pyx_RefNannySetupContext("txn_id", 0);
  10055. __Pyx_TraceCall("txn_id (wrapper)", __pyx_f[0], 649, 0, __PYX_ERR(0, 649, __pyx_L1_error));
  10056. __Pyx_XDECREF(__pyx_r);
  10057. __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_txn_id(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
  10058. __Pyx_GOTREF(__pyx_t_1);
  10059. __pyx_r = __pyx_t_1;
  10060. __pyx_t_1 = 0;
  10061. goto __pyx_L0;
  10062. /* function exit code */
  10063. __pyx_L1_error:;
  10064. __Pyx_XDECREF(__pyx_t_1);
  10065. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10066. __pyx_r = NULL;
  10067. __pyx_L0:;
  10068. __Pyx_XGIVEREF(__pyx_r);
  10069. __Pyx_TraceReturn(__pyx_r, 0);
  10070. __Pyx_RefNannyFinishContext();
  10071. return __pyx_r;
  10072. }
  10073. /* "lakesuperior/store/base_lmdb_store.pyx":653
  10074. *
  10075. *
  10076. * cdef size_t _txn_id(self) except -1: # <<<<<<<<<<<<<<
  10077. * return lmdb.mdb_txn_id(self.txn)
  10078. *
  10079. */
  10080. static size_t __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_id(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  10081. size_t __pyx_r;
  10082. __Pyx_TraceDeclarations
  10083. __Pyx_RefNannyDeclarations
  10084. __Pyx_RefNannySetupContext("_txn_id", 0);
  10085. __Pyx_TraceCall("_txn_id", __pyx_f[0], 653, 0, __PYX_ERR(0, 653, __pyx_L1_error));
  10086. /* "lakesuperior/store/base_lmdb_store.pyx":654
  10087. *
  10088. * cdef size_t _txn_id(self) except -1:
  10089. * return lmdb.mdb_txn_id(self.txn) # <<<<<<<<<<<<<<
  10090. *
  10091. *
  10092. */
  10093. __pyx_r = mdb_txn_id(__pyx_v_self->txn);
  10094. goto __pyx_L0;
  10095. /* "lakesuperior/store/base_lmdb_store.pyx":653
  10096. *
  10097. *
  10098. * cdef size_t _txn_id(self) except -1: # <<<<<<<<<<<<<<
  10099. * return lmdb.mdb_txn_id(self.txn)
  10100. *
  10101. */
  10102. /* function exit code */
  10103. __pyx_L1_error:;
  10104. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10105. __pyx_r = -1L;
  10106. __pyx_L0:;
  10107. __Pyx_TraceReturn(Py_None, 0);
  10108. __Pyx_RefNannyFinishContext();
  10109. return __pyx_r;
  10110. }
  10111. /* "lakesuperior/store/base_lmdb_store.pyx":657
  10112. *
  10113. *
  10114. * cdef lmdb.MDB_dbi get_dbi( # <<<<<<<<<<<<<<
  10115. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL):
  10116. * """
  10117. */
  10118. static MDB_dbi __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi *__pyx_optional_args) {
  10119. /* "lakesuperior/store/base_lmdb_store.pyx":658
  10120. *
  10121. * cdef lmdb.MDB_dbi get_dbi(
  10122. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL): # <<<<<<<<<<<<<<
  10123. * """
  10124. * Return a DB handle by database name.
  10125. */
  10126. unsigned char *__pyx_v_dblabel = ((unsigned char *)NULL);
  10127. MDB_txn *__pyx_v_txn = ((MDB_txn *)NULL);
  10128. size_t __pyx_v_dbidx;
  10129. MDB_dbi __pyx_r;
  10130. __Pyx_TraceDeclarations
  10131. __Pyx_RefNannyDeclarations
  10132. int __pyx_t_1;
  10133. MDB_txn *__pyx_t_2;
  10134. PyObject *__pyx_t_3 = NULL;
  10135. PyObject *__pyx_t_4 = NULL;
  10136. size_t __pyx_t_5;
  10137. PyObject *__pyx_t_6 = NULL;
  10138. PyObject *__pyx_t_7 = NULL;
  10139. PyObject *__pyx_t_8 = NULL;
  10140. size_t __pyx_t_9;
  10141. __Pyx_RefNannySetupContext("get_dbi", 0);
  10142. __Pyx_TraceCall("get_dbi", __pyx_f[0], 657, 0, __PYX_ERR(0, 657, __pyx_L1_error));
  10143. if (__pyx_optional_args) {
  10144. if (__pyx_optional_args->__pyx_n > 0) {
  10145. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  10146. if (__pyx_optional_args->__pyx_n > 1) {
  10147. __pyx_v_txn = __pyx_optional_args->txn;
  10148. }
  10149. }
  10150. }
  10151. /* "lakesuperior/store/base_lmdb_store.pyx":664
  10152. * cdef size_t dbidx
  10153. *
  10154. * if txn is NULL: # <<<<<<<<<<<<<<
  10155. * txn = self.txn
  10156. *
  10157. */
  10158. __pyx_t_1 = ((__pyx_v_txn == NULL) != 0);
  10159. if (__pyx_t_1) {
  10160. /* "lakesuperior/store/base_lmdb_store.pyx":665
  10161. *
  10162. * if txn is NULL:
  10163. * txn = self.txn # <<<<<<<<<<<<<<
  10164. *
  10165. * if dblabel is NULL:
  10166. */
  10167. __pyx_t_2 = __pyx_v_self->txn;
  10168. __pyx_v_txn = __pyx_t_2;
  10169. /* "lakesuperior/store/base_lmdb_store.pyx":664
  10170. * cdef size_t dbidx
  10171. *
  10172. * if txn is NULL: # <<<<<<<<<<<<<<
  10173. * txn = self.txn
  10174. *
  10175. */
  10176. }
  10177. /* "lakesuperior/store/base_lmdb_store.pyx":667
  10178. * txn = self.txn
  10179. *
  10180. * if dblabel is NULL: # <<<<<<<<<<<<<<
  10181. * logger.debug('Getting DBI without label.')
  10182. * dbidx = (
  10183. */
  10184. __pyx_t_1 = ((__pyx_v_dblabel == NULL) != 0);
  10185. if (__pyx_t_1) {
  10186. /* "lakesuperior/store/base_lmdb_store.pyx":668
  10187. *
  10188. * if dblabel is NULL:
  10189. * logger.debug('Getting DBI without label.') # <<<<<<<<<<<<<<
  10190. * dbidx = (
  10191. * 0 if dblabel is NULL
  10192. */
  10193. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 668, __pyx_L1_error)
  10194. __Pyx_GOTREF(__pyx_t_3);
  10195. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 668, __pyx_L1_error)
  10196. __Pyx_GOTREF(__pyx_t_4);
  10197. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  10198. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 668, __pyx_L1_error)
  10199. __Pyx_GOTREF(__pyx_t_3);
  10200. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10201. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  10202. /* "lakesuperior/store/base_lmdb_store.pyx":667
  10203. * txn = self.txn
  10204. *
  10205. * if dblabel is NULL: # <<<<<<<<<<<<<<
  10206. * logger.debug('Getting DBI without label.')
  10207. * dbidx = (
  10208. */
  10209. }
  10210. /* "lakesuperior/store/base_lmdb_store.pyx":670
  10211. * logger.debug('Getting DBI without label.')
  10212. * dbidx = (
  10213. * 0 if dblabel is NULL # <<<<<<<<<<<<<<
  10214. * else self.dbi_labels.index(dblabel.decode()))
  10215. * #logger.debug(
  10216. */
  10217. if (((__pyx_v_dblabel == NULL) != 0)) {
  10218. __pyx_t_5 = 0;
  10219. } else {
  10220. /* "lakesuperior/store/base_lmdb_store.pyx":671
  10221. * dbidx = (
  10222. * 0 if dblabel is NULL
  10223. * else self.dbi_labels.index(dblabel.decode())) # <<<<<<<<<<<<<<
  10224. * #logger.debug(
  10225. * # f'Got DBI {self.dbis[dbidx]} with label {dblabel} '
  10226. */
  10227. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dbi_labels); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 671, __pyx_L1_error)
  10228. __Pyx_GOTREF(__pyx_t_4);
  10229. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 671, __pyx_L1_error)
  10230. __Pyx_GOTREF(__pyx_t_6);
  10231. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10232. __pyx_t_4 = __Pyx_decode_c_string(((char const *)__pyx_v_dblabel), 0, strlen(((char const *)__pyx_v_dblabel)), NULL, NULL, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 671, __pyx_L1_error)
  10233. __Pyx_GOTREF(__pyx_t_4);
  10234. __pyx_t_7 = NULL;
  10235. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  10236. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  10237. if (likely(__pyx_t_7)) {
  10238. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  10239. __Pyx_INCREF(__pyx_t_7);
  10240. __Pyx_INCREF(function);
  10241. __Pyx_DECREF_SET(__pyx_t_6, function);
  10242. }
  10243. }
  10244. if (!__pyx_t_7) {
  10245. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 671, __pyx_L1_error)
  10246. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10247. __Pyx_GOTREF(__pyx_t_3);
  10248. } else {
  10249. #if CYTHON_FAST_PYCALL
  10250. if (PyFunction_Check(__pyx_t_6)) {
  10251. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
  10252. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 671, __pyx_L1_error)
  10253. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  10254. __Pyx_GOTREF(__pyx_t_3);
  10255. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10256. } else
  10257. #endif
  10258. #if CYTHON_FAST_PYCCALL
  10259. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  10260. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
  10261. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 671, __pyx_L1_error)
  10262. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  10263. __Pyx_GOTREF(__pyx_t_3);
  10264. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10265. } else
  10266. #endif
  10267. {
  10268. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 671, __pyx_L1_error)
  10269. __Pyx_GOTREF(__pyx_t_8);
  10270. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  10271. __Pyx_GIVEREF(__pyx_t_4);
  10272. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4);
  10273. __pyx_t_4 = 0;
  10274. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 671, __pyx_L1_error)
  10275. __Pyx_GOTREF(__pyx_t_3);
  10276. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  10277. }
  10278. }
  10279. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10280. __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 671, __pyx_L1_error)
  10281. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  10282. __pyx_t_5 = __pyx_t_9;
  10283. }
  10284. __pyx_v_dbidx = __pyx_t_5;
  10285. /* "lakesuperior/store/base_lmdb_store.pyx":676
  10286. * # f'and index #{dbidx}')
  10287. *
  10288. * return self.dbis[dbidx] # <<<<<<<<<<<<<<
  10289. *
  10290. *
  10291. */
  10292. __pyx_r = (__pyx_v_self->dbis[__pyx_v_dbidx]);
  10293. goto __pyx_L0;
  10294. /* "lakesuperior/store/base_lmdb_store.pyx":657
  10295. *
  10296. *
  10297. * cdef lmdb.MDB_dbi get_dbi( # <<<<<<<<<<<<<<
  10298. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL):
  10299. * """
  10300. */
  10301. /* function exit code */
  10302. __pyx_L1_error:;
  10303. __Pyx_XDECREF(__pyx_t_3);
  10304. __Pyx_XDECREF(__pyx_t_4);
  10305. __Pyx_XDECREF(__pyx_t_6);
  10306. __Pyx_XDECREF(__pyx_t_7);
  10307. __Pyx_XDECREF(__pyx_t_8);
  10308. __Pyx_WriteUnraisable("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_dbi", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  10309. __pyx_r = 0;
  10310. __pyx_L0:;
  10311. __Pyx_TraceReturn(Py_None, 0);
  10312. __Pyx_RefNannyFinishContext();
  10313. return __pyx_r;
  10314. }
  10315. /* "lakesuperior/store/base_lmdb_store.pyx":679
  10316. *
  10317. *
  10318. * cdef lmdb.MDB_cursor *_cur_open( # <<<<<<<<<<<<<<
  10319. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL) except *:
  10320. * cdef:
  10321. */
  10322. static MDB_cursor *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open *__pyx_optional_args) {
  10323. /* "lakesuperior/store/base_lmdb_store.pyx":680
  10324. *
  10325. * cdef lmdb.MDB_cursor *_cur_open(
  10326. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL) except *: # <<<<<<<<<<<<<<
  10327. * cdef:
  10328. * lmdb.MDB_dbi dbi
  10329. */
  10330. unsigned char *__pyx_v_dblabel = ((unsigned char *)NULL);
  10331. MDB_txn *__pyx_v_txn = ((MDB_txn *)NULL);
  10332. MDB_dbi __pyx_v_dbi;
  10333. MDB_cursor *__pyx_r;
  10334. __Pyx_TraceDeclarations
  10335. __Pyx_RefNannyDeclarations
  10336. int __pyx_t_1;
  10337. MDB_txn *__pyx_t_2;
  10338. MDB_dbi __pyx_t_3;
  10339. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_4;
  10340. PyObject *__pyx_t_5 = NULL;
  10341. PyObject *__pyx_t_6 = NULL;
  10342. PyObject *__pyx_t_7 = NULL;
  10343. Py_ssize_t __pyx_t_8;
  10344. Py_UCS4 __pyx_t_9;
  10345. PyObject *__pyx_t_10 = NULL;
  10346. PyObject *__pyx_t_11 = NULL;
  10347. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_12;
  10348. PyObject *__pyx_t_13 = NULL;
  10349. PyObject *__pyx_t_14 = NULL;
  10350. __Pyx_RefNannySetupContext("_cur_open", 0);
  10351. __Pyx_TraceCall("_cur_open", __pyx_f[0], 679, 0, __PYX_ERR(0, 679, __pyx_L1_error));
  10352. if (__pyx_optional_args) {
  10353. if (__pyx_optional_args->__pyx_n > 0) {
  10354. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  10355. if (__pyx_optional_args->__pyx_n > 1) {
  10356. __pyx_v_txn = __pyx_optional_args->txn;
  10357. }
  10358. }
  10359. }
  10360. /* "lakesuperior/store/base_lmdb_store.pyx":684
  10361. * lmdb.MDB_dbi dbi
  10362. *
  10363. * if txn is NULL: # <<<<<<<<<<<<<<
  10364. * txn = self.txn
  10365. *
  10366. */
  10367. __pyx_t_1 = ((__pyx_v_txn == NULL) != 0);
  10368. if (__pyx_t_1) {
  10369. /* "lakesuperior/store/base_lmdb_store.pyx":685
  10370. *
  10371. * if txn is NULL:
  10372. * txn = self.txn # <<<<<<<<<<<<<<
  10373. *
  10374. * dbi = self.get_dbi(dblabel, txn=txn)
  10375. */
  10376. __pyx_t_2 = __pyx_v_self->txn;
  10377. __pyx_v_txn = __pyx_t_2;
  10378. /* "lakesuperior/store/base_lmdb_store.pyx":684
  10379. * lmdb.MDB_dbi dbi
  10380. *
  10381. * if txn is NULL: # <<<<<<<<<<<<<<
  10382. * txn = self.txn
  10383. *
  10384. */
  10385. }
  10386. /* "lakesuperior/store/base_lmdb_store.pyx":687
  10387. * txn = self.txn
  10388. *
  10389. * dbi = self.get_dbi(dblabel, txn=txn) # <<<<<<<<<<<<<<
  10390. *
  10391. * logger.debug(f'Opening cursor for DB {dblabel} (DBI {dbi})...')
  10392. */
  10393. __pyx_t_4.__pyx_n = 2;
  10394. __pyx_t_4.dblabel = __pyx_v_dblabel;
  10395. __pyx_t_4.txn = __pyx_v_txn;
  10396. __pyx_t_3 = ((struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self->__pyx_vtab)->get_dbi(__pyx_v_self, &__pyx_t_4);
  10397. __pyx_v_dbi = __pyx_t_3;
  10398. /* "lakesuperior/store/base_lmdb_store.pyx":689
  10399. * dbi = self.get_dbi(dblabel, txn=txn)
  10400. *
  10401. * logger.debug(f'Opening cursor for DB {dblabel} (DBI {dbi})...') # <<<<<<<<<<<<<<
  10402. * #try:
  10403. * # # FIXME Either reuse the cursor, if it works, or remove this code.
  10404. */
  10405. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 689, __pyx_L1_error)
  10406. __Pyx_GOTREF(__pyx_t_6);
  10407. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_debug); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 689, __pyx_L1_error)
  10408. __Pyx_GOTREF(__pyx_t_7);
  10409. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10410. __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 689, __pyx_L1_error)
  10411. __Pyx_GOTREF(__pyx_t_6);
  10412. __pyx_t_8 = 0;
  10413. __pyx_t_9 = 127;
  10414. __Pyx_INCREF(__pyx_kp_u_Opening_cursor_for_DB);
  10415. __pyx_t_8 += 22;
  10416. __Pyx_GIVEREF(__pyx_kp_u_Opening_cursor_for_DB);
  10417. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_Opening_cursor_for_DB);
  10418. __pyx_t_10 = __Pyx_PyBytes_FromCString(__pyx_v_dblabel); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 689, __pyx_L1_error)
  10419. __Pyx_GOTREF(__pyx_t_10);
  10420. __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_t_10, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L1_error)
  10421. __Pyx_GOTREF(__pyx_t_11);
  10422. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10423. __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_9;
  10424. __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11);
  10425. __Pyx_GIVEREF(__pyx_t_11);
  10426. PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_11);
  10427. __pyx_t_11 = 0;
  10428. __Pyx_INCREF(__pyx_kp_u_DBI);
  10429. __pyx_t_8 += 6;
  10430. __Pyx_GIVEREF(__pyx_kp_u_DBI);
  10431. PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u_DBI);
  10432. __pyx_t_11 = __Pyx_PyInt_From_MDB_dbi(__pyx_v_dbi); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L1_error)
  10433. __Pyx_GOTREF(__pyx_t_11);
  10434. __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_t_11, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 689, __pyx_L1_error)
  10435. __Pyx_GOTREF(__pyx_t_10);
  10436. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  10437. __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_9;
  10438. __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10);
  10439. __Pyx_GIVEREF(__pyx_t_10);
  10440. PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_10);
  10441. __pyx_t_10 = 0;
  10442. __Pyx_INCREF(__pyx_kp_u__20);
  10443. __pyx_t_8 += 4;
  10444. __Pyx_GIVEREF(__pyx_kp_u__20);
  10445. PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_kp_u__20);
  10446. __pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_6, 5, __pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 689, __pyx_L1_error)
  10447. __Pyx_GOTREF(__pyx_t_10);
  10448. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10449. __pyx_t_6 = NULL;
  10450. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
  10451. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
  10452. if (likely(__pyx_t_6)) {
  10453. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  10454. __Pyx_INCREF(__pyx_t_6);
  10455. __Pyx_INCREF(function);
  10456. __Pyx_DECREF_SET(__pyx_t_7, function);
  10457. }
  10458. }
  10459. if (!__pyx_t_6) {
  10460. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error)
  10461. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10462. __Pyx_GOTREF(__pyx_t_5);
  10463. } else {
  10464. #if CYTHON_FAST_PYCALL
  10465. if (PyFunction_Check(__pyx_t_7)) {
  10466. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  10467. __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error)
  10468. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  10469. __Pyx_GOTREF(__pyx_t_5);
  10470. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10471. } else
  10472. #endif
  10473. #if CYTHON_FAST_PYCCALL
  10474. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  10475. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  10476. __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error)
  10477. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  10478. __Pyx_GOTREF(__pyx_t_5);
  10479. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10480. } else
  10481. #endif
  10482. {
  10483. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L1_error)
  10484. __Pyx_GOTREF(__pyx_t_11);
  10485. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
  10486. __Pyx_GIVEREF(__pyx_t_10);
  10487. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_10);
  10488. __pyx_t_10 = 0;
  10489. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error)
  10490. __Pyx_GOTREF(__pyx_t_5);
  10491. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  10492. }
  10493. }
  10494. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10495. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10496. /* "lakesuperior/store/base_lmdb_store.pyx":701
  10497. * _check(
  10498. * lmdb.mdb_cursor_open(txn, dbi, self.curs + dbi),
  10499. * f'Error opening cursor: {dblabel}') # <<<<<<<<<<<<<<
  10500. * logger.debug('...opened @ {:x}.'.format(<unsigned long>self.curs[dbi]))
  10501. *
  10502. */
  10503. __pyx_t_5 = __Pyx_PyBytes_FromCString(__pyx_v_dblabel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 701, __pyx_L1_error)
  10504. __Pyx_GOTREF(__pyx_t_5);
  10505. __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 701, __pyx_L1_error)
  10506. __Pyx_GOTREF(__pyx_t_7);
  10507. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10508. __pyx_t_5 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Error_opening_cursor, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 701, __pyx_L1_error)
  10509. __Pyx_GOTREF(__pyx_t_5);
  10510. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10511. /* "lakesuperior/store/base_lmdb_store.pyx":699
  10512. * # f'Error opening cursor: {dblabel}')
  10513. * # logger.debug(f'Created brand new cursor for DBI {dbi}.')
  10514. * _check( # <<<<<<<<<<<<<<
  10515. * lmdb.mdb_cursor_open(txn, dbi, self.curs + dbi),
  10516. * f'Error opening cursor: {dblabel}')
  10517. */
  10518. __pyx_t_12.__pyx_n = 1;
  10519. __pyx_t_12.message = ((PyObject*)__pyx_t_5);
  10520. __pyx_f_12lakesuperior_5store_15base_lmdb_store__check(mdb_cursor_open(__pyx_v_txn, __pyx_v_dbi, (__pyx_v_self->curs + __pyx_v_dbi)), &__pyx_t_12); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 699, __pyx_L1_error)
  10521. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10522. /* "lakesuperior/store/base_lmdb_store.pyx":702
  10523. * lmdb.mdb_cursor_open(txn, dbi, self.curs + dbi),
  10524. * f'Error opening cursor: {dblabel}')
  10525. * logger.debug('...opened @ {:x}.'.format(<unsigned long>self.curs[dbi])) # <<<<<<<<<<<<<<
  10526. *
  10527. * return self.curs[dbi]
  10528. */
  10529. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 702, __pyx_L1_error)
  10530. __Pyx_GOTREF(__pyx_t_7);
  10531. __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_debug); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 702, __pyx_L1_error)
  10532. __Pyx_GOTREF(__pyx_t_11);
  10533. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10534. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_opened_x, __pyx_n_s_format); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 702, __pyx_L1_error)
  10535. __Pyx_GOTREF(__pyx_t_10);
  10536. __pyx_t_6 = __Pyx_PyInt_From_unsigned_long(((unsigned long)(__pyx_v_self->curs[__pyx_v_dbi]))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 702, __pyx_L1_error)
  10537. __Pyx_GOTREF(__pyx_t_6);
  10538. __pyx_t_13 = NULL;
  10539. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
  10540. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10);
  10541. if (likely(__pyx_t_13)) {
  10542. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  10543. __Pyx_INCREF(__pyx_t_13);
  10544. __Pyx_INCREF(function);
  10545. __Pyx_DECREF_SET(__pyx_t_10, function);
  10546. }
  10547. }
  10548. if (!__pyx_t_13) {
  10549. __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 702, __pyx_L1_error)
  10550. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10551. __Pyx_GOTREF(__pyx_t_7);
  10552. } else {
  10553. #if CYTHON_FAST_PYCALL
  10554. if (PyFunction_Check(__pyx_t_10)) {
  10555. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  10556. __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 702, __pyx_L1_error)
  10557. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  10558. __Pyx_GOTREF(__pyx_t_7);
  10559. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10560. } else
  10561. #endif
  10562. #if CYTHON_FAST_PYCCALL
  10563. if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
  10564. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  10565. __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 702, __pyx_L1_error)
  10566. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  10567. __Pyx_GOTREF(__pyx_t_7);
  10568. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10569. } else
  10570. #endif
  10571. {
  10572. __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 702, __pyx_L1_error)
  10573. __Pyx_GOTREF(__pyx_t_14);
  10574. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
  10575. __Pyx_GIVEREF(__pyx_t_6);
  10576. PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_6);
  10577. __pyx_t_6 = 0;
  10578. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 702, __pyx_L1_error)
  10579. __Pyx_GOTREF(__pyx_t_7);
  10580. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  10581. }
  10582. }
  10583. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10584. __pyx_t_10 = NULL;
  10585. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
  10586. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
  10587. if (likely(__pyx_t_10)) {
  10588. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
  10589. __Pyx_INCREF(__pyx_t_10);
  10590. __Pyx_INCREF(function);
  10591. __Pyx_DECREF_SET(__pyx_t_11, function);
  10592. }
  10593. }
  10594. if (!__pyx_t_10) {
  10595. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 702, __pyx_L1_error)
  10596. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10597. __Pyx_GOTREF(__pyx_t_5);
  10598. } else {
  10599. #if CYTHON_FAST_PYCALL
  10600. if (PyFunction_Check(__pyx_t_11)) {
  10601. PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_7};
  10602. __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 702, __pyx_L1_error)
  10603. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  10604. __Pyx_GOTREF(__pyx_t_5);
  10605. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10606. } else
  10607. #endif
  10608. #if CYTHON_FAST_PYCCALL
  10609. if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
  10610. PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_7};
  10611. __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 702, __pyx_L1_error)
  10612. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  10613. __Pyx_GOTREF(__pyx_t_5);
  10614. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10615. } else
  10616. #endif
  10617. {
  10618. __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 702, __pyx_L1_error)
  10619. __Pyx_GOTREF(__pyx_t_14);
  10620. __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_10); __pyx_t_10 = NULL;
  10621. __Pyx_GIVEREF(__pyx_t_7);
  10622. PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_7);
  10623. __pyx_t_7 = 0;
  10624. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 702, __pyx_L1_error)
  10625. __Pyx_GOTREF(__pyx_t_5);
  10626. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  10627. }
  10628. }
  10629. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  10630. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10631. /* "lakesuperior/store/base_lmdb_store.pyx":704
  10632. * logger.debug('...opened @ {:x}.'.format(<unsigned long>self.curs[dbi]))
  10633. *
  10634. * return self.curs[dbi] # <<<<<<<<<<<<<<
  10635. *
  10636. *
  10637. */
  10638. __pyx_r = (__pyx_v_self->curs[__pyx_v_dbi]);
  10639. goto __pyx_L0;
  10640. /* "lakesuperior/store/base_lmdb_store.pyx":679
  10641. *
  10642. *
  10643. * cdef lmdb.MDB_cursor *_cur_open( # <<<<<<<<<<<<<<
  10644. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL) except *:
  10645. * cdef:
  10646. */
  10647. /* function exit code */
  10648. __pyx_L1_error:;
  10649. __Pyx_XDECREF(__pyx_t_5);
  10650. __Pyx_XDECREF(__pyx_t_6);
  10651. __Pyx_XDECREF(__pyx_t_7);
  10652. __Pyx_XDECREF(__pyx_t_10);
  10653. __Pyx_XDECREF(__pyx_t_11);
  10654. __Pyx_XDECREF(__pyx_t_13);
  10655. __Pyx_XDECREF(__pyx_t_14);
  10656. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._cur_open", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10657. __pyx_r = 0;
  10658. __pyx_L0:;
  10659. __Pyx_TraceReturn(Py_None, 0);
  10660. __Pyx_RefNannyFinishContext();
  10661. return __pyx_r;
  10662. }
  10663. /* "lakesuperior/store/base_lmdb_store.pyx":707
  10664. *
  10665. *
  10666. * cdef void _cur_close(self, lmdb.MDB_cursor *cur) except *: # <<<<<<<<<<<<<<
  10667. * """Close a cursor."""
  10668. * #logger.info('Closing cursor @ {:x} for DBI {}...'.format(
  10669. */
  10670. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_close(CYTHON_UNUSED struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, MDB_cursor *__pyx_v_cur) {
  10671. __Pyx_TraceDeclarations
  10672. __Pyx_RefNannyDeclarations
  10673. __Pyx_RefNannySetupContext("_cur_close", 0);
  10674. __Pyx_TraceCall("_cur_close", __pyx_f[0], 707, 0, __PYX_ERR(0, 707, __pyx_L1_error));
  10675. /* "lakesuperior/store/base_lmdb_store.pyx":711
  10676. * #logger.info('Closing cursor @ {:x} for DBI {}...'.format(
  10677. * # <unsigned long>cur, lmdb.mdb_cursor_dbi(cur) ))
  10678. * lmdb.mdb_cursor_close(cur) # <<<<<<<<<<<<<<
  10679. * #logger.info('...closed.')
  10680. *
  10681. */
  10682. mdb_cursor_close(__pyx_v_cur);
  10683. /* "lakesuperior/store/base_lmdb_store.pyx":707
  10684. *
  10685. *
  10686. * cdef void _cur_close(self, lmdb.MDB_cursor *cur) except *: # <<<<<<<<<<<<<<
  10687. * """Close a cursor."""
  10688. * #logger.info('Closing cursor @ {:x} for DBI {}...'.format(
  10689. */
  10690. /* function exit code */
  10691. goto __pyx_L0;
  10692. __pyx_L1_error:;
  10693. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._cur_close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10694. __pyx_L0:;
  10695. __Pyx_TraceReturn(Py_None, 0);
  10696. __Pyx_RefNannyFinishContext();
  10697. }
  10698. /* "lakesuperior/store/base_lmdb_store.pxd":15
  10699. * cdef class BaseLmdbStore:
  10700. * cdef:
  10701. * readonly bint is_txn_open # <<<<<<<<<<<<<<
  10702. * public bint _open
  10703. * unsigned int _readers
  10704. */
  10705. /* Python wrapper */
  10706. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open_1__get__(PyObject *__pyx_v_self); /*proto*/
  10707. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open_1__get__(PyObject *__pyx_v_self) {
  10708. PyObject *__pyx_r = 0;
  10709. __Pyx_RefNannyDeclarations
  10710. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  10711. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open___get__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  10712. /* function exit code */
  10713. __Pyx_RefNannyFinishContext();
  10714. return __pyx_r;
  10715. }
  10716. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  10717. PyObject *__pyx_r = NULL;
  10718. __Pyx_TraceDeclarations
  10719. __Pyx_RefNannyDeclarations
  10720. PyObject *__pyx_t_1 = NULL;
  10721. __Pyx_RefNannySetupContext("__get__", 0);
  10722. __Pyx_TraceCall("__get__", __pyx_f[2], 15, 0, __PYX_ERR(2, 15, __pyx_L1_error));
  10723. __Pyx_XDECREF(__pyx_r);
  10724. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_txn_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  10725. __Pyx_GOTREF(__pyx_t_1);
  10726. __pyx_r = __pyx_t_1;
  10727. __pyx_t_1 = 0;
  10728. goto __pyx_L0;
  10729. /* function exit code */
  10730. __pyx_L1_error:;
  10731. __Pyx_XDECREF(__pyx_t_1);
  10732. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.is_txn_open.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10733. __pyx_r = NULL;
  10734. __pyx_L0:;
  10735. __Pyx_XGIVEREF(__pyx_r);
  10736. __Pyx_TraceReturn(__pyx_r, 0);
  10737. __Pyx_RefNannyFinishContext();
  10738. return __pyx_r;
  10739. }
  10740. /* "lakesuperior/store/base_lmdb_store.pxd":16
  10741. * cdef:
  10742. * readonly bint is_txn_open
  10743. * public bint _open # <<<<<<<<<<<<<<
  10744. * unsigned int _readers
  10745. * readonly str env_path
  10746. */
  10747. /* Python wrapper */
  10748. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_1__get__(PyObject *__pyx_v_self); /*proto*/
  10749. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_1__get__(PyObject *__pyx_v_self) {
  10750. PyObject *__pyx_r = 0;
  10751. __Pyx_RefNannyDeclarations
  10752. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  10753. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open___get__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  10754. /* function exit code */
  10755. __Pyx_RefNannyFinishContext();
  10756. return __pyx_r;
  10757. }
  10758. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  10759. PyObject *__pyx_r = NULL;
  10760. __Pyx_TraceDeclarations
  10761. __Pyx_RefNannyDeclarations
  10762. PyObject *__pyx_t_1 = NULL;
  10763. __Pyx_RefNannySetupContext("__get__", 0);
  10764. __Pyx_TraceCall("__get__", __pyx_f[2], 16, 0, __PYX_ERR(2, 16, __pyx_L1_error));
  10765. __Pyx_XDECREF(__pyx_r);
  10766. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 16, __pyx_L1_error)
  10767. __Pyx_GOTREF(__pyx_t_1);
  10768. __pyx_r = __pyx_t_1;
  10769. __pyx_t_1 = 0;
  10770. goto __pyx_L0;
  10771. /* function exit code */
  10772. __pyx_L1_error:;
  10773. __Pyx_XDECREF(__pyx_t_1);
  10774. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._open.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10775. __pyx_r = NULL;
  10776. __pyx_L0:;
  10777. __Pyx_XGIVEREF(__pyx_r);
  10778. __Pyx_TraceReturn(__pyx_r, 0);
  10779. __Pyx_RefNannyFinishContext();
  10780. return __pyx_r;
  10781. }
  10782. /* Python wrapper */
  10783. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
  10784. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  10785. int __pyx_r;
  10786. __Pyx_RefNannyDeclarations
  10787. __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  10788. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_2__set__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), ((PyObject *)__pyx_v_value));
  10789. /* function exit code */
  10790. __Pyx_RefNannyFinishContext();
  10791. return __pyx_r;
  10792. }
  10793. static int __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_2__set__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_value) {
  10794. int __pyx_r;
  10795. __Pyx_TraceDeclarations
  10796. __Pyx_RefNannyDeclarations
  10797. int __pyx_t_1;
  10798. __Pyx_RefNannySetupContext("__set__", 0);
  10799. __Pyx_TraceCall("__set__", __pyx_f[2], 16, 0, __PYX_ERR(2, 16, __pyx_L1_error));
  10800. __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 16, __pyx_L1_error)
  10801. __pyx_v_self->_open = __pyx_t_1;
  10802. /* function exit code */
  10803. __pyx_r = 0;
  10804. goto __pyx_L0;
  10805. __pyx_L1_error:;
  10806. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._open.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10807. __pyx_r = -1;
  10808. __pyx_L0:;
  10809. __Pyx_TraceReturn(Py_None, 0);
  10810. __Pyx_RefNannyFinishContext();
  10811. return __pyx_r;
  10812. }
  10813. /* "lakesuperior/store/base_lmdb_store.pxd":18
  10814. * public bint _open
  10815. * unsigned int _readers
  10816. * readonly str env_path # <<<<<<<<<<<<<<
  10817. * lmdb.MDB_dbi *dbis
  10818. * lmdb.MDB_env *dbenv
  10819. */
  10820. /* Python wrapper */
  10821. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path_1__get__(PyObject *__pyx_v_self); /*proto*/
  10822. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path_1__get__(PyObject *__pyx_v_self) {
  10823. PyObject *__pyx_r = 0;
  10824. __Pyx_RefNannyDeclarations
  10825. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  10826. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path___get__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  10827. /* function exit code */
  10828. __Pyx_RefNannyFinishContext();
  10829. return __pyx_r;
  10830. }
  10831. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  10832. PyObject *__pyx_r = NULL;
  10833. __Pyx_TraceDeclarations
  10834. __Pyx_RefNannyDeclarations
  10835. __Pyx_RefNannySetupContext("__get__", 0);
  10836. __Pyx_TraceCall("__get__", __pyx_f[2], 18, 0, __PYX_ERR(2, 18, __pyx_L1_error));
  10837. __Pyx_XDECREF(__pyx_r);
  10838. __Pyx_INCREF(__pyx_v_self->env_path);
  10839. __pyx_r = __pyx_v_self->env_path;
  10840. goto __pyx_L0;
  10841. /* function exit code */
  10842. __pyx_L1_error:;
  10843. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.env_path.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10844. __pyx_r = NULL;
  10845. __pyx_L0:;
  10846. __Pyx_XGIVEREF(__pyx_r);
  10847. __Pyx_TraceReturn(__pyx_r, 0);
  10848. __Pyx_RefNannyFinishContext();
  10849. return __pyx_r;
  10850. }
  10851. /* "(tree fragment)":1
  10852. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  10853. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10854. * def __setstate_cython__(self, __pyx_state):
  10855. */
  10856. /* Python wrapper */
  10857. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_34__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  10858. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_34__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  10859. PyObject *__pyx_r = 0;
  10860. __Pyx_RefNannyDeclarations
  10861. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  10862. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_33__reduce_cython__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  10863. /* function exit code */
  10864. __Pyx_RefNannyFinishContext();
  10865. return __pyx_r;
  10866. }
  10867. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_33__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  10868. PyObject *__pyx_r = NULL;
  10869. __Pyx_TraceDeclarations
  10870. __Pyx_RefNannyDeclarations
  10871. PyObject *__pyx_t_1 = NULL;
  10872. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  10873. __Pyx_TraceCall("__reduce_cython__", __pyx_f[1], 1, 0, __PYX_ERR(1, 1, __pyx_L1_error));
  10874. /* "(tree fragment)":2
  10875. * def __reduce_cython__(self):
  10876. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  10877. * def __setstate_cython__(self, __pyx_state):
  10878. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10879. */
  10880. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
  10881. __Pyx_GOTREF(__pyx_t_1);
  10882. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  10883. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10884. __PYX_ERR(1, 2, __pyx_L1_error)
  10885. /* "(tree fragment)":1
  10886. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  10887. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10888. * def __setstate_cython__(self, __pyx_state):
  10889. */
  10890. /* function exit code */
  10891. __pyx_L1_error:;
  10892. __Pyx_XDECREF(__pyx_t_1);
  10893. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10894. __pyx_r = NULL;
  10895. __Pyx_XGIVEREF(__pyx_r);
  10896. __Pyx_TraceReturn(__pyx_r, 0);
  10897. __Pyx_RefNannyFinishContext();
  10898. return __pyx_r;
  10899. }
  10900. /* "(tree fragment)":3
  10901. * def __reduce_cython__(self):
  10902. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10903. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  10904. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10905. */
  10906. /* Python wrapper */
  10907. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_36__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  10908. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_36__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  10909. PyObject *__pyx_r = 0;
  10910. __Pyx_RefNannyDeclarations
  10911. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  10912. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_35__setstate_cython__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
  10913. /* function exit code */
  10914. __Pyx_RefNannyFinishContext();
  10915. return __pyx_r;
  10916. }
  10917. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_35__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  10918. PyObject *__pyx_r = NULL;
  10919. __Pyx_TraceDeclarations
  10920. __Pyx_RefNannyDeclarations
  10921. PyObject *__pyx_t_1 = NULL;
  10922. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  10923. __Pyx_TraceCall("__setstate_cython__", __pyx_f[1], 3, 0, __PYX_ERR(1, 3, __pyx_L1_error));
  10924. /* "(tree fragment)":4
  10925. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10926. * def __setstate_cython__(self, __pyx_state):
  10927. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  10928. */
  10929. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  10930. __Pyx_GOTREF(__pyx_t_1);
  10931. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  10932. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10933. __PYX_ERR(1, 4, __pyx_L1_error)
  10934. /* "(tree fragment)":3
  10935. * def __reduce_cython__(self):
  10936. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10937. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  10938. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10939. */
  10940. /* function exit code */
  10941. __pyx_L1_error:;
  10942. __Pyx_XDECREF(__pyx_t_1);
  10943. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10944. __pyx_r = NULL;
  10945. __Pyx_XGIVEREF(__pyx_r);
  10946. __Pyx_TraceReturn(__pyx_r, 0);
  10947. __Pyx_RefNannyFinishContext();
  10948. return __pyx_r;
  10949. }
  10950. static struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  10951. static PyObject *__pyx_tp_new_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  10952. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *p;
  10953. PyObject *o;
  10954. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  10955. o = (*t->tp_alloc)(t, 0);
  10956. } else {
  10957. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  10958. }
  10959. if (unlikely(!o)) return 0;
  10960. p = ((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)o);
  10961. p->__pyx_vtab = __pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  10962. p->env_path = ((PyObject*)Py_None); Py_INCREF(Py_None);
  10963. return o;
  10964. }
  10965. static void __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore(PyObject *o) {
  10966. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *p = (struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)o;
  10967. #if CYTHON_USE_TP_FINALIZE
  10968. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
  10969. if (PyObject_CallFinalizerFromDealloc(o)) return;
  10970. }
  10971. #endif
  10972. {
  10973. PyObject *etype, *eval, *etb;
  10974. PyErr_Fetch(&etype, &eval, &etb);
  10975. ++Py_REFCNT(o);
  10976. __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_3__dealloc__(o);
  10977. --Py_REFCNT(o);
  10978. PyErr_Restore(etype, eval, etb);
  10979. }
  10980. Py_CLEAR(p->env_path);
  10981. (*Py_TYPE(o)->tp_free)(o);
  10982. }
  10983. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_open(PyObject *o, CYTHON_UNUSED void *x) {
  10984. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open_1__get__(o);
  10985. }
  10986. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_readers(PyObject *o, CYTHON_UNUSED void *x) {
  10987. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers_1__get__(o);
  10988. }
  10989. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_txn_open(PyObject *o, CYTHON_UNUSED void *x) {
  10990. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open_1__get__(o);
  10991. }
  10992. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open(PyObject *o, CYTHON_UNUSED void *x) {
  10993. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_1__get__(o);
  10994. }
  10995. static int __pyx_setprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  10996. if (v) {
  10997. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_3__set__(o, v);
  10998. }
  10999. else {
  11000. PyErr_SetString(PyExc_NotImplementedError, "__del__");
  11001. return -1;
  11002. }
  11003. }
  11004. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_env_path(PyObject *o, CYTHON_UNUSED void *x) {
  11005. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path_1__get__(o);
  11006. }
  11007. static PyMethodDef __pyx_methods_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore[] = {
  11008. {"open_env", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5open_env, METH_O, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_4open_env},
  11009. {"close_env", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env, METH_VARARGS|METH_KEYWORDS, 0},
  11010. {"destroy", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8destroy},
  11011. {"txn_ctx", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11txn_ctx, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_10txn_ctx},
  11012. {"begin", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_14begin, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_13begin},
  11013. {"commit", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_16commit, METH_NOARGS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit},
  11014. {"abort", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_18abort, METH_NOARGS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort},
  11015. {"rollback", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_20rollback, METH_NOARGS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback},
  11016. {"key_exists", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_22key_exists, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_21key_exists},
  11017. {"put", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_24put, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_23put},
  11018. {"get_data", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_25get_data},
  11019. {"delete", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_28delete, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_27delete},
  11020. {"stats", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats, METH_NOARGS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats},
  11021. {"txn_id", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id, METH_NOARGS, 0},
  11022. {"__reduce_cython__", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_34__reduce_cython__, METH_NOARGS, 0},
  11023. {"__setstate_cython__", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_36__setstate_cython__, METH_O, 0},
  11024. {0, 0, 0, 0}
  11025. };
  11026. static struct PyGetSetDef __pyx_getsets_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore[] = {
  11027. {(char *)"is_open", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_open, 0, (char *)0, 0},
  11028. {(char *)"readers", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_readers, 0, (char *)0, 0},
  11029. {(char *)"is_txn_open", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_txn_open, 0, (char *)0, 0},
  11030. {(char *)"_open", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open, __pyx_setprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open, (char *)0, 0},
  11031. {(char *)"env_path", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_env_path, 0, (char *)0, 0},
  11032. {0, 0, 0, 0, 0}
  11033. };
  11034. static PyTypeObject __pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = {
  11035. PyVarObject_HEAD_INIT(0, 0)
  11036. "lakesuperior.store.base_lmdb_store.BaseLmdbStore", /*tp_name*/
  11037. sizeof(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore), /*tp_basicsize*/
  11038. 0, /*tp_itemsize*/
  11039. __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_dealloc*/
  11040. 0, /*tp_print*/
  11041. 0, /*tp_getattr*/
  11042. 0, /*tp_setattr*/
  11043. #if PY_MAJOR_VERSION < 3
  11044. 0, /*tp_compare*/
  11045. #endif
  11046. #if PY_MAJOR_VERSION >= 3
  11047. 0, /*tp_as_async*/
  11048. #endif
  11049. 0, /*tp_repr*/
  11050. 0, /*tp_as_number*/
  11051. 0, /*tp_as_sequence*/
  11052. 0, /*tp_as_mapping*/
  11053. 0, /*tp_hash*/
  11054. 0, /*tp_call*/
  11055. 0, /*tp_str*/
  11056. 0, /*tp_getattro*/
  11057. 0, /*tp_setattro*/
  11058. 0, /*tp_as_buffer*/
  11059. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  11060. "\n Generic LMDB store abstract class.\n\n This class contains convenience method to create an LMDB store for any\n purpose and provides some convenience methods to wrap cursors and\n transactions into contexts.\n\n Example usage::\n\n >>> class MyStore(BaseLmdbStore):\n ... path = '/base/store/path'\n ... dbi_flags = ('db1', 'db2')\n ...\n >>> ms = MyStore()\n >>> # \"with\" wraps the operation in a transaction.\n >>> with ms.cur(index='db1', write=True):\n ... cur.put(b'key1', b'val1')\n True\n\n ", /*tp_doc*/
  11061. 0, /*tp_traverse*/
  11062. 0, /*tp_clear*/
  11063. 0, /*tp_richcompare*/
  11064. 0, /*tp_weaklistoffset*/
  11065. 0, /*tp_iter*/
  11066. 0, /*tp_iternext*/
  11067. __pyx_methods_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_methods*/
  11068. 0, /*tp_members*/
  11069. __pyx_getsets_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_getset*/
  11070. 0, /*tp_base*/
  11071. 0, /*tp_dict*/
  11072. 0, /*tp_descr_get*/
  11073. 0, /*tp_descr_set*/
  11074. 0, /*tp_dictoffset*/
  11075. __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_1__init__, /*tp_init*/
  11076. 0, /*tp_alloc*/
  11077. __pyx_tp_new_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_new*/
  11078. 0, /*tp_free*/
  11079. 0, /*tp_is_gc*/
  11080. 0, /*tp_bases*/
  11081. 0, /*tp_mro*/
  11082. 0, /*tp_cache*/
  11083. 0, /*tp_subclasses*/
  11084. 0, /*tp_weaklist*/
  11085. 0, /*tp_del*/
  11086. 0, /*tp_version_tag*/
  11087. #if PY_VERSION_HEX >= 0x030400a1
  11088. 0, /*tp_finalize*/
  11089. #endif
  11090. };
  11091. static struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *__pyx_freelist_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx[8];
  11092. static int __pyx_freecount_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = 0;
  11093. static PyObject *__pyx_tp_new_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  11094. PyObject *o;
  11095. if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx)))) {
  11096. o = (PyObject*)__pyx_freelist_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx[--__pyx_freecount_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx];
  11097. memset(o, 0, sizeof(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx));
  11098. (void) PyObject_INIT(o, t);
  11099. PyObject_GC_Track(o);
  11100. } else {
  11101. o = (*t->tp_alloc)(t, 0);
  11102. if (unlikely(!o)) return 0;
  11103. }
  11104. return o;
  11105. }
  11106. static void __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx(PyObject *o) {
  11107. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *p = (struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *)o;
  11108. PyObject_GC_UnTrack(o);
  11109. Py_CLEAR(p->__pyx_v_self);
  11110. Py_CLEAR(p->__pyx_v_write);
  11111. Py_CLEAR(p->__pyx_t_0);
  11112. Py_CLEAR(p->__pyx_t_1);
  11113. Py_CLEAR(p->__pyx_t_2);
  11114. if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx)))) {
  11115. __pyx_freelist_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx[__pyx_freecount_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx++] = ((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *)o);
  11116. } else {
  11117. (*Py_TYPE(o)->tp_free)(o);
  11118. }
  11119. }
  11120. static int __pyx_tp_traverse_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx(PyObject *o, visitproc v, void *a) {
  11121. int e;
  11122. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *p = (struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *)o;
  11123. if (p->__pyx_v_self) {
  11124. e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  11125. }
  11126. if (p->__pyx_v_write) {
  11127. e = (*v)(p->__pyx_v_write, a); if (e) return e;
  11128. }
  11129. if (p->__pyx_t_0) {
  11130. e = (*v)(p->__pyx_t_0, a); if (e) return e;
  11131. }
  11132. if (p->__pyx_t_1) {
  11133. e = (*v)(p->__pyx_t_1, a); if (e) return e;
  11134. }
  11135. if (p->__pyx_t_2) {
  11136. e = (*v)(p->__pyx_t_2, a); if (e) return e;
  11137. }
  11138. return 0;
  11139. }
  11140. static PyTypeObject __pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = {
  11141. PyVarObject_HEAD_INIT(0, 0)
  11142. "lakesuperior.store.base_lmdb_store.__pyx_scope_struct__txn_ctx", /*tp_name*/
  11143. sizeof(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx), /*tp_basicsize*/
  11144. 0, /*tp_itemsize*/
  11145. __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx, /*tp_dealloc*/
  11146. 0, /*tp_print*/
  11147. 0, /*tp_getattr*/
  11148. 0, /*tp_setattr*/
  11149. #if PY_MAJOR_VERSION < 3
  11150. 0, /*tp_compare*/
  11151. #endif
  11152. #if PY_MAJOR_VERSION >= 3
  11153. 0, /*tp_as_async*/
  11154. #endif
  11155. 0, /*tp_repr*/
  11156. 0, /*tp_as_number*/
  11157. 0, /*tp_as_sequence*/
  11158. 0, /*tp_as_mapping*/
  11159. 0, /*tp_hash*/
  11160. 0, /*tp_call*/
  11161. 0, /*tp_str*/
  11162. 0, /*tp_getattro*/
  11163. 0, /*tp_setattro*/
  11164. 0, /*tp_as_buffer*/
  11165. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  11166. 0, /*tp_doc*/
  11167. __pyx_tp_traverse_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx, /*tp_traverse*/
  11168. 0, /*tp_clear*/
  11169. 0, /*tp_richcompare*/
  11170. 0, /*tp_weaklistoffset*/
  11171. 0, /*tp_iter*/
  11172. 0, /*tp_iternext*/
  11173. 0, /*tp_methods*/
  11174. 0, /*tp_members*/
  11175. 0, /*tp_getset*/
  11176. 0, /*tp_base*/
  11177. 0, /*tp_dict*/
  11178. 0, /*tp_descr_get*/
  11179. 0, /*tp_descr_set*/
  11180. 0, /*tp_dictoffset*/
  11181. 0, /*tp_init*/
  11182. 0, /*tp_alloc*/
  11183. __pyx_tp_new_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx, /*tp_new*/
  11184. 0, /*tp_free*/
  11185. 0, /*tp_is_gc*/
  11186. 0, /*tp_bases*/
  11187. 0, /*tp_mro*/
  11188. 0, /*tp_cache*/
  11189. 0, /*tp_subclasses*/
  11190. 0, /*tp_weaklist*/
  11191. 0, /*tp_del*/
  11192. 0, /*tp_version_tag*/
  11193. #if PY_VERSION_HEX >= 0x030400a1
  11194. 0, /*tp_finalize*/
  11195. #endif
  11196. };
  11197. static PyMethodDef __pyx_methods[] = {
  11198. {0, 0, 0, 0}
  11199. };
  11200. #if PY_MAJOR_VERSION >= 3
  11201. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11202. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  11203. static int __pyx_pymod_exec_base_lmdb_store(PyObject* module); /*proto*/
  11204. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  11205. {Py_mod_create, (void*)__pyx_pymod_create},
  11206. {Py_mod_exec, (void*)__pyx_pymod_exec_base_lmdb_store},
  11207. {0, NULL}
  11208. };
  11209. #endif
  11210. static struct PyModuleDef __pyx_moduledef = {
  11211. PyModuleDef_HEAD_INIT,
  11212. "base_lmdb_store",
  11213. 0, /* m_doc */
  11214. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11215. 0, /* m_size */
  11216. #else
  11217. -1, /* m_size */
  11218. #endif
  11219. __pyx_methods /* m_methods */,
  11220. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11221. __pyx_moduledef_slots, /* m_slots */
  11222. #else
  11223. NULL, /* m_reload */
  11224. #endif
  11225. NULL, /* m_traverse */
  11226. NULL, /* m_clear */
  11227. NULL /* m_free */
  11228. };
  11229. #endif
  11230. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  11231. {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
  11232. {&__pyx_n_s_BaseLmdbStore_txn_ctx, __pyx_k_BaseLmdbStore_txn_ctx, sizeof(__pyx_k_BaseLmdbStore_txn_ctx), 0, 0, 1, 1},
  11233. {&__pyx_kp_u_Cleaning_up_store_env, __pyx_k_Cleaning_up_store_env, sizeof(__pyx_k_Cleaning_up_store_env), 0, 1, 0, 0},
  11234. {&__pyx_kp_u_Cleared_stale_readers, __pyx_k_Cleared_stale_readers, sizeof(__pyx_k_Cleared_stale_readers), 0, 1, 0, 0},
  11235. {&__pyx_kp_u_Closing_store_env, __pyx_k_Closing_store_env, sizeof(__pyx_k_Closing_store_env), 0, 1, 0, 0},
  11236. {&__pyx_kp_u_Could_not_create_store_at_Error, __pyx_k_Could_not_create_store_at_Error, sizeof(__pyx_k_Could_not_create_store_at_Error), 0, 1, 0, 0},
  11237. {&__pyx_kp_u_Created_DB, __pyx_k_Created_DB, sizeof(__pyx_k_Created_DB), 0, 1, 0, 0},
  11238. {&__pyx_kp_u_Created_DBenv_x, __pyx_k_Created_DBenv_x, sizeof(__pyx_k_Created_DBenv_x), 0, 1, 0, 0},
  11239. {&__pyx_kp_u_Creating_DBs, __pyx_k_Creating_DBs, sizeof(__pyx_k_Creating_DBs), 0, 1, 0, 0},
  11240. {&__pyx_kp_u_DBI, __pyx_k_DBI, sizeof(__pyx_k_DBI), 0, 1, 0, 0},
  11241. {&__pyx_kp_u_DBenv_address_x, __pyx_k_DBenv_address_x, sizeof(__pyx_k_DBenv_address_x), 0, 1, 0, 0},
  11242. {&__pyx_kp_u_Environment_already_open, __pyx_k_Environment_already_open, sizeof(__pyx_k_Environment_already_open), 0, 1, 0, 0},
  11243. {&__pyx_kp_u_Error_creating_DB_environment_ha, __pyx_k_Error_creating_DB_environment_ha, sizeof(__pyx_k_Error_creating_DB_environment_ha), 0, 1, 0, 0},
  11244. {&__pyx_kp_u_Error_getting_data_for_key, __pyx_k_Error_getting_data_for_key, sizeof(__pyx_k_Error_getting_data_for_key), 0, 1, 0, 0},
  11245. {&__pyx_kp_u_Error_getting_datbase_stats, __pyx_k_Error_getting_datbase_stats, sizeof(__pyx_k_Error_getting_datbase_stats), 0, 1, 0, 0},
  11246. {&__pyx_kp_u_Error_opening_cursor, __pyx_k_Error_opening_cursor, sizeof(__pyx_k_Error_opening_cursor), 0, 1, 0, 0},
  11247. {&__pyx_kp_u_Error_opening_the_database_envir, __pyx_k_Error_opening_the_database_envir, sizeof(__pyx_k_Error_opening_the_database_envir), 0, 1, 0, 0},
  11248. {&__pyx_kp_u_Error_opening_transaction, __pyx_k_Error_opening_transaction, sizeof(__pyx_k_Error_opening_transaction), 0, 1, 0, 0},
  11249. {&__pyx_kp_u_Error_putting_data, __pyx_k_Error_putting_data, sizeof(__pyx_k_Error_putting_data), 0, 1, 0, 0},
  11250. {&__pyx_kp_u_Error_setting_map_size, __pyx_k_Error_setting_map_size, sizeof(__pyx_k_Error_setting_map_size), 0, 1, 0, 0},
  11251. {&__pyx_kp_u_Error_setting_max_databases, __pyx_k_Error_setting_max_databases, sizeof(__pyx_k_Error_setting_max_databases), 0, 1, 0, 0},
  11252. {&__pyx_kp_u_Error_setting_max_readers, __pyx_k_Error_setting_max_readers, sizeof(__pyx_k_Error_setting_max_readers), 0, 1, 0, 0},
  11253. {&__pyx_n_s_FileNotFoundError, __pyx_k_FileNotFoundError, sizeof(__pyx_k_FileNotFoundError), 0, 0, 1, 1},
  11254. {&__pyx_kp_u_Getting_DBI_without_label, __pyx_k_Getting_DBI_without_label, sizeof(__pyx_k_Getting_DBI_without_label), 0, 1, 0, 0},
  11255. {&__pyx_kp_u_Internal_error, __pyx_k_Internal_error, sizeof(__pyx_k_Internal_error), 0, 1, 0, 0},
  11256. {&__pyx_n_s_KeyExistsError, __pyx_k_KeyExistsError, sizeof(__pyx_k_KeyExistsError), 0, 0, 1, 1},
  11257. {&__pyx_n_s_KeyNotFoundError, __pyx_k_KeyNotFoundError, sizeof(__pyx_k_KeyNotFoundError), 0, 0, 1, 1},
  11258. {&__pyx_kp_u_LMDB_Error, __pyx_k_LMDB_Error, sizeof(__pyx_k_LMDB_Error), 0, 1, 0, 0},
  11259. {&__pyx_n_s_LmdbError, __pyx_k_LmdbError, sizeof(__pyx_k_LmdbError), 0, 0, 1, 1},
  11260. {&__pyx_kp_u_Max_readers, __pyx_k_Max_readers, sizeof(__pyx_k_Max_readers), 0, 1, 0, 0},
  11261. {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  11262. {&__pyx_kp_u_None, __pyx_k_None, sizeof(__pyx_k_None), 0, 1, 0, 0},
  11263. {&__pyx_kp_u_Opened_transaction_x, __pyx_k_Opened_transaction_x, sizeof(__pyx_k_Opened_transaction_x), 0, 1, 0, 0},
  11264. {&__pyx_kp_u_Opening_cursor_for_DB, __pyx_k_Opening_cursor_for_DB, sizeof(__pyx_k_Opening_cursor_for_DB), 0, 1, 0, 0},
  11265. {&__pyx_kp_u_Opening_environment_at, __pyx_k_Opening_environment_at, sizeof(__pyx_k_Opening_environment_at), 0, 1, 0, 0},
  11266. {&__pyx_kp_u_Opening_transaction_in_PID_threa, __pyx_k_Opening_transaction_in_PID_threa, sizeof(__pyx_k_Opening_transaction_in_PID_threa), 0, 1, 0, 0},
  11267. {&__pyx_n_u_RO, __pyx_k_RO, sizeof(__pyx_k_RO), 0, 1, 0, 1},
  11268. {&__pyx_n_u_RW, __pyx_k_RW, sizeof(__pyx_k_RW), 0, 1, 0, 1},
  11269. {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  11270. {&__pyx_kp_u_Store_is_not_open, __pyx_k_Store_is_not_open, sizeof(__pyx_k_Store_is_not_open), 0, 1, 0, 0},
  11271. {&__pyx_kp_u_Store_must_be_opened_first, __pyx_k_Store_must_be_opened_first, sizeof(__pyx_k_Store_must_be_opened_first), 0, 1, 0, 0},
  11272. {&__pyx_kp_u_Transaction_aborted, __pyx_k_Transaction_aborted, sizeof(__pyx_k_Transaction_aborted), 0, 1, 0, 0},
  11273. {&__pyx_kp_u_Transaction_committed, __pyx_k_Transaction_committed, sizeof(__pyx_k_Transaction_committed), 0, 1, 0, 0},
  11274. {&__pyx_kp_u_Transaction_is_already_active_No, __pyx_k_Transaction_is_already_active_No, sizeof(__pyx_k_Transaction_is_already_active_No), 0, 1, 0, 0},
  11275. {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  11276. {&__pyx_kp_u__20, __pyx_k__20, sizeof(__pyx_k__20), 0, 1, 0, 0},
  11277. {&__pyx_kp_u__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 1, 0, 0},
  11278. {&__pyx_kp_u__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 1, 0, 0},
  11279. {&__pyx_n_s_abort, __pyx_k_abort, sizeof(__pyx_k_abort), 0, 0, 1, 1},
  11280. {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  11281. {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  11282. {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  11283. {&__pyx_n_s_close_env, __pyx_k_close_env, sizeof(__pyx_k_close_env), 0, 0, 1, 1},
  11284. {&__pyx_n_s_commit_pending_transaction, __pyx_k_commit_pending_transaction, sizeof(__pyx_k_commit_pending_transaction), 0, 0, 1, 1},
  11285. {&__pyx_n_s_contextlib, __pyx_k_contextlib, sizeof(__pyx_k_contextlib), 0, 0, 1, 1},
  11286. {&__pyx_n_s_contextmanager, __pyx_k_contextmanager, sizeof(__pyx_k_contextmanager), 0, 0, 1, 1},
  11287. {&__pyx_n_s_create, __pyx_k_create, sizeof(__pyx_k_create), 0, 0, 1, 1},
  11288. {&__pyx_n_s_currentThread, __pyx_k_currentThread, sizeof(__pyx_k_currentThread), 0, 0, 1, 1},
  11289. {&__pyx_n_s_current_process, __pyx_k_current_process, sizeof(__pyx_k_current_process), 0, 0, 1, 1},
  11290. {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  11291. {&__pyx_n_s_data_v, __pyx_k_data_v, sizeof(__pyx_k_data_v), 0, 0, 1, 1},
  11292. {&__pyx_n_u_db_stats, __pyx_k_db_stats, sizeof(__pyx_k_db_stats), 0, 1, 0, 1},
  11293. {&__pyx_n_s_dbi, __pyx_k_dbi, sizeof(__pyx_k_dbi), 0, 0, 1, 1},
  11294. {&__pyx_n_s_dbi_flags, __pyx_k_dbi_flags, sizeof(__pyx_k_dbi_flags), 0, 0, 1, 1},
  11295. {&__pyx_n_s_dbi_labels, __pyx_k_dbi_labels, sizeof(__pyx_k_dbi_labels), 0, 0, 1, 1},
  11296. {&__pyx_n_s_dblabel, __pyx_k_dblabel, sizeof(__pyx_k_dblabel), 0, 0, 1, 1},
  11297. {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  11298. {&__pyx_n_s_destroy, __pyx_k_destroy, sizeof(__pyx_k_destroy), 0, 0, 1, 1},
  11299. {&__pyx_n_s_dirname, __pyx_k_dirname, sizeof(__pyx_k_dirname), 0, 0, 1, 1},
  11300. {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  11301. {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  11302. {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
  11303. {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  11304. {&__pyx_n_s_env, __pyx_k_env, sizeof(__pyx_k_env), 0, 0, 1, 1},
  11305. {&__pyx_n_s_env_flags, __pyx_k_env_flags, sizeof(__pyx_k_env_flags), 0, 0, 1, 1},
  11306. {&__pyx_n_s_env_path, __pyx_k_env_path, sizeof(__pyx_k_env_path), 0, 0, 1, 1},
  11307. {&__pyx_n_s_env_perms, __pyx_k_env_perms, sizeof(__pyx_k_env_perms), 0, 0, 1, 1},
  11308. {&__pyx_n_u_env_size, __pyx_k_env_size, sizeof(__pyx_k_env_size), 0, 1, 0, 1},
  11309. {&__pyx_n_u_env_stats, __pyx_k_env_stats, sizeof(__pyx_k_env_stats), 0, 1, 0, 1},
  11310. {&__pyx_n_s_exist_ok, __pyx_k_exist_ok, sizeof(__pyx_k_exist_ok), 0, 0, 1, 1},
  11311. {&__pyx_n_s_exists, __pyx_k_exists, sizeof(__pyx_k_exists), 0, 0, 1, 1},
  11312. {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  11313. {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
  11314. {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  11315. {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  11316. {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1},
  11317. {&__pyx_n_s_getName, __pyx_k_getName, sizeof(__pyx_k_getName), 0, 0, 1, 1},
  11318. {&__pyx_n_s_get_data, __pyx_k_get_data, sizeof(__pyx_k_get_data), 0, 0, 1, 1},
  11319. {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  11320. {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  11321. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  11322. {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  11323. {&__pyx_n_s_info, __pyx_k_info, sizeof(__pyx_k_info), 0, 0, 1, 1},
  11324. {&__pyx_n_s_is_open, __pyx_k_is_open, sizeof(__pyx_k_is_open), 0, 0, 1, 1},
  11325. {&__pyx_n_s_is_txn_rw, __pyx_k_is_txn_rw, sizeof(__pyx_k_is_txn_rw), 0, 0, 1, 1},
  11326. {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  11327. {&__pyx_n_s_key_v, __pyx_k_key_v, sizeof(__pyx_k_key_v), 0, 0, 1, 1},
  11328. {&__pyx_n_s_lakesuperior, __pyx_k_lakesuperior, sizeof(__pyx_k_lakesuperior), 0, 0, 1, 1},
  11329. {&__pyx_n_s_lakesuperior_store_base_lmdb_sto, __pyx_k_lakesuperior_store_base_lmdb_sto, sizeof(__pyx_k_lakesuperior_store_base_lmdb_sto), 0, 0, 1, 1},
  11330. {&__pyx_kp_u_lock, __pyx_k_lock, sizeof(__pyx_k_lock), 0, 1, 0, 0},
  11331. {&__pyx_n_s_logger, __pyx_k_logger, sizeof(__pyx_k_logger), 0, 0, 1, 1},
  11332. {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
  11333. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  11334. {&__pyx_n_s_makedirs, __pyx_k_makedirs, sizeof(__pyx_k_makedirs), 0, 0, 1, 1},
  11335. {&__pyx_n_u_map_size, __pyx_k_map_size, sizeof(__pyx_k_map_size), 0, 1, 0, 1},
  11336. {&__pyx_n_u_max_dbs, __pyx_k_max_dbs, sizeof(__pyx_k_max_dbs), 0, 1, 0, 1},
  11337. {&__pyx_n_u_max_spare_txns, __pyx_k_max_spare_txns, sizeof(__pyx_k_max_spare_txns), 0, 1, 0, 1},
  11338. {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  11339. {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  11340. {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  11341. {&__pyx_n_s_ms_branch_pages, __pyx_k_ms_branch_pages, sizeof(__pyx_k_ms_branch_pages), 0, 0, 1, 1},
  11342. {&__pyx_n_s_ms_depth, __pyx_k_ms_depth, sizeof(__pyx_k_ms_depth), 0, 0, 1, 1},
  11343. {&__pyx_n_s_ms_entries, __pyx_k_ms_entries, sizeof(__pyx_k_ms_entries), 0, 0, 1, 1},
  11344. {&__pyx_n_s_ms_leaf_pages, __pyx_k_ms_leaf_pages, sizeof(__pyx_k_ms_leaf_pages), 0, 0, 1, 1},
  11345. {&__pyx_n_s_ms_overflow_pages, __pyx_k_ms_overflow_pages, sizeof(__pyx_k_ms_overflow_pages), 0, 0, 1, 1},
  11346. {&__pyx_n_s_ms_psize, __pyx_k_ms_psize, sizeof(__pyx_k_ms_psize), 0, 0, 1, 1},
  11347. {&__pyx_n_s_multiprocessing, __pyx_k_multiprocessing, sizeof(__pyx_k_multiprocessing), 0, 0, 1, 1},
  11348. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  11349. {&__pyx_n_s_new_txn, __pyx_k_new_txn, sizeof(__pyx_k_new_txn), 0, 0, 1, 1},
  11350. {&__pyx_n_s_open_env, __pyx_k_open_env, sizeof(__pyx_k_open_env), 0, 0, 1, 1},
  11351. {&__pyx_kp_u_opened_x, __pyx_k_opened_x, sizeof(__pyx_k_opened_x), 0, 1, 0, 0},
  11352. {&__pyx_n_s_options, __pyx_k_options, sizeof(__pyx_k_options), 0, 0, 1, 1},
  11353. {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
  11354. {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
  11355. {&__pyx_n_s_path_2, __pyx_k_path_2, sizeof(__pyx_k_path_2), 0, 0, 1, 1},
  11356. {&__pyx_n_s_pid, __pyx_k_pid, sizeof(__pyx_k_pid), 0, 0, 1, 1},
  11357. {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  11358. {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
  11359. {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  11360. {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  11361. {&__pyx_n_s_rc, __pyx_k_rc, sizeof(__pyx_k_rc), 0, 0, 1, 1},
  11362. {&__pyx_n_s_readers_mult, __pyx_k_readers_mult, sizeof(__pyx_k_readers_mult), 0, 0, 1, 1},
  11363. {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  11364. {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  11365. {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  11366. {&__pyx_n_s_rmtree, __pyx_k_rmtree, sizeof(__pyx_k_rmtree), 0, 0, 1, 1},
  11367. {&__pyx_kp_s_self_curs_self_dbenv_self_dbis_s, __pyx_k_self_curs_self_dbenv_self_dbis_s, sizeof(__pyx_k_self_curs_self_dbenv_self_dbis_s), 0, 0, 1, 0},
  11368. {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  11369. {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  11370. {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  11371. {&__pyx_n_s_shutil, __pyx_k_shutil, sizeof(__pyx_k_shutil), 0, 0, 1, 1},
  11372. {&__pyx_n_s_st_size, __pyx_k_st_size, sizeof(__pyx_k_st_size), 0, 0, 1, 1},
  11373. {&__pyx_n_s_stat, __pyx_k_stat, sizeof(__pyx_k_stat), 0, 0, 1, 1},
  11374. {&__pyx_n_s_stats, __pyx_k_stats, sizeof(__pyx_k_stats), 0, 0, 1, 1},
  11375. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  11376. {&__pyx_n_s_threading, __pyx_k_threading, sizeof(__pyx_k_threading), 0, 0, 1, 1},
  11377. {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  11378. {&__pyx_n_s_txn_ctx, __pyx_k_txn_ctx, sizeof(__pyx_k_txn_ctx), 0, 0, 1, 1},
  11379. {&__pyx_n_s_txn_id, __pyx_k_txn_id, sizeof(__pyx_k_txn_id), 0, 0, 1, 1},
  11380. {&__pyx_kp_u_txn_is_open, __pyx_k_txn_is_open, sizeof(__pyx_k_txn_is_open), 0, 1, 0, 0},
  11381. {&__pyx_n_s_unlink, __pyx_k_unlink, sizeof(__pyx_k_unlink), 0, 0, 1, 1},
  11382. {&__pyx_n_s_warning, __pyx_k_warning, sizeof(__pyx_k_warning), 0, 0, 1, 1},
  11383. {&__pyx_n_s_workers, __pyx_k_workers, sizeof(__pyx_k_workers), 0, 0, 1, 1},
  11384. {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
  11385. {&__pyx_n_s_wsgi, __pyx_k_wsgi, sizeof(__pyx_k_wsgi), 0, 0, 1, 1},
  11386. {&__pyx_kp_u_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 1, 0, 0},
  11387. {0, 0, 0, 0, 0, 0, 0}
  11388. };
  11389. static int __Pyx_InitCachedBuiltins(void) {
  11390. __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 252, __pyx_L1_error)
  11391. __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 267, __pyx_L1_error)
  11392. __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 375, __pyx_L1_error)
  11393. __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
  11394. return 0;
  11395. __pyx_L1_error:;
  11396. return -1;
  11397. }
  11398. static int __Pyx_InitCachedConstants(void) {
  11399. __Pyx_RefNannyDeclarations
  11400. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  11401. /* "lakesuperior/store/base_lmdb_store.pyx":166
  11402. * """
  11403. * if self.is_open:
  11404. * logger.warning('Environment already open.') # <<<<<<<<<<<<<<
  11405. * return
  11406. *
  11407. */
  11408. __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Environment_already_open); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 166, __pyx_L1_error)
  11409. __Pyx_GOTREF(__pyx_tuple__2);
  11410. __Pyx_GIVEREF(__pyx_tuple__2);
  11411. /* "lakesuperior/store/base_lmdb_store.pyx":195
  11412. * # Set map size.
  11413. * _check(
  11414. * lmdb.mdb_env_set_mapsize(self.dbenv, self.options.get( # <<<<<<<<<<<<<<
  11415. * 'map_size', 1024 ** 3)),
  11416. * 'Error setting map size: {}')
  11417. */
  11418. __pyx_tuple__3 = PyTuple_Pack(2, __pyx_n_u_map_size, __pyx_int_1073741824); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 195, __pyx_L1_error)
  11419. __Pyx_GOTREF(__pyx_tuple__3);
  11420. __Pyx_GIVEREF(__pyx_tuple__3);
  11421. /* "lakesuperior/store/base_lmdb_store.pyx":264
  11422. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  11423. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  11424. * logger.info(f'Creating DBs.') # <<<<<<<<<<<<<<
  11425. * try:
  11426. * if len(self.dbi_labels):
  11427. */
  11428. __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Creating_DBs); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 264, __pyx_L1_error)
  11429. __Pyx_GOTREF(__pyx_tuple__5);
  11430. __Pyx_GIVEREF(__pyx_tuple__5);
  11431. /* "lakesuperior/store/base_lmdb_store.pyx":289
  11432. *
  11433. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  11434. * logger.debug('Cleaning up store env.') # <<<<<<<<<<<<<<
  11435. * if self.is_open:
  11436. * logger.debug('Closing store env.')
  11437. */
  11438. __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Cleaning_up_store_env); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 289, __pyx_L1_error)
  11439. __Pyx_GOTREF(__pyx_tuple__7);
  11440. __Pyx_GIVEREF(__pyx_tuple__7);
  11441. /* "lakesuperior/store/base_lmdb_store.pyx":291
  11442. * logger.debug('Cleaning up store env.')
  11443. * if self.is_open:
  11444. * logger.debug('Closing store env.') # <<<<<<<<<<<<<<
  11445. * if self.is_txn_open is True:
  11446. * if commit_pending_transaction:
  11447. */
  11448. __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Closing_store_env); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 291, __pyx_L1_error)
  11449. __Pyx_GOTREF(__pyx_tuple__8);
  11450. __Pyx_GIVEREF(__pyx_tuple__8);
  11451. /* "lakesuperior/store/base_lmdb_store.pyx":343
  11452. * """
  11453. * if not self.is_open:
  11454. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  11455. *
  11456. * if self.is_txn_open:
  11457. */
  11458. __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_Store_is_not_open); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 343, __pyx_L1_error)
  11459. __Pyx_GOTREF(__pyx_tuple__9);
  11460. __Pyx_GIVEREF(__pyx_tuple__9);
  11461. /* "lakesuperior/store/base_lmdb_store.pyx":346
  11462. *
  11463. * if self.is_txn_open:
  11464. * logger.debug( # <<<<<<<<<<<<<<
  11465. * 'Transaction is already active. Not opening another one.')
  11466. * #logger.debug('before yield')
  11467. */
  11468. __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_u_Transaction_is_already_active_No); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 346, __pyx_L1_error)
  11469. __Pyx_GOTREF(__pyx_tuple__10);
  11470. __Pyx_GIVEREF(__pyx_tuple__10);
  11471. /* "lakesuperior/store/base_lmdb_store.pyx":375
  11472. * """
  11473. * if not self.is_open:
  11474. * raise RuntimeError('Store must be opened first.') # <<<<<<<<<<<<<<
  11475. * #logger.debug('Beginning a {} transaction.'.format(
  11476. * # 'read/write' if write else 'read-only'))
  11477. */
  11478. __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_Store_must_be_opened_first); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 375, __pyx_L1_error)
  11479. __Pyx_GOTREF(__pyx_tuple__11);
  11480. __Pyx_GIVEREF(__pyx_tuple__11);
  11481. /* "lakesuperior/store/base_lmdb_store.pyx":407
  11482. * """
  11483. * if new_txn is True:
  11484. * with self.txn_ctx(): # <<<<<<<<<<<<<<
  11485. * return self._key_exists(
  11486. * key, len(key), dblabel=dblabel.encode())
  11487. */
  11488. __pyx_tuple__12 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 407, __pyx_L1_error)
  11489. __Pyx_GOTREF(__pyx_tuple__12);
  11490. __Pyx_GIVEREF(__pyx_tuple__12);
  11491. __pyx_tuple__13 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 407, __pyx_L1_error)
  11492. __Pyx_GOTREF(__pyx_tuple__13);
  11493. __Pyx_GIVEREF(__pyx_tuple__13);
  11494. /* "lakesuperior/store/base_lmdb_store.pyx":608
  11495. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  11496. * if not self.is_open:
  11497. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  11498. *
  11499. * cdef:
  11500. */
  11501. __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_u_Store_is_not_open); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 608, __pyx_L1_error)
  11502. __Pyx_GOTREF(__pyx_tuple__18);
  11503. __Pyx_GIVEREF(__pyx_tuple__18);
  11504. /* "lakesuperior/store/base_lmdb_store.pyx":668
  11505. *
  11506. * if dblabel is NULL:
  11507. * logger.debug('Getting DBI without label.') # <<<<<<<<<<<<<<
  11508. * dbidx = (
  11509. * 0 if dblabel is NULL
  11510. */
  11511. __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_u_Getting_DBI_without_label); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 668, __pyx_L1_error)
  11512. __Pyx_GOTREF(__pyx_tuple__19);
  11513. __Pyx_GIVEREF(__pyx_tuple__19);
  11514. /* "(tree fragment)":2
  11515. * def __reduce_cython__(self):
  11516. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  11517. * def __setstate_cython__(self, __pyx_state):
  11518. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  11519. */
  11520. __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_self_curs_self_dbenv_self_dbis_s); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 2, __pyx_L1_error)
  11521. __Pyx_GOTREF(__pyx_tuple__21);
  11522. __Pyx_GIVEREF(__pyx_tuple__21);
  11523. /* "(tree fragment)":4
  11524. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  11525. * def __setstate_cython__(self, __pyx_state):
  11526. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  11527. */
  11528. __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_self_curs_self_dbenv_self_dbis_s); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(1, 4, __pyx_L1_error)
  11529. __Pyx_GOTREF(__pyx_tuple__22);
  11530. __Pyx_GIVEREF(__pyx_tuple__22);
  11531. __Pyx_RefNannyFinishContext();
  11532. return 0;
  11533. __pyx_L1_error:;
  11534. __Pyx_RefNannyFinishContext();
  11535. return -1;
  11536. }
  11537. static int __Pyx_InitGlobals(void) {
  11538. /* InitThreads.init */
  11539. #ifdef WITH_THREAD
  11540. PyEval_InitThreads();
  11541. #endif
  11542. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  11543. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  11544. __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  11545. __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  11546. __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  11547. __pyx_int_416 = PyInt_FromLong(416); if (unlikely(!__pyx_int_416)) __PYX_ERR(0, 1, __pyx_L1_error)
  11548. __pyx_int_488 = PyInt_FromLong(488); if (unlikely(!__pyx_int_488)) __PYX_ERR(0, 1, __pyx_L1_error)
  11549. __pyx_int_1073741824 = PyInt_FromLong(1073741824L); if (unlikely(!__pyx_int_1073741824)) __PYX_ERR(0, 1, __pyx_L1_error)
  11550. return 0;
  11551. __pyx_L1_error:;
  11552. return -1;
  11553. }
  11554. static int __Pyx_modinit_global_init_code(void); /*proto*/
  11555. static int __Pyx_modinit_variable_export_code(void); /*proto*/
  11556. static int __Pyx_modinit_function_export_code(void); /*proto*/
  11557. static int __Pyx_modinit_type_init_code(void); /*proto*/
  11558. static int __Pyx_modinit_type_import_code(void); /*proto*/
  11559. static int __Pyx_modinit_variable_import_code(void); /*proto*/
  11560. static int __Pyx_modinit_function_import_code(void); /*proto*/
  11561. static int __Pyx_modinit_global_init_code(void) {
  11562. __Pyx_RefNannyDeclarations
  11563. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  11564. /*--- Global init code ---*/
  11565. __Pyx_RefNannyFinishContext();
  11566. return 0;
  11567. }
  11568. static int __Pyx_modinit_variable_export_code(void) {
  11569. __Pyx_RefNannyDeclarations
  11570. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  11571. /*--- Variable export code ---*/
  11572. if (__Pyx_ExportVoidPtr(__pyx_n_s_rc, (void *)&__pyx_v_12lakesuperior_5store_15base_lmdb_store_rc, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11573. if (__Pyx_ExportVoidPtr(__pyx_n_s_i, (void *)&__pyx_v_12lakesuperior_5store_15base_lmdb_store_i, "size_t") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11574. if (__Pyx_ExportVoidPtr(__pyx_n_s_key_v, (void *)&__pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v, "struct MDB_val") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11575. if (__Pyx_ExportVoidPtr(__pyx_n_s_data_v, (void *)&__pyx_v_12lakesuperior_5store_15base_lmdb_store_data_v, "struct MDB_val") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11576. if (__Pyx_ExportVoidPtr(__pyx_n_s_dbi, (void *)&__pyx_v_12lakesuperior_5store_15base_lmdb_store_dbi, "MDB_dbi") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11577. __Pyx_RefNannyFinishContext();
  11578. return 0;
  11579. __pyx_L1_error:;
  11580. __Pyx_RefNannyFinishContext();
  11581. return -1;
  11582. }
  11583. static int __Pyx_modinit_function_export_code(void) {
  11584. __Pyx_RefNannyDeclarations
  11585. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  11586. /*--- Function export code ---*/
  11587. if (__Pyx_ExportFunction("_check", (void (*)(void))__pyx_f_12lakesuperior_5store_15base_lmdb_store__check, "void (int, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11588. __Pyx_RefNannyFinishContext();
  11589. return 0;
  11590. __pyx_L1_error:;
  11591. __Pyx_RefNannyFinishContext();
  11592. return -1;
  11593. }
  11594. static int __Pyx_modinit_type_init_code(void) {
  11595. __Pyx_RefNannyDeclarations
  11596. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  11597. /*--- Type init code ---*/
  11598. __pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = &__pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  11599. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._clear_stale_readers = (void (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__clear_stale_readers;
  11600. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._cur_close = (void (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, MDB_cursor *))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_close;
  11601. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._init_dbis = (void (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis;
  11602. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._txn_begin = (void (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin;
  11603. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._txn_commit = (void (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_commit;
  11604. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._txn_abort = (void (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_abort;
  11605. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._key_exists = (int (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, unsigned char *, unsigned char, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists;
  11606. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._txn_id = (size_t (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_id;
  11607. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._cur_open = (MDB_cursor *(*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open;
  11608. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.get_dbi = (MDB_dbi (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi;
  11609. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._put = (void (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, unsigned char *, size_t, unsigned char *, size_t, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put;
  11610. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._get_data = (void (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, unsigned char *, size_t, struct MDB_val *, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data;
  11611. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._delete = (void (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, unsigned char *, size_t, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete;
  11612. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore._stats = (PyObject *(*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__stats;
  11613. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.close_env = (void (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env;
  11614. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.destroy = (void (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy;
  11615. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.get_data = (PyObject *(*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data;
  11616. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.stats = (PyObject *(*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats;
  11617. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.txn_id = (int (*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_txn_id;
  11618. if (PyType_Ready(&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  11619. __pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.tp_print = 0;
  11620. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.tp_dictoffset && __pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.tp_getattro == PyObject_GenericGetAttr)) {
  11621. __pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  11622. }
  11623. #if CYTHON_COMPILING_IN_CPYTHON
  11624. {
  11625. PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 49, __pyx_L1_error)
  11626. if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
  11627. __pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
  11628. __pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__.doc = __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__;
  11629. ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__;
  11630. }
  11631. }
  11632. #endif
  11633. if (__Pyx_SetVtable(__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.tp_dict, __pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  11634. if (PyObject_SetAttrString(__pyx_m, "BaseLmdbStore", (PyObject *)&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  11635. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  11636. __pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = &__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  11637. if (PyType_Ready(&__pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx) < 0) __PYX_ERR(0, 334, __pyx_L1_error)
  11638. __pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx.tp_print = 0;
  11639. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx.tp_dictoffset && __pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx.tp_getattro == PyObject_GenericGetAttr)) {
  11640. __pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  11641. }
  11642. __pyx_ptype_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = &__pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx;
  11643. __Pyx_RefNannyFinishContext();
  11644. return 0;
  11645. __pyx_L1_error:;
  11646. __Pyx_RefNannyFinishContext();
  11647. return -1;
  11648. }
  11649. static int __Pyx_modinit_type_import_code(void) {
  11650. __Pyx_RefNannyDeclarations
  11651. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  11652. /*--- Type import code ---*/
  11653. __Pyx_RefNannyFinishContext();
  11654. return 0;
  11655. }
  11656. static int __Pyx_modinit_variable_import_code(void) {
  11657. __Pyx_RefNannyDeclarations
  11658. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  11659. /*--- Variable import code ---*/
  11660. __Pyx_RefNannyFinishContext();
  11661. return 0;
  11662. }
  11663. static int __Pyx_modinit_function_import_code(void) {
  11664. __Pyx_RefNannyDeclarations
  11665. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  11666. /*--- Function import code ---*/
  11667. __Pyx_RefNannyFinishContext();
  11668. return 0;
  11669. }
  11670. #if PY_MAJOR_VERSION < 3
  11671. #ifdef CYTHON_NO_PYINIT_EXPORT
  11672. #define __Pyx_PyMODINIT_FUNC void
  11673. #else
  11674. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  11675. #endif
  11676. #else
  11677. #ifdef CYTHON_NO_PYINIT_EXPORT
  11678. #define __Pyx_PyMODINIT_FUNC PyObject *
  11679. #else
  11680. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  11681. #endif
  11682. #endif
  11683. #ifndef CYTHON_SMALL_CODE
  11684. #if defined(__clang__)
  11685. #define CYTHON_SMALL_CODE
  11686. #elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
  11687. #define CYTHON_SMALL_CODE __attribute__((optimize("Os")))
  11688. #else
  11689. #define CYTHON_SMALL_CODE
  11690. #endif
  11691. #endif
  11692. #if PY_MAJOR_VERSION < 3
  11693. __Pyx_PyMODINIT_FUNC initbase_lmdb_store(void) CYTHON_SMALL_CODE; /*proto*/
  11694. __Pyx_PyMODINIT_FUNC initbase_lmdb_store(void)
  11695. #else
  11696. __Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void) CYTHON_SMALL_CODE; /*proto*/
  11697. __Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void)
  11698. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11699. {
  11700. return PyModuleDef_Init(&__pyx_moduledef);
  11701. }
  11702. static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
  11703. PyObject *value = PyObject_GetAttrString(spec, from_name);
  11704. int result = 0;
  11705. if (likely(value)) {
  11706. result = PyDict_SetItemString(moddict, to_name, value);
  11707. Py_DECREF(value);
  11708. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  11709. PyErr_Clear();
  11710. } else {
  11711. result = -1;
  11712. }
  11713. return result;
  11714. }
  11715. static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
  11716. PyObject *module = NULL, *moddict, *modname;
  11717. if (__pyx_m)
  11718. return __Pyx_NewRef(__pyx_m);
  11719. modname = PyObject_GetAttrString(spec, "name");
  11720. if (unlikely(!modname)) goto bad;
  11721. module = PyModule_NewObject(modname);
  11722. Py_DECREF(modname);
  11723. if (unlikely(!module)) goto bad;
  11724. moddict = PyModule_GetDict(module);
  11725. if (unlikely(!moddict)) goto bad;
  11726. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
  11727. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
  11728. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
  11729. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
  11730. return module;
  11731. bad:
  11732. Py_XDECREF(module);
  11733. return NULL;
  11734. }
  11735. static int __pyx_pymod_exec_base_lmdb_store(PyObject *__pyx_pyinit_module)
  11736. #endif
  11737. #endif
  11738. {
  11739. __Pyx_TraceDeclarations
  11740. PyObject *__pyx_t_1 = NULL;
  11741. PyObject *__pyx_t_2 = NULL;
  11742. PyObject *__pyx_t_3 = NULL;
  11743. PyObject *__pyx_t_4 = NULL;
  11744. PyObject *__pyx_t_5 = NULL;
  11745. __Pyx_RefNannyDeclarations
  11746. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11747. if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
  11748. #elif PY_MAJOR_VERSION >= 3
  11749. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  11750. #endif
  11751. #if CYTHON_REFNANNY
  11752. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  11753. if (!__Pyx_RefNanny) {
  11754. PyErr_Clear();
  11755. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  11756. if (!__Pyx_RefNanny)
  11757. Py_FatalError("failed to import 'refnanny' module");
  11758. }
  11759. #endif
  11760. __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void)", 0);
  11761. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11762. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  11763. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  11764. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  11765. #ifdef __Pyx_CyFunction_USED
  11766. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11767. #endif
  11768. #ifdef __Pyx_FusedFunction_USED
  11769. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11770. #endif
  11771. #ifdef __Pyx_Coroutine_USED
  11772. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11773. #endif
  11774. #ifdef __Pyx_Generator_USED
  11775. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11776. #endif
  11777. #ifdef __Pyx_AsyncGen_USED
  11778. if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11779. #endif
  11780. #ifdef __Pyx_StopAsyncIteration_USED
  11781. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11782. #endif
  11783. /*--- Library function declarations ---*/
  11784. /*--- Threads initialization code ---*/
  11785. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  11786. #ifdef WITH_THREAD /* Python build with threading support? */
  11787. PyEval_InitThreads();
  11788. #endif
  11789. #endif
  11790. /*--- Module creation code ---*/
  11791. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11792. __pyx_m = __pyx_pyinit_module;
  11793. Py_INCREF(__pyx_m);
  11794. #else
  11795. #if PY_MAJOR_VERSION < 3
  11796. __pyx_m = Py_InitModule4("base_lmdb_store", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  11797. #else
  11798. __pyx_m = PyModule_Create(&__pyx_moduledef);
  11799. #endif
  11800. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  11801. #endif
  11802. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  11803. Py_INCREF(__pyx_d);
  11804. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  11805. __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  11806. #if CYTHON_COMPILING_IN_PYPY
  11807. Py_INCREF(__pyx_b);
  11808. #endif
  11809. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  11810. /*--- Initialize various global constants etc. ---*/
  11811. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11812. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  11813. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11814. #endif
  11815. if (__pyx_module_is_main_lakesuperior__store__base_lmdb_store) {
  11816. if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11817. }
  11818. #if PY_MAJOR_VERSION >= 3
  11819. {
  11820. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  11821. if (!PyDict_GetItemString(modules, "lakesuperior.store.base_lmdb_store")) {
  11822. if (unlikely(PyDict_SetItemString(modules, "lakesuperior.store.base_lmdb_store", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  11823. }
  11824. }
  11825. #endif
  11826. /*--- Builtin init code ---*/
  11827. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11828. /*--- Constants init code ---*/
  11829. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11830. /*--- Global type/function init code ---*/
  11831. (void)__Pyx_modinit_global_init_code();
  11832. if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
  11833. if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
  11834. if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  11835. (void)__Pyx_modinit_type_import_code();
  11836. (void)__Pyx_modinit_variable_import_code();
  11837. (void)__Pyx_modinit_function_import_code();
  11838. /*--- Execution code ---*/
  11839. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  11840. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11841. #endif
  11842. __Pyx_TraceCall("__Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void)", __pyx_f[0], 1, 0, __PYX_ERR(0, 1, __pyx_L1_error));
  11843. /* "lakesuperior/store/base_lmdb_store.pyx":1
  11844. * import logging # <<<<<<<<<<<<<<
  11845. * import os
  11846. * import threading
  11847. */
  11848. __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  11849. __Pyx_GOTREF(__pyx_t_1);
  11850. if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11851. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11852. /* "lakesuperior/store/base_lmdb_store.pyx":2
  11853. * import logging
  11854. * import os # <<<<<<<<<<<<<<
  11855. * import threading
  11856. * import multiprocessing
  11857. */
  11858. __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)
  11859. __Pyx_GOTREF(__pyx_t_1);
  11860. if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
  11861. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11862. /* "lakesuperior/store/base_lmdb_store.pyx":3
  11863. * import logging
  11864. * import os
  11865. * import threading # <<<<<<<<<<<<<<
  11866. * import multiprocessing
  11867. *
  11868. */
  11869. __pyx_t_1 = __Pyx_Import(__pyx_n_s_threading, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
  11870. __Pyx_GOTREF(__pyx_t_1);
  11871. if (PyDict_SetItem(__pyx_d, __pyx_n_s_threading, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
  11872. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11873. /* "lakesuperior/store/base_lmdb_store.pyx":4
  11874. * import os
  11875. * import threading
  11876. * import multiprocessing # <<<<<<<<<<<<<<
  11877. *
  11878. * from contextlib import contextmanager
  11879. */
  11880. __pyx_t_1 = __Pyx_Import(__pyx_n_s_multiprocessing, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
  11881. __Pyx_GOTREF(__pyx_t_1);
  11882. if (PyDict_SetItem(__pyx_d, __pyx_n_s_multiprocessing, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
  11883. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11884. /* "lakesuperior/store/base_lmdb_store.pyx":6
  11885. * import multiprocessing
  11886. *
  11887. * from contextlib import contextmanager # <<<<<<<<<<<<<<
  11888. * from os import makedirs, path
  11889. * from shutil import rmtree
  11890. */
  11891. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
  11892. __Pyx_GOTREF(__pyx_t_1);
  11893. __Pyx_INCREF(__pyx_n_s_contextmanager);
  11894. __Pyx_GIVEREF(__pyx_n_s_contextmanager);
  11895. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_contextmanager);
  11896. __pyx_t_2 = __Pyx_Import(__pyx_n_s_contextlib, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error)
  11897. __Pyx_GOTREF(__pyx_t_2);
  11898. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11899. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_contextmanager); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
  11900. __Pyx_GOTREF(__pyx_t_1);
  11901. if (PyDict_SetItem(__pyx_d, __pyx_n_s_contextmanager, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  11902. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11903. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11904. /* "lakesuperior/store/base_lmdb_store.pyx":7
  11905. *
  11906. * from contextlib import contextmanager
  11907. * from os import makedirs, path # <<<<<<<<<<<<<<
  11908. * from shutil import rmtree
  11909. *
  11910. */
  11911. __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  11912. __Pyx_GOTREF(__pyx_t_2);
  11913. __Pyx_INCREF(__pyx_n_s_makedirs);
  11914. __Pyx_GIVEREF(__pyx_n_s_makedirs);
  11915. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_makedirs);
  11916. __Pyx_INCREF(__pyx_n_s_path);
  11917. __Pyx_GIVEREF(__pyx_n_s_path);
  11918. PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_path);
  11919. __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
  11920. __Pyx_GOTREF(__pyx_t_1);
  11921. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11922. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_makedirs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  11923. __Pyx_GOTREF(__pyx_t_2);
  11924. if (PyDict_SetItem(__pyx_d, __pyx_n_s_makedirs, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  11925. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11926. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  11927. __Pyx_GOTREF(__pyx_t_2);
  11928. if (PyDict_SetItem(__pyx_d, __pyx_n_s_path, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  11929. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11930. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11931. /* "lakesuperior/store/base_lmdb_store.pyx":8
  11932. * from contextlib import contextmanager
  11933. * from os import makedirs, path
  11934. * from shutil import rmtree # <<<<<<<<<<<<<<
  11935. *
  11936. * from lakesuperior import env, wsgi
  11937. */
  11938. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  11939. __Pyx_GOTREF(__pyx_t_1);
  11940. __Pyx_INCREF(__pyx_n_s_rmtree);
  11941. __Pyx_GIVEREF(__pyx_n_s_rmtree);
  11942. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_rmtree);
  11943. __pyx_t_2 = __Pyx_Import(__pyx_n_s_shutil, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
  11944. __Pyx_GOTREF(__pyx_t_2);
  11945. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11946. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_rmtree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  11947. __Pyx_GOTREF(__pyx_t_1);
  11948. if (PyDict_SetItem(__pyx_d, __pyx_n_s_rmtree, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  11949. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11950. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11951. /* "lakesuperior/store/base_lmdb_store.pyx":10
  11952. * from shutil import rmtree
  11953. *
  11954. * from lakesuperior import env, wsgi # <<<<<<<<<<<<<<
  11955. *
  11956. * from lakesuperior.cy_include cimport cylmdb as lmdb
  11957. */
  11958. __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  11959. __Pyx_GOTREF(__pyx_t_2);
  11960. __Pyx_INCREF(__pyx_n_s_env);
  11961. __Pyx_GIVEREF(__pyx_n_s_env);
  11962. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_env);
  11963. __Pyx_INCREF(__pyx_n_s_wsgi);
  11964. __Pyx_GIVEREF(__pyx_n_s_wsgi);
  11965. PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_wsgi);
  11966. __pyx_t_1 = __Pyx_Import(__pyx_n_s_lakesuperior, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
  11967. __Pyx_GOTREF(__pyx_t_1);
  11968. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11969. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_env); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  11970. __Pyx_GOTREF(__pyx_t_2);
  11971. if (PyDict_SetItem(__pyx_d, __pyx_n_s_env, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  11972. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11973. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_wsgi); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  11974. __Pyx_GOTREF(__pyx_t_2);
  11975. if (PyDict_SetItem(__pyx_d, __pyx_n_s_wsgi, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  11976. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11977. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11978. /* "lakesuperior/store/base_lmdb_store.pyx":19
  11979. *
  11980. *
  11981. * logger = logging.getLogger(__name__) # <<<<<<<<<<<<<<
  11982. *
  11983. *
  11984. */
  11985. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  11986. __Pyx_GOTREF(__pyx_t_1);
  11987. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
  11988. __Pyx_GOTREF(__pyx_t_2);
  11989. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11990. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  11991. __Pyx_GOTREF(__pyx_t_1);
  11992. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error)
  11993. __Pyx_GOTREF(__pyx_t_3);
  11994. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11995. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11996. if (PyDict_SetItem(__pyx_d, __pyx_n_s_logger, __pyx_t_3) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
  11997. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  11998. /* "lakesuperior/store/base_lmdb_store.pyx":38
  11999. *
  12000. *
  12001. * class LmdbError(Exception): # <<<<<<<<<<<<<<
  12002. * pass
  12003. *
  12004. */
  12005. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error)
  12006. __Pyx_GOTREF(__pyx_t_3);
  12007. __Pyx_INCREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  12008. __Pyx_GIVEREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  12009. PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  12010. __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  12011. __Pyx_GOTREF(__pyx_t_1);
  12012. __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_3, __pyx_n_s_LmdbError, __pyx_n_s_LmdbError, (PyObject *) NULL, __pyx_n_s_lakesuperior_store_base_lmdb_sto, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
  12013. __Pyx_GOTREF(__pyx_t_2);
  12014. __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_LmdbError, __pyx_t_3, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 38, __pyx_L1_error)
  12015. __Pyx_GOTREF(__pyx_t_4);
  12016. if (PyDict_SetItem(__pyx_d, __pyx_n_s_LmdbError, __pyx_t_4) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
  12017. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  12018. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12019. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12020. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12021. /* "lakesuperior/store/base_lmdb_store.pyx":41
  12022. * pass
  12023. *
  12024. * class KeyNotFoundError(LmdbError): # <<<<<<<<<<<<<<
  12025. * pass
  12026. *
  12027. */
  12028. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error)
  12029. __Pyx_GOTREF(__pyx_t_3);
  12030. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
  12031. __Pyx_GOTREF(__pyx_t_1);
  12032. __Pyx_GIVEREF(__pyx_t_3);
  12033. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  12034. __pyx_t_3 = 0;
  12035. __pyx_t_3 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error)
  12036. __Pyx_GOTREF(__pyx_t_3);
  12037. __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_3, __pyx_t_1, __pyx_n_s_KeyNotFoundError, __pyx_n_s_KeyNotFoundError, (PyObject *) NULL, __pyx_n_s_lakesuperior_store_base_lmdb_sto, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error)
  12038. __Pyx_GOTREF(__pyx_t_2);
  12039. __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_3, __pyx_n_s_KeyNotFoundError, __pyx_t_1, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 41, __pyx_L1_error)
  12040. __Pyx_GOTREF(__pyx_t_4);
  12041. if (PyDict_SetItem(__pyx_d, __pyx_n_s_KeyNotFoundError, __pyx_t_4) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
  12042. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  12043. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12044. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12045. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12046. /* "lakesuperior/store/base_lmdb_store.pyx":44
  12047. * pass
  12048. *
  12049. * class KeyExistsError(LmdbError): # <<<<<<<<<<<<<<
  12050. * pass
  12051. *
  12052. */
  12053. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
  12054. __Pyx_GOTREF(__pyx_t_1);
  12055. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error)
  12056. __Pyx_GOTREF(__pyx_t_3);
  12057. __Pyx_GIVEREF(__pyx_t_1);
  12058. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  12059. __pyx_t_1 = 0;
  12060. __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
  12061. __Pyx_GOTREF(__pyx_t_1);
  12062. __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_3, __pyx_n_s_KeyExistsError, __pyx_n_s_KeyExistsError, (PyObject *) NULL, __pyx_n_s_lakesuperior_store_base_lmdb_sto, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error)
  12063. __Pyx_GOTREF(__pyx_t_2);
  12064. __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_KeyExistsError, __pyx_t_3, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 44, __pyx_L1_error)
  12065. __Pyx_GOTREF(__pyx_t_4);
  12066. if (PyDict_SetItem(__pyx_d, __pyx_n_s_KeyExistsError, __pyx_t_4) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
  12067. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  12068. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12069. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12070. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12071. /* "lakesuperior/store/base_lmdb_store.pyx":71
  12072. * """
  12073. *
  12074. * dbi_labels = [] # <<<<<<<<<<<<<<
  12075. * dbi_flags = {}
  12076. * """
  12077. */
  12078. __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
  12079. __Pyx_GOTREF(__pyx_t_3);
  12080. if (PyDict_SetItem((PyObject *)__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore->tp_dict, __pyx_n_s_dbi_labels, __pyx_t_3) < 0) __PYX_ERR(0, 71, __pyx_L1_error)
  12081. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12082. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12083. /* "lakesuperior/store/base_lmdb_store.pyx":72
  12084. *
  12085. * dbi_labels = []
  12086. * dbi_flags = {} # <<<<<<<<<<<<<<
  12087. * """
  12088. * Configuration of databases in the environment.
  12089. */
  12090. __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
  12091. __Pyx_GOTREF(__pyx_t_3);
  12092. if (PyDict_SetItem((PyObject *)__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore->tp_dict, __pyx_n_s_dbi_flags, __pyx_t_3) < 0) __PYX_ERR(0, 72, __pyx_L1_error)
  12093. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12094. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12095. /* "lakesuperior/store/base_lmdb_store.pyx":87
  12096. * """
  12097. *
  12098. * env_flags = 0 # <<<<<<<<<<<<<<
  12099. * """
  12100. * LMDB environment flags.
  12101. */
  12102. if (PyDict_SetItem((PyObject *)__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore->tp_dict, __pyx_n_s_env_flags, __pyx_int_0) < 0) __PYX_ERR(0, 87, __pyx_L1_error)
  12103. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12104. /* "lakesuperior/store/base_lmdb_store.pyx":95
  12105. * """
  12106. *
  12107. * env_perms = 0o640 # <<<<<<<<<<<<<<
  12108. * """
  12109. * The UNIX permissions to set on created environment files and semaphores.
  12110. */
  12111. if (PyDict_SetItem((PyObject *)__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore->tp_dict, __pyx_n_s_env_perms, __pyx_int_416) < 0) __PYX_ERR(0, 95, __pyx_L1_error)
  12112. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12113. /* "lakesuperior/store/base_lmdb_store.pyx":103
  12114. * """
  12115. *
  12116. * options = {} # <<<<<<<<<<<<<<
  12117. * """
  12118. * LMDB environment option overrides. Setting this is not required.
  12119. */
  12120. __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 103, __pyx_L1_error)
  12121. __Pyx_GOTREF(__pyx_t_3);
  12122. if (PyDict_SetItem((PyObject *)__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore->tp_dict, __pyx_n_s_options, __pyx_t_3) < 0) __PYX_ERR(0, 103, __pyx_L1_error)
  12123. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12124. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12125. /* "lakesuperior/store/base_lmdb_store.pyx":122
  12126. * """
  12127. *
  12128. * readers_mult = 4 # <<<<<<<<<<<<<<
  12129. * """
  12130. * Number to multiply WSGI workers by to set the numer of LMDB reader slots.
  12131. */
  12132. if (PyDict_SetItem((PyObject *)__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore->tp_dict, __pyx_n_s_readers_mult, __pyx_int_4) < 0) __PYX_ERR(0, 122, __pyx_L1_error)
  12133. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12134. /* "lakesuperior/store/base_lmdb_store.pyx":333
  12135. * ### PYTHON-ACCESSIBLE METHODS ###
  12136. *
  12137. * @contextmanager # <<<<<<<<<<<<<<
  12138. * def txn_ctx(self, write=False):
  12139. * """
  12140. */
  12141. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_contextmanager); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
  12142. __Pyx_GOTREF(__pyx_t_1);
  12143. /* "lakesuperior/store/base_lmdb_store.pyx":334
  12144. *
  12145. * @contextmanager
  12146. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  12147. * """
  12148. * Transaction context manager.
  12149. */
  12150. __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, __pyx_n_s_txn_ctx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
  12151. __Pyx_GOTREF(__pyx_t_2);
  12152. __pyx_t_4 = NULL;
  12153. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  12154. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
  12155. if (likely(__pyx_t_4)) {
  12156. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  12157. __Pyx_INCREF(__pyx_t_4);
  12158. __Pyx_INCREF(function);
  12159. __Pyx_DECREF_SET(__pyx_t_1, function);
  12160. }
  12161. }
  12162. if (!__pyx_t_4) {
  12163. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L1_error)
  12164. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12165. __Pyx_GOTREF(__pyx_t_3);
  12166. } else {
  12167. #if CYTHON_FAST_PYCALL
  12168. if (PyFunction_Check(__pyx_t_1)) {
  12169. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
  12170. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L1_error)
  12171. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  12172. __Pyx_GOTREF(__pyx_t_3);
  12173. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12174. } else
  12175. #endif
  12176. #if CYTHON_FAST_PYCCALL
  12177. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  12178. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
  12179. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L1_error)
  12180. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  12181. __Pyx_GOTREF(__pyx_t_3);
  12182. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12183. } else
  12184. #endif
  12185. {
  12186. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 333, __pyx_L1_error)
  12187. __Pyx_GOTREF(__pyx_t_5);
  12188. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  12189. __Pyx_GIVEREF(__pyx_t_2);
  12190. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
  12191. __pyx_t_2 = 0;
  12192. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L1_error)
  12193. __Pyx_GOTREF(__pyx_t_3);
  12194. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  12195. }
  12196. }
  12197. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12198. if (PyDict_SetItem((PyObject *)__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore->tp_dict, __pyx_n_s_txn_ctx, __pyx_t_3) < 0) __PYX_ERR(0, 334, __pyx_L1_error)
  12199. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12200. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12201. /* "lakesuperior/store/base_lmdb_store.pyx":416
  12202. * cdef inline bint _key_exists(
  12203. * self, unsigned char *key, unsigned char klen,
  12204. * unsigned char *dblabel=b'') except -1: # <<<<<<<<<<<<<<
  12205. * """
  12206. * Return whether a key exists in a database.
  12207. */
  12208. __pyx_k__14 = ((unsigned char *)((char const *)""));
  12209. /* "lakesuperior/store/base_lmdb_store.pyx":449
  12210. * cdef void _put(
  12211. * self, unsigned char *key, size_t key_size, unsigned char *data,
  12212. * size_t data_size, unsigned char *dblabel='', # <<<<<<<<<<<<<<
  12213. * lmdb.MDB_txn *txn=NULL, unsigned int flags=0) except *:
  12214. * """
  12215. */
  12216. __pyx_k__15 = ((unsigned char *)((char const *)""));
  12217. /* "lakesuperior/store/base_lmdb_store.pyx":484
  12218. * cdef void _get_data(
  12219. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  12220. * unsigned char *dblabel='') except *: # <<<<<<<<<<<<<<
  12221. * """
  12222. * Get a single value (non-dup) for a key.
  12223. */
  12224. __pyx_k__16 = ((unsigned char *)((char const *)""));
  12225. /* "lakesuperior/store/base_lmdb_store.pyx":508
  12226. * cdef void _delete(
  12227. * self, unsigned char *key, size_t klen,
  12228. * unsigned char *dblabel=b'') except *: # <<<<<<<<<<<<<<
  12229. * """
  12230. * Delete one single value by key from a non-dup database.
  12231. */
  12232. __pyx_k__17 = ((unsigned char *)((char const *)""));
  12233. /* "lakesuperior/store/base_lmdb_store.pyx":1
  12234. * import logging # <<<<<<<<<<<<<<
  12235. * import os
  12236. * import threading
  12237. */
  12238. __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  12239. __Pyx_GOTREF(__pyx_t_3);
  12240. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  12241. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12242. __Pyx_TraceReturn(Py_None, 0);
  12243. /*--- Wrapped vars code ---*/
  12244. goto __pyx_L0;
  12245. __pyx_L1_error:;
  12246. __Pyx_XDECREF(__pyx_t_1);
  12247. __Pyx_XDECREF(__pyx_t_2);
  12248. __Pyx_XDECREF(__pyx_t_3);
  12249. __Pyx_XDECREF(__pyx_t_4);
  12250. __Pyx_XDECREF(__pyx_t_5);
  12251. if (__pyx_m) {
  12252. if (__pyx_d) {
  12253. __Pyx_AddTraceback("init lakesuperior.store.base_lmdb_store", 0, __pyx_lineno, __pyx_filename);
  12254. }
  12255. Py_DECREF(__pyx_m); __pyx_m = 0;
  12256. } else if (!PyErr_Occurred()) {
  12257. PyErr_SetString(PyExc_ImportError, "init lakesuperior.store.base_lmdb_store");
  12258. }
  12259. __pyx_L0:;
  12260. __Pyx_RefNannyFinishContext();
  12261. #if CYTHON_PEP489_MULTI_PHASE_INIT
  12262. return (__pyx_m != NULL) ? 0 : -1;
  12263. #elif PY_MAJOR_VERSION >= 3
  12264. return __pyx_m;
  12265. #else
  12266. return;
  12267. #endif
  12268. }
  12269. /* --- Runtime support code --- */
  12270. /* Refnanny */
  12271. #if CYTHON_REFNANNY
  12272. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  12273. PyObject *m = NULL, *p = NULL;
  12274. void *r = NULL;
  12275. m = PyImport_ImportModule((char *)modname);
  12276. if (!m) goto end;
  12277. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  12278. if (!p) goto end;
  12279. r = PyLong_AsVoidPtr(p);
  12280. end:
  12281. Py_XDECREF(p);
  12282. Py_XDECREF(m);
  12283. return (__Pyx_RefNannyAPIStruct *)r;
  12284. }
  12285. #endif
  12286. /* PyObjectGetAttrStr */
  12287. #if CYTHON_USE_TYPE_SLOTS
  12288. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  12289. PyTypeObject* tp = Py_TYPE(obj);
  12290. if (likely(tp->tp_getattro))
  12291. return tp->tp_getattro(obj, attr_name);
  12292. #if PY_MAJOR_VERSION < 3
  12293. if (likely(tp->tp_getattr))
  12294. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  12295. #endif
  12296. return PyObject_GetAttr(obj, attr_name);
  12297. }
  12298. #endif
  12299. /* GetBuiltinName */
  12300. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  12301. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  12302. if (unlikely(!result)) {
  12303. PyErr_Format(PyExc_NameError,
  12304. #if PY_MAJOR_VERSION >= 3
  12305. "name '%U' is not defined", name);
  12306. #else
  12307. "name '%.200s' is not defined", PyString_AS_STRING(name));
  12308. #endif
  12309. }
  12310. return result;
  12311. }
  12312. /* PyErrFetchRestore */
  12313. #if CYTHON_FAST_THREAD_STATE
  12314. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  12315. PyObject *tmp_type, *tmp_value, *tmp_tb;
  12316. tmp_type = tstate->curexc_type;
  12317. tmp_value = tstate->curexc_value;
  12318. tmp_tb = tstate->curexc_traceback;
  12319. tstate->curexc_type = type;
  12320. tstate->curexc_value = value;
  12321. tstate->curexc_traceback = tb;
  12322. Py_XDECREF(tmp_type);
  12323. Py_XDECREF(tmp_value);
  12324. Py_XDECREF(tmp_tb);
  12325. }
  12326. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  12327. *type = tstate->curexc_type;
  12328. *value = tstate->curexc_value;
  12329. *tb = tstate->curexc_traceback;
  12330. tstate->curexc_type = 0;
  12331. tstate->curexc_value = 0;
  12332. tstate->curexc_traceback = 0;
  12333. }
  12334. #endif
  12335. /* Profile */
  12336. #if CYTHON_PROFILE
  12337. static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
  12338. PyFrameObject** frame,
  12339. PyThreadState* tstate,
  12340. const char *funcname,
  12341. const char *srcfile,
  12342. int firstlineno) {
  12343. PyObject *type, *value, *traceback;
  12344. int retval;
  12345. if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
  12346. if (*code == NULL) {
  12347. *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
  12348. if (*code == NULL) return 0;
  12349. }
  12350. *frame = PyFrame_New(
  12351. tstate, /*PyThreadState *tstate*/
  12352. *code, /*PyCodeObject *code*/
  12353. __pyx_d, /*PyObject *globals*/
  12354. 0 /*PyObject *locals*/
  12355. );
  12356. if (*frame == NULL) return 0;
  12357. if (CYTHON_TRACE && (*frame)->f_trace == NULL) {
  12358. Py_INCREF(Py_None);
  12359. (*frame)->f_trace = Py_None;
  12360. }
  12361. #if PY_VERSION_HEX < 0x030400B1
  12362. } else {
  12363. (*frame)->f_tstate = tstate;
  12364. #endif
  12365. }
  12366. __Pyx_PyFrame_SetLineNumber(*frame, firstlineno);
  12367. retval = 1;
  12368. tstate->tracing++;
  12369. tstate->use_tracing = 0;
  12370. __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
  12371. #if CYTHON_TRACE
  12372. if (tstate->c_tracefunc)
  12373. retval = tstate->c_tracefunc(tstate->c_traceobj, *frame, PyTrace_CALL, NULL) == 0;
  12374. if (retval && tstate->c_profilefunc)
  12375. #endif
  12376. retval = tstate->c_profilefunc(tstate->c_profileobj, *frame, PyTrace_CALL, NULL) == 0;
  12377. tstate->use_tracing = (tstate->c_profilefunc ||
  12378. (CYTHON_TRACE && tstate->c_tracefunc));
  12379. tstate->tracing--;
  12380. if (retval) {
  12381. __Pyx_ErrRestoreInState(tstate, type, value, traceback);
  12382. return tstate->use_tracing && retval;
  12383. } else {
  12384. Py_XDECREF(type);
  12385. Py_XDECREF(value);
  12386. Py_XDECREF(traceback);
  12387. return -1;
  12388. }
  12389. }
  12390. static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) {
  12391. PyObject *py_srcfile = 0;
  12392. PyObject *py_funcname = 0;
  12393. PyCodeObject *py_code = 0;
  12394. #if PY_MAJOR_VERSION < 3
  12395. py_funcname = PyString_FromString(funcname);
  12396. py_srcfile = PyString_FromString(srcfile);
  12397. #else
  12398. py_funcname = PyUnicode_FromString(funcname);
  12399. py_srcfile = PyUnicode_FromString(srcfile);
  12400. #endif
  12401. if (!py_funcname | !py_srcfile) goto bad;
  12402. py_code = PyCode_New(
  12403. 0,
  12404. #if PY_MAJOR_VERSION >= 3
  12405. 0,
  12406. #endif
  12407. 0,
  12408. 0,
  12409. CO_OPTIMIZED | CO_NEWLOCALS,
  12410. __pyx_empty_bytes, /*PyObject *code,*/
  12411. __pyx_empty_tuple, /*PyObject *consts,*/
  12412. __pyx_empty_tuple, /*PyObject *names,*/
  12413. __pyx_empty_tuple, /*PyObject *varnames,*/
  12414. __pyx_empty_tuple, /*PyObject *freevars,*/
  12415. __pyx_empty_tuple, /*PyObject *cellvars,*/
  12416. py_srcfile, /*PyObject *filename,*/
  12417. py_funcname, /*PyObject *name,*/
  12418. firstlineno,
  12419. __pyx_empty_bytes /*PyObject *lnotab*/
  12420. );
  12421. bad:
  12422. Py_XDECREF(py_srcfile);
  12423. Py_XDECREF(py_funcname);
  12424. return py_code;
  12425. }
  12426. #endif
  12427. /* GetModuleGlobalName */
  12428. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  12429. PyObject *result;
  12430. #if !CYTHON_AVOID_BORROWED_REFS
  12431. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
  12432. result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
  12433. if (likely(result)) {
  12434. Py_INCREF(result);
  12435. } else if (unlikely(PyErr_Occurred())) {
  12436. result = NULL;
  12437. } else {
  12438. #else
  12439. result = PyDict_GetItem(__pyx_d, name);
  12440. if (likely(result)) {
  12441. Py_INCREF(result);
  12442. } else {
  12443. #endif
  12444. #else
  12445. result = PyObject_GetItem(__pyx_d, name);
  12446. if (!result) {
  12447. PyErr_Clear();
  12448. #endif
  12449. result = __Pyx_GetBuiltinName(name);
  12450. }
  12451. return result;
  12452. }
  12453. /* PyCFunctionFastCall */
  12454. #if CYTHON_FAST_PYCCALL
  12455. static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
  12456. PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
  12457. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  12458. PyObject *self = PyCFunction_GET_SELF(func);
  12459. int flags = PyCFunction_GET_FLAGS(func);
  12460. assert(PyCFunction_Check(func));
  12461. assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
  12462. assert(nargs >= 0);
  12463. assert(nargs == 0 || args != NULL);
  12464. /* _PyCFunction_FastCallDict() must not be called with an exception set,
  12465. because it may clear it (directly or indirectly) and so the
  12466. caller loses its exception */
  12467. assert(!PyErr_Occurred());
  12468. if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
  12469. return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
  12470. } else {
  12471. return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
  12472. }
  12473. }
  12474. #endif
  12475. /* PyFunctionFastCall */
  12476. #if CYTHON_FAST_PYCALL
  12477. #include "frameobject.h"
  12478. static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
  12479. PyObject *globals) {
  12480. PyFrameObject *f;
  12481. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  12482. PyObject **fastlocals;
  12483. Py_ssize_t i;
  12484. PyObject *result;
  12485. assert(globals != NULL);
  12486. /* XXX Perhaps we should create a specialized
  12487. PyFrame_New() that doesn't take locals, but does
  12488. take builtins without sanity checking them.
  12489. */
  12490. assert(tstate != NULL);
  12491. f = PyFrame_New(tstate, co, globals, NULL);
  12492. if (f == NULL) {
  12493. return NULL;
  12494. }
  12495. fastlocals = f->f_localsplus;
  12496. for (i = 0; i < na; i++) {
  12497. Py_INCREF(*args);
  12498. fastlocals[i] = *args++;
  12499. }
  12500. result = PyEval_EvalFrameEx(f,0);
  12501. ++tstate->recursion_depth;
  12502. Py_DECREF(f);
  12503. --tstate->recursion_depth;
  12504. return result;
  12505. }
  12506. #if 1 || PY_VERSION_HEX < 0x030600B1
  12507. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
  12508. PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
  12509. PyObject *globals = PyFunction_GET_GLOBALS(func);
  12510. PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
  12511. PyObject *closure;
  12512. #if PY_MAJOR_VERSION >= 3
  12513. PyObject *kwdefs;
  12514. #endif
  12515. PyObject *kwtuple, **k;
  12516. PyObject **d;
  12517. Py_ssize_t nd;
  12518. Py_ssize_t nk;
  12519. PyObject *result;
  12520. assert(kwargs == NULL || PyDict_Check(kwargs));
  12521. nk = kwargs ? PyDict_Size(kwargs) : 0;
  12522. if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
  12523. return NULL;
  12524. }
  12525. if (
  12526. #if PY_MAJOR_VERSION >= 3
  12527. co->co_kwonlyargcount == 0 &&
  12528. #endif
  12529. likely(kwargs == NULL || nk == 0) &&
  12530. co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
  12531. if (argdefs == NULL && co->co_argcount == nargs) {
  12532. result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
  12533. goto done;
  12534. }
  12535. else if (nargs == 0 && argdefs != NULL
  12536. && co->co_argcount == Py_SIZE(argdefs)) {
  12537. /* function called with no arguments, but all parameters have
  12538. a default value: use default values as arguments .*/
  12539. args = &PyTuple_GET_ITEM(argdefs, 0);
  12540. result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
  12541. goto done;
  12542. }
  12543. }
  12544. if (kwargs != NULL) {
  12545. Py_ssize_t pos, i;
  12546. kwtuple = PyTuple_New(2 * nk);
  12547. if (kwtuple == NULL) {
  12548. result = NULL;
  12549. goto done;
  12550. }
  12551. k = &PyTuple_GET_ITEM(kwtuple, 0);
  12552. pos = i = 0;
  12553. while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
  12554. Py_INCREF(k[i]);
  12555. Py_INCREF(k[i+1]);
  12556. i += 2;
  12557. }
  12558. nk = i / 2;
  12559. }
  12560. else {
  12561. kwtuple = NULL;
  12562. k = NULL;
  12563. }
  12564. closure = PyFunction_GET_CLOSURE(func);
  12565. #if PY_MAJOR_VERSION >= 3
  12566. kwdefs = PyFunction_GET_KW_DEFAULTS(func);
  12567. #endif
  12568. if (argdefs != NULL) {
  12569. d = &PyTuple_GET_ITEM(argdefs, 0);
  12570. nd = Py_SIZE(argdefs);
  12571. }
  12572. else {
  12573. d = NULL;
  12574. nd = 0;
  12575. }
  12576. #if PY_MAJOR_VERSION >= 3
  12577. result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
  12578. args, nargs,
  12579. k, (int)nk,
  12580. d, (int)nd, kwdefs, closure);
  12581. #else
  12582. result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
  12583. args, nargs,
  12584. k, (int)nk,
  12585. d, (int)nd, closure);
  12586. #endif
  12587. Py_XDECREF(kwtuple);
  12588. done:
  12589. Py_LeaveRecursiveCall();
  12590. return result;
  12591. }
  12592. #endif
  12593. #endif
  12594. /* PyObjectCall */
  12595. #if CYTHON_COMPILING_IN_CPYTHON
  12596. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  12597. PyObject *result;
  12598. ternaryfunc call = func->ob_type->tp_call;
  12599. if (unlikely(!call))
  12600. return PyObject_Call(func, arg, kw);
  12601. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  12602. return NULL;
  12603. result = (*call)(func, arg, kw);
  12604. Py_LeaveRecursiveCall();
  12605. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  12606. PyErr_SetString(
  12607. PyExc_SystemError,
  12608. "NULL result without error in PyObject_Call");
  12609. }
  12610. return result;
  12611. }
  12612. #endif
  12613. /* PyObjectCallMethO */
  12614. #if CYTHON_COMPILING_IN_CPYTHON
  12615. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  12616. PyObject *self, *result;
  12617. PyCFunction cfunc;
  12618. cfunc = PyCFunction_GET_FUNCTION(func);
  12619. self = PyCFunction_GET_SELF(func);
  12620. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  12621. return NULL;
  12622. result = cfunc(self, arg);
  12623. Py_LeaveRecursiveCall();
  12624. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  12625. PyErr_SetString(
  12626. PyExc_SystemError,
  12627. "NULL result without error in PyObject_Call");
  12628. }
  12629. return result;
  12630. }
  12631. #endif
  12632. /* PyObjectCallOneArg */
  12633. #if CYTHON_COMPILING_IN_CPYTHON
  12634. static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  12635. PyObject *result;
  12636. PyObject *args = PyTuple_New(1);
  12637. if (unlikely(!args)) return NULL;
  12638. Py_INCREF(arg);
  12639. PyTuple_SET_ITEM(args, 0, arg);
  12640. result = __Pyx_PyObject_Call(func, args, NULL);
  12641. Py_DECREF(args);
  12642. return result;
  12643. }
  12644. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  12645. #if CYTHON_FAST_PYCALL
  12646. if (PyFunction_Check(func)) {
  12647. return __Pyx_PyFunction_FastCall(func, &arg, 1);
  12648. }
  12649. #endif
  12650. if (likely(PyCFunction_Check(func))) {
  12651. if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
  12652. return __Pyx_PyObject_CallMethO(func, arg);
  12653. #if CYTHON_FAST_PYCCALL
  12654. } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
  12655. return __Pyx_PyCFunction_FastCall(func, &arg, 1);
  12656. #endif
  12657. }
  12658. }
  12659. return __Pyx__PyObject_CallOneArg(func, arg);
  12660. }
  12661. #else
  12662. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  12663. PyObject *result;
  12664. PyObject *args = PyTuple_Pack(1, arg);
  12665. if (unlikely(!args)) return NULL;
  12666. result = __Pyx_PyObject_Call(func, args, NULL);
  12667. Py_DECREF(args);
  12668. return result;
  12669. }
  12670. #endif
  12671. /* PyObjectCallNoArg */
  12672. #if CYTHON_COMPILING_IN_CPYTHON
  12673. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  12674. #if CYTHON_FAST_PYCALL
  12675. if (PyFunction_Check(func)) {
  12676. return __Pyx_PyFunction_FastCall(func, NULL, 0);
  12677. }
  12678. #endif
  12679. #ifdef __Pyx_CyFunction_USED
  12680. if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
  12681. #else
  12682. if (likely(PyCFunction_Check(func))) {
  12683. #endif
  12684. if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
  12685. return __Pyx_PyObject_CallMethO(func, NULL);
  12686. }
  12687. }
  12688. return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
  12689. }
  12690. #endif
  12691. /* RaiseException */
  12692. #if PY_MAJOR_VERSION < 3
  12693. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  12694. CYTHON_UNUSED PyObject *cause) {
  12695. __Pyx_PyThreadState_declare
  12696. Py_XINCREF(type);
  12697. if (!value || value == Py_None)
  12698. value = NULL;
  12699. else
  12700. Py_INCREF(value);
  12701. if (!tb || tb == Py_None)
  12702. tb = NULL;
  12703. else {
  12704. Py_INCREF(tb);
  12705. if (!PyTraceBack_Check(tb)) {
  12706. PyErr_SetString(PyExc_TypeError,
  12707. "raise: arg 3 must be a traceback or None");
  12708. goto raise_error;
  12709. }
  12710. }
  12711. if (PyType_Check(type)) {
  12712. #if CYTHON_COMPILING_IN_PYPY
  12713. if (!value) {
  12714. Py_INCREF(Py_None);
  12715. value = Py_None;
  12716. }
  12717. #endif
  12718. PyErr_NormalizeException(&type, &value, &tb);
  12719. } else {
  12720. if (value) {
  12721. PyErr_SetString(PyExc_TypeError,
  12722. "instance exception may not have a separate value");
  12723. goto raise_error;
  12724. }
  12725. value = type;
  12726. type = (PyObject*) Py_TYPE(type);
  12727. Py_INCREF(type);
  12728. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  12729. PyErr_SetString(PyExc_TypeError,
  12730. "raise: exception class must be a subclass of BaseException");
  12731. goto raise_error;
  12732. }
  12733. }
  12734. __Pyx_PyThreadState_assign
  12735. __Pyx_ErrRestore(type, value, tb);
  12736. return;
  12737. raise_error:
  12738. Py_XDECREF(value);
  12739. Py_XDECREF(type);
  12740. Py_XDECREF(tb);
  12741. return;
  12742. }
  12743. #else
  12744. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  12745. PyObject* owned_instance = NULL;
  12746. if (tb == Py_None) {
  12747. tb = 0;
  12748. } else if (tb && !PyTraceBack_Check(tb)) {
  12749. PyErr_SetString(PyExc_TypeError,
  12750. "raise: arg 3 must be a traceback or None");
  12751. goto bad;
  12752. }
  12753. if (value == Py_None)
  12754. value = 0;
  12755. if (PyExceptionInstance_Check(type)) {
  12756. if (value) {
  12757. PyErr_SetString(PyExc_TypeError,
  12758. "instance exception may not have a separate value");
  12759. goto bad;
  12760. }
  12761. value = type;
  12762. type = (PyObject*) Py_TYPE(value);
  12763. } else if (PyExceptionClass_Check(type)) {
  12764. PyObject *instance_class = NULL;
  12765. if (value && PyExceptionInstance_Check(value)) {
  12766. instance_class = (PyObject*) Py_TYPE(value);
  12767. if (instance_class != type) {
  12768. int is_subclass = PyObject_IsSubclass(instance_class, type);
  12769. if (!is_subclass) {
  12770. instance_class = NULL;
  12771. } else if (unlikely(is_subclass == -1)) {
  12772. goto bad;
  12773. } else {
  12774. type = instance_class;
  12775. }
  12776. }
  12777. }
  12778. if (!instance_class) {
  12779. PyObject *args;
  12780. if (!value)
  12781. args = PyTuple_New(0);
  12782. else if (PyTuple_Check(value)) {
  12783. Py_INCREF(value);
  12784. args = value;
  12785. } else
  12786. args = PyTuple_Pack(1, value);
  12787. if (!args)
  12788. goto bad;
  12789. owned_instance = PyObject_Call(type, args, NULL);
  12790. Py_DECREF(args);
  12791. if (!owned_instance)
  12792. goto bad;
  12793. value = owned_instance;
  12794. if (!PyExceptionInstance_Check(value)) {
  12795. PyErr_Format(PyExc_TypeError,
  12796. "calling %R should have returned an instance of "
  12797. "BaseException, not %R",
  12798. type, Py_TYPE(value));
  12799. goto bad;
  12800. }
  12801. }
  12802. } else {
  12803. PyErr_SetString(PyExc_TypeError,
  12804. "raise: exception class must be a subclass of BaseException");
  12805. goto bad;
  12806. }
  12807. if (cause) {
  12808. PyObject *fixed_cause;
  12809. if (cause == Py_None) {
  12810. fixed_cause = NULL;
  12811. } else if (PyExceptionClass_Check(cause)) {
  12812. fixed_cause = PyObject_CallObject(cause, NULL);
  12813. if (fixed_cause == NULL)
  12814. goto bad;
  12815. } else if (PyExceptionInstance_Check(cause)) {
  12816. fixed_cause = cause;
  12817. Py_INCREF(fixed_cause);
  12818. } else {
  12819. PyErr_SetString(PyExc_TypeError,
  12820. "exception causes must derive from "
  12821. "BaseException");
  12822. goto bad;
  12823. }
  12824. PyException_SetCause(value, fixed_cause);
  12825. }
  12826. PyErr_SetObject(type, value);
  12827. if (tb) {
  12828. #if CYTHON_COMPILING_IN_PYPY
  12829. PyObject *tmp_type, *tmp_value, *tmp_tb;
  12830. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  12831. Py_INCREF(tb);
  12832. PyErr_Restore(tmp_type, tmp_value, tb);
  12833. Py_XDECREF(tmp_tb);
  12834. #else
  12835. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  12836. PyObject* tmp_tb = tstate->curexc_traceback;
  12837. if (tb != tmp_tb) {
  12838. Py_INCREF(tb);
  12839. tstate->curexc_traceback = tb;
  12840. Py_XDECREF(tmp_tb);
  12841. }
  12842. #endif
  12843. }
  12844. bad:
  12845. Py_XDECREF(owned_instance);
  12846. return;
  12847. }
  12848. #endif
  12849. /* decode_c_string */
  12850. static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
  12851. const char* cstring, Py_ssize_t start, Py_ssize_t stop,
  12852. const char* encoding, const char* errors,
  12853. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
  12854. Py_ssize_t length;
  12855. if (unlikely((start < 0) | (stop < 0))) {
  12856. size_t slen = strlen(cstring);
  12857. if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
  12858. PyErr_SetString(PyExc_OverflowError,
  12859. "c-string too long to convert to Python");
  12860. return NULL;
  12861. }
  12862. length = (Py_ssize_t) slen;
  12863. if (start < 0) {
  12864. start += length;
  12865. if (start < 0)
  12866. start = 0;
  12867. }
  12868. if (stop < 0)
  12869. stop += length;
  12870. }
  12871. length = stop - start;
  12872. if (unlikely(length <= 0))
  12873. return PyUnicode_FromUnicode(NULL, 0);
  12874. cstring += start;
  12875. if (decode_func) {
  12876. return decode_func(cstring, length, errors);
  12877. } else {
  12878. return PyUnicode_Decode(cstring, length, encoding, errors);
  12879. }
  12880. }
  12881. /* RaiseDoubleKeywords */
  12882. static void __Pyx_RaiseDoubleKeywordsError(
  12883. const char* func_name,
  12884. PyObject* kw_name)
  12885. {
  12886. PyErr_Format(PyExc_TypeError,
  12887. #if PY_MAJOR_VERSION >= 3
  12888. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  12889. #else
  12890. "%s() got multiple values for keyword argument '%s'", func_name,
  12891. PyString_AsString(kw_name));
  12892. #endif
  12893. }
  12894. /* ParseKeywords */
  12895. static int __Pyx_ParseOptionalKeywords(
  12896. PyObject *kwds,
  12897. PyObject **argnames[],
  12898. PyObject *kwds2,
  12899. PyObject *values[],
  12900. Py_ssize_t num_pos_args,
  12901. const char* function_name)
  12902. {
  12903. PyObject *key = 0, *value = 0;
  12904. Py_ssize_t pos = 0;
  12905. PyObject*** name;
  12906. PyObject*** first_kw_arg = argnames + num_pos_args;
  12907. while (PyDict_Next(kwds, &pos, &key, &value)) {
  12908. name = first_kw_arg;
  12909. while (*name && (**name != key)) name++;
  12910. if (*name) {
  12911. values[name-argnames] = value;
  12912. continue;
  12913. }
  12914. name = first_kw_arg;
  12915. #if PY_MAJOR_VERSION < 3
  12916. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  12917. while (*name) {
  12918. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  12919. && _PyString_Eq(**name, key)) {
  12920. values[name-argnames] = value;
  12921. break;
  12922. }
  12923. name++;
  12924. }
  12925. if (*name) continue;
  12926. else {
  12927. PyObject*** argname = argnames;
  12928. while (argname != first_kw_arg) {
  12929. if ((**argname == key) || (
  12930. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  12931. && _PyString_Eq(**argname, key))) {
  12932. goto arg_passed_twice;
  12933. }
  12934. argname++;
  12935. }
  12936. }
  12937. } else
  12938. #endif
  12939. if (likely(PyUnicode_Check(key))) {
  12940. while (*name) {
  12941. int cmp = (**name == key) ? 0 :
  12942. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  12943. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  12944. #endif
  12945. PyUnicode_Compare(**name, key);
  12946. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  12947. if (cmp == 0) {
  12948. values[name-argnames] = value;
  12949. break;
  12950. }
  12951. name++;
  12952. }
  12953. if (*name) continue;
  12954. else {
  12955. PyObject*** argname = argnames;
  12956. while (argname != first_kw_arg) {
  12957. int cmp = (**argname == key) ? 0 :
  12958. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  12959. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  12960. #endif
  12961. PyUnicode_Compare(**argname, key);
  12962. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  12963. if (cmp == 0) goto arg_passed_twice;
  12964. argname++;
  12965. }
  12966. }
  12967. } else
  12968. goto invalid_keyword_type;
  12969. if (kwds2) {
  12970. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  12971. } else {
  12972. goto invalid_keyword;
  12973. }
  12974. }
  12975. return 0;
  12976. arg_passed_twice:
  12977. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  12978. goto bad;
  12979. invalid_keyword_type:
  12980. PyErr_Format(PyExc_TypeError,
  12981. "%.200s() keywords must be strings", function_name);
  12982. goto bad;
  12983. invalid_keyword:
  12984. PyErr_Format(PyExc_TypeError,
  12985. #if PY_MAJOR_VERSION < 3
  12986. "%.200s() got an unexpected keyword argument '%.200s'",
  12987. function_name, PyString_AsString(key));
  12988. #else
  12989. "%s() got an unexpected keyword argument '%U'",
  12990. function_name, key);
  12991. #endif
  12992. bad:
  12993. return -1;
  12994. }
  12995. /* RaiseArgTupleInvalid */
  12996. static void __Pyx_RaiseArgtupleInvalid(
  12997. const char* func_name,
  12998. int exact,
  12999. Py_ssize_t num_min,
  13000. Py_ssize_t num_max,
  13001. Py_ssize_t num_found)
  13002. {
  13003. Py_ssize_t num_expected;
  13004. const char *more_or_less;
  13005. if (num_found < num_min) {
  13006. num_expected = num_min;
  13007. more_or_less = "at least";
  13008. } else {
  13009. num_expected = num_max;
  13010. more_or_less = "at most";
  13011. }
  13012. if (exact) {
  13013. more_or_less = "exactly";
  13014. }
  13015. PyErr_Format(PyExc_TypeError,
  13016. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  13017. func_name, more_or_less, num_expected,
  13018. (num_expected == 1) ? "" : "s", num_found);
  13019. }
  13020. /* WriteUnraisableException */
  13021. static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
  13022. CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
  13023. int full_traceback, CYTHON_UNUSED int nogil) {
  13024. PyObject *old_exc, *old_val, *old_tb;
  13025. PyObject *ctx;
  13026. __Pyx_PyThreadState_declare
  13027. #ifdef WITH_THREAD
  13028. PyGILState_STATE state;
  13029. if (nogil)
  13030. state = PyGILState_Ensure();
  13031. #ifdef _MSC_VER
  13032. else state = (PyGILState_STATE)-1;
  13033. #endif
  13034. #endif
  13035. __Pyx_PyThreadState_assign
  13036. __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
  13037. if (full_traceback) {
  13038. Py_XINCREF(old_exc);
  13039. Py_XINCREF(old_val);
  13040. Py_XINCREF(old_tb);
  13041. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  13042. PyErr_PrintEx(1);
  13043. }
  13044. #if PY_MAJOR_VERSION < 3
  13045. ctx = PyString_FromString(name);
  13046. #else
  13047. ctx = PyUnicode_FromString(name);
  13048. #endif
  13049. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  13050. if (!ctx) {
  13051. PyErr_WriteUnraisable(Py_None);
  13052. } else {
  13053. PyErr_WriteUnraisable(ctx);
  13054. Py_DECREF(ctx);
  13055. }
  13056. #ifdef WITH_THREAD
  13057. if (nogil)
  13058. PyGILState_Release(state);
  13059. #endif
  13060. }
  13061. /* SaveResetException */
  13062. #if CYTHON_FAST_THREAD_STATE
  13063. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13064. #if PY_VERSION_HEX >= 0x030700A3
  13065. *type = tstate->exc_state.exc_type;
  13066. *value = tstate->exc_state.exc_value;
  13067. *tb = tstate->exc_state.exc_traceback;
  13068. #else
  13069. *type = tstate->exc_type;
  13070. *value = tstate->exc_value;
  13071. *tb = tstate->exc_traceback;
  13072. #endif
  13073. Py_XINCREF(*type);
  13074. Py_XINCREF(*value);
  13075. Py_XINCREF(*tb);
  13076. }
  13077. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  13078. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13079. #if PY_VERSION_HEX >= 0x030700A3
  13080. tmp_type = tstate->exc_state.exc_type;
  13081. tmp_value = tstate->exc_state.exc_value;
  13082. tmp_tb = tstate->exc_state.exc_traceback;
  13083. tstate->exc_state.exc_type = type;
  13084. tstate->exc_state.exc_value = value;
  13085. tstate->exc_state.exc_traceback = tb;
  13086. #else
  13087. tmp_type = tstate->exc_type;
  13088. tmp_value = tstate->exc_value;
  13089. tmp_tb = tstate->exc_traceback;
  13090. tstate->exc_type = type;
  13091. tstate->exc_value = value;
  13092. tstate->exc_traceback = tb;
  13093. #endif
  13094. Py_XDECREF(tmp_type);
  13095. Py_XDECREF(tmp_value);
  13096. Py_XDECREF(tmp_tb);
  13097. }
  13098. #endif
  13099. /* PyErrExceptionMatches */
  13100. #if CYTHON_FAST_THREAD_STATE
  13101. static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  13102. Py_ssize_t i, n;
  13103. n = PyTuple_GET_SIZE(tuple);
  13104. #if PY_MAJOR_VERSION >= 3
  13105. for (i=0; i<n; i++) {
  13106. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  13107. }
  13108. #endif
  13109. for (i=0; i<n; i++) {
  13110. if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
  13111. }
  13112. return 0;
  13113. }
  13114. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  13115. PyObject *exc_type = tstate->curexc_type;
  13116. if (exc_type == err) return 1;
  13117. if (unlikely(!exc_type)) return 0;
  13118. if (unlikely(PyTuple_Check(err)))
  13119. return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
  13120. return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
  13121. }
  13122. #endif
  13123. /* GetException */
  13124. #if CYTHON_FAST_THREAD_STATE
  13125. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13126. #else
  13127. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
  13128. #endif
  13129. PyObject *local_type, *local_value, *local_tb;
  13130. #if CYTHON_FAST_THREAD_STATE
  13131. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13132. local_type = tstate->curexc_type;
  13133. local_value = tstate->curexc_value;
  13134. local_tb = tstate->curexc_traceback;
  13135. tstate->curexc_type = 0;
  13136. tstate->curexc_value = 0;
  13137. tstate->curexc_traceback = 0;
  13138. #else
  13139. PyErr_Fetch(&local_type, &local_value, &local_tb);
  13140. #endif
  13141. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  13142. #if CYTHON_FAST_THREAD_STATE
  13143. if (unlikely(tstate->curexc_type))
  13144. #else
  13145. if (unlikely(PyErr_Occurred()))
  13146. #endif
  13147. goto bad;
  13148. #if PY_MAJOR_VERSION >= 3
  13149. if (local_tb) {
  13150. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  13151. goto bad;
  13152. }
  13153. #endif
  13154. Py_XINCREF(local_tb);
  13155. Py_XINCREF(local_type);
  13156. Py_XINCREF(local_value);
  13157. *type = local_type;
  13158. *value = local_value;
  13159. *tb = local_tb;
  13160. #if CYTHON_FAST_THREAD_STATE
  13161. #if PY_VERSION_HEX >= 0x030700A3
  13162. tmp_type = tstate->exc_state.exc_type;
  13163. tmp_value = tstate->exc_state.exc_value;
  13164. tmp_tb = tstate->exc_state.exc_traceback;
  13165. tstate->exc_state.exc_type = local_type;
  13166. tstate->exc_state.exc_value = local_value;
  13167. tstate->exc_state.exc_traceback = local_tb;
  13168. #else
  13169. tmp_type = tstate->exc_type;
  13170. tmp_value = tstate->exc_value;
  13171. tmp_tb = tstate->exc_traceback;
  13172. tstate->exc_type = local_type;
  13173. tstate->exc_value = local_value;
  13174. tstate->exc_traceback = local_tb;
  13175. #endif
  13176. Py_XDECREF(tmp_type);
  13177. Py_XDECREF(tmp_value);
  13178. Py_XDECREF(tmp_tb);
  13179. #else
  13180. PyErr_SetExcInfo(local_type, local_value, local_tb);
  13181. #endif
  13182. return 0;
  13183. bad:
  13184. *type = 0;
  13185. *value = 0;
  13186. *tb = 0;
  13187. Py_XDECREF(local_type);
  13188. Py_XDECREF(local_value);
  13189. Py_XDECREF(local_tb);
  13190. return -1;
  13191. }
  13192. /* SwapException */
  13193. #if CYTHON_FAST_THREAD_STATE
  13194. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13195. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13196. #if PY_VERSION_HEX >= 0x030700A3
  13197. tmp_type = tstate->exc_state.exc_type;
  13198. tmp_value = tstate->exc_state.exc_value;
  13199. tmp_tb = tstate->exc_state.exc_traceback;
  13200. tstate->exc_state.exc_type = *type;
  13201. tstate->exc_state.exc_value = *value;
  13202. tstate->exc_state.exc_traceback = *tb;
  13203. #else
  13204. tmp_type = tstate->exc_type;
  13205. tmp_value = tstate->exc_value;
  13206. tmp_tb = tstate->exc_traceback;
  13207. tstate->exc_type = *type;
  13208. tstate->exc_value = *value;
  13209. tstate->exc_traceback = *tb;
  13210. #endif
  13211. *type = tmp_type;
  13212. *value = tmp_value;
  13213. *tb = tmp_tb;
  13214. }
  13215. #else
  13216. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  13217. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13218. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  13219. PyErr_SetExcInfo(*type, *value, *tb);
  13220. *type = tmp_type;
  13221. *value = tmp_value;
  13222. *tb = tmp_tb;
  13223. }
  13224. #endif
  13225. /* PyUnicode_Unicode */
  13226. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj) {
  13227. if (unlikely(obj == Py_None))
  13228. obj = __pyx_kp_u_None;
  13229. return __Pyx_NewRef(obj);
  13230. }
  13231. /* JoinPyUnicode */
  13232. static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
  13233. CYTHON_UNUSED Py_UCS4 max_char) {
  13234. #if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  13235. PyObject *result_uval;
  13236. int result_ukind;
  13237. Py_ssize_t i, char_pos;
  13238. void *result_udata;
  13239. #if CYTHON_PEP393_ENABLED
  13240. result_uval = PyUnicode_New(result_ulength, max_char);
  13241. if (unlikely(!result_uval)) return NULL;
  13242. result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
  13243. result_udata = PyUnicode_DATA(result_uval);
  13244. #else
  13245. result_uval = PyUnicode_FromUnicode(NULL, result_ulength);
  13246. if (unlikely(!result_uval)) return NULL;
  13247. result_ukind = sizeof(Py_UNICODE);
  13248. result_udata = PyUnicode_AS_UNICODE(result_uval);
  13249. #endif
  13250. char_pos = 0;
  13251. for (i=0; i < value_count; i++) {
  13252. int ukind;
  13253. Py_ssize_t ulength;
  13254. void *udata;
  13255. PyObject *uval = PyTuple_GET_ITEM(value_tuple, i);
  13256. if (unlikely(__Pyx_PyUnicode_READY(uval)))
  13257. goto bad;
  13258. ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
  13259. if (unlikely(!ulength))
  13260. continue;
  13261. if (unlikely(char_pos + ulength < 0))
  13262. goto overflow;
  13263. ukind = __Pyx_PyUnicode_KIND(uval);
  13264. udata = __Pyx_PyUnicode_DATA(uval);
  13265. if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
  13266. memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
  13267. } else {
  13268. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
  13269. _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
  13270. #else
  13271. Py_ssize_t j;
  13272. for (j=0; j < ulength; j++) {
  13273. Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
  13274. __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
  13275. }
  13276. #endif
  13277. }
  13278. char_pos += ulength;
  13279. }
  13280. return result_uval;
  13281. overflow:
  13282. PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
  13283. bad:
  13284. Py_DECREF(result_uval);
  13285. return NULL;
  13286. #else
  13287. result_ulength++;
  13288. value_count++;
  13289. return PyUnicode_Join(__pyx_empty_unicode, value_tuple);
  13290. #endif
  13291. }
  13292. /* FastTypeChecks */
  13293. #if CYTHON_COMPILING_IN_CPYTHON
  13294. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  13295. while (a) {
  13296. a = a->tp_base;
  13297. if (a == b)
  13298. return 1;
  13299. }
  13300. return b == &PyBaseObject_Type;
  13301. }
  13302. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  13303. PyObject *mro;
  13304. if (a == b) return 1;
  13305. mro = a->tp_mro;
  13306. if (likely(mro)) {
  13307. Py_ssize_t i, n;
  13308. n = PyTuple_GET_SIZE(mro);
  13309. for (i = 0; i < n; i++) {
  13310. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  13311. return 1;
  13312. }
  13313. return 0;
  13314. }
  13315. return __Pyx_InBases(a, b);
  13316. }
  13317. #if PY_MAJOR_VERSION == 2
  13318. static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
  13319. PyObject *exception, *value, *tb;
  13320. int res;
  13321. __Pyx_PyThreadState_declare
  13322. __Pyx_PyThreadState_assign
  13323. __Pyx_ErrFetch(&exception, &value, &tb);
  13324. res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
  13325. if (unlikely(res == -1)) {
  13326. PyErr_WriteUnraisable(err);
  13327. res = 0;
  13328. }
  13329. if (!res) {
  13330. res = PyObject_IsSubclass(err, exc_type2);
  13331. if (unlikely(res == -1)) {
  13332. PyErr_WriteUnraisable(err);
  13333. res = 0;
  13334. }
  13335. }
  13336. __Pyx_ErrRestore(exception, value, tb);
  13337. return res;
  13338. }
  13339. #else
  13340. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  13341. int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
  13342. if (!res) {
  13343. res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  13344. }
  13345. return res;
  13346. }
  13347. #endif
  13348. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  13349. Py_ssize_t i, n;
  13350. assert(PyExceptionClass_Check(exc_type));
  13351. n = PyTuple_GET_SIZE(tuple);
  13352. #if PY_MAJOR_VERSION >= 3
  13353. for (i=0; i<n; i++) {
  13354. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  13355. }
  13356. #endif
  13357. for (i=0; i<n; i++) {
  13358. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  13359. #if PY_MAJOR_VERSION < 3
  13360. if (likely(exc_type == t)) return 1;
  13361. #endif
  13362. if (likely(PyExceptionClass_Check(t))) {
  13363. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  13364. } else {
  13365. }
  13366. }
  13367. return 0;
  13368. }
  13369. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  13370. if (likely(err == exc_type)) return 1;
  13371. if (likely(PyExceptionClass_Check(err))) {
  13372. if (likely(PyExceptionClass_Check(exc_type))) {
  13373. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  13374. } else if (likely(PyTuple_Check(exc_type))) {
  13375. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  13376. } else {
  13377. }
  13378. }
  13379. return PyErr_GivenExceptionMatches(err, exc_type);
  13380. }
  13381. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  13382. assert(PyExceptionClass_Check(exc_type1));
  13383. assert(PyExceptionClass_Check(exc_type2));
  13384. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  13385. if (likely(PyExceptionClass_Check(err))) {
  13386. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  13387. }
  13388. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  13389. }
  13390. #endif
  13391. /* PyObjectSetAttrStr */
  13392. #if CYTHON_USE_TYPE_SLOTS
  13393. static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
  13394. PyTypeObject* tp = Py_TYPE(obj);
  13395. if (likely(tp->tp_setattro))
  13396. return tp->tp_setattro(obj, attr_name, value);
  13397. #if PY_MAJOR_VERSION < 3
  13398. if (likely(tp->tp_setattr))
  13399. return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
  13400. #endif
  13401. return PyObject_SetAttr(obj, attr_name, value);
  13402. }
  13403. #endif
  13404. /* PyIntBinop */
  13405. #if !CYTHON_COMPILING_IN_PYPY
  13406. static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
  13407. #if PY_MAJOR_VERSION < 3
  13408. if (likely(PyInt_CheckExact(op1))) {
  13409. const long b = intval;
  13410. long x;
  13411. long a = PyInt_AS_LONG(op1);
  13412. x = (long)((unsigned long)a + b);
  13413. if (likely((x^a) >= 0 || (x^b) >= 0))
  13414. return PyInt_FromLong(x);
  13415. return PyLong_Type.tp_as_number->nb_add(op1, op2);
  13416. }
  13417. #endif
  13418. #if CYTHON_USE_PYLONG_INTERNALS
  13419. if (likely(PyLong_CheckExact(op1))) {
  13420. const long b = intval;
  13421. long a, x;
  13422. #ifdef HAVE_LONG_LONG
  13423. const PY_LONG_LONG llb = intval;
  13424. PY_LONG_LONG lla, llx;
  13425. #endif
  13426. const digit* digits = ((PyLongObject*)op1)->ob_digit;
  13427. const Py_ssize_t size = Py_SIZE(op1);
  13428. if (likely(__Pyx_sst_abs(size) <= 1)) {
  13429. a = likely(size) ? digits[0] : 0;
  13430. if (size == -1) a = -a;
  13431. } else {
  13432. switch (size) {
  13433. case -2:
  13434. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  13435. a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13436. break;
  13437. #ifdef HAVE_LONG_LONG
  13438. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  13439. lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  13440. goto long_long;
  13441. #endif
  13442. }
  13443. CYTHON_FALLTHROUGH;
  13444. case 2:
  13445. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  13446. a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13447. break;
  13448. #ifdef HAVE_LONG_LONG
  13449. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  13450. lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  13451. goto long_long;
  13452. #endif
  13453. }
  13454. CYTHON_FALLTHROUGH;
  13455. case -3:
  13456. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  13457. a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13458. break;
  13459. #ifdef HAVE_LONG_LONG
  13460. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  13461. lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  13462. goto long_long;
  13463. #endif
  13464. }
  13465. CYTHON_FALLTHROUGH;
  13466. case 3:
  13467. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  13468. a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13469. break;
  13470. #ifdef HAVE_LONG_LONG
  13471. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  13472. lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  13473. goto long_long;
  13474. #endif
  13475. }
  13476. CYTHON_FALLTHROUGH;
  13477. case -4:
  13478. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  13479. a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13480. break;
  13481. #ifdef HAVE_LONG_LONG
  13482. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  13483. lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  13484. goto long_long;
  13485. #endif
  13486. }
  13487. CYTHON_FALLTHROUGH;
  13488. case 4:
  13489. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  13490. a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13491. break;
  13492. #ifdef HAVE_LONG_LONG
  13493. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  13494. lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  13495. goto long_long;
  13496. #endif
  13497. }
  13498. CYTHON_FALLTHROUGH;
  13499. default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
  13500. }
  13501. }
  13502. x = a + b;
  13503. return PyLong_FromLong(x);
  13504. #ifdef HAVE_LONG_LONG
  13505. long_long:
  13506. llx = lla + llb;
  13507. return PyLong_FromLongLong(llx);
  13508. #endif
  13509. }
  13510. #endif
  13511. if (PyFloat_CheckExact(op1)) {
  13512. const long b = intval;
  13513. double a = PyFloat_AS_DOUBLE(op1);
  13514. double result;
  13515. PyFPE_START_PROTECT("add", return NULL)
  13516. result = ((double)a) + (double)b;
  13517. PyFPE_END_PROTECT(result)
  13518. return PyFloat_FromDouble(result);
  13519. }
  13520. return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
  13521. }
  13522. #endif
  13523. /* DictGetItem */
  13524. #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
  13525. static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
  13526. PyObject *value;
  13527. value = PyDict_GetItemWithError(d, key);
  13528. if (unlikely(!value)) {
  13529. if (!PyErr_Occurred()) {
  13530. PyObject* args = PyTuple_Pack(1, key);
  13531. if (likely(args))
  13532. PyErr_SetObject(PyExc_KeyError, args);
  13533. Py_XDECREF(args);
  13534. }
  13535. return NULL;
  13536. }
  13537. Py_INCREF(value);
  13538. return value;
  13539. }
  13540. #endif
  13541. /* PyObject_GenericGetAttrNoDict */
  13542. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  13543. static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
  13544. PyErr_Format(PyExc_AttributeError,
  13545. #if PY_MAJOR_VERSION >= 3
  13546. "'%.50s' object has no attribute '%U'",
  13547. tp->tp_name, attr_name);
  13548. #else
  13549. "'%.50s' object has no attribute '%.400s'",
  13550. tp->tp_name, PyString_AS_STRING(attr_name));
  13551. #endif
  13552. return NULL;
  13553. }
  13554. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
  13555. PyObject *descr;
  13556. PyTypeObject *tp = Py_TYPE(obj);
  13557. if (unlikely(!PyString_Check(attr_name))) {
  13558. return PyObject_GenericGetAttr(obj, attr_name);
  13559. }
  13560. assert(!tp->tp_dictoffset);
  13561. descr = _PyType_Lookup(tp, attr_name);
  13562. if (unlikely(!descr)) {
  13563. return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
  13564. }
  13565. Py_INCREF(descr);
  13566. #if PY_MAJOR_VERSION < 3
  13567. if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
  13568. #endif
  13569. {
  13570. descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
  13571. if (unlikely(f)) {
  13572. PyObject *res = f(descr, obj, (PyObject *)tp);
  13573. Py_DECREF(descr);
  13574. return res;
  13575. }
  13576. }
  13577. return descr;
  13578. }
  13579. #endif
  13580. /* PyObject_GenericGetAttr */
  13581. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  13582. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
  13583. if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
  13584. return PyObject_GenericGetAttr(obj, attr_name);
  13585. }
  13586. return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
  13587. }
  13588. #endif
  13589. /* SetVTable */
  13590. static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
  13591. #if PY_VERSION_HEX >= 0x02070000
  13592. PyObject *ob = PyCapsule_New(vtable, 0, 0);
  13593. #else
  13594. PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
  13595. #endif
  13596. if (!ob)
  13597. goto bad;
  13598. if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
  13599. goto bad;
  13600. Py_DECREF(ob);
  13601. return 0;
  13602. bad:
  13603. Py_XDECREF(ob);
  13604. return -1;
  13605. }
  13606. /* SetupReduce */
  13607. static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  13608. int ret;
  13609. PyObject *name_attr;
  13610. name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  13611. if (likely(name_attr)) {
  13612. ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  13613. } else {
  13614. ret = -1;
  13615. }
  13616. if (unlikely(ret < 0)) {
  13617. PyErr_Clear();
  13618. ret = 0;
  13619. }
  13620. Py_XDECREF(name_attr);
  13621. return ret;
  13622. }
  13623. static int __Pyx_setup_reduce(PyObject* type_obj) {
  13624. int ret = 0;
  13625. PyObject *object_reduce = NULL;
  13626. PyObject *object_reduce_ex = NULL;
  13627. PyObject *reduce = NULL;
  13628. PyObject *reduce_ex = NULL;
  13629. PyObject *reduce_cython = NULL;
  13630. PyObject *setstate = NULL;
  13631. PyObject *setstate_cython = NULL;
  13632. #if CYTHON_USE_PYTYPE_LOOKUP
  13633. if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
  13634. #else
  13635. if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
  13636. #endif
  13637. #if CYTHON_USE_PYTYPE_LOOKUP
  13638. object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  13639. #else
  13640. object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  13641. #endif
  13642. reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
  13643. if (reduce_ex == object_reduce_ex) {
  13644. #if CYTHON_USE_PYTYPE_LOOKUP
  13645. object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  13646. #else
  13647. object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  13648. #endif
  13649. reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
  13650. if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
  13651. reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
  13652. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
  13653. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
  13654. setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
  13655. if (!setstate) PyErr_Clear();
  13656. if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
  13657. setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
  13658. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
  13659. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
  13660. }
  13661. PyType_Modified((PyTypeObject*)type_obj);
  13662. }
  13663. }
  13664. goto GOOD;
  13665. BAD:
  13666. if (!PyErr_Occurred())
  13667. PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
  13668. ret = -1;
  13669. GOOD:
  13670. #if !CYTHON_USE_PYTYPE_LOOKUP
  13671. Py_XDECREF(object_reduce);
  13672. Py_XDECREF(object_reduce_ex);
  13673. #endif
  13674. Py_XDECREF(reduce);
  13675. Py_XDECREF(reduce_ex);
  13676. Py_XDECREF(reduce_cython);
  13677. Py_XDECREF(setstate);
  13678. Py_XDECREF(setstate_cython);
  13679. return ret;
  13680. }
  13681. /* Import */
  13682. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  13683. PyObject *empty_list = 0;
  13684. PyObject *module = 0;
  13685. PyObject *global_dict = 0;
  13686. PyObject *empty_dict = 0;
  13687. PyObject *list;
  13688. #if PY_MAJOR_VERSION < 3
  13689. PyObject *py_import;
  13690. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  13691. if (!py_import)
  13692. goto bad;
  13693. #endif
  13694. if (from_list)
  13695. list = from_list;
  13696. else {
  13697. empty_list = PyList_New(0);
  13698. if (!empty_list)
  13699. goto bad;
  13700. list = empty_list;
  13701. }
  13702. global_dict = PyModule_GetDict(__pyx_m);
  13703. if (!global_dict)
  13704. goto bad;
  13705. empty_dict = PyDict_New();
  13706. if (!empty_dict)
  13707. goto bad;
  13708. {
  13709. #if PY_MAJOR_VERSION >= 3
  13710. if (level == -1) {
  13711. if (strchr(__Pyx_MODULE_NAME, '.')) {
  13712. module = PyImport_ImportModuleLevelObject(
  13713. name, global_dict, empty_dict, list, 1);
  13714. if (!module) {
  13715. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  13716. goto bad;
  13717. PyErr_Clear();
  13718. }
  13719. }
  13720. level = 0;
  13721. }
  13722. #endif
  13723. if (!module) {
  13724. #if PY_MAJOR_VERSION < 3
  13725. PyObject *py_level = PyInt_FromLong(level);
  13726. if (!py_level)
  13727. goto bad;
  13728. module = PyObject_CallFunctionObjArgs(py_import,
  13729. name, global_dict, empty_dict, list, py_level, NULL);
  13730. Py_DECREF(py_level);
  13731. #else
  13732. module = PyImport_ImportModuleLevelObject(
  13733. name, global_dict, empty_dict, list, level);
  13734. #endif
  13735. }
  13736. }
  13737. bad:
  13738. #if PY_MAJOR_VERSION < 3
  13739. Py_XDECREF(py_import);
  13740. #endif
  13741. Py_XDECREF(empty_list);
  13742. Py_XDECREF(empty_dict);
  13743. return module;
  13744. }
  13745. /* ImportFrom */
  13746. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  13747. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  13748. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  13749. PyErr_Format(PyExc_ImportError,
  13750. #if PY_MAJOR_VERSION < 3
  13751. "cannot import name %.230s", PyString_AS_STRING(name));
  13752. #else
  13753. "cannot import name %S", name);
  13754. #endif
  13755. }
  13756. return value;
  13757. }
  13758. /* CalculateMetaclass */
  13759. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
  13760. Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
  13761. for (i=0; i < nbases; i++) {
  13762. PyTypeObject *tmptype;
  13763. PyObject *tmp = PyTuple_GET_ITEM(bases, i);
  13764. tmptype = Py_TYPE(tmp);
  13765. #if PY_MAJOR_VERSION < 3
  13766. if (tmptype == &PyClass_Type)
  13767. continue;
  13768. #endif
  13769. if (!metaclass) {
  13770. metaclass = tmptype;
  13771. continue;
  13772. }
  13773. if (PyType_IsSubtype(metaclass, tmptype))
  13774. continue;
  13775. if (PyType_IsSubtype(tmptype, metaclass)) {
  13776. metaclass = tmptype;
  13777. continue;
  13778. }
  13779. PyErr_SetString(PyExc_TypeError,
  13780. "metaclass conflict: "
  13781. "the metaclass of a derived class "
  13782. "must be a (non-strict) subclass "
  13783. "of the metaclasses of all its bases");
  13784. return NULL;
  13785. }
  13786. if (!metaclass) {
  13787. #if PY_MAJOR_VERSION < 3
  13788. metaclass = &PyClass_Type;
  13789. #else
  13790. metaclass = &PyType_Type;
  13791. #endif
  13792. }
  13793. Py_INCREF((PyObject*) metaclass);
  13794. return (PyObject*) metaclass;
  13795. }
  13796. /* Py3ClassCreate */
  13797. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
  13798. PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
  13799. PyObject *ns;
  13800. if (metaclass) {
  13801. PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
  13802. if (prep) {
  13803. PyObject *pargs = PyTuple_Pack(2, name, bases);
  13804. if (unlikely(!pargs)) {
  13805. Py_DECREF(prep);
  13806. return NULL;
  13807. }
  13808. ns = PyObject_Call(prep, pargs, mkw);
  13809. Py_DECREF(prep);
  13810. Py_DECREF(pargs);
  13811. } else {
  13812. if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
  13813. return NULL;
  13814. PyErr_Clear();
  13815. ns = PyDict_New();
  13816. }
  13817. } else {
  13818. ns = PyDict_New();
  13819. }
  13820. if (unlikely(!ns))
  13821. return NULL;
  13822. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
  13823. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
  13824. if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
  13825. return ns;
  13826. bad:
  13827. Py_DECREF(ns);
  13828. return NULL;
  13829. }
  13830. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
  13831. PyObject *dict, PyObject *mkw,
  13832. int calculate_metaclass, int allow_py2_metaclass) {
  13833. PyObject *result, *margs;
  13834. PyObject *owned_metaclass = NULL;
  13835. if (allow_py2_metaclass) {
  13836. owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
  13837. if (owned_metaclass) {
  13838. metaclass = owned_metaclass;
  13839. } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
  13840. PyErr_Clear();
  13841. } else {
  13842. return NULL;
  13843. }
  13844. }
  13845. if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
  13846. metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
  13847. Py_XDECREF(owned_metaclass);
  13848. if (unlikely(!metaclass))
  13849. return NULL;
  13850. owned_metaclass = metaclass;
  13851. }
  13852. margs = PyTuple_Pack(3, name, bases, dict);
  13853. if (unlikely(!margs)) {
  13854. result = NULL;
  13855. } else {
  13856. result = PyObject_Call(metaclass, margs, mkw);
  13857. Py_DECREF(margs);
  13858. }
  13859. Py_XDECREF(owned_metaclass);
  13860. return result;
  13861. }
  13862. /* GetNameInClass */
  13863. static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
  13864. __Pyx_PyThreadState_declare
  13865. __Pyx_PyThreadState_assign
  13866. if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
  13867. return NULL;
  13868. __Pyx_PyErr_Clear();
  13869. return __Pyx_GetModuleGlobalName(name);
  13870. }
  13871. static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
  13872. PyObject *result;
  13873. result = __Pyx_PyObject_GetAttrStr(nmspace, name);
  13874. if (!result) {
  13875. result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
  13876. }
  13877. return result;
  13878. }
  13879. /* CLineInTraceback */
  13880. #ifndef CYTHON_CLINE_IN_TRACEBACK
  13881. static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
  13882. PyObject *use_cline;
  13883. PyObject *ptype, *pvalue, *ptraceback;
  13884. #if CYTHON_COMPILING_IN_CPYTHON
  13885. PyObject **cython_runtime_dict;
  13886. #endif
  13887. if (unlikely(!__pyx_cython_runtime)) {
  13888. return c_line;
  13889. }
  13890. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  13891. #if CYTHON_COMPILING_IN_CPYTHON
  13892. cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
  13893. if (likely(cython_runtime_dict)) {
  13894. use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
  13895. } else
  13896. #endif
  13897. {
  13898. PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
  13899. if (use_cline_obj) {
  13900. use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
  13901. Py_DECREF(use_cline_obj);
  13902. } else {
  13903. PyErr_Clear();
  13904. use_cline = NULL;
  13905. }
  13906. }
  13907. if (!use_cline) {
  13908. c_line = 0;
  13909. PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
  13910. }
  13911. else if (PyObject_Not(use_cline) != 0) {
  13912. c_line = 0;
  13913. }
  13914. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  13915. return c_line;
  13916. }
  13917. #endif
  13918. /* CodeObjectCache */
  13919. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  13920. int start = 0, mid = 0, end = count - 1;
  13921. if (end >= 0 && code_line > entries[end].code_line) {
  13922. return count;
  13923. }
  13924. while (start < end) {
  13925. mid = start + (end - start) / 2;
  13926. if (code_line < entries[mid].code_line) {
  13927. end = mid;
  13928. } else if (code_line > entries[mid].code_line) {
  13929. start = mid + 1;
  13930. } else {
  13931. return mid;
  13932. }
  13933. }
  13934. if (code_line <= entries[mid].code_line) {
  13935. return mid;
  13936. } else {
  13937. return mid + 1;
  13938. }
  13939. }
  13940. static PyCodeObject *__pyx_find_code_object(int code_line) {
  13941. PyCodeObject* code_object;
  13942. int pos;
  13943. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  13944. return NULL;
  13945. }
  13946. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  13947. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  13948. return NULL;
  13949. }
  13950. code_object = __pyx_code_cache.entries[pos].code_object;
  13951. Py_INCREF(code_object);
  13952. return code_object;
  13953. }
  13954. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  13955. int pos, i;
  13956. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  13957. if (unlikely(!code_line)) {
  13958. return;
  13959. }
  13960. if (unlikely(!entries)) {
  13961. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  13962. if (likely(entries)) {
  13963. __pyx_code_cache.entries = entries;
  13964. __pyx_code_cache.max_count = 64;
  13965. __pyx_code_cache.count = 1;
  13966. entries[0].code_line = code_line;
  13967. entries[0].code_object = code_object;
  13968. Py_INCREF(code_object);
  13969. }
  13970. return;
  13971. }
  13972. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  13973. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  13974. PyCodeObject* tmp = entries[pos].code_object;
  13975. entries[pos].code_object = code_object;
  13976. Py_DECREF(tmp);
  13977. return;
  13978. }
  13979. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  13980. int new_max = __pyx_code_cache.max_count + 64;
  13981. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  13982. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  13983. if (unlikely(!entries)) {
  13984. return;
  13985. }
  13986. __pyx_code_cache.entries = entries;
  13987. __pyx_code_cache.max_count = new_max;
  13988. }
  13989. for (i=__pyx_code_cache.count; i>pos; i--) {
  13990. entries[i] = entries[i-1];
  13991. }
  13992. entries[pos].code_line = code_line;
  13993. entries[pos].code_object = code_object;
  13994. __pyx_code_cache.count++;
  13995. Py_INCREF(code_object);
  13996. }
  13997. /* AddTraceback */
  13998. #include "compile.h"
  13999. #include "frameobject.h"
  14000. #include "traceback.h"
  14001. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  14002. const char *funcname, int c_line,
  14003. int py_line, const char *filename) {
  14004. PyCodeObject *py_code = 0;
  14005. PyObject *py_srcfile = 0;
  14006. PyObject *py_funcname = 0;
  14007. #if PY_MAJOR_VERSION < 3
  14008. py_srcfile = PyString_FromString(filename);
  14009. #else
  14010. py_srcfile = PyUnicode_FromString(filename);
  14011. #endif
  14012. if (!py_srcfile) goto bad;
  14013. if (c_line) {
  14014. #if PY_MAJOR_VERSION < 3
  14015. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  14016. #else
  14017. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  14018. #endif
  14019. }
  14020. else {
  14021. #if PY_MAJOR_VERSION < 3
  14022. py_funcname = PyString_FromString(funcname);
  14023. #else
  14024. py_funcname = PyUnicode_FromString(funcname);
  14025. #endif
  14026. }
  14027. if (!py_funcname) goto bad;
  14028. py_code = __Pyx_PyCode_New(
  14029. 0,
  14030. 0,
  14031. 0,
  14032. 0,
  14033. 0,
  14034. __pyx_empty_bytes, /*PyObject *code,*/
  14035. __pyx_empty_tuple, /*PyObject *consts,*/
  14036. __pyx_empty_tuple, /*PyObject *names,*/
  14037. __pyx_empty_tuple, /*PyObject *varnames,*/
  14038. __pyx_empty_tuple, /*PyObject *freevars,*/
  14039. __pyx_empty_tuple, /*PyObject *cellvars,*/
  14040. py_srcfile, /*PyObject *filename,*/
  14041. py_funcname, /*PyObject *name,*/
  14042. py_line,
  14043. __pyx_empty_bytes /*PyObject *lnotab*/
  14044. );
  14045. Py_DECREF(py_srcfile);
  14046. Py_DECREF(py_funcname);
  14047. return py_code;
  14048. bad:
  14049. Py_XDECREF(py_srcfile);
  14050. Py_XDECREF(py_funcname);
  14051. return NULL;
  14052. }
  14053. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  14054. int py_line, const char *filename) {
  14055. PyCodeObject *py_code = 0;
  14056. PyFrameObject *py_frame = 0;
  14057. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  14058. if (c_line) {
  14059. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  14060. }
  14061. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  14062. if (!py_code) {
  14063. py_code = __Pyx_CreateCodeObjectForTraceback(
  14064. funcname, c_line, py_line, filename);
  14065. if (!py_code) goto bad;
  14066. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  14067. }
  14068. py_frame = PyFrame_New(
  14069. tstate, /*PyThreadState *tstate,*/
  14070. py_code, /*PyCodeObject *code,*/
  14071. __pyx_d, /*PyObject *globals,*/
  14072. 0 /*PyObject *locals*/
  14073. );
  14074. if (!py_frame) goto bad;
  14075. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  14076. PyTraceBack_Here(py_frame);
  14077. bad:
  14078. Py_XDECREF(py_code);
  14079. Py_XDECREF(py_frame);
  14080. }
  14081. /* CIntToPy */
  14082. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
  14083. const int neg_one = (int) -1, const_zero = (int) 0;
  14084. const int is_unsigned = neg_one > const_zero;
  14085. if (is_unsigned) {
  14086. if (sizeof(int) < sizeof(long)) {
  14087. return PyInt_FromLong((long) value);
  14088. } else if (sizeof(int) <= sizeof(unsigned long)) {
  14089. return PyLong_FromUnsignedLong((unsigned long) value);
  14090. #ifdef HAVE_LONG_LONG
  14091. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  14092. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14093. #endif
  14094. }
  14095. } else {
  14096. if (sizeof(int) <= sizeof(long)) {
  14097. return PyInt_FromLong((long) value);
  14098. #ifdef HAVE_LONG_LONG
  14099. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  14100. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14101. #endif
  14102. }
  14103. }
  14104. {
  14105. int one = 1; int little = (int)*(unsigned char *)&one;
  14106. unsigned char *bytes = (unsigned char *)&value;
  14107. return _PyLong_FromByteArray(bytes, sizeof(int),
  14108. little, !is_unsigned);
  14109. }
  14110. }
  14111. /* CIntToPy */
  14112. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
  14113. const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
  14114. const int is_unsigned = neg_one > const_zero;
  14115. if (is_unsigned) {
  14116. if (sizeof(unsigned int) < sizeof(long)) {
  14117. return PyInt_FromLong((long) value);
  14118. } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
  14119. return PyLong_FromUnsignedLong((unsigned long) value);
  14120. #ifdef HAVE_LONG_LONG
  14121. } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
  14122. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14123. #endif
  14124. }
  14125. } else {
  14126. if (sizeof(unsigned int) <= sizeof(long)) {
  14127. return PyInt_FromLong((long) value);
  14128. #ifdef HAVE_LONG_LONG
  14129. } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
  14130. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14131. #endif
  14132. }
  14133. }
  14134. {
  14135. int one = 1; int little = (int)*(unsigned char *)&one;
  14136. unsigned char *bytes = (unsigned char *)&value;
  14137. return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
  14138. little, !is_unsigned);
  14139. }
  14140. }
  14141. /* CIntToPy */
  14142. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) {
  14143. const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0;
  14144. const int is_unsigned = neg_one > const_zero;
  14145. if (is_unsigned) {
  14146. if (sizeof(unsigned long) < sizeof(long)) {
  14147. return PyInt_FromLong((long) value);
  14148. } else if (sizeof(unsigned long) <= sizeof(unsigned long)) {
  14149. return PyLong_FromUnsignedLong((unsigned long) value);
  14150. #ifdef HAVE_LONG_LONG
  14151. } else if (sizeof(unsigned long) <= sizeof(unsigned PY_LONG_LONG)) {
  14152. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14153. #endif
  14154. }
  14155. } else {
  14156. if (sizeof(unsigned long) <= sizeof(long)) {
  14157. return PyInt_FromLong((long) value);
  14158. #ifdef HAVE_LONG_LONG
  14159. } else if (sizeof(unsigned long) <= sizeof(PY_LONG_LONG)) {
  14160. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14161. #endif
  14162. }
  14163. }
  14164. {
  14165. int one = 1; int little = (int)*(unsigned char *)&one;
  14166. unsigned char *bytes = (unsigned char *)&value;
  14167. return _PyLong_FromByteArray(bytes, sizeof(unsigned long),
  14168. little, !is_unsigned);
  14169. }
  14170. }
  14171. /* CIntFromPyVerify */
  14172. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  14173. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  14174. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  14175. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  14176. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  14177. {\
  14178. func_type value = func_value;\
  14179. if (sizeof(target_type) < sizeof(func_type)) {\
  14180. if (unlikely(value != (func_type) (target_type) value)) {\
  14181. func_type zero = 0;\
  14182. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  14183. return (target_type) -1;\
  14184. if (is_unsigned && unlikely(value < zero))\
  14185. goto raise_neg_overflow;\
  14186. else\
  14187. goto raise_overflow;\
  14188. }\
  14189. }\
  14190. return (target_type) value;\
  14191. }
  14192. /* CIntToPy */
  14193. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  14194. const long neg_one = (long) -1, const_zero = (long) 0;
  14195. const int is_unsigned = neg_one > const_zero;
  14196. if (is_unsigned) {
  14197. if (sizeof(long) < sizeof(long)) {
  14198. return PyInt_FromLong((long) value);
  14199. } else if (sizeof(long) <= sizeof(unsigned long)) {
  14200. return PyLong_FromUnsignedLong((unsigned long) value);
  14201. #ifdef HAVE_LONG_LONG
  14202. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  14203. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14204. #endif
  14205. }
  14206. } else {
  14207. if (sizeof(long) <= sizeof(long)) {
  14208. return PyInt_FromLong((long) value);
  14209. #ifdef HAVE_LONG_LONG
  14210. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  14211. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14212. #endif
  14213. }
  14214. }
  14215. {
  14216. int one = 1; int little = (int)*(unsigned char *)&one;
  14217. unsigned char *bytes = (unsigned char *)&value;
  14218. return _PyLong_FromByteArray(bytes, sizeof(long),
  14219. little, !is_unsigned);
  14220. }
  14221. }
  14222. /* CIntToPy */
  14223. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_MDB_dbi(MDB_dbi value) {
  14224. const MDB_dbi neg_one = (MDB_dbi) -1, const_zero = (MDB_dbi) 0;
  14225. const int is_unsigned = neg_one > const_zero;
  14226. if (is_unsigned) {
  14227. if (sizeof(MDB_dbi) < sizeof(long)) {
  14228. return PyInt_FromLong((long) value);
  14229. } else if (sizeof(MDB_dbi) <= sizeof(unsigned long)) {
  14230. return PyLong_FromUnsignedLong((unsigned long) value);
  14231. #ifdef HAVE_LONG_LONG
  14232. } else if (sizeof(MDB_dbi) <= sizeof(unsigned PY_LONG_LONG)) {
  14233. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14234. #endif
  14235. }
  14236. } else {
  14237. if (sizeof(MDB_dbi) <= sizeof(long)) {
  14238. return PyInt_FromLong((long) value);
  14239. #ifdef HAVE_LONG_LONG
  14240. } else if (sizeof(MDB_dbi) <= sizeof(PY_LONG_LONG)) {
  14241. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14242. #endif
  14243. }
  14244. }
  14245. {
  14246. int one = 1; int little = (int)*(unsigned char *)&one;
  14247. unsigned char *bytes = (unsigned char *)&value;
  14248. return _PyLong_FromByteArray(bytes, sizeof(MDB_dbi),
  14249. little, !is_unsigned);
  14250. }
  14251. }
  14252. static PyObject* __pyx_convert__to_py_struct__MDB_stat(struct MDB_stat s) {
  14253. PyObject* res;
  14254. PyObject* member;
  14255. res = __Pyx_PyDict_NewPresized(6); if (unlikely(!res)) return NULL;
  14256. member = __Pyx_PyInt_From_unsigned_int(s.ms_psize); if (unlikely(!member)) goto bad;
  14257. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_psize, member) < 0)) goto bad;
  14258. Py_DECREF(member);
  14259. member = __Pyx_PyInt_From_unsigned_int(s.ms_depth); if (unlikely(!member)) goto bad;
  14260. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_depth, member) < 0)) goto bad;
  14261. Py_DECREF(member);
  14262. member = __Pyx_PyInt_FromSize_t(s.ms_branch_pages); if (unlikely(!member)) goto bad;
  14263. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_branch_pages, member) < 0)) goto bad;
  14264. Py_DECREF(member);
  14265. member = __Pyx_PyInt_FromSize_t(s.ms_leaf_pages); if (unlikely(!member)) goto bad;
  14266. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_leaf_pages, member) < 0)) goto bad;
  14267. Py_DECREF(member);
  14268. member = __Pyx_PyInt_FromSize_t(s.ms_overflow_pages); if (unlikely(!member)) goto bad;
  14269. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_overflow_pages, member) < 0)) goto bad;
  14270. Py_DECREF(member);
  14271. member = __Pyx_PyInt_FromSize_t(s.ms_entries); if (unlikely(!member)) goto bad;
  14272. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_entries, member) < 0)) goto bad;
  14273. Py_DECREF(member);
  14274. return res;
  14275. bad:
  14276. Py_XDECREF(member);
  14277. Py_DECREF(res);
  14278. return NULL;
  14279. }
  14280. /* CIntFromPy */
  14281. static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
  14282. const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
  14283. const int is_unsigned = neg_one > const_zero;
  14284. #if PY_MAJOR_VERSION < 3
  14285. if (likely(PyInt_Check(x))) {
  14286. if (sizeof(size_t) < sizeof(long)) {
  14287. __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
  14288. } else {
  14289. long val = PyInt_AS_LONG(x);
  14290. if (is_unsigned && unlikely(val < 0)) {
  14291. goto raise_neg_overflow;
  14292. }
  14293. return (size_t) val;
  14294. }
  14295. } else
  14296. #endif
  14297. if (likely(PyLong_Check(x))) {
  14298. if (is_unsigned) {
  14299. #if CYTHON_USE_PYLONG_INTERNALS
  14300. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14301. switch (Py_SIZE(x)) {
  14302. case 0: return (size_t) 0;
  14303. case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
  14304. case 2:
  14305. if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
  14306. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14307. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14308. } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
  14309. return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14310. }
  14311. }
  14312. break;
  14313. case 3:
  14314. if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
  14315. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14316. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14317. } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
  14318. return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14319. }
  14320. }
  14321. break;
  14322. case 4:
  14323. if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
  14324. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14325. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14326. } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
  14327. return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14328. }
  14329. }
  14330. break;
  14331. }
  14332. #endif
  14333. #if CYTHON_COMPILING_IN_CPYTHON
  14334. if (unlikely(Py_SIZE(x) < 0)) {
  14335. goto raise_neg_overflow;
  14336. }
  14337. #else
  14338. {
  14339. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14340. if (unlikely(result < 0))
  14341. return (size_t) -1;
  14342. if (unlikely(result == 1))
  14343. goto raise_neg_overflow;
  14344. }
  14345. #endif
  14346. if (sizeof(size_t) <= sizeof(unsigned long)) {
  14347. __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
  14348. #ifdef HAVE_LONG_LONG
  14349. } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
  14350. __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14351. #endif
  14352. }
  14353. } else {
  14354. #if CYTHON_USE_PYLONG_INTERNALS
  14355. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14356. switch (Py_SIZE(x)) {
  14357. case 0: return (size_t) 0;
  14358. case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
  14359. case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0])
  14360. case -2:
  14361. if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
  14362. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14363. __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14364. } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14365. return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14366. }
  14367. }
  14368. break;
  14369. case 2:
  14370. if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
  14371. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14372. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14373. } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14374. return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14375. }
  14376. }
  14377. break;
  14378. case -3:
  14379. if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14380. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14381. __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14382. } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14383. return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14384. }
  14385. }
  14386. break;
  14387. case 3:
  14388. if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
  14389. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14390. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14391. } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14392. return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14393. }
  14394. }
  14395. break;
  14396. case -4:
  14397. if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14398. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14399. __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14400. } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
  14401. return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14402. }
  14403. }
  14404. break;
  14405. case 4:
  14406. if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
  14407. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14408. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14409. } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
  14410. return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14411. }
  14412. }
  14413. break;
  14414. }
  14415. #endif
  14416. if (sizeof(size_t) <= sizeof(long)) {
  14417. __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
  14418. #ifdef HAVE_LONG_LONG
  14419. } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
  14420. __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
  14421. #endif
  14422. }
  14423. }
  14424. {
  14425. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14426. PyErr_SetString(PyExc_RuntimeError,
  14427. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14428. #else
  14429. size_t val;
  14430. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14431. #if PY_MAJOR_VERSION < 3
  14432. if (likely(v) && !PyLong_Check(v)) {
  14433. PyObject *tmp = v;
  14434. v = PyNumber_Long(tmp);
  14435. Py_DECREF(tmp);
  14436. }
  14437. #endif
  14438. if (likely(v)) {
  14439. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14440. unsigned char *bytes = (unsigned char *)&val;
  14441. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14442. bytes, sizeof(val),
  14443. is_little, !is_unsigned);
  14444. Py_DECREF(v);
  14445. if (likely(!ret))
  14446. return val;
  14447. }
  14448. #endif
  14449. return (size_t) -1;
  14450. }
  14451. } else {
  14452. size_t val;
  14453. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14454. if (!tmp) return (size_t) -1;
  14455. val = __Pyx_PyInt_As_size_t(tmp);
  14456. Py_DECREF(tmp);
  14457. return val;
  14458. }
  14459. raise_overflow:
  14460. PyErr_SetString(PyExc_OverflowError,
  14461. "value too large to convert to size_t");
  14462. return (size_t) -1;
  14463. raise_neg_overflow:
  14464. PyErr_SetString(PyExc_OverflowError,
  14465. "can't convert negative value to size_t");
  14466. return (size_t) -1;
  14467. }
  14468. /* CIntFromPy */
  14469. static CYTHON_INLINE MDB_dbi __Pyx_PyInt_As_MDB_dbi(PyObject *x) {
  14470. const MDB_dbi neg_one = (MDB_dbi) -1, const_zero = (MDB_dbi) 0;
  14471. const int is_unsigned = neg_one > const_zero;
  14472. #if PY_MAJOR_VERSION < 3
  14473. if (likely(PyInt_Check(x))) {
  14474. if (sizeof(MDB_dbi) < sizeof(long)) {
  14475. __PYX_VERIFY_RETURN_INT(MDB_dbi, long, PyInt_AS_LONG(x))
  14476. } else {
  14477. long val = PyInt_AS_LONG(x);
  14478. if (is_unsigned && unlikely(val < 0)) {
  14479. goto raise_neg_overflow;
  14480. }
  14481. return (MDB_dbi) val;
  14482. }
  14483. } else
  14484. #endif
  14485. if (likely(PyLong_Check(x))) {
  14486. if (is_unsigned) {
  14487. #if CYTHON_USE_PYLONG_INTERNALS
  14488. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14489. switch (Py_SIZE(x)) {
  14490. case 0: return (MDB_dbi) 0;
  14491. case 1: __PYX_VERIFY_RETURN_INT(MDB_dbi, digit, digits[0])
  14492. case 2:
  14493. if (8 * sizeof(MDB_dbi) > 1 * PyLong_SHIFT) {
  14494. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14495. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14496. } else if (8 * sizeof(MDB_dbi) >= 2 * PyLong_SHIFT) {
  14497. return (MDB_dbi) (((((MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0]));
  14498. }
  14499. }
  14500. break;
  14501. case 3:
  14502. if (8 * sizeof(MDB_dbi) > 2 * PyLong_SHIFT) {
  14503. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14504. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14505. } else if (8 * sizeof(MDB_dbi) >= 3 * PyLong_SHIFT) {
  14506. return (MDB_dbi) (((((((MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0]));
  14507. }
  14508. }
  14509. break;
  14510. case 4:
  14511. if (8 * sizeof(MDB_dbi) > 3 * PyLong_SHIFT) {
  14512. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14513. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14514. } else if (8 * sizeof(MDB_dbi) >= 4 * PyLong_SHIFT) {
  14515. return (MDB_dbi) (((((((((MDB_dbi)digits[3]) << PyLong_SHIFT) | (MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0]));
  14516. }
  14517. }
  14518. break;
  14519. }
  14520. #endif
  14521. #if CYTHON_COMPILING_IN_CPYTHON
  14522. if (unlikely(Py_SIZE(x) < 0)) {
  14523. goto raise_neg_overflow;
  14524. }
  14525. #else
  14526. {
  14527. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14528. if (unlikely(result < 0))
  14529. return (MDB_dbi) -1;
  14530. if (unlikely(result == 1))
  14531. goto raise_neg_overflow;
  14532. }
  14533. #endif
  14534. if (sizeof(MDB_dbi) <= sizeof(unsigned long)) {
  14535. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, unsigned long, PyLong_AsUnsignedLong(x))
  14536. #ifdef HAVE_LONG_LONG
  14537. } else if (sizeof(MDB_dbi) <= sizeof(unsigned PY_LONG_LONG)) {
  14538. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14539. #endif
  14540. }
  14541. } else {
  14542. #if CYTHON_USE_PYLONG_INTERNALS
  14543. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14544. switch (Py_SIZE(x)) {
  14545. case 0: return (MDB_dbi) 0;
  14546. case -1: __PYX_VERIFY_RETURN_INT(MDB_dbi, sdigit, (sdigit) (-(sdigit)digits[0]))
  14547. case 1: __PYX_VERIFY_RETURN_INT(MDB_dbi, digit, +digits[0])
  14548. case -2:
  14549. if (8 * sizeof(MDB_dbi) - 1 > 1 * PyLong_SHIFT) {
  14550. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14551. __PYX_VERIFY_RETURN_INT(MDB_dbi, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14552. } else if (8 * sizeof(MDB_dbi) - 1 > 2 * PyLong_SHIFT) {
  14553. return (MDB_dbi) (((MDB_dbi)-1)*(((((MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14554. }
  14555. }
  14556. break;
  14557. case 2:
  14558. if (8 * sizeof(MDB_dbi) > 1 * PyLong_SHIFT) {
  14559. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14560. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14561. } else if (8 * sizeof(MDB_dbi) - 1 > 2 * PyLong_SHIFT) {
  14562. return (MDB_dbi) ((((((MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14563. }
  14564. }
  14565. break;
  14566. case -3:
  14567. if (8 * sizeof(MDB_dbi) - 1 > 2 * PyLong_SHIFT) {
  14568. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14569. __PYX_VERIFY_RETURN_INT(MDB_dbi, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14570. } else if (8 * sizeof(MDB_dbi) - 1 > 3 * PyLong_SHIFT) {
  14571. return (MDB_dbi) (((MDB_dbi)-1)*(((((((MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14572. }
  14573. }
  14574. break;
  14575. case 3:
  14576. if (8 * sizeof(MDB_dbi) > 2 * PyLong_SHIFT) {
  14577. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14578. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14579. } else if (8 * sizeof(MDB_dbi) - 1 > 3 * PyLong_SHIFT) {
  14580. return (MDB_dbi) ((((((((MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14581. }
  14582. }
  14583. break;
  14584. case -4:
  14585. if (8 * sizeof(MDB_dbi) - 1 > 3 * PyLong_SHIFT) {
  14586. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14587. __PYX_VERIFY_RETURN_INT(MDB_dbi, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14588. } else if (8 * sizeof(MDB_dbi) - 1 > 4 * PyLong_SHIFT) {
  14589. return (MDB_dbi) (((MDB_dbi)-1)*(((((((((MDB_dbi)digits[3]) << PyLong_SHIFT) | (MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14590. }
  14591. }
  14592. break;
  14593. case 4:
  14594. if (8 * sizeof(MDB_dbi) > 3 * PyLong_SHIFT) {
  14595. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14596. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14597. } else if (8 * sizeof(MDB_dbi) - 1 > 4 * PyLong_SHIFT) {
  14598. return (MDB_dbi) ((((((((((MDB_dbi)digits[3]) << PyLong_SHIFT) | (MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14599. }
  14600. }
  14601. break;
  14602. }
  14603. #endif
  14604. if (sizeof(MDB_dbi) <= sizeof(long)) {
  14605. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, long, PyLong_AsLong(x))
  14606. #ifdef HAVE_LONG_LONG
  14607. } else if (sizeof(MDB_dbi) <= sizeof(PY_LONG_LONG)) {
  14608. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, PY_LONG_LONG, PyLong_AsLongLong(x))
  14609. #endif
  14610. }
  14611. }
  14612. {
  14613. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14614. PyErr_SetString(PyExc_RuntimeError,
  14615. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14616. #else
  14617. MDB_dbi val;
  14618. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14619. #if PY_MAJOR_VERSION < 3
  14620. if (likely(v) && !PyLong_Check(v)) {
  14621. PyObject *tmp = v;
  14622. v = PyNumber_Long(tmp);
  14623. Py_DECREF(tmp);
  14624. }
  14625. #endif
  14626. if (likely(v)) {
  14627. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14628. unsigned char *bytes = (unsigned char *)&val;
  14629. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14630. bytes, sizeof(val),
  14631. is_little, !is_unsigned);
  14632. Py_DECREF(v);
  14633. if (likely(!ret))
  14634. return val;
  14635. }
  14636. #endif
  14637. return (MDB_dbi) -1;
  14638. }
  14639. } else {
  14640. MDB_dbi val;
  14641. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14642. if (!tmp) return (MDB_dbi) -1;
  14643. val = __Pyx_PyInt_As_MDB_dbi(tmp);
  14644. Py_DECREF(tmp);
  14645. return val;
  14646. }
  14647. raise_overflow:
  14648. PyErr_SetString(PyExc_OverflowError,
  14649. "value too large to convert to MDB_dbi");
  14650. return (MDB_dbi) -1;
  14651. raise_neg_overflow:
  14652. PyErr_SetString(PyExc_OverflowError,
  14653. "can't convert negative value to MDB_dbi");
  14654. return (MDB_dbi) -1;
  14655. }
  14656. /* CIntFromPy */
  14657. static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) {
  14658. const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
  14659. const int is_unsigned = neg_one > const_zero;
  14660. #if PY_MAJOR_VERSION < 3
  14661. if (likely(PyInt_Check(x))) {
  14662. if (sizeof(unsigned int) < sizeof(long)) {
  14663. __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x))
  14664. } else {
  14665. long val = PyInt_AS_LONG(x);
  14666. if (is_unsigned && unlikely(val < 0)) {
  14667. goto raise_neg_overflow;
  14668. }
  14669. return (unsigned int) val;
  14670. }
  14671. } else
  14672. #endif
  14673. if (likely(PyLong_Check(x))) {
  14674. if (is_unsigned) {
  14675. #if CYTHON_USE_PYLONG_INTERNALS
  14676. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14677. switch (Py_SIZE(x)) {
  14678. case 0: return (unsigned int) 0;
  14679. case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0])
  14680. case 2:
  14681. if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
  14682. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14683. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14684. } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) {
  14685. return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
  14686. }
  14687. }
  14688. break;
  14689. case 3:
  14690. if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
  14691. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14692. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14693. } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) {
  14694. return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
  14695. }
  14696. }
  14697. break;
  14698. case 4:
  14699. if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
  14700. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14701. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14702. } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) {
  14703. return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
  14704. }
  14705. }
  14706. break;
  14707. }
  14708. #endif
  14709. #if CYTHON_COMPILING_IN_CPYTHON
  14710. if (unlikely(Py_SIZE(x) < 0)) {
  14711. goto raise_neg_overflow;
  14712. }
  14713. #else
  14714. {
  14715. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14716. if (unlikely(result < 0))
  14717. return (unsigned int) -1;
  14718. if (unlikely(result == 1))
  14719. goto raise_neg_overflow;
  14720. }
  14721. #endif
  14722. if (sizeof(unsigned int) <= sizeof(unsigned long)) {
  14723. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x))
  14724. #ifdef HAVE_LONG_LONG
  14725. } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
  14726. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14727. #endif
  14728. }
  14729. } else {
  14730. #if CYTHON_USE_PYLONG_INTERNALS
  14731. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14732. switch (Py_SIZE(x)) {
  14733. case 0: return (unsigned int) 0;
  14734. case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0]))
  14735. case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0])
  14736. case -2:
  14737. if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) {
  14738. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14739. __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14740. } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
  14741. return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14742. }
  14743. }
  14744. break;
  14745. case 2:
  14746. if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
  14747. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14748. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14749. } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
  14750. return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14751. }
  14752. }
  14753. break;
  14754. case -3:
  14755. if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
  14756. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14757. __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14758. } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
  14759. return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14760. }
  14761. }
  14762. break;
  14763. case 3:
  14764. if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
  14765. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14766. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14767. } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
  14768. return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14769. }
  14770. }
  14771. break;
  14772. case -4:
  14773. if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
  14774. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14775. __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14776. } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
  14777. return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14778. }
  14779. }
  14780. break;
  14781. case 4:
  14782. if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
  14783. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14784. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14785. } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
  14786. return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14787. }
  14788. }
  14789. break;
  14790. }
  14791. #endif
  14792. if (sizeof(unsigned int) <= sizeof(long)) {
  14793. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x))
  14794. #ifdef HAVE_LONG_LONG
  14795. } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
  14796. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x))
  14797. #endif
  14798. }
  14799. }
  14800. {
  14801. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14802. PyErr_SetString(PyExc_RuntimeError,
  14803. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14804. #else
  14805. unsigned int val;
  14806. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14807. #if PY_MAJOR_VERSION < 3
  14808. if (likely(v) && !PyLong_Check(v)) {
  14809. PyObject *tmp = v;
  14810. v = PyNumber_Long(tmp);
  14811. Py_DECREF(tmp);
  14812. }
  14813. #endif
  14814. if (likely(v)) {
  14815. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14816. unsigned char *bytes = (unsigned char *)&val;
  14817. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14818. bytes, sizeof(val),
  14819. is_little, !is_unsigned);
  14820. Py_DECREF(v);
  14821. if (likely(!ret))
  14822. return val;
  14823. }
  14824. #endif
  14825. return (unsigned int) -1;
  14826. }
  14827. } else {
  14828. unsigned int val;
  14829. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14830. if (!tmp) return (unsigned int) -1;
  14831. val = __Pyx_PyInt_As_unsigned_int(tmp);
  14832. Py_DECREF(tmp);
  14833. return val;
  14834. }
  14835. raise_overflow:
  14836. PyErr_SetString(PyExc_OverflowError,
  14837. "value too large to convert to unsigned int");
  14838. return (unsigned int) -1;
  14839. raise_neg_overflow:
  14840. PyErr_SetString(PyExc_OverflowError,
  14841. "can't convert negative value to unsigned int");
  14842. return (unsigned int) -1;
  14843. }
  14844. /* CIntFromPy */
  14845. static CYTHON_INLINE mode_t __Pyx_PyInt_As_mode_t(PyObject *x) {
  14846. const mode_t neg_one = (mode_t) -1, const_zero = (mode_t) 0;
  14847. const int is_unsigned = neg_one > const_zero;
  14848. #if PY_MAJOR_VERSION < 3
  14849. if (likely(PyInt_Check(x))) {
  14850. if (sizeof(mode_t) < sizeof(long)) {
  14851. __PYX_VERIFY_RETURN_INT(mode_t, long, PyInt_AS_LONG(x))
  14852. } else {
  14853. long val = PyInt_AS_LONG(x);
  14854. if (is_unsigned && unlikely(val < 0)) {
  14855. goto raise_neg_overflow;
  14856. }
  14857. return (mode_t) val;
  14858. }
  14859. } else
  14860. #endif
  14861. if (likely(PyLong_Check(x))) {
  14862. if (is_unsigned) {
  14863. #if CYTHON_USE_PYLONG_INTERNALS
  14864. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14865. switch (Py_SIZE(x)) {
  14866. case 0: return (mode_t) 0;
  14867. case 1: __PYX_VERIFY_RETURN_INT(mode_t, digit, digits[0])
  14868. case 2:
  14869. if (8 * sizeof(mode_t) > 1 * PyLong_SHIFT) {
  14870. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14871. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14872. } else if (8 * sizeof(mode_t) >= 2 * PyLong_SHIFT) {
  14873. return (mode_t) (((((mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0]));
  14874. }
  14875. }
  14876. break;
  14877. case 3:
  14878. if (8 * sizeof(mode_t) > 2 * PyLong_SHIFT) {
  14879. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14880. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14881. } else if (8 * sizeof(mode_t) >= 3 * PyLong_SHIFT) {
  14882. return (mode_t) (((((((mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0]));
  14883. }
  14884. }
  14885. break;
  14886. case 4:
  14887. if (8 * sizeof(mode_t) > 3 * PyLong_SHIFT) {
  14888. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14889. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14890. } else if (8 * sizeof(mode_t) >= 4 * PyLong_SHIFT) {
  14891. return (mode_t) (((((((((mode_t)digits[3]) << PyLong_SHIFT) | (mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0]));
  14892. }
  14893. }
  14894. break;
  14895. }
  14896. #endif
  14897. #if CYTHON_COMPILING_IN_CPYTHON
  14898. if (unlikely(Py_SIZE(x) < 0)) {
  14899. goto raise_neg_overflow;
  14900. }
  14901. #else
  14902. {
  14903. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14904. if (unlikely(result < 0))
  14905. return (mode_t) -1;
  14906. if (unlikely(result == 1))
  14907. goto raise_neg_overflow;
  14908. }
  14909. #endif
  14910. if (sizeof(mode_t) <= sizeof(unsigned long)) {
  14911. __PYX_VERIFY_RETURN_INT_EXC(mode_t, unsigned long, PyLong_AsUnsignedLong(x))
  14912. #ifdef HAVE_LONG_LONG
  14913. } else if (sizeof(mode_t) <= sizeof(unsigned PY_LONG_LONG)) {
  14914. __PYX_VERIFY_RETURN_INT_EXC(mode_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14915. #endif
  14916. }
  14917. } else {
  14918. #if CYTHON_USE_PYLONG_INTERNALS
  14919. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14920. switch (Py_SIZE(x)) {
  14921. case 0: return (mode_t) 0;
  14922. case -1: __PYX_VERIFY_RETURN_INT(mode_t, sdigit, (sdigit) (-(sdigit)digits[0]))
  14923. case 1: __PYX_VERIFY_RETURN_INT(mode_t, digit, +digits[0])
  14924. case -2:
  14925. if (8 * sizeof(mode_t) - 1 > 1 * PyLong_SHIFT) {
  14926. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14927. __PYX_VERIFY_RETURN_INT(mode_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14928. } else if (8 * sizeof(mode_t) - 1 > 2 * PyLong_SHIFT) {
  14929. return (mode_t) (((mode_t)-1)*(((((mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  14930. }
  14931. }
  14932. break;
  14933. case 2:
  14934. if (8 * sizeof(mode_t) > 1 * PyLong_SHIFT) {
  14935. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14936. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14937. } else if (8 * sizeof(mode_t) - 1 > 2 * PyLong_SHIFT) {
  14938. return (mode_t) ((((((mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  14939. }
  14940. }
  14941. break;
  14942. case -3:
  14943. if (8 * sizeof(mode_t) - 1 > 2 * PyLong_SHIFT) {
  14944. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14945. __PYX_VERIFY_RETURN_INT(mode_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14946. } else if (8 * sizeof(mode_t) - 1 > 3 * PyLong_SHIFT) {
  14947. return (mode_t) (((mode_t)-1)*(((((((mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  14948. }
  14949. }
  14950. break;
  14951. case 3:
  14952. if (8 * sizeof(mode_t) > 2 * PyLong_SHIFT) {
  14953. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14954. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14955. } else if (8 * sizeof(mode_t) - 1 > 3 * PyLong_SHIFT) {
  14956. return (mode_t) ((((((((mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  14957. }
  14958. }
  14959. break;
  14960. case -4:
  14961. if (8 * sizeof(mode_t) - 1 > 3 * PyLong_SHIFT) {
  14962. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14963. __PYX_VERIFY_RETURN_INT(mode_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14964. } else if (8 * sizeof(mode_t) - 1 > 4 * PyLong_SHIFT) {
  14965. return (mode_t) (((mode_t)-1)*(((((((((mode_t)digits[3]) << PyLong_SHIFT) | (mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  14966. }
  14967. }
  14968. break;
  14969. case 4:
  14970. if (8 * sizeof(mode_t) > 3 * PyLong_SHIFT) {
  14971. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14972. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14973. } else if (8 * sizeof(mode_t) - 1 > 4 * PyLong_SHIFT) {
  14974. return (mode_t) ((((((((((mode_t)digits[3]) << PyLong_SHIFT) | (mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  14975. }
  14976. }
  14977. break;
  14978. }
  14979. #endif
  14980. if (sizeof(mode_t) <= sizeof(long)) {
  14981. __PYX_VERIFY_RETURN_INT_EXC(mode_t, long, PyLong_AsLong(x))
  14982. #ifdef HAVE_LONG_LONG
  14983. } else if (sizeof(mode_t) <= sizeof(PY_LONG_LONG)) {
  14984. __PYX_VERIFY_RETURN_INT_EXC(mode_t, PY_LONG_LONG, PyLong_AsLongLong(x))
  14985. #endif
  14986. }
  14987. }
  14988. {
  14989. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14990. PyErr_SetString(PyExc_RuntimeError,
  14991. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14992. #else
  14993. mode_t val;
  14994. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14995. #if PY_MAJOR_VERSION < 3
  14996. if (likely(v) && !PyLong_Check(v)) {
  14997. PyObject *tmp = v;
  14998. v = PyNumber_Long(tmp);
  14999. Py_DECREF(tmp);
  15000. }
  15001. #endif
  15002. if (likely(v)) {
  15003. int one = 1; int is_little = (int)*(unsigned char *)&one;
  15004. unsigned char *bytes = (unsigned char *)&val;
  15005. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  15006. bytes, sizeof(val),
  15007. is_little, !is_unsigned);
  15008. Py_DECREF(v);
  15009. if (likely(!ret))
  15010. return val;
  15011. }
  15012. #endif
  15013. return (mode_t) -1;
  15014. }
  15015. } else {
  15016. mode_t val;
  15017. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  15018. if (!tmp) return (mode_t) -1;
  15019. val = __Pyx_PyInt_As_mode_t(tmp);
  15020. Py_DECREF(tmp);
  15021. return val;
  15022. }
  15023. raise_overflow:
  15024. PyErr_SetString(PyExc_OverflowError,
  15025. "value too large to convert to mode_t");
  15026. return (mode_t) -1;
  15027. raise_neg_overflow:
  15028. PyErr_SetString(PyExc_OverflowError,
  15029. "can't convert negative value to mode_t");
  15030. return (mode_t) -1;
  15031. }
  15032. /* CIntFromPy */
  15033. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  15034. const int neg_one = (int) -1, const_zero = (int) 0;
  15035. const int is_unsigned = neg_one > const_zero;
  15036. #if PY_MAJOR_VERSION < 3
  15037. if (likely(PyInt_Check(x))) {
  15038. if (sizeof(int) < sizeof(long)) {
  15039. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  15040. } else {
  15041. long val = PyInt_AS_LONG(x);
  15042. if (is_unsigned && unlikely(val < 0)) {
  15043. goto raise_neg_overflow;
  15044. }
  15045. return (int) val;
  15046. }
  15047. } else
  15048. #endif
  15049. if (likely(PyLong_Check(x))) {
  15050. if (is_unsigned) {
  15051. #if CYTHON_USE_PYLONG_INTERNALS
  15052. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15053. switch (Py_SIZE(x)) {
  15054. case 0: return (int) 0;
  15055. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  15056. case 2:
  15057. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  15058. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15059. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15060. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  15061. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  15062. }
  15063. }
  15064. break;
  15065. case 3:
  15066. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  15067. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15068. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15069. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  15070. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  15071. }
  15072. }
  15073. break;
  15074. case 4:
  15075. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  15076. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15077. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15078. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  15079. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  15080. }
  15081. }
  15082. break;
  15083. }
  15084. #endif
  15085. #if CYTHON_COMPILING_IN_CPYTHON
  15086. if (unlikely(Py_SIZE(x) < 0)) {
  15087. goto raise_neg_overflow;
  15088. }
  15089. #else
  15090. {
  15091. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  15092. if (unlikely(result < 0))
  15093. return (int) -1;
  15094. if (unlikely(result == 1))
  15095. goto raise_neg_overflow;
  15096. }
  15097. #endif
  15098. if (sizeof(int) <= sizeof(unsigned long)) {
  15099. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  15100. #ifdef HAVE_LONG_LONG
  15101. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  15102. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  15103. #endif
  15104. }
  15105. } else {
  15106. #if CYTHON_USE_PYLONG_INTERNALS
  15107. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15108. switch (Py_SIZE(x)) {
  15109. case 0: return (int) 0;
  15110. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  15111. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  15112. case -2:
  15113. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  15114. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15115. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15116. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  15117. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15118. }
  15119. }
  15120. break;
  15121. case 2:
  15122. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  15123. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15124. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15125. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  15126. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15127. }
  15128. }
  15129. break;
  15130. case -3:
  15131. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  15132. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15133. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15134. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  15135. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15136. }
  15137. }
  15138. break;
  15139. case 3:
  15140. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  15141. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15142. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15143. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  15144. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15145. }
  15146. }
  15147. break;
  15148. case -4:
  15149. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  15150. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15151. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15152. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  15153. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15154. }
  15155. }
  15156. break;
  15157. case 4:
  15158. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  15159. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15160. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15161. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  15162. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15163. }
  15164. }
  15165. break;
  15166. }
  15167. #endif
  15168. if (sizeof(int) <= sizeof(long)) {
  15169. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  15170. #ifdef HAVE_LONG_LONG
  15171. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  15172. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  15173. #endif
  15174. }
  15175. }
  15176. {
  15177. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  15178. PyErr_SetString(PyExc_RuntimeError,
  15179. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  15180. #else
  15181. int val;
  15182. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  15183. #if PY_MAJOR_VERSION < 3
  15184. if (likely(v) && !PyLong_Check(v)) {
  15185. PyObject *tmp = v;
  15186. v = PyNumber_Long(tmp);
  15187. Py_DECREF(tmp);
  15188. }
  15189. #endif
  15190. if (likely(v)) {
  15191. int one = 1; int is_little = (int)*(unsigned char *)&one;
  15192. unsigned char *bytes = (unsigned char *)&val;
  15193. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  15194. bytes, sizeof(val),
  15195. is_little, !is_unsigned);
  15196. Py_DECREF(v);
  15197. if (likely(!ret))
  15198. return val;
  15199. }
  15200. #endif
  15201. return (int) -1;
  15202. }
  15203. } else {
  15204. int val;
  15205. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  15206. if (!tmp) return (int) -1;
  15207. val = __Pyx_PyInt_As_int(tmp);
  15208. Py_DECREF(tmp);
  15209. return val;
  15210. }
  15211. raise_overflow:
  15212. PyErr_SetString(PyExc_OverflowError,
  15213. "value too large to convert to int");
  15214. return (int) -1;
  15215. raise_neg_overflow:
  15216. PyErr_SetString(PyExc_OverflowError,
  15217. "can't convert negative value to int");
  15218. return (int) -1;
  15219. }
  15220. /* CIntFromPy */
  15221. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  15222. const long neg_one = (long) -1, const_zero = (long) 0;
  15223. const int is_unsigned = neg_one > const_zero;
  15224. #if PY_MAJOR_VERSION < 3
  15225. if (likely(PyInt_Check(x))) {
  15226. if (sizeof(long) < sizeof(long)) {
  15227. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  15228. } else {
  15229. long val = PyInt_AS_LONG(x);
  15230. if (is_unsigned && unlikely(val < 0)) {
  15231. goto raise_neg_overflow;
  15232. }
  15233. return (long) val;
  15234. }
  15235. } else
  15236. #endif
  15237. if (likely(PyLong_Check(x))) {
  15238. if (is_unsigned) {
  15239. #if CYTHON_USE_PYLONG_INTERNALS
  15240. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15241. switch (Py_SIZE(x)) {
  15242. case 0: return (long) 0;
  15243. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  15244. case 2:
  15245. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  15246. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15247. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15248. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  15249. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  15250. }
  15251. }
  15252. break;
  15253. case 3:
  15254. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  15255. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15256. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15257. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  15258. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  15259. }
  15260. }
  15261. break;
  15262. case 4:
  15263. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  15264. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15265. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15266. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  15267. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  15268. }
  15269. }
  15270. break;
  15271. }
  15272. #endif
  15273. #if CYTHON_COMPILING_IN_CPYTHON
  15274. if (unlikely(Py_SIZE(x) < 0)) {
  15275. goto raise_neg_overflow;
  15276. }
  15277. #else
  15278. {
  15279. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  15280. if (unlikely(result < 0))
  15281. return (long) -1;
  15282. if (unlikely(result == 1))
  15283. goto raise_neg_overflow;
  15284. }
  15285. #endif
  15286. if (sizeof(long) <= sizeof(unsigned long)) {
  15287. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  15288. #ifdef HAVE_LONG_LONG
  15289. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  15290. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  15291. #endif
  15292. }
  15293. } else {
  15294. #if CYTHON_USE_PYLONG_INTERNALS
  15295. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15296. switch (Py_SIZE(x)) {
  15297. case 0: return (long) 0;
  15298. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  15299. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  15300. case -2:
  15301. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  15302. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15303. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15304. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  15305. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15306. }
  15307. }
  15308. break;
  15309. case 2:
  15310. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  15311. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15312. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15313. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  15314. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15315. }
  15316. }
  15317. break;
  15318. case -3:
  15319. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  15320. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15321. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15322. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  15323. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15324. }
  15325. }
  15326. break;
  15327. case 3:
  15328. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  15329. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15330. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15331. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  15332. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15333. }
  15334. }
  15335. break;
  15336. case -4:
  15337. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  15338. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15339. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15340. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  15341. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15342. }
  15343. }
  15344. break;
  15345. case 4:
  15346. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  15347. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15348. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15349. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  15350. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15351. }
  15352. }
  15353. break;
  15354. }
  15355. #endif
  15356. if (sizeof(long) <= sizeof(long)) {
  15357. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  15358. #ifdef HAVE_LONG_LONG
  15359. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  15360. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  15361. #endif
  15362. }
  15363. }
  15364. {
  15365. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  15366. PyErr_SetString(PyExc_RuntimeError,
  15367. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  15368. #else
  15369. long val;
  15370. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  15371. #if PY_MAJOR_VERSION < 3
  15372. if (likely(v) && !PyLong_Check(v)) {
  15373. PyObject *tmp = v;
  15374. v = PyNumber_Long(tmp);
  15375. Py_DECREF(tmp);
  15376. }
  15377. #endif
  15378. if (likely(v)) {
  15379. int one = 1; int is_little = (int)*(unsigned char *)&one;
  15380. unsigned char *bytes = (unsigned char *)&val;
  15381. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  15382. bytes, sizeof(val),
  15383. is_little, !is_unsigned);
  15384. Py_DECREF(v);
  15385. if (likely(!ret))
  15386. return val;
  15387. }
  15388. #endif
  15389. return (long) -1;
  15390. }
  15391. } else {
  15392. long val;
  15393. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  15394. if (!tmp) return (long) -1;
  15395. val = __Pyx_PyInt_As_long(tmp);
  15396. Py_DECREF(tmp);
  15397. return val;
  15398. }
  15399. raise_overflow:
  15400. PyErr_SetString(PyExc_OverflowError,
  15401. "value too large to convert to long");
  15402. return (long) -1;
  15403. raise_neg_overflow:
  15404. PyErr_SetString(PyExc_OverflowError,
  15405. "can't convert negative value to long");
  15406. return (long) -1;
  15407. }
  15408. /* FetchCommonType */
  15409. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
  15410. PyObject* fake_module;
  15411. PyTypeObject* cached_type = NULL;
  15412. fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
  15413. if (!fake_module) return NULL;
  15414. Py_INCREF(fake_module);
  15415. cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
  15416. if (cached_type) {
  15417. if (!PyType_Check((PyObject*)cached_type)) {
  15418. PyErr_Format(PyExc_TypeError,
  15419. "Shared Cython type %.200s is not a type object",
  15420. type->tp_name);
  15421. goto bad;
  15422. }
  15423. if (cached_type->tp_basicsize != type->tp_basicsize) {
  15424. PyErr_Format(PyExc_TypeError,
  15425. "Shared Cython type %.200s has the wrong size, try recompiling",
  15426. type->tp_name);
  15427. goto bad;
  15428. }
  15429. } else {
  15430. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
  15431. PyErr_Clear();
  15432. if (PyType_Ready(type) < 0) goto bad;
  15433. if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
  15434. goto bad;
  15435. Py_INCREF(type);
  15436. cached_type = type;
  15437. }
  15438. done:
  15439. Py_DECREF(fake_module);
  15440. return cached_type;
  15441. bad:
  15442. Py_XDECREF(cached_type);
  15443. cached_type = NULL;
  15444. goto done;
  15445. }
  15446. /* PyObjectCallMethod1 */
  15447. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
  15448. PyObject *result = NULL;
  15449. #if CYTHON_UNPACK_METHODS
  15450. if (likely(PyMethod_Check(method))) {
  15451. PyObject *self = PyMethod_GET_SELF(method);
  15452. if (likely(self)) {
  15453. PyObject *args;
  15454. PyObject *function = PyMethod_GET_FUNCTION(method);
  15455. #if CYTHON_FAST_PYCALL
  15456. if (PyFunction_Check(function)) {
  15457. PyObject *args[2] = {self, arg};
  15458. result = __Pyx_PyFunction_FastCall(function, args, 2);
  15459. goto done;
  15460. }
  15461. #endif
  15462. #if CYTHON_FAST_PYCCALL
  15463. if (__Pyx_PyFastCFunction_Check(function)) {
  15464. PyObject *args[2] = {self, arg};
  15465. result = __Pyx_PyCFunction_FastCall(function, args, 2);
  15466. goto done;
  15467. }
  15468. #endif
  15469. args = PyTuple_New(2);
  15470. if (unlikely(!args)) goto done;
  15471. Py_INCREF(self);
  15472. PyTuple_SET_ITEM(args, 0, self);
  15473. Py_INCREF(arg);
  15474. PyTuple_SET_ITEM(args, 1, arg);
  15475. Py_INCREF(function);
  15476. result = __Pyx_PyObject_Call(function, args, NULL);
  15477. Py_DECREF(args);
  15478. Py_DECREF(function);
  15479. return result;
  15480. }
  15481. }
  15482. #endif
  15483. result = __Pyx_PyObject_CallOneArg(method, arg);
  15484. goto done;
  15485. done:
  15486. return result;
  15487. }
  15488. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
  15489. PyObject *method, *result;
  15490. method = __Pyx_PyObject_GetAttrStr(obj, method_name);
  15491. if (unlikely(!method)) return NULL;
  15492. result = __Pyx__PyObject_CallMethod1(method, arg);
  15493. Py_DECREF(method);
  15494. return result;
  15495. }
  15496. /* CoroutineBase */
  15497. #include <structmember.h>
  15498. #include <frameobject.h>
  15499. #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
  15500. static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
  15501. PyObject *et, *ev, *tb;
  15502. PyObject *value = NULL;
  15503. __Pyx_ErrFetch(&et, &ev, &tb);
  15504. if (!et) {
  15505. Py_XDECREF(tb);
  15506. Py_XDECREF(ev);
  15507. Py_INCREF(Py_None);
  15508. *pvalue = Py_None;
  15509. return 0;
  15510. }
  15511. if (likely(et == PyExc_StopIteration)) {
  15512. if (!ev) {
  15513. Py_INCREF(Py_None);
  15514. value = Py_None;
  15515. }
  15516. #if PY_VERSION_HEX >= 0x030300A0
  15517. else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
  15518. value = ((PyStopIterationObject *)ev)->value;
  15519. Py_INCREF(value);
  15520. Py_DECREF(ev);
  15521. }
  15522. #endif
  15523. else if (unlikely(PyTuple_Check(ev))) {
  15524. if (PyTuple_GET_SIZE(ev) >= 1) {
  15525. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  15526. value = PyTuple_GET_ITEM(ev, 0);
  15527. Py_INCREF(value);
  15528. #else
  15529. value = PySequence_ITEM(ev, 0);
  15530. #endif
  15531. } else {
  15532. Py_INCREF(Py_None);
  15533. value = Py_None;
  15534. }
  15535. Py_DECREF(ev);
  15536. }
  15537. else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
  15538. value = ev;
  15539. }
  15540. if (likely(value)) {
  15541. Py_XDECREF(tb);
  15542. Py_DECREF(et);
  15543. *pvalue = value;
  15544. return 0;
  15545. }
  15546. } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
  15547. __Pyx_ErrRestore(et, ev, tb);
  15548. return -1;
  15549. }
  15550. PyErr_NormalizeException(&et, &ev, &tb);
  15551. if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
  15552. __Pyx_ErrRestore(et, ev, tb);
  15553. return -1;
  15554. }
  15555. Py_XDECREF(tb);
  15556. Py_DECREF(et);
  15557. #if PY_VERSION_HEX >= 0x030300A0
  15558. value = ((PyStopIterationObject *)ev)->value;
  15559. Py_INCREF(value);
  15560. Py_DECREF(ev);
  15561. #else
  15562. {
  15563. PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
  15564. Py_DECREF(ev);
  15565. if (likely(args)) {
  15566. value = PySequence_GetItem(args, 0);
  15567. Py_DECREF(args);
  15568. }
  15569. if (unlikely(!value)) {
  15570. __Pyx_ErrRestore(NULL, NULL, NULL);
  15571. Py_INCREF(Py_None);
  15572. value = Py_None;
  15573. }
  15574. }
  15575. #endif
  15576. *pvalue = value;
  15577. return 0;
  15578. }
  15579. static CYTHON_INLINE
  15580. void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
  15581. PyObject *exc_type = self->exc_type;
  15582. PyObject *exc_value = self->exc_value;
  15583. PyObject *exc_traceback = self->exc_traceback;
  15584. self->exc_type = NULL;
  15585. self->exc_value = NULL;
  15586. self->exc_traceback = NULL;
  15587. Py_XDECREF(exc_type);
  15588. Py_XDECREF(exc_value);
  15589. Py_XDECREF(exc_traceback);
  15590. }
  15591. #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
  15592. static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
  15593. const char *msg;
  15594. if (0) {
  15595. #ifdef __Pyx_Coroutine_USED
  15596. } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
  15597. msg = "coroutine already executing";
  15598. #endif
  15599. #ifdef __Pyx_AsyncGen_USED
  15600. } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
  15601. msg = "async generator already executing";
  15602. #endif
  15603. } else {
  15604. msg = "generator already executing";
  15605. }
  15606. PyErr_SetString(PyExc_ValueError, msg);
  15607. }
  15608. #define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
  15609. static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
  15610. const char *msg;
  15611. if (0) {
  15612. #ifdef __Pyx_Coroutine_USED
  15613. } else if (__Pyx_Coroutine_Check(gen)) {
  15614. msg = "can't send non-None value to a just-started coroutine";
  15615. #endif
  15616. #ifdef __Pyx_AsyncGen_USED
  15617. } else if (__Pyx_AsyncGen_CheckExact(gen)) {
  15618. msg = "can't send non-None value to a just-started async generator";
  15619. #endif
  15620. } else {
  15621. msg = "can't send non-None value to a just-started generator";
  15622. }
  15623. PyErr_SetString(PyExc_TypeError, msg);
  15624. }
  15625. #define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
  15626. static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
  15627. #ifdef __Pyx_Coroutine_USED
  15628. if (!closing && __Pyx_Coroutine_Check(gen)) {
  15629. PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
  15630. } else
  15631. #endif
  15632. if (value) {
  15633. #ifdef __Pyx_AsyncGen_USED
  15634. if (__Pyx_AsyncGen_CheckExact(gen))
  15635. PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
  15636. else
  15637. #endif
  15638. PyErr_SetNone(PyExc_StopIteration);
  15639. }
  15640. }
  15641. static
  15642. PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
  15643. __Pyx_PyThreadState_declare
  15644. PyThreadState *tstate;
  15645. PyObject *retval;
  15646. assert(!self->is_running);
  15647. if (unlikely(self->resume_label == 0)) {
  15648. if (unlikely(value && value != Py_None)) {
  15649. return __Pyx_Coroutine_NotStartedError((PyObject*)self);
  15650. }
  15651. }
  15652. if (unlikely(self->resume_label == -1)) {
  15653. return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
  15654. }
  15655. #if CYTHON_FAST_THREAD_STATE
  15656. __Pyx_PyThreadState_assign
  15657. tstate = __pyx_tstate;
  15658. #else
  15659. tstate = __Pyx_PyThreadState_Current;
  15660. #endif
  15661. if (self->exc_type) {
  15662. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  15663. #else
  15664. if (self->exc_traceback) {
  15665. PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
  15666. PyFrameObject *f = tb->tb_frame;
  15667. Py_XINCREF(tstate->frame);
  15668. assert(f->f_back == NULL);
  15669. f->f_back = tstate->frame;
  15670. }
  15671. #endif
  15672. __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
  15673. &self->exc_traceback);
  15674. } else {
  15675. __Pyx_Coroutine_ExceptionClear(self);
  15676. __Pyx_ExceptionSave(&self->exc_type, &self->exc_value, &self->exc_traceback);
  15677. }
  15678. self->is_running = 1;
  15679. retval = self->body((PyObject *) self, tstate, value);
  15680. self->is_running = 0;
  15681. return retval;
  15682. }
  15683. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self) {
  15684. if (likely(self->exc_traceback)) {
  15685. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  15686. #else
  15687. PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
  15688. PyFrameObject *f = tb->tb_frame;
  15689. Py_CLEAR(f->f_back);
  15690. #endif
  15691. }
  15692. }
  15693. static CYTHON_INLINE
  15694. PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
  15695. if (unlikely(!retval)) {
  15696. __Pyx_PyThreadState_declare
  15697. __Pyx_PyThreadState_assign
  15698. if (!__Pyx_PyErr_Occurred()) {
  15699. PyObject *exc = PyExc_StopIteration;
  15700. #ifdef __Pyx_AsyncGen_USED
  15701. if (__Pyx_AsyncGen_CheckExact(gen))
  15702. exc = __Pyx_PyExc_StopAsyncIteration;
  15703. #endif
  15704. __Pyx_PyErr_SetNone(exc);
  15705. }
  15706. }
  15707. return retval;
  15708. }
  15709. static CYTHON_INLINE
  15710. PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
  15711. PyObject *ret;
  15712. PyObject *val = NULL;
  15713. __Pyx_Coroutine_Undelegate(gen);
  15714. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
  15715. ret = __Pyx_Coroutine_SendEx(gen, val, 0);
  15716. Py_XDECREF(val);
  15717. return ret;
  15718. }
  15719. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
  15720. PyObject *retval;
  15721. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  15722. PyObject *yf = gen->yieldfrom;
  15723. if (unlikely(gen->is_running))
  15724. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15725. if (yf) {
  15726. PyObject *ret;
  15727. gen->is_running = 1;
  15728. #ifdef __Pyx_Generator_USED
  15729. if (__Pyx_Generator_CheckExact(yf)) {
  15730. ret = __Pyx_Coroutine_Send(yf, value);
  15731. } else
  15732. #endif
  15733. #ifdef __Pyx_Coroutine_USED
  15734. if (__Pyx_Coroutine_Check(yf)) {
  15735. ret = __Pyx_Coroutine_Send(yf, value);
  15736. } else
  15737. #endif
  15738. #ifdef __Pyx_AsyncGen_USED
  15739. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  15740. ret = __Pyx_async_gen_asend_send(yf, value);
  15741. } else
  15742. #endif
  15743. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
  15744. if (PyGen_CheckExact(yf)) {
  15745. ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  15746. } else
  15747. #endif
  15748. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
  15749. if (PyCoro_CheckExact(yf)) {
  15750. ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  15751. } else
  15752. #endif
  15753. {
  15754. if (value == Py_None)
  15755. ret = Py_TYPE(yf)->tp_iternext(yf);
  15756. else
  15757. ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
  15758. }
  15759. gen->is_running = 0;
  15760. if (likely(ret)) {
  15761. return ret;
  15762. }
  15763. retval = __Pyx_Coroutine_FinishDelegation(gen);
  15764. } else {
  15765. retval = __Pyx_Coroutine_SendEx(gen, value, 0);
  15766. }
  15767. return __Pyx_Coroutine_MethodReturn(self, retval);
  15768. }
  15769. static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
  15770. PyObject *retval = NULL;
  15771. int err = 0;
  15772. #ifdef __Pyx_Generator_USED
  15773. if (__Pyx_Generator_CheckExact(yf)) {
  15774. retval = __Pyx_Coroutine_Close(yf);
  15775. if (!retval)
  15776. return -1;
  15777. } else
  15778. #endif
  15779. #ifdef __Pyx_Coroutine_USED
  15780. if (__Pyx_Coroutine_Check(yf)) {
  15781. retval = __Pyx_Coroutine_Close(yf);
  15782. if (!retval)
  15783. return -1;
  15784. } else
  15785. if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  15786. retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
  15787. if (!retval)
  15788. return -1;
  15789. } else
  15790. #endif
  15791. #ifdef __Pyx_AsyncGen_USED
  15792. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  15793. retval = __Pyx_async_gen_asend_close(yf, NULL);
  15794. } else
  15795. if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
  15796. retval = __Pyx_async_gen_athrow_close(yf, NULL);
  15797. } else
  15798. #endif
  15799. {
  15800. PyObject *meth;
  15801. gen->is_running = 1;
  15802. meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
  15803. if (unlikely(!meth)) {
  15804. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
  15805. PyErr_WriteUnraisable(yf);
  15806. }
  15807. PyErr_Clear();
  15808. } else {
  15809. retval = PyObject_CallFunction(meth, NULL);
  15810. Py_DECREF(meth);
  15811. if (!retval)
  15812. err = -1;
  15813. }
  15814. gen->is_running = 0;
  15815. }
  15816. Py_XDECREF(retval);
  15817. return err;
  15818. }
  15819. static PyObject *__Pyx_Generator_Next(PyObject *self) {
  15820. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  15821. PyObject *yf = gen->yieldfrom;
  15822. if (unlikely(gen->is_running))
  15823. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15824. if (yf) {
  15825. PyObject *ret;
  15826. gen->is_running = 1;
  15827. #ifdef __Pyx_Generator_USED
  15828. if (__Pyx_Generator_CheckExact(yf)) {
  15829. ret = __Pyx_Generator_Next(yf);
  15830. } else
  15831. #endif
  15832. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
  15833. if (PyGen_CheckExact(yf)) {
  15834. ret = _PyGen_Send((PyGenObject*)yf, NULL);
  15835. } else
  15836. #endif
  15837. #ifdef __Pyx_Coroutine_USED
  15838. if (__Pyx_Coroutine_Check(yf)) {
  15839. ret = __Pyx_Coroutine_Send(yf, Py_None);
  15840. } else
  15841. #endif
  15842. ret = Py_TYPE(yf)->tp_iternext(yf);
  15843. gen->is_running = 0;
  15844. if (likely(ret)) {
  15845. return ret;
  15846. }
  15847. return __Pyx_Coroutine_FinishDelegation(gen);
  15848. }
  15849. return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
  15850. }
  15851. static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
  15852. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15853. PyObject *retval, *raised_exception;
  15854. PyObject *yf = gen->yieldfrom;
  15855. int err = 0;
  15856. if (unlikely(gen->is_running))
  15857. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15858. if (yf) {
  15859. Py_INCREF(yf);
  15860. err = __Pyx_Coroutine_CloseIter(gen, yf);
  15861. __Pyx_Coroutine_Undelegate(gen);
  15862. Py_DECREF(yf);
  15863. }
  15864. if (err == 0)
  15865. PyErr_SetNone(PyExc_GeneratorExit);
  15866. retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
  15867. if (unlikely(retval)) {
  15868. const char *msg;
  15869. Py_DECREF(retval);
  15870. if ((0)) {
  15871. #ifdef __Pyx_Coroutine_USED
  15872. } else if (__Pyx_Coroutine_Check(self)) {
  15873. msg = "coroutine ignored GeneratorExit";
  15874. #endif
  15875. #ifdef __Pyx_AsyncGen_USED
  15876. } else if (__Pyx_AsyncGen_CheckExact(self)) {
  15877. #if PY_VERSION_HEX < 0x03060000
  15878. msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
  15879. #else
  15880. msg = "async generator ignored GeneratorExit";
  15881. #endif
  15882. #endif
  15883. } else {
  15884. msg = "generator ignored GeneratorExit";
  15885. }
  15886. PyErr_SetString(PyExc_RuntimeError, msg);
  15887. return NULL;
  15888. }
  15889. raised_exception = PyErr_Occurred();
  15890. if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
  15891. if (raised_exception) PyErr_Clear();
  15892. Py_INCREF(Py_None);
  15893. return Py_None;
  15894. }
  15895. return NULL;
  15896. }
  15897. static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
  15898. PyObject *args, int close_on_genexit) {
  15899. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15900. PyObject *yf = gen->yieldfrom;
  15901. if (unlikely(gen->is_running))
  15902. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15903. if (yf) {
  15904. PyObject *ret;
  15905. Py_INCREF(yf);
  15906. if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
  15907. int err = __Pyx_Coroutine_CloseIter(gen, yf);
  15908. Py_DECREF(yf);
  15909. __Pyx_Coroutine_Undelegate(gen);
  15910. if (err < 0)
  15911. return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
  15912. goto throw_here;
  15913. }
  15914. gen->is_running = 1;
  15915. if (0
  15916. #ifdef __Pyx_Generator_USED
  15917. || __Pyx_Generator_CheckExact(yf)
  15918. #endif
  15919. #ifdef __Pyx_Coroutine_USED
  15920. || __Pyx_Coroutine_Check(yf)
  15921. #endif
  15922. ) {
  15923. ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
  15924. #ifdef __Pyx_Coroutine_USED
  15925. } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  15926. ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
  15927. #endif
  15928. } else {
  15929. PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
  15930. if (unlikely(!meth)) {
  15931. Py_DECREF(yf);
  15932. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
  15933. gen->is_running = 0;
  15934. return NULL;
  15935. }
  15936. PyErr_Clear();
  15937. __Pyx_Coroutine_Undelegate(gen);
  15938. gen->is_running = 0;
  15939. goto throw_here;
  15940. }
  15941. if (likely(args)) {
  15942. ret = PyObject_CallObject(meth, args);
  15943. } else {
  15944. ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
  15945. }
  15946. Py_DECREF(meth);
  15947. }
  15948. gen->is_running = 0;
  15949. Py_DECREF(yf);
  15950. if (!ret) {
  15951. ret = __Pyx_Coroutine_FinishDelegation(gen);
  15952. }
  15953. return __Pyx_Coroutine_MethodReturn(self, ret);
  15954. }
  15955. throw_here:
  15956. __Pyx_Raise(typ, val, tb, NULL);
  15957. return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
  15958. }
  15959. static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
  15960. PyObject *typ;
  15961. PyObject *val = NULL;
  15962. PyObject *tb = NULL;
  15963. if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
  15964. return NULL;
  15965. return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
  15966. }
  15967. static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
  15968. Py_VISIT(gen->closure);
  15969. Py_VISIT(gen->classobj);
  15970. Py_VISIT(gen->yieldfrom);
  15971. Py_VISIT(gen->exc_type);
  15972. Py_VISIT(gen->exc_value);
  15973. Py_VISIT(gen->exc_traceback);
  15974. return 0;
  15975. }
  15976. static int __Pyx_Coroutine_clear(PyObject *self) {
  15977. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15978. Py_CLEAR(gen->closure);
  15979. Py_CLEAR(gen->classobj);
  15980. Py_CLEAR(gen->yieldfrom);
  15981. Py_CLEAR(gen->exc_type);
  15982. Py_CLEAR(gen->exc_value);
  15983. Py_CLEAR(gen->exc_traceback);
  15984. #ifdef __Pyx_AsyncGen_USED
  15985. if (__Pyx_AsyncGen_CheckExact(self)) {
  15986. Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
  15987. }
  15988. #endif
  15989. Py_CLEAR(gen->gi_code);
  15990. Py_CLEAR(gen->gi_name);
  15991. Py_CLEAR(gen->gi_qualname);
  15992. Py_CLEAR(gen->gi_modulename);
  15993. return 0;
  15994. }
  15995. static void __Pyx_Coroutine_dealloc(PyObject *self) {
  15996. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15997. PyObject_GC_UnTrack(gen);
  15998. if (gen->gi_weakreflist != NULL)
  15999. PyObject_ClearWeakRefs(self);
  16000. if (gen->resume_label >= 0) {
  16001. PyObject_GC_Track(self);
  16002. #if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
  16003. if (PyObject_CallFinalizerFromDealloc(self))
  16004. #else
  16005. Py_TYPE(gen)->tp_del(self);
  16006. if (self->ob_refcnt > 0)
  16007. #endif
  16008. {
  16009. return;
  16010. }
  16011. PyObject_GC_UnTrack(self);
  16012. }
  16013. #ifdef __Pyx_AsyncGen_USED
  16014. if (__Pyx_AsyncGen_CheckExact(self)) {
  16015. /* We have to handle this case for asynchronous generators
  16016. right here, because this code has to be between UNTRACK
  16017. and GC_Del. */
  16018. Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
  16019. }
  16020. #endif
  16021. __Pyx_Coroutine_clear(self);
  16022. PyObject_GC_Del(gen);
  16023. }
  16024. static void __Pyx_Coroutine_del(PyObject *self) {
  16025. PyObject *error_type, *error_value, *error_traceback;
  16026. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  16027. __Pyx_PyThreadState_declare
  16028. if (gen->resume_label < 0) {
  16029. return;
  16030. }
  16031. #if !CYTHON_USE_TP_FINALIZE
  16032. assert(self->ob_refcnt == 0);
  16033. self->ob_refcnt = 1;
  16034. #endif
  16035. __Pyx_PyThreadState_assign
  16036. __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
  16037. #ifdef __Pyx_AsyncGen_USED
  16038. if (__Pyx_AsyncGen_CheckExact(self)) {
  16039. __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
  16040. PyObject *finalizer = agen->ag_finalizer;
  16041. if (finalizer && !agen->ag_closed) {
  16042. PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
  16043. if (unlikely(!res)) {
  16044. PyErr_WriteUnraisable(self);
  16045. } else {
  16046. Py_DECREF(res);
  16047. }
  16048. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  16049. return;
  16050. }
  16051. }
  16052. #endif
  16053. if (unlikely(gen->resume_label == 0 && !error_value)) {
  16054. #ifdef __Pyx_Coroutine_USED
  16055. #ifdef __Pyx_Generator_USED
  16056. if (!__Pyx_Generator_CheckExact(self))
  16057. #endif
  16058. {
  16059. PyObject_GC_UnTrack(self);
  16060. #if PY_MAJOR_VERSION >= 3 || defined(PyErr_WarnFormat)
  16061. if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
  16062. PyErr_WriteUnraisable(self);
  16063. #else
  16064. {PyObject *msg;
  16065. char *cmsg;
  16066. #if CYTHON_COMPILING_IN_PYPY
  16067. msg = NULL;
  16068. cmsg = (char*) "coroutine was never awaited";
  16069. #else
  16070. char *cname;
  16071. PyObject *qualname;
  16072. qualname = gen->gi_qualname;
  16073. cname = PyString_AS_STRING(qualname);
  16074. msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
  16075. if (unlikely(!msg)) {
  16076. PyErr_Clear();
  16077. cmsg = (char*) "coroutine was never awaited";
  16078. } else {
  16079. cmsg = PyString_AS_STRING(msg);
  16080. }
  16081. #endif
  16082. if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
  16083. PyErr_WriteUnraisable(self);
  16084. Py_XDECREF(msg);}
  16085. #endif
  16086. PyObject_GC_Track(self);
  16087. }
  16088. #endif
  16089. } else {
  16090. PyObject *res = __Pyx_Coroutine_Close(self);
  16091. if (unlikely(!res)) {
  16092. if (PyErr_Occurred())
  16093. PyErr_WriteUnraisable(self);
  16094. } else {
  16095. Py_DECREF(res);
  16096. }
  16097. }
  16098. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  16099. #if !CYTHON_USE_TP_FINALIZE
  16100. assert(self->ob_refcnt > 0);
  16101. if (--self->ob_refcnt == 0) {
  16102. return;
  16103. }
  16104. {
  16105. Py_ssize_t refcnt = self->ob_refcnt;
  16106. _Py_NewReference(self);
  16107. self->ob_refcnt = refcnt;
  16108. }
  16109. #if CYTHON_COMPILING_IN_CPYTHON
  16110. assert(PyType_IS_GC(self->ob_type) &&
  16111. _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
  16112. _Py_DEC_REFTOTAL;
  16113. #endif
  16114. #ifdef COUNT_ALLOCS
  16115. --Py_TYPE(self)->tp_frees;
  16116. --Py_TYPE(self)->tp_allocs;
  16117. #endif
  16118. #endif
  16119. }
  16120. static PyObject *
  16121. __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
  16122. {
  16123. PyObject *name = self->gi_name;
  16124. if (unlikely(!name)) name = Py_None;
  16125. Py_INCREF(name);
  16126. return name;
  16127. }
  16128. static int
  16129. __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value)
  16130. {
  16131. PyObject *tmp;
  16132. #if PY_MAJOR_VERSION >= 3
  16133. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  16134. #else
  16135. if (unlikely(value == NULL || !PyString_Check(value))) {
  16136. #endif
  16137. PyErr_SetString(PyExc_TypeError,
  16138. "__name__ must be set to a string object");
  16139. return -1;
  16140. }
  16141. tmp = self->gi_name;
  16142. Py_INCREF(value);
  16143. self->gi_name = value;
  16144. Py_XDECREF(tmp);
  16145. return 0;
  16146. }
  16147. static PyObject *
  16148. __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
  16149. {
  16150. PyObject *name = self->gi_qualname;
  16151. if (unlikely(!name)) name = Py_None;
  16152. Py_INCREF(name);
  16153. return name;
  16154. }
  16155. static int
  16156. __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value)
  16157. {
  16158. PyObject *tmp;
  16159. #if PY_MAJOR_VERSION >= 3
  16160. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  16161. #else
  16162. if (unlikely(value == NULL || !PyString_Check(value))) {
  16163. #endif
  16164. PyErr_SetString(PyExc_TypeError,
  16165. "__qualname__ must be set to a string object");
  16166. return -1;
  16167. }
  16168. tmp = self->gi_qualname;
  16169. Py_INCREF(value);
  16170. self->gi_qualname = value;
  16171. Py_XDECREF(tmp);
  16172. return 0;
  16173. }
  16174. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  16175. PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  16176. PyObject *name, PyObject *qualname, PyObject *module_name) {
  16177. __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
  16178. if (unlikely(!gen))
  16179. return NULL;
  16180. return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
  16181. }
  16182. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  16183. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  16184. PyObject *name, PyObject *qualname, PyObject *module_name) {
  16185. gen->body = body;
  16186. gen->closure = closure;
  16187. Py_XINCREF(closure);
  16188. gen->is_running = 0;
  16189. gen->resume_label = 0;
  16190. gen->classobj = NULL;
  16191. gen->yieldfrom = NULL;
  16192. gen->exc_type = NULL;
  16193. gen->exc_value = NULL;
  16194. gen->exc_traceback = NULL;
  16195. gen->gi_weakreflist = NULL;
  16196. Py_XINCREF(qualname);
  16197. gen->gi_qualname = qualname;
  16198. Py_XINCREF(name);
  16199. gen->gi_name = name;
  16200. Py_XINCREF(module_name);
  16201. gen->gi_modulename = module_name;
  16202. Py_XINCREF(code);
  16203. gen->gi_code = code;
  16204. PyObject_GC_Track(gen);
  16205. return gen;
  16206. }
  16207. /* PatchModuleWithCoroutine */
  16208. static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
  16209. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  16210. int result;
  16211. PyObject *globals, *result_obj;
  16212. globals = PyDict_New(); if (unlikely(!globals)) goto ignore;
  16213. result = PyDict_SetItemString(globals, "_cython_coroutine_type",
  16214. #ifdef __Pyx_Coroutine_USED
  16215. (PyObject*)__pyx_CoroutineType);
  16216. #else
  16217. Py_None);
  16218. #endif
  16219. if (unlikely(result < 0)) goto ignore;
  16220. result = PyDict_SetItemString(globals, "_cython_generator_type",
  16221. #ifdef __Pyx_Generator_USED
  16222. (PyObject*)__pyx_GeneratorType);
  16223. #else
  16224. Py_None);
  16225. #endif
  16226. if (unlikely(result < 0)) goto ignore;
  16227. if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
  16228. if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
  16229. result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
  16230. if (unlikely(!result_obj)) goto ignore;
  16231. Py_DECREF(result_obj);
  16232. Py_DECREF(globals);
  16233. return module;
  16234. ignore:
  16235. Py_XDECREF(globals);
  16236. PyErr_WriteUnraisable(module);
  16237. if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
  16238. Py_DECREF(module);
  16239. module = NULL;
  16240. }
  16241. #else
  16242. py_code++;
  16243. #endif
  16244. return module;
  16245. }
  16246. /* PatchGeneratorABC */
  16247. #ifndef CYTHON_REGISTER_ABCS
  16248. #define CYTHON_REGISTER_ABCS 1
  16249. #endif
  16250. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  16251. static PyObject* __Pyx_patch_abc_module(PyObject *module);
  16252. static PyObject* __Pyx_patch_abc_module(PyObject *module) {
  16253. module = __Pyx_Coroutine_patch_module(
  16254. module, ""
  16255. "if _cython_generator_type is not None:\n"
  16256. " try: Generator = _module.Generator\n"
  16257. " except AttributeError: pass\n"
  16258. " else: Generator.register(_cython_generator_type)\n"
  16259. "if _cython_coroutine_type is not None:\n"
  16260. " try: Coroutine = _module.Coroutine\n"
  16261. " except AttributeError: pass\n"
  16262. " else: Coroutine.register(_cython_coroutine_type)\n"
  16263. );
  16264. return module;
  16265. }
  16266. #endif
  16267. static int __Pyx_patch_abc(void) {
  16268. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  16269. static int abc_patched = 0;
  16270. if (CYTHON_REGISTER_ABCS && !abc_patched) {
  16271. PyObject *module;
  16272. module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
  16273. if (!module) {
  16274. PyErr_WriteUnraisable(NULL);
  16275. if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
  16276. ((PY_MAJOR_VERSION >= 3) ?
  16277. "Cython module failed to register with collections.abc module" :
  16278. "Cython module failed to register with collections module"), 1) < 0)) {
  16279. return -1;
  16280. }
  16281. } else {
  16282. module = __Pyx_patch_abc_module(module);
  16283. abc_patched = 1;
  16284. if (unlikely(!module))
  16285. return -1;
  16286. Py_DECREF(module);
  16287. }
  16288. module = PyImport_ImportModule("backports_abc");
  16289. if (module) {
  16290. module = __Pyx_patch_abc_module(module);
  16291. Py_XDECREF(module);
  16292. }
  16293. if (!module) {
  16294. PyErr_Clear();
  16295. }
  16296. }
  16297. #else
  16298. if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
  16299. #endif
  16300. return 0;
  16301. }
  16302. /* Generator */
  16303. static PyMethodDef __pyx_Generator_methods[] = {
  16304. {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
  16305. (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
  16306. {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
  16307. (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
  16308. {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS,
  16309. (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
  16310. {0, 0, 0, 0}
  16311. };
  16312. static PyMemberDef __pyx_Generator_memberlist[] = {
  16313. {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
  16314. {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
  16315. (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
  16316. {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
  16317. {0, 0, 0, 0, 0}
  16318. };
  16319. static PyGetSetDef __pyx_Generator_getsets[] = {
  16320. {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
  16321. (char*) PyDoc_STR("name of the generator"), 0},
  16322. {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
  16323. (char*) PyDoc_STR("qualified name of the generator"), 0},
  16324. {0, 0, 0, 0, 0}
  16325. };
  16326. static PyTypeObject __pyx_GeneratorType_type = {
  16327. PyVarObject_HEAD_INIT(0, 0)
  16328. "generator",
  16329. sizeof(__pyx_CoroutineObject),
  16330. 0,
  16331. (destructor) __Pyx_Coroutine_dealloc,
  16332. 0,
  16333. 0,
  16334. 0,
  16335. 0,
  16336. 0,
  16337. 0,
  16338. 0,
  16339. 0,
  16340. 0,
  16341. 0,
  16342. 0,
  16343. 0,
  16344. 0,
  16345. 0,
  16346. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
  16347. 0,
  16348. (traverseproc) __Pyx_Coroutine_traverse,
  16349. 0,
  16350. 0,
  16351. offsetof(__pyx_CoroutineObject, gi_weakreflist),
  16352. 0,
  16353. (iternextfunc) __Pyx_Generator_Next,
  16354. __pyx_Generator_methods,
  16355. __pyx_Generator_memberlist,
  16356. __pyx_Generator_getsets,
  16357. 0,
  16358. 0,
  16359. 0,
  16360. 0,
  16361. 0,
  16362. 0,
  16363. 0,
  16364. 0,
  16365. 0,
  16366. 0,
  16367. 0,
  16368. 0,
  16369. 0,
  16370. 0,
  16371. 0,
  16372. #if CYTHON_USE_TP_FINALIZE
  16373. 0,
  16374. #else
  16375. __Pyx_Coroutine_del,
  16376. #endif
  16377. 0,
  16378. #if CYTHON_USE_TP_FINALIZE
  16379. __Pyx_Coroutine_del,
  16380. #elif PY_VERSION_HEX >= 0x030400a1
  16381. 0,
  16382. #endif
  16383. };
  16384. static int __pyx_Generator_init(void) {
  16385. __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  16386. __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
  16387. __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
  16388. if (unlikely(!__pyx_GeneratorType)) {
  16389. return -1;
  16390. }
  16391. return 0;
  16392. }
  16393. /* CheckBinaryVersion */
  16394. static int __Pyx_check_binary_version(void) {
  16395. char ctversion[4], rtversion[4];
  16396. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  16397. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  16398. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  16399. char message[200];
  16400. PyOS_snprintf(message, sizeof(message),
  16401. "compiletime version %s of module '%.100s' "
  16402. "does not match runtime version %s",
  16403. ctversion, __Pyx_MODULE_NAME, rtversion);
  16404. return PyErr_WarnEx(NULL, message, 1);
  16405. }
  16406. return 0;
  16407. }
  16408. /* VoidPtrExport */
  16409. static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
  16410. PyObject *d;
  16411. PyObject *cobj = 0;
  16412. d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
  16413. Py_XINCREF(d);
  16414. if (!d) {
  16415. d = PyDict_New();
  16416. if (!d)
  16417. goto bad;
  16418. if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
  16419. goto bad;
  16420. }
  16421. #if PY_VERSION_HEX >= 0x02070000
  16422. cobj = PyCapsule_New(p, sig, 0);
  16423. #else
  16424. cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
  16425. #endif
  16426. if (!cobj)
  16427. goto bad;
  16428. if (PyDict_SetItem(d, name, cobj) < 0)
  16429. goto bad;
  16430. Py_DECREF(cobj);
  16431. Py_DECREF(d);
  16432. return 0;
  16433. bad:
  16434. Py_XDECREF(cobj);
  16435. Py_XDECREF(d);
  16436. return -1;
  16437. }
  16438. /* FunctionExport */
  16439. static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
  16440. PyObject *d = 0;
  16441. PyObject *cobj = 0;
  16442. union {
  16443. void (*fp)(void);
  16444. void *p;
  16445. } tmp;
  16446. d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
  16447. if (!d) {
  16448. PyErr_Clear();
  16449. d = PyDict_New();
  16450. if (!d)
  16451. goto bad;
  16452. Py_INCREF(d);
  16453. if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
  16454. goto bad;
  16455. }
  16456. tmp.fp = f;
  16457. #if PY_VERSION_HEX >= 0x02070000
  16458. cobj = PyCapsule_New(tmp.p, sig, 0);
  16459. #else
  16460. cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
  16461. #endif
  16462. if (!cobj)
  16463. goto bad;
  16464. if (PyDict_SetItemString(d, name, cobj) < 0)
  16465. goto bad;
  16466. Py_DECREF(cobj);
  16467. Py_DECREF(d);
  16468. return 0;
  16469. bad:
  16470. Py_XDECREF(cobj);
  16471. Py_XDECREF(d);
  16472. return -1;
  16473. }
  16474. /* InitStrings */
  16475. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  16476. while (t->p) {
  16477. #if PY_MAJOR_VERSION < 3
  16478. if (t->is_unicode) {
  16479. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  16480. } else if (t->intern) {
  16481. *t->p = PyString_InternFromString(t->s);
  16482. } else {
  16483. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  16484. }
  16485. #else
  16486. if (t->is_unicode | t->is_str) {
  16487. if (t->intern) {
  16488. *t->p = PyUnicode_InternFromString(t->s);
  16489. } else if (t->encoding) {
  16490. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  16491. } else {
  16492. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  16493. }
  16494. } else {
  16495. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  16496. }
  16497. #endif
  16498. if (!*t->p)
  16499. return -1;
  16500. if (PyObject_Hash(*t->p) == -1)
  16501. return -1;
  16502. ++t;
  16503. }
  16504. return 0;
  16505. }
  16506. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  16507. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  16508. }
  16509. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  16510. Py_ssize_t ignore;
  16511. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  16512. }
  16513. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  16514. #if !CYTHON_PEP393_ENABLED
  16515. static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  16516. char* defenc_c;
  16517. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  16518. if (!defenc) return NULL;
  16519. defenc_c = PyBytes_AS_STRING(defenc);
  16520. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16521. {
  16522. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  16523. char* c;
  16524. for (c = defenc_c; c < end; c++) {
  16525. if ((unsigned char) (*c) >= 128) {
  16526. PyUnicode_AsASCIIString(o);
  16527. return NULL;
  16528. }
  16529. }
  16530. }
  16531. #endif
  16532. *length = PyBytes_GET_SIZE(defenc);
  16533. return defenc_c;
  16534. }
  16535. #else
  16536. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  16537. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  16538. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16539. if (likely(PyUnicode_IS_ASCII(o))) {
  16540. *length = PyUnicode_GET_LENGTH(o);
  16541. return PyUnicode_AsUTF8(o);
  16542. } else {
  16543. PyUnicode_AsASCIIString(o);
  16544. return NULL;
  16545. }
  16546. #else
  16547. return PyUnicode_AsUTF8AndSize(o, length);
  16548. #endif
  16549. }
  16550. #endif
  16551. #endif
  16552. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  16553. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  16554. if (
  16555. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16556. __Pyx_sys_getdefaultencoding_not_ascii &&
  16557. #endif
  16558. PyUnicode_Check(o)) {
  16559. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  16560. } else
  16561. #endif
  16562. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  16563. if (PyByteArray_Check(o)) {
  16564. *length = PyByteArray_GET_SIZE(o);
  16565. return PyByteArray_AS_STRING(o);
  16566. } else
  16567. #endif
  16568. {
  16569. char* result;
  16570. int r = PyBytes_AsStringAndSize(o, &result, length);
  16571. if (unlikely(r < 0)) {
  16572. return NULL;
  16573. } else {
  16574. return result;
  16575. }
  16576. }
  16577. }
  16578. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  16579. int is_true = x == Py_True;
  16580. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  16581. else return PyObject_IsTrue(x);
  16582. }
  16583. static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
  16584. #if PY_MAJOR_VERSION >= 3
  16585. if (PyLong_Check(result)) {
  16586. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  16587. "__int__ returned non-int (type %.200s). "
  16588. "The ability to return an instance of a strict subclass of int "
  16589. "is deprecated, and may be removed in a future version of Python.",
  16590. Py_TYPE(result)->tp_name)) {
  16591. Py_DECREF(result);
  16592. return NULL;
  16593. }
  16594. return result;
  16595. }
  16596. #endif
  16597. PyErr_Format(PyExc_TypeError,
  16598. "__%.4s__ returned non-%.4s (type %.200s)",
  16599. type_name, type_name, Py_TYPE(result)->tp_name);
  16600. Py_DECREF(result);
  16601. return NULL;
  16602. }
  16603. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  16604. #if CYTHON_USE_TYPE_SLOTS
  16605. PyNumberMethods *m;
  16606. #endif
  16607. const char *name = NULL;
  16608. PyObject *res = NULL;
  16609. #if PY_MAJOR_VERSION < 3
  16610. if (likely(PyInt_Check(x) || PyLong_Check(x)))
  16611. #else
  16612. if (likely(PyLong_Check(x)))
  16613. #endif
  16614. return __Pyx_NewRef(x);
  16615. #if CYTHON_USE_TYPE_SLOTS
  16616. m = Py_TYPE(x)->tp_as_number;
  16617. #if PY_MAJOR_VERSION < 3
  16618. if (m && m->nb_int) {
  16619. name = "int";
  16620. res = m->nb_int(x);
  16621. }
  16622. else if (m && m->nb_long) {
  16623. name = "long";
  16624. res = m->nb_long(x);
  16625. }
  16626. #else
  16627. if (likely(m && m->nb_int)) {
  16628. name = "int";
  16629. res = m->nb_int(x);
  16630. }
  16631. #endif
  16632. #else
  16633. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  16634. res = PyNumber_Int(x);
  16635. }
  16636. #endif
  16637. if (likely(res)) {
  16638. #if PY_MAJOR_VERSION < 3
  16639. if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
  16640. #else
  16641. if (unlikely(!PyLong_CheckExact(res))) {
  16642. #endif
  16643. return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
  16644. }
  16645. }
  16646. else if (!PyErr_Occurred()) {
  16647. PyErr_SetString(PyExc_TypeError,
  16648. "an integer is required");
  16649. }
  16650. return res;
  16651. }
  16652. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  16653. Py_ssize_t ival;
  16654. PyObject *x;
  16655. #if PY_MAJOR_VERSION < 3
  16656. if (likely(PyInt_CheckExact(b))) {
  16657. if (sizeof(Py_ssize_t) >= sizeof(long))
  16658. return PyInt_AS_LONG(b);
  16659. else
  16660. return PyInt_AsSsize_t(x);
  16661. }
  16662. #endif
  16663. if (likely(PyLong_CheckExact(b))) {
  16664. #if CYTHON_USE_PYLONG_INTERNALS
  16665. const digit* digits = ((PyLongObject*)b)->ob_digit;
  16666. const Py_ssize_t size = Py_SIZE(b);
  16667. if (likely(__Pyx_sst_abs(size) <= 1)) {
  16668. ival = likely(size) ? digits[0] : 0;
  16669. if (size == -1) ival = -ival;
  16670. return ival;
  16671. } else {
  16672. switch (size) {
  16673. case 2:
  16674. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  16675. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16676. }
  16677. break;
  16678. case -2:
  16679. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  16680. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16681. }
  16682. break;
  16683. case 3:
  16684. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  16685. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16686. }
  16687. break;
  16688. case -3:
  16689. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  16690. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16691. }
  16692. break;
  16693. case 4:
  16694. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  16695. return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16696. }
  16697. break;
  16698. case -4:
  16699. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  16700. return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16701. }
  16702. break;
  16703. }
  16704. }
  16705. #endif
  16706. return PyLong_AsSsize_t(b);
  16707. }
  16708. x = PyNumber_Index(b);
  16709. if (!x) return -1;
  16710. ival = PyInt_AsSsize_t(x);
  16711. Py_DECREF(x);
  16712. return ival;
  16713. }
  16714. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  16715. return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
  16716. }
  16717. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  16718. return PyInt_FromSize_t(ival);
  16719. }
  16720. #endif /* Py_PYTHON_H */