base_lmdb_store.c 743 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467
  1. /* Generated by Cython 0.28.4 */
  2. /* BEGIN: Cython Metadata
  3. {
  4. "distutils": {
  5. "depends": [],
  6. "include_dirs": [
  7. "/home/scossu/code/lsup/src/ext/include",
  8. "/home/scossu/code/lsup/src/lakesuperior/cy_include"
  9. ],
  10. "name": "lakesuperior.store.base_lmdb_store",
  11. "sources": [
  12. "/home/scossu/code/lsup/src/lakesuperior/store/base_lmdb_store.pyx",
  13. "/home/scossu/code/lsup/src/ext/lib/mdb.c",
  14. "/home/scossu/code/lsup/src/ext/lib/midl.c"
  15. ]
  16. },
  17. "module_name": "lakesuperior.store.base_lmdb_store"
  18. }
  19. END: Cython Metadata */
  20. #define PY_SSIZE_T_CLEAN
  21. #include "Python.h"
  22. #ifndef Py_PYTHON_H
  23. #error Python headers needed to compile C extensions, please install development version of Python.
  24. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
  25. #error Cython requires Python 2.6+ or Python 3.3+.
  26. #else
  27. #define CYTHON_ABI "0_28_4"
  28. #define CYTHON_FUTURE_DIVISION 1
  29. #include <stddef.h>
  30. #ifndef offsetof
  31. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  32. #endif
  33. #if !defined(WIN32) && !defined(MS_WINDOWS)
  34. #ifndef __stdcall
  35. #define __stdcall
  36. #endif
  37. #ifndef __cdecl
  38. #define __cdecl
  39. #endif
  40. #ifndef __fastcall
  41. #define __fastcall
  42. #endif
  43. #endif
  44. #ifndef DL_IMPORT
  45. #define DL_IMPORT(t) t
  46. #endif
  47. #ifndef DL_EXPORT
  48. #define DL_EXPORT(t) t
  49. #endif
  50. #define __PYX_COMMA ,
  51. #ifndef HAVE_LONG_LONG
  52. #if PY_VERSION_HEX >= 0x02070000
  53. #define HAVE_LONG_LONG
  54. #endif
  55. #endif
  56. #ifndef PY_LONG_LONG
  57. #define PY_LONG_LONG LONG_LONG
  58. #endif
  59. #ifndef Py_HUGE_VAL
  60. #define Py_HUGE_VAL HUGE_VAL
  61. #endif
  62. #ifdef PYPY_VERSION
  63. #define CYTHON_COMPILING_IN_PYPY 1
  64. #define CYTHON_COMPILING_IN_PYSTON 0
  65. #define CYTHON_COMPILING_IN_CPYTHON 0
  66. #undef CYTHON_USE_TYPE_SLOTS
  67. #define CYTHON_USE_TYPE_SLOTS 0
  68. #undef CYTHON_USE_PYTYPE_LOOKUP
  69. #define CYTHON_USE_PYTYPE_LOOKUP 0
  70. #if PY_VERSION_HEX < 0x03050000
  71. #undef CYTHON_USE_ASYNC_SLOTS
  72. #define CYTHON_USE_ASYNC_SLOTS 0
  73. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  74. #define CYTHON_USE_ASYNC_SLOTS 1
  75. #endif
  76. #undef CYTHON_USE_PYLIST_INTERNALS
  77. #define CYTHON_USE_PYLIST_INTERNALS 0
  78. #undef CYTHON_USE_UNICODE_INTERNALS
  79. #define CYTHON_USE_UNICODE_INTERNALS 0
  80. #undef CYTHON_USE_UNICODE_WRITER
  81. #define CYTHON_USE_UNICODE_WRITER 0
  82. #undef CYTHON_USE_PYLONG_INTERNALS
  83. #define CYTHON_USE_PYLONG_INTERNALS 0
  84. #undef CYTHON_AVOID_BORROWED_REFS
  85. #define CYTHON_AVOID_BORROWED_REFS 1
  86. #undef CYTHON_ASSUME_SAFE_MACROS
  87. #define CYTHON_ASSUME_SAFE_MACROS 0
  88. #undef CYTHON_UNPACK_METHODS
  89. #define CYTHON_UNPACK_METHODS 0
  90. #undef CYTHON_FAST_THREAD_STATE
  91. #define CYTHON_FAST_THREAD_STATE 0
  92. #undef CYTHON_FAST_PYCALL
  93. #define CYTHON_FAST_PYCALL 0
  94. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  95. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  96. #undef CYTHON_USE_TP_FINALIZE
  97. #define CYTHON_USE_TP_FINALIZE 0
  98. #elif defined(PYSTON_VERSION)
  99. #define CYTHON_COMPILING_IN_PYPY 0
  100. #define CYTHON_COMPILING_IN_PYSTON 1
  101. #define CYTHON_COMPILING_IN_CPYTHON 0
  102. #ifndef CYTHON_USE_TYPE_SLOTS
  103. #define CYTHON_USE_TYPE_SLOTS 1
  104. #endif
  105. #undef CYTHON_USE_PYTYPE_LOOKUP
  106. #define CYTHON_USE_PYTYPE_LOOKUP 0
  107. #undef CYTHON_USE_ASYNC_SLOTS
  108. #define CYTHON_USE_ASYNC_SLOTS 0
  109. #undef CYTHON_USE_PYLIST_INTERNALS
  110. #define CYTHON_USE_PYLIST_INTERNALS 0
  111. #ifndef CYTHON_USE_UNICODE_INTERNALS
  112. #define CYTHON_USE_UNICODE_INTERNALS 1
  113. #endif
  114. #undef CYTHON_USE_UNICODE_WRITER
  115. #define CYTHON_USE_UNICODE_WRITER 0
  116. #undef CYTHON_USE_PYLONG_INTERNALS
  117. #define CYTHON_USE_PYLONG_INTERNALS 0
  118. #ifndef CYTHON_AVOID_BORROWED_REFS
  119. #define CYTHON_AVOID_BORROWED_REFS 0
  120. #endif
  121. #ifndef CYTHON_ASSUME_SAFE_MACROS
  122. #define CYTHON_ASSUME_SAFE_MACROS 1
  123. #endif
  124. #ifndef CYTHON_UNPACK_METHODS
  125. #define CYTHON_UNPACK_METHODS 1
  126. #endif
  127. #undef CYTHON_FAST_THREAD_STATE
  128. #define CYTHON_FAST_THREAD_STATE 0
  129. #undef CYTHON_FAST_PYCALL
  130. #define CYTHON_FAST_PYCALL 0
  131. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  132. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  133. #undef CYTHON_USE_TP_FINALIZE
  134. #define CYTHON_USE_TP_FINALIZE 0
  135. #else
  136. #define CYTHON_COMPILING_IN_PYPY 0
  137. #define CYTHON_COMPILING_IN_PYSTON 0
  138. #define CYTHON_COMPILING_IN_CPYTHON 1
  139. #ifndef CYTHON_USE_TYPE_SLOTS
  140. #define CYTHON_USE_TYPE_SLOTS 1
  141. #endif
  142. #if PY_VERSION_HEX < 0x02070000
  143. #undef CYTHON_USE_PYTYPE_LOOKUP
  144. #define CYTHON_USE_PYTYPE_LOOKUP 0
  145. #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
  146. #define CYTHON_USE_PYTYPE_LOOKUP 1
  147. #endif
  148. #if PY_MAJOR_VERSION < 3
  149. #undef CYTHON_USE_ASYNC_SLOTS
  150. #define CYTHON_USE_ASYNC_SLOTS 0
  151. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  152. #define CYTHON_USE_ASYNC_SLOTS 1
  153. #endif
  154. #if PY_VERSION_HEX < 0x02070000
  155. #undef CYTHON_USE_PYLONG_INTERNALS
  156. #define CYTHON_USE_PYLONG_INTERNALS 0
  157. #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
  158. #define CYTHON_USE_PYLONG_INTERNALS 1
  159. #endif
  160. #ifndef CYTHON_USE_PYLIST_INTERNALS
  161. #define CYTHON_USE_PYLIST_INTERNALS 1
  162. #endif
  163. #ifndef CYTHON_USE_UNICODE_INTERNALS
  164. #define CYTHON_USE_UNICODE_INTERNALS 1
  165. #endif
  166. #if PY_VERSION_HEX < 0x030300F0
  167. #undef CYTHON_USE_UNICODE_WRITER
  168. #define CYTHON_USE_UNICODE_WRITER 0
  169. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  170. #define CYTHON_USE_UNICODE_WRITER 1
  171. #endif
  172. #ifndef CYTHON_AVOID_BORROWED_REFS
  173. #define CYTHON_AVOID_BORROWED_REFS 0
  174. #endif
  175. #ifndef CYTHON_ASSUME_SAFE_MACROS
  176. #define CYTHON_ASSUME_SAFE_MACROS 1
  177. #endif
  178. #ifndef CYTHON_UNPACK_METHODS
  179. #define CYTHON_UNPACK_METHODS 1
  180. #endif
  181. #ifndef CYTHON_FAST_THREAD_STATE
  182. #define CYTHON_FAST_THREAD_STATE 1
  183. #endif
  184. #ifndef CYTHON_FAST_PYCALL
  185. #define CYTHON_FAST_PYCALL 1
  186. #endif
  187. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  188. #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
  189. #endif
  190. #ifndef CYTHON_USE_TP_FINALIZE
  191. #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  192. #endif
  193. #endif
  194. #if !defined(CYTHON_FAST_PYCCALL)
  195. #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
  196. #endif
  197. #if CYTHON_USE_PYLONG_INTERNALS
  198. #include "longintrepr.h"
  199. #undef SHIFT
  200. #undef BASE
  201. #undef MASK
  202. #endif
  203. #ifndef __has_attribute
  204. #define __has_attribute(x) 0
  205. #endif
  206. #ifndef __has_cpp_attribute
  207. #define __has_cpp_attribute(x) 0
  208. #endif
  209. #ifndef CYTHON_RESTRICT
  210. #if defined(__GNUC__)
  211. #define CYTHON_RESTRICT __restrict__
  212. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  213. #define CYTHON_RESTRICT __restrict
  214. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  215. #define CYTHON_RESTRICT restrict
  216. #else
  217. #define CYTHON_RESTRICT
  218. #endif
  219. #endif
  220. #ifndef CYTHON_UNUSED
  221. # if defined(__GNUC__)
  222. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  223. # define CYTHON_UNUSED __attribute__ ((__unused__))
  224. # else
  225. # define CYTHON_UNUSED
  226. # endif
  227. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  228. # define CYTHON_UNUSED __attribute__ ((__unused__))
  229. # else
  230. # define CYTHON_UNUSED
  231. # endif
  232. #endif
  233. #ifndef CYTHON_MAYBE_UNUSED_VAR
  234. # if defined(__cplusplus)
  235. template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
  236. # else
  237. # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
  238. # endif
  239. #endif
  240. #ifndef CYTHON_NCP_UNUSED
  241. # if CYTHON_COMPILING_IN_CPYTHON
  242. # define CYTHON_NCP_UNUSED
  243. # else
  244. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  245. # endif
  246. #endif
  247. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  248. #ifdef _MSC_VER
  249. #ifndef _MSC_STDINT_H_
  250. #if _MSC_VER < 1300
  251. typedef unsigned char uint8_t;
  252. typedef unsigned int uint32_t;
  253. #else
  254. typedef unsigned __int8 uint8_t;
  255. typedef unsigned __int32 uint32_t;
  256. #endif
  257. #endif
  258. #else
  259. #include <stdint.h>
  260. #endif
  261. #ifndef CYTHON_FALLTHROUGH
  262. #if defined(__cplusplus) && __cplusplus >= 201103L
  263. #if __has_cpp_attribute(fallthrough)
  264. #define CYTHON_FALLTHROUGH [[fallthrough]]
  265. #elif __has_cpp_attribute(clang::fallthrough)
  266. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  267. #elif __has_cpp_attribute(gnu::fallthrough)
  268. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  269. #endif
  270. #endif
  271. #ifndef CYTHON_FALLTHROUGH
  272. #if __has_attribute(fallthrough)
  273. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  274. #else
  275. #define CYTHON_FALLTHROUGH
  276. #endif
  277. #endif
  278. #if defined(__clang__ ) && defined(__apple_build_version__)
  279. #if __apple_build_version__ < 7000000
  280. #undef CYTHON_FALLTHROUGH
  281. #define CYTHON_FALLTHROUGH
  282. #endif
  283. #endif
  284. #endif
  285. #ifndef CYTHON_INLINE
  286. #if defined(__clang__)
  287. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  288. #elif defined(__GNUC__)
  289. #define CYTHON_INLINE __inline__
  290. #elif defined(_MSC_VER)
  291. #define CYTHON_INLINE __inline
  292. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  293. #define CYTHON_INLINE inline
  294. #else
  295. #define CYTHON_INLINE
  296. #endif
  297. #endif
  298. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  299. #define Py_OptimizeFlag 0
  300. #endif
  301. #define __PYX_BUILD_PY_SSIZE_T "n"
  302. #define CYTHON_FORMAT_SSIZE_T "z"
  303. #if PY_MAJOR_VERSION < 3
  304. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  305. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  306. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  307. #define __Pyx_DefaultClassType PyClass_Type
  308. #else
  309. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  310. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  311. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  312. #define __Pyx_DefaultClassType PyType_Type
  313. #endif
  314. #ifndef Py_TPFLAGS_CHECKTYPES
  315. #define Py_TPFLAGS_CHECKTYPES 0
  316. #endif
  317. #ifndef Py_TPFLAGS_HAVE_INDEX
  318. #define Py_TPFLAGS_HAVE_INDEX 0
  319. #endif
  320. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  321. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  322. #endif
  323. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  324. #define Py_TPFLAGS_HAVE_FINALIZE 0
  325. #endif
  326. #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  327. #ifndef METH_FASTCALL
  328. #define METH_FASTCALL 0x80
  329. #endif
  330. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  331. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  332. Py_ssize_t nargs, PyObject *kwnames);
  333. #else
  334. #define __Pyx_PyCFunctionFast _PyCFunctionFast
  335. #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  336. #endif
  337. #if CYTHON_FAST_PYCCALL
  338. #define __Pyx_PyFastCFunction_Check(func)\
  339. ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
  340. #else
  341. #define __Pyx_PyFastCFunction_Check(func) 0
  342. #endif
  343. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  344. #define PyObject_Malloc(s) PyMem_Malloc(s)
  345. #define PyObject_Free(p) PyMem_Free(p)
  346. #define PyObject_Realloc(p) PyMem_Realloc(p)
  347. #endif
  348. #if CYTHON_COMPILING_IN_PYSTON
  349. #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
  350. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
  351. #else
  352. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  353. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  354. #endif
  355. #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  356. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  357. #elif PY_VERSION_HEX >= 0x03060000
  358. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  359. #elif PY_VERSION_HEX >= 0x03000000
  360. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  361. #else
  362. #define __Pyx_PyThreadState_Current _PyThreadState_Current
  363. #endif
  364. #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
  365. #include "pythread.h"
  366. #define Py_tss_NEEDS_INIT 0
  367. typedef int Py_tss_t;
  368. static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  369. *key = PyThread_create_key();
  370. return 0; // PyThread_create_key reports success always
  371. }
  372. static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  373. Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  374. *key = Py_tss_NEEDS_INIT;
  375. return key;
  376. }
  377. static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  378. PyObject_Free(key);
  379. }
  380. static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  381. return *key != Py_tss_NEEDS_INIT;
  382. }
  383. static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  384. PyThread_delete_key(*key);
  385. *key = Py_tss_NEEDS_INIT;
  386. }
  387. static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  388. return PyThread_set_key_value(*key, value);
  389. }
  390. static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  391. return PyThread_get_key_value(*key);
  392. }
  393. #endif // TSS (Thread Specific Storage) API
  394. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  395. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  396. #else
  397. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  398. #endif
  399. #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  400. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  401. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  402. #else
  403. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  404. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  405. #endif
  406. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
  407. #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  408. #else
  409. #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
  410. #endif
  411. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  412. #define CYTHON_PEP393_ENABLED 1
  413. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  414. 0 : _PyUnicode_Ready((PyObject *)(op)))
  415. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  416. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  417. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  418. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  419. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  420. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  421. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
  422. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  423. #else
  424. #define CYTHON_PEP393_ENABLED 0
  425. #define PyUnicode_1BYTE_KIND 1
  426. #define PyUnicode_2BYTE_KIND 2
  427. #define PyUnicode_4BYTE_KIND 4
  428. #define __Pyx_PyUnicode_READY(op) (0)
  429. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  430. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  431. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  432. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  433. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  434. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  435. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  436. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  437. #endif
  438. #if CYTHON_COMPILING_IN_PYPY
  439. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  440. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  441. #else
  442. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  443. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  444. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  445. #endif
  446. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  447. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  448. #endif
  449. #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  450. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  451. #endif
  452. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  453. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  454. #endif
  455. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  456. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  457. #if PY_MAJOR_VERSION >= 3
  458. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  459. #else
  460. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  461. #endif
  462. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  463. #define PyObject_ASCII(o) PyObject_Repr(o)
  464. #endif
  465. #if PY_MAJOR_VERSION >= 3
  466. #define PyBaseString_Type PyUnicode_Type
  467. #define PyStringObject PyUnicodeObject
  468. #define PyString_Type PyUnicode_Type
  469. #define PyString_Check PyUnicode_Check
  470. #define PyString_CheckExact PyUnicode_CheckExact
  471. #define PyObject_Unicode PyObject_Str
  472. #endif
  473. #if PY_MAJOR_VERSION >= 3
  474. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  475. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  476. #else
  477. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  478. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  479. #endif
  480. #ifndef PySet_CheckExact
  481. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  482. #endif
  483. #if CYTHON_ASSUME_SAFE_MACROS
  484. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  485. #else
  486. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  487. #endif
  488. #if PY_MAJOR_VERSION >= 3
  489. #define PyIntObject PyLongObject
  490. #define PyInt_Type PyLong_Type
  491. #define PyInt_Check(op) PyLong_Check(op)
  492. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  493. #define PyInt_FromString PyLong_FromString
  494. #define PyInt_FromUnicode PyLong_FromUnicode
  495. #define PyInt_FromLong PyLong_FromLong
  496. #define PyInt_FromSize_t PyLong_FromSize_t
  497. #define PyInt_FromSsize_t PyLong_FromSsize_t
  498. #define PyInt_AsLong PyLong_AsLong
  499. #define PyInt_AS_LONG PyLong_AS_LONG
  500. #define PyInt_AsSsize_t PyLong_AsSsize_t
  501. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  502. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  503. #define PyNumber_Int PyNumber_Long
  504. #endif
  505. #if PY_MAJOR_VERSION >= 3
  506. #define PyBoolObject PyLongObject
  507. #endif
  508. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  509. #ifndef PyUnicode_InternFromString
  510. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  511. #endif
  512. #endif
  513. #if PY_VERSION_HEX < 0x030200A4
  514. typedef long Py_hash_t;
  515. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  516. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  517. #else
  518. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  519. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  520. #endif
  521. #if PY_MAJOR_VERSION >= 3
  522. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
  523. #else
  524. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  525. #endif
  526. #if CYTHON_USE_ASYNC_SLOTS
  527. #if PY_VERSION_HEX >= 0x030500B1
  528. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  529. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  530. #else
  531. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  532. #endif
  533. #else
  534. #define __Pyx_PyType_AsAsync(obj) NULL
  535. #endif
  536. #ifndef __Pyx_PyAsyncMethodsStruct
  537. typedef struct {
  538. unaryfunc am_await;
  539. unaryfunc am_aiter;
  540. unaryfunc am_anext;
  541. } __Pyx_PyAsyncMethodsStruct;
  542. #endif
  543. #if defined(WIN32) || defined(MS_WINDOWS)
  544. #define _USE_MATH_DEFINES
  545. #endif
  546. #include <math.h>
  547. #ifdef NAN
  548. #define __PYX_NAN() ((float) NAN)
  549. #else
  550. static CYTHON_INLINE float __PYX_NAN() {
  551. float value;
  552. memset(&value, 0xFF, sizeof(value));
  553. return value;
  554. }
  555. #endif
  556. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  557. #define __Pyx_truncl trunc
  558. #else
  559. #define __Pyx_truncl truncl
  560. #endif
  561. #define __PYX_ERR(f_index, lineno, Ln_error) \
  562. { \
  563. __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
  564. }
  565. #ifndef __PYX_EXTERN_C
  566. #ifdef __cplusplus
  567. #define __PYX_EXTERN_C extern "C"
  568. #else
  569. #define __PYX_EXTERN_C extern
  570. #endif
  571. #endif
  572. #define __PYX_HAVE__lakesuperior__store__base_lmdb_store
  573. #define __PYX_HAVE_API__lakesuperior__store__base_lmdb_store
  574. /* Early includes */
  575. #include <stdint.h>
  576. #include <sys/types.h>
  577. #include "lmdb.h"
  578. #include <errno.h>
  579. #ifdef _OPENMP
  580. #include <omp.h>
  581. #endif /* _OPENMP */
  582. #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
  583. #define CYTHON_WITHOUT_ASSERTIONS
  584. #endif
  585. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  586. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  587. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  588. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  589. #define __PYX_DEFAULT_STRING_ENCODING ""
  590. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  591. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  592. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  593. #define __Pyx_long_cast(x) ((long)x)
  594. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  595. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  596. (sizeof(type) > sizeof(Py_ssize_t) &&\
  597. likely(v < (type)PY_SSIZE_T_MAX ||\
  598. v == (type)PY_SSIZE_T_MAX) &&\
  599. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  600. v == (type)PY_SSIZE_T_MIN))) ||\
  601. (sizeof(type) == sizeof(Py_ssize_t) &&\
  602. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  603. v == (type)PY_SSIZE_T_MAX))) )
  604. #if defined (__cplusplus) && __cplusplus >= 201103L
  605. #include <cstdlib>
  606. #define __Pyx_sst_abs(value) std::abs(value)
  607. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  608. #define __Pyx_sst_abs(value) abs(value)
  609. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  610. #define __Pyx_sst_abs(value) labs(value)
  611. #elif defined (_MSC_VER)
  612. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  613. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  614. #define __Pyx_sst_abs(value) llabs(value)
  615. #elif defined (__GNUC__)
  616. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  617. #else
  618. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  619. #endif
  620. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  621. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  622. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  623. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  624. #define __Pyx_PyBytes_FromString PyBytes_FromString
  625. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  626. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  627. #if PY_MAJOR_VERSION < 3
  628. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  629. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  630. #else
  631. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  632. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  633. #endif
  634. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  635. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  636. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  637. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  638. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  639. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  640. #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
  641. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  642. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  643. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  644. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  645. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  646. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  647. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  648. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  649. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  650. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
  651. const Py_UNICODE *u_end = u;
  652. while (*u_end++) ;
  653. return (size_t)(u_end - u - 1);
  654. }
  655. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  656. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  657. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  658. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  659. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  660. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  661. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  662. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  663. #define __Pyx_PySequence_Tuple(obj)\
  664. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  665. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  666. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  667. #if CYTHON_ASSUME_SAFE_MACROS
  668. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  669. #else
  670. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  671. #endif
  672. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  673. #if PY_MAJOR_VERSION >= 3
  674. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  675. #else
  676. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  677. #endif
  678. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  679. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  680. static int __Pyx_sys_getdefaultencoding_not_ascii;
  681. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  682. PyObject* sys;
  683. PyObject* default_encoding = NULL;
  684. PyObject* ascii_chars_u = NULL;
  685. PyObject* ascii_chars_b = NULL;
  686. const char* default_encoding_c;
  687. sys = PyImport_ImportModule("sys");
  688. if (!sys) goto bad;
  689. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  690. Py_DECREF(sys);
  691. if (!default_encoding) goto bad;
  692. default_encoding_c = PyBytes_AsString(default_encoding);
  693. if (!default_encoding_c) goto bad;
  694. if (strcmp(default_encoding_c, "ascii") == 0) {
  695. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  696. } else {
  697. char ascii_chars[128];
  698. int c;
  699. for (c = 0; c < 128; c++) {
  700. ascii_chars[c] = c;
  701. }
  702. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  703. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  704. if (!ascii_chars_u) goto bad;
  705. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  706. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  707. PyErr_Format(
  708. PyExc_ValueError,
  709. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  710. default_encoding_c);
  711. goto bad;
  712. }
  713. Py_DECREF(ascii_chars_u);
  714. Py_DECREF(ascii_chars_b);
  715. }
  716. Py_DECREF(default_encoding);
  717. return 0;
  718. bad:
  719. Py_XDECREF(default_encoding);
  720. Py_XDECREF(ascii_chars_u);
  721. Py_XDECREF(ascii_chars_b);
  722. return -1;
  723. }
  724. #endif
  725. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  726. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  727. #else
  728. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  729. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  730. static char* __PYX_DEFAULT_STRING_ENCODING;
  731. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  732. PyObject* sys;
  733. PyObject* default_encoding = NULL;
  734. char* default_encoding_c;
  735. sys = PyImport_ImportModule("sys");
  736. if (!sys) goto bad;
  737. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  738. Py_DECREF(sys);
  739. if (!default_encoding) goto bad;
  740. default_encoding_c = PyBytes_AsString(default_encoding);
  741. if (!default_encoding_c) goto bad;
  742. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
  743. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  744. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  745. Py_DECREF(default_encoding);
  746. return 0;
  747. bad:
  748. Py_XDECREF(default_encoding);
  749. return -1;
  750. }
  751. #endif
  752. #endif
  753. /* Test for GCC > 2.95 */
  754. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  755. #define likely(x) __builtin_expect(!!(x), 1)
  756. #define unlikely(x) __builtin_expect(!!(x), 0)
  757. #else /* !__GNUC__ or GCC < 2.95 */
  758. #define likely(x) (x)
  759. #define unlikely(x) (x)
  760. #endif /* __GNUC__ */
  761. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  762. static PyObject *__pyx_m = NULL;
  763. static PyObject *__pyx_d;
  764. static PyObject *__pyx_b;
  765. static PyObject *__pyx_cython_runtime = NULL;
  766. static PyObject *__pyx_empty_tuple;
  767. static PyObject *__pyx_empty_bytes;
  768. static PyObject *__pyx_empty_unicode;
  769. static int __pyx_lineno;
  770. static int __pyx_clineno = 0;
  771. static const char * __pyx_cfilenm= __FILE__;
  772. static const char *__pyx_filename;
  773. static const char *__pyx_f[] = {
  774. "lakesuperior/store/base_lmdb_store.pyx",
  775. "stringsource",
  776. "lakesuperior/store/base_lmdb_store.pxd",
  777. };
  778. /*--- Type declarations ---*/
  779. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  780. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx;
  781. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check;
  782. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis;
  783. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin;
  784. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists;
  785. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open;
  786. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi;
  787. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put;
  788. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data;
  789. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete;
  790. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env;
  791. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy;
  792. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data;
  793. /* "lakesuperior/store/base_lmdb_store.pxd":10
  794. * lmdb.MDB_dbi dbi
  795. *
  796. * void _check(int rc, str message=*) except * # <<<<<<<<<<<<<<
  797. *
  798. *
  799. */
  800. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check {
  801. int __pyx_n;
  802. PyObject *message;
  803. };
  804. /* "lakesuperior/store/base_lmdb_store.pxd":26
  805. * void _clear_stale_readers(self) except *
  806. * void _cur_close(self, lmdb.MDB_cursor *cur) except *
  807. * void _init_dbis(self, create=*) except * # <<<<<<<<<<<<<<
  808. * void _txn_begin(self, write=*, lmdb.MDB_txn *parent=*) except *
  809. * void _txn_commit(self) except *
  810. */
  811. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis {
  812. int __pyx_n;
  813. PyObject *create;
  814. };
  815. /* "lakesuperior/store/base_lmdb_store.pxd":27
  816. * void _cur_close(self, lmdb.MDB_cursor *cur) except *
  817. * void _init_dbis(self, create=*) except *
  818. * void _txn_begin(self, write=*, lmdb.MDB_txn *parent=*) except * # <<<<<<<<<<<<<<
  819. * void _txn_commit(self) except *
  820. * void _txn_abort(self) except *
  821. */
  822. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin {
  823. int __pyx_n;
  824. PyObject *write;
  825. MDB_txn *parent;
  826. };
  827. /* "lakesuperior/store/base_lmdb_store.pxd":30
  828. * void _txn_commit(self) except *
  829. * void _txn_abort(self) except *
  830. * inline bint _key_exists( # <<<<<<<<<<<<<<
  831. * self, unsigned char *key, unsigned char klen,
  832. * unsigned char *dblabel=*) except -1
  833. */
  834. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists {
  835. int __pyx_n;
  836. unsigned char *dblabel;
  837. };
  838. /* "lakesuperior/store/base_lmdb_store.pxd":35
  839. *
  840. * size_t _txn_id(self) except -1
  841. * lmdb.MDB_cursor *_cur_open( # <<<<<<<<<<<<<<
  842. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*) except *
  843. *
  844. */
  845. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open {
  846. int __pyx_n;
  847. unsigned char *dblabel;
  848. MDB_txn *txn;
  849. };
  850. /* "lakesuperior/store/base_lmdb_store.pxd":38
  851. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*) except *
  852. *
  853. * lmdb.MDB_dbi get_dbi( # <<<<<<<<<<<<<<
  854. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*)
  855. *
  856. */
  857. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi {
  858. int __pyx_n;
  859. unsigned char *dblabel;
  860. MDB_txn *txn;
  861. };
  862. /* "lakesuperior/store/base_lmdb_store.pxd":41
  863. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*)
  864. *
  865. * void _put( # <<<<<<<<<<<<<<
  866. * self, unsigned char *key, size_t key_size, unsigned char *data,
  867. * size_t data_size, unsigned char *dblabel=*,
  868. */
  869. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put {
  870. int __pyx_n;
  871. unsigned char *dblabel;
  872. MDB_txn *txn;
  873. unsigned int flags;
  874. };
  875. /* "lakesuperior/store/base_lmdb_store.pxd":46
  876. * lmdb.MDB_txn *txn=*, unsigned int flags=*) except *
  877. *
  878. * void _get_data( # <<<<<<<<<<<<<<
  879. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  880. * unsigned char *dblabel=*) except *
  881. */
  882. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data {
  883. int __pyx_n;
  884. unsigned char *dblabel;
  885. };
  886. /* "lakesuperior/store/base_lmdb_store.pxd":50
  887. * unsigned char *dblabel=*) except *
  888. *
  889. * void _delete( # <<<<<<<<<<<<<<
  890. * self, unsigned char *key, size_t klen,
  891. * unsigned char *dblabel=*) except *
  892. */
  893. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete {
  894. int __pyx_n;
  895. unsigned char *dblabel;
  896. };
  897. /* "lakesuperior/store/base_lmdb_store.pxd":57
  898. * #int _reader_list_callback(self, const unsigned char *msg, void *str_)
  899. *
  900. * cpdef void close_env(self, bint commit_pending_transaction=*) except * # <<<<<<<<<<<<<<
  901. * cpdef void destroy(self, _path=*) except *
  902. * #cpdef get_dup_data(self, unsigned char *key, db=*)
  903. */
  904. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env {
  905. int __pyx_n;
  906. int commit_pending_transaction;
  907. };
  908. /* "lakesuperior/store/base_lmdb_store.pxd":58
  909. *
  910. * cpdef void close_env(self, bint commit_pending_transaction=*) except *
  911. * cpdef void destroy(self, _path=*) except * # <<<<<<<<<<<<<<
  912. * #cpdef get_dup_data(self, unsigned char *key, db=*)
  913. * #cpdef get_all_pairs(self, db=*)
  914. */
  915. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy {
  916. int __pyx_n;
  917. PyObject *_path;
  918. };
  919. /* "lakesuperior/store/base_lmdb_store.pxd":61
  920. * #cpdef get_dup_data(self, unsigned char *key, db=*)
  921. * #cpdef get_all_pairs(self, db=*)
  922. * cpdef bytes get_data(self, key, dblabel=*) # <<<<<<<<<<<<<<
  923. * cpdef dict stats(self)
  924. * cpdef int txn_id(self)
  925. */
  926. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data {
  927. int __pyx_n;
  928. PyObject *dblabel;
  929. };
  930. /* "lakesuperior/store/base_lmdb_store.pxd":13
  931. *
  932. *
  933. * cdef class BaseLmdbStore: # <<<<<<<<<<<<<<
  934. * cdef:
  935. * readonly bint is_txn_open
  936. */
  937. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore {
  938. PyObject_HEAD
  939. struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_vtab;
  940. int is_txn_open;
  941. int _open;
  942. unsigned int _readers;
  943. PyObject *env_path;
  944. MDB_dbi *dbis;
  945. MDB_env *dbenv;
  946. MDB_txn *txn;
  947. MDB_cursor **curs;
  948. };
  949. /* "lakesuperior/store/base_lmdb_store.pyx":334
  950. *
  951. * @contextmanager
  952. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  953. * """
  954. * Transaction context manager.
  955. */
  956. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx {
  957. PyObject_HEAD
  958. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self;
  959. PyObject *__pyx_v_write;
  960. PyObject *__pyx_t_0;
  961. PyObject *__pyx_t_1;
  962. PyObject *__pyx_t_2;
  963. };
  964. /* "lakesuperior/store/base_lmdb_store.pyx":49
  965. *
  966. *
  967. * cdef class BaseLmdbStore: # <<<<<<<<<<<<<<
  968. * """
  969. * Generic LMDB store abstract class.
  970. */
  971. struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore {
  972. void (*_clear_stale_readers)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  973. void (*_cur_close)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, MDB_cursor *);
  974. 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);
  975. 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);
  976. void (*_txn_commit)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  977. void (*_txn_abort)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  978. 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);
  979. size_t (*_txn_id)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  980. 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);
  981. 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);
  982. 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);
  983. 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);
  984. 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);
  985. PyObject *(*_stats)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  986. 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);
  987. 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);
  988. 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);
  989. PyObject *(*stats)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch);
  990. int (*txn_id)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch);
  991. };
  992. static struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  993. 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);
  994. /* --- Runtime support code (head) --- */
  995. /* Refnanny.proto */
  996. #ifndef CYTHON_REFNANNY
  997. #define CYTHON_REFNANNY 0
  998. #endif
  999. #if CYTHON_REFNANNY
  1000. typedef struct {
  1001. void (*INCREF)(void*, PyObject*, int);
  1002. void (*DECREF)(void*, PyObject*, int);
  1003. void (*GOTREF)(void*, PyObject*, int);
  1004. void (*GIVEREF)(void*, PyObject*, int);
  1005. void* (*SetupContext)(const char*, int, const char*);
  1006. void (*FinishContext)(void**);
  1007. } __Pyx_RefNannyAPIStruct;
  1008. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  1009. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  1010. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  1011. #ifdef WITH_THREAD
  1012. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1013. if (acquire_gil) {\
  1014. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1015. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  1016. PyGILState_Release(__pyx_gilstate_save);\
  1017. } else {\
  1018. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  1019. }
  1020. #else
  1021. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1022. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  1023. #endif
  1024. #define __Pyx_RefNannyFinishContext()\
  1025. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  1026. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1027. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1028. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1029. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1030. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  1031. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  1032. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  1033. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  1034. #else
  1035. #define __Pyx_RefNannyDeclarations
  1036. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  1037. #define __Pyx_RefNannyFinishContext()
  1038. #define __Pyx_INCREF(r) Py_INCREF(r)
  1039. #define __Pyx_DECREF(r) Py_DECREF(r)
  1040. #define __Pyx_GOTREF(r)
  1041. #define __Pyx_GIVEREF(r)
  1042. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  1043. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  1044. #define __Pyx_XGOTREF(r)
  1045. #define __Pyx_XGIVEREF(r)
  1046. #endif
  1047. #define __Pyx_XDECREF_SET(r, v) do {\
  1048. PyObject *tmp = (PyObject *) r;\
  1049. r = v; __Pyx_XDECREF(tmp);\
  1050. } while (0)
  1051. #define __Pyx_DECREF_SET(r, v) do {\
  1052. PyObject *tmp = (PyObject *) r;\
  1053. r = v; __Pyx_DECREF(tmp);\
  1054. } while (0)
  1055. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  1056. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  1057. /* PyObjectGetAttrStr.proto */
  1058. #if CYTHON_USE_TYPE_SLOTS
  1059. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  1060. #else
  1061. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  1062. #endif
  1063. /* GetBuiltinName.proto */
  1064. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  1065. /* PyThreadStateGet.proto */
  1066. #if CYTHON_FAST_THREAD_STATE
  1067. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1068. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  1069. #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
  1070. #else
  1071. #define __Pyx_PyThreadState_declare
  1072. #define __Pyx_PyThreadState_assign
  1073. #define __Pyx_PyErr_Occurred() PyErr_Occurred()
  1074. #endif
  1075. /* PyErrFetchRestore.proto */
  1076. #if CYTHON_FAST_THREAD_STATE
  1077. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  1078. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1079. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1080. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1081. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1082. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1083. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1084. #if CYTHON_COMPILING_IN_CPYTHON
  1085. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  1086. #else
  1087. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1088. #endif
  1089. #else
  1090. #define __Pyx_PyErr_Clear() PyErr_Clear()
  1091. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1092. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1093. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1094. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  1095. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  1096. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1097. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1098. #endif
  1099. /* Profile.proto */
  1100. #ifndef CYTHON_PROFILE
  1101. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  1102. #define CYTHON_PROFILE 0
  1103. #else
  1104. #define CYTHON_PROFILE 1
  1105. #endif
  1106. #endif
  1107. #ifndef CYTHON_TRACE_NOGIL
  1108. #define CYTHON_TRACE_NOGIL 0
  1109. #else
  1110. #if CYTHON_TRACE_NOGIL && !defined(CYTHON_TRACE)
  1111. #define CYTHON_TRACE 1
  1112. #endif
  1113. #endif
  1114. #ifndef CYTHON_TRACE
  1115. #define CYTHON_TRACE 0
  1116. #endif
  1117. #if CYTHON_TRACE
  1118. #undef CYTHON_PROFILE_REUSE_FRAME
  1119. #endif
  1120. #ifndef CYTHON_PROFILE_REUSE_FRAME
  1121. #define CYTHON_PROFILE_REUSE_FRAME 0
  1122. #endif
  1123. #if CYTHON_PROFILE || CYTHON_TRACE
  1124. #include "compile.h"
  1125. #include "frameobject.h"
  1126. #include "traceback.h"
  1127. #if CYTHON_PROFILE_REUSE_FRAME
  1128. #define CYTHON_FRAME_MODIFIER static
  1129. #define CYTHON_FRAME_DEL(frame)
  1130. #else
  1131. #define CYTHON_FRAME_MODIFIER
  1132. #define CYTHON_FRAME_DEL(frame) Py_CLEAR(frame)
  1133. #endif
  1134. #define __Pyx_TraceDeclarations\
  1135. static PyCodeObject *__pyx_frame_code = NULL;\
  1136. CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL;\
  1137. int __Pyx_use_tracing = 0;
  1138. #define __Pyx_TraceFrameInit(codeobj)\
  1139. if (codeobj) __pyx_frame_code = (PyCodeObject*) codeobj;
  1140. #ifdef WITH_THREAD
  1141. #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  1142. if (nogil) {\
  1143. if (CYTHON_TRACE_NOGIL) {\
  1144. PyThreadState *tstate;\
  1145. PyGILState_STATE state = PyGILState_Ensure();\
  1146. tstate = __Pyx_PyThreadState_Current;\
  1147. if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
  1148. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1149. __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
  1150. }\
  1151. PyGILState_Release(state);\
  1152. if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
  1153. }\
  1154. } else {\
  1155. PyThreadState* tstate = PyThreadState_GET();\
  1156. if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
  1157. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1158. __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
  1159. if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
  1160. }\
  1161. }
  1162. #else
  1163. #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  1164. { PyThreadState* tstate = PyThreadState_GET();\
  1165. if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
  1166. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1167. __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
  1168. if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
  1169. }\
  1170. }
  1171. #endif
  1172. #define __Pyx_TraceException()\
  1173. if (likely(!__Pyx_use_tracing)); else {\
  1174. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1175. if (tstate->use_tracing &&\
  1176. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1177. tstate->tracing++;\
  1178. tstate->use_tracing = 0;\
  1179. PyObject *exc_info = __Pyx_GetExceptionTuple(tstate);\
  1180. if (exc_info) {\
  1181. if (CYTHON_TRACE && tstate->c_tracefunc)\
  1182. tstate->c_tracefunc(\
  1183. tstate->c_traceobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
  1184. tstate->c_profilefunc(\
  1185. tstate->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
  1186. Py_DECREF(exc_info);\
  1187. }\
  1188. tstate->use_tracing = 1;\
  1189. tstate->tracing--;\
  1190. }\
  1191. }
  1192. static void __Pyx_call_return_trace_func(PyThreadState *tstate, PyFrameObject *frame, PyObject *result) {
  1193. PyObject *type, *value, *traceback;
  1194. __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
  1195. tstate->tracing++;
  1196. tstate->use_tracing = 0;
  1197. if (CYTHON_TRACE && tstate->c_tracefunc)
  1198. tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_RETURN, result);
  1199. if (tstate->c_profilefunc)
  1200. tstate->c_profilefunc(tstate->c_profileobj, frame, PyTrace_RETURN, result);
  1201. CYTHON_FRAME_DEL(frame);
  1202. tstate->use_tracing = 1;
  1203. tstate->tracing--;
  1204. __Pyx_ErrRestoreInState(tstate, type, value, traceback);
  1205. }
  1206. #ifdef WITH_THREAD
  1207. #define __Pyx_TraceReturn(result, nogil)\
  1208. if (likely(!__Pyx_use_tracing)); else {\
  1209. if (nogil) {\
  1210. if (CYTHON_TRACE_NOGIL) {\
  1211. PyThreadState *tstate;\
  1212. PyGILState_STATE state = PyGILState_Ensure();\
  1213. tstate = __Pyx_PyThreadState_Current;\
  1214. if (tstate->use_tracing) {\
  1215. __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
  1216. }\
  1217. PyGILState_Release(state);\
  1218. }\
  1219. } else {\
  1220. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1221. if (tstate->use_tracing) {\
  1222. __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
  1223. }\
  1224. }\
  1225. }
  1226. #else
  1227. #define __Pyx_TraceReturn(result, nogil)\
  1228. if (likely(!__Pyx_use_tracing)); else {\
  1229. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1230. if (tstate->use_tracing) {\
  1231. __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
  1232. }\
  1233. }
  1234. #endif
  1235. static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno);
  1236. static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, PyThreadState* tstate, const char *funcname, const char *srcfile, int firstlineno);
  1237. #else
  1238. #define __Pyx_TraceDeclarations
  1239. #define __Pyx_TraceFrameInit(codeobj)
  1240. #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error) if ((1)); else goto_error;
  1241. #define __Pyx_TraceException()
  1242. #define __Pyx_TraceReturn(result, nogil)
  1243. #endif
  1244. #if CYTHON_TRACE
  1245. static int __Pyx_call_line_trace_func(PyThreadState *tstate, PyFrameObject *frame, int lineno) {
  1246. int ret;
  1247. PyObject *type, *value, *traceback;
  1248. __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
  1249. __Pyx_PyFrame_SetLineNumber(frame, lineno);
  1250. tstate->tracing++;
  1251. tstate->use_tracing = 0;
  1252. ret = tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_LINE, NULL);
  1253. tstate->use_tracing = 1;
  1254. tstate->tracing--;
  1255. if (likely(!ret)) {
  1256. __Pyx_ErrRestoreInState(tstate, type, value, traceback);
  1257. } else {
  1258. Py_XDECREF(type);
  1259. Py_XDECREF(value);
  1260. Py_XDECREF(traceback);
  1261. }
  1262. return ret;
  1263. }
  1264. #ifdef WITH_THREAD
  1265. #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  1266. if (likely(!__Pyx_use_tracing)); else {\
  1267. if (nogil) {\
  1268. if (CYTHON_TRACE_NOGIL) {\
  1269. int ret = 0;\
  1270. PyThreadState *tstate;\
  1271. PyGILState_STATE state = PyGILState_Ensure();\
  1272. tstate = __Pyx_PyThreadState_Current;\
  1273. if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
  1274. ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
  1275. }\
  1276. PyGILState_Release(state);\
  1277. if (unlikely(ret)) goto_error;\
  1278. }\
  1279. } else {\
  1280. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1281. if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
  1282. int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
  1283. if (unlikely(ret)) goto_error;\
  1284. }\
  1285. }\
  1286. }
  1287. #else
  1288. #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  1289. if (likely(!__Pyx_use_tracing)); else {\
  1290. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1291. if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
  1292. int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
  1293. if (unlikely(ret)) goto_error;\
  1294. }\
  1295. }
  1296. #endif
  1297. #else
  1298. #define __Pyx_TraceLine(lineno, nogil, goto_error) if ((1)); else goto_error;
  1299. #endif
  1300. /* GetModuleGlobalName.proto */
  1301. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
  1302. /* PyCFunctionFastCall.proto */
  1303. #if CYTHON_FAST_PYCCALL
  1304. static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
  1305. #else
  1306. #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
  1307. #endif
  1308. /* PyFunctionFastCall.proto */
  1309. #if CYTHON_FAST_PYCALL
  1310. #define __Pyx_PyFunction_FastCall(func, args, nargs)\
  1311. __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
  1312. #if 1 || PY_VERSION_HEX < 0x030600B1
  1313. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
  1314. #else
  1315. #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
  1316. #endif
  1317. #endif
  1318. /* PyObjectCall.proto */
  1319. #if CYTHON_COMPILING_IN_CPYTHON
  1320. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  1321. #else
  1322. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  1323. #endif
  1324. /* PyObjectCallMethO.proto */
  1325. #if CYTHON_COMPILING_IN_CPYTHON
  1326. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  1327. #endif
  1328. /* PyObjectCallOneArg.proto */
  1329. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  1330. /* PyObjectCallNoArg.proto */
  1331. #if CYTHON_COMPILING_IN_CPYTHON
  1332. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  1333. #else
  1334. #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
  1335. #endif
  1336. /* RaiseException.proto */
  1337. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  1338. /* IncludeStringH.proto */
  1339. #include <string.h>
  1340. /* decode_c_string_utf16.proto */
  1341. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
  1342. int byteorder = 0;
  1343. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1344. }
  1345. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
  1346. int byteorder = -1;
  1347. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1348. }
  1349. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
  1350. int byteorder = 1;
  1351. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1352. }
  1353. /* decode_c_string.proto */
  1354. static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
  1355. const char* cstring, Py_ssize_t start, Py_ssize_t stop,
  1356. const char* encoding, const char* errors,
  1357. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
  1358. /* RaiseDoubleKeywords.proto */
  1359. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  1360. /* ParseKeywords.proto */
  1361. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
  1362. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
  1363. const char* function_name);
  1364. /* RaiseArgTupleInvalid.proto */
  1365. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  1366. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  1367. /* WriteUnraisableException.proto */
  1368. static void __Pyx_WriteUnraisable(const char *name, int clineno,
  1369. int lineno, const char *filename,
  1370. int full_traceback, int nogil);
  1371. /* SaveResetException.proto */
  1372. #if CYTHON_FAST_THREAD_STATE
  1373. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  1374. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1375. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  1376. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1377. #else
  1378. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  1379. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  1380. #endif
  1381. /* PyErrExceptionMatches.proto */
  1382. #if CYTHON_FAST_THREAD_STATE
  1383. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  1384. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  1385. #else
  1386. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  1387. #endif
  1388. /* GetException.proto */
  1389. #if CYTHON_FAST_THREAD_STATE
  1390. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  1391. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1392. #else
  1393. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  1394. #endif
  1395. /* SwapException.proto */
  1396. #if CYTHON_FAST_THREAD_STATE
  1397. #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
  1398. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1399. #else
  1400. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
  1401. #endif
  1402. /* PyUnicode_Unicode.proto */
  1403. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj);
  1404. /* JoinPyUnicode.proto */
  1405. static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
  1406. Py_UCS4 max_char);
  1407. /* PyObjectFormatSimple.proto */
  1408. #if CYTHON_COMPILING_IN_PYPY
  1409. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1410. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1411. PyObject_Format(s, f))
  1412. #elif PY_MAJOR_VERSION < 3
  1413. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1414. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1415. likely(PyString_CheckExact(s)) ? PyUnicode_FromEncodedObject(s, NULL, "strict") :\
  1416. PyObject_Format(s, f))
  1417. #elif CYTHON_USE_TYPE_SLOTS
  1418. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1419. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1420. likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_str(s) :\
  1421. likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_str(s) :\
  1422. PyObject_Format(s, f))
  1423. #else
  1424. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1425. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1426. PyObject_Format(s, f))
  1427. #endif
  1428. /* FastTypeChecks.proto */
  1429. #if CYTHON_COMPILING_IN_CPYTHON
  1430. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  1431. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  1432. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  1433. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  1434. #else
  1435. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  1436. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  1437. #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
  1438. #endif
  1439. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  1440. /* PyObjectSetAttrStr.proto */
  1441. #if CYTHON_USE_TYPE_SLOTS
  1442. #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
  1443. static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
  1444. #else
  1445. #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
  1446. #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
  1447. #endif
  1448. /* PyObjectLookupSpecial.proto */
  1449. #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
  1450. static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
  1451. PyObject *res;
  1452. PyTypeObject *tp = Py_TYPE(obj);
  1453. #if PY_MAJOR_VERSION < 3
  1454. if (unlikely(PyInstance_Check(obj)))
  1455. return __Pyx_PyObject_GetAttrStr(obj, attr_name);
  1456. #endif
  1457. res = _PyType_Lookup(tp, attr_name);
  1458. if (likely(res)) {
  1459. descrgetfunc f = Py_TYPE(res)->tp_descr_get;
  1460. if (!f) {
  1461. Py_INCREF(res);
  1462. } else {
  1463. res = f(res, obj, (PyObject *)tp);
  1464. }
  1465. } else {
  1466. PyErr_SetObject(PyExc_AttributeError, attr_name);
  1467. }
  1468. return res;
  1469. }
  1470. #else
  1471. #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
  1472. #endif
  1473. /* PyIntBinop.proto */
  1474. #if !CYTHON_COMPILING_IN_PYPY
  1475. static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
  1476. #else
  1477. #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
  1478. (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
  1479. #endif
  1480. /* DictGetItem.proto */
  1481. #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
  1482. static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
  1483. #define __Pyx_PyObject_Dict_GetItem(obj, name)\
  1484. (likely(PyDict_CheckExact(obj)) ?\
  1485. __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
  1486. #else
  1487. #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
  1488. #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
  1489. #endif
  1490. /* PyObject_GenericGetAttrNoDict.proto */
  1491. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1492. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
  1493. #else
  1494. #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
  1495. #endif
  1496. /* PyObject_GenericGetAttr.proto */
  1497. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1498. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
  1499. #else
  1500. #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
  1501. #endif
  1502. /* SetVTable.proto */
  1503. static int __Pyx_SetVtable(PyObject *dict, void *vtable);
  1504. /* SetupReduce.proto */
  1505. static int __Pyx_setup_reduce(PyObject* type_obj);
  1506. /* Import.proto */
  1507. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
  1508. /* ImportFrom.proto */
  1509. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  1510. /* CalculateMetaclass.proto */
  1511. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
  1512. /* Py3ClassCreate.proto */
  1513. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
  1514. PyObject *mkw, PyObject *modname, PyObject *doc);
  1515. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
  1516. PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
  1517. /* GetNameInClass.proto */
  1518. static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);
  1519. /* CLineInTraceback.proto */
  1520. #ifdef CYTHON_CLINE_IN_TRACEBACK
  1521. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  1522. #else
  1523. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  1524. #endif
  1525. /* CodeObjectCache.proto */
  1526. typedef struct {
  1527. PyCodeObject* code_object;
  1528. int code_line;
  1529. } __Pyx_CodeObjectCacheEntry;
  1530. struct __Pyx_CodeObjectCache {
  1531. int count;
  1532. int max_count;
  1533. __Pyx_CodeObjectCacheEntry* entries;
  1534. };
  1535. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  1536. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  1537. static PyCodeObject *__pyx_find_code_object(int code_line);
  1538. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  1539. /* AddTraceback.proto */
  1540. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1541. int py_line, const char *filename);
  1542. /* CIntToPy.proto */
  1543. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
  1544. /* CIntToPy.proto */
  1545. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
  1546. /* CIntToPy.proto */
  1547. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value);
  1548. /* CIntToPy.proto */
  1549. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  1550. /* CIntToPy.proto */
  1551. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_MDB_dbi(MDB_dbi value);
  1552. static PyObject* __pyx_convert__to_py_struct__MDB_stat(struct MDB_stat s);
  1553. /* CIntFromPy.proto */
  1554. static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
  1555. /* CIntFromPy.proto */
  1556. static CYTHON_INLINE MDB_dbi __Pyx_PyInt_As_MDB_dbi(PyObject *);
  1557. /* CIntFromPy.proto */
  1558. static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *);
  1559. /* CIntFromPy.proto */
  1560. static CYTHON_INLINE mode_t __Pyx_PyInt_As_mode_t(PyObject *);
  1561. /* CIntFromPy.proto */
  1562. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  1563. /* CIntFromPy.proto */
  1564. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  1565. /* FetchCommonType.proto */
  1566. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
  1567. /* PyObjectCallMethod1.proto */
  1568. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
  1569. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg);
  1570. /* CoroutineBase.proto */
  1571. typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
  1572. typedef struct {
  1573. PyObject_HEAD
  1574. __pyx_coroutine_body_t body;
  1575. PyObject *closure;
  1576. PyObject *exc_type;
  1577. PyObject *exc_value;
  1578. PyObject *exc_traceback;
  1579. PyObject *gi_weakreflist;
  1580. PyObject *classobj;
  1581. PyObject *yieldfrom;
  1582. PyObject *gi_name;
  1583. PyObject *gi_qualname;
  1584. PyObject *gi_modulename;
  1585. PyObject *gi_code;
  1586. int resume_label;
  1587. char is_running;
  1588. } __pyx_CoroutineObject;
  1589. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  1590. PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  1591. PyObject *name, PyObject *qualname, PyObject *module_name);
  1592. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  1593. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  1594. PyObject *name, PyObject *qualname, PyObject *module_name);
  1595. static int __Pyx_Coroutine_clear(PyObject *self);
  1596. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
  1597. static PyObject *__Pyx_Coroutine_Close(PyObject *self);
  1598. static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
  1599. #define __Pyx_Coroutine_SwapException(self) {\
  1600. __Pyx_ExceptionSwap(&(self)->exc_type, &(self)->exc_value, &(self)->exc_traceback);\
  1601. __Pyx_Coroutine_ResetFrameBackpointer(self);\
  1602. }
  1603. #define __Pyx_Coroutine_ResetAndClearException(self) {\
  1604. __Pyx_ExceptionReset((self)->exc_type, (self)->exc_value, (self)->exc_traceback);\
  1605. (self)->exc_type = (self)->exc_value = (self)->exc_traceback = NULL;\
  1606. }
  1607. #if CYTHON_FAST_THREAD_STATE
  1608. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  1609. __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
  1610. #else
  1611. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  1612. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
  1613. #endif
  1614. static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
  1615. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self);
  1616. /* PatchModuleWithCoroutine.proto */
  1617. static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);
  1618. /* PatchGeneratorABC.proto */
  1619. static int __Pyx_patch_abc(void);
  1620. /* Generator.proto */
  1621. #define __Pyx_Generator_USED
  1622. static PyTypeObject *__pyx_GeneratorType = 0;
  1623. #define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
  1624. #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
  1625. __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
  1626. static PyObject *__Pyx_Generator_Next(PyObject *self);
  1627. static int __pyx_Generator_init(void);
  1628. /* CheckBinaryVersion.proto */
  1629. static int __Pyx_check_binary_version(void);
  1630. /* VoidPtrExport.proto */
  1631. static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
  1632. /* FunctionExport.proto */
  1633. static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
  1634. /* InitStrings.proto */
  1635. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  1636. 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*/
  1637. 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*/
  1638. 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*/
  1639. 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*/
  1640. 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*/
  1641. 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*/
  1642. 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*/
  1643. 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*/
  1644. 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*/
  1645. 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*/
  1646. static PyObject *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto*/
  1647. 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*/
  1648. 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*/
  1649. 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*/
  1650. 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*/
  1651. 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*/
  1652. 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*/
  1653. 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*/
  1654. 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*/
  1655. /* Module declarations from 'lakesuperior.cy_include' */
  1656. /* Module declarations from 'libc.stdint' */
  1657. /* Module declarations from 'posix.types' */
  1658. /* Module declarations from 'lakesuperior.cy_include.cylmdb' */
  1659. /* Module declarations from 'libc' */
  1660. /* Module declarations from 'libc.errno' */
  1661. /* Module declarations from 'cpython.mem' */
  1662. /* Module declarations from 'lakesuperior.store.base_lmdb_store' */
  1663. static PyTypeObject *__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = 0;
  1664. static PyTypeObject *__pyx_ptype_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = 0;
  1665. static int __pyx_v_12lakesuperior_5store_15base_lmdb_store_rc;
  1666. static size_t __pyx_v_12lakesuperior_5store_15base_lmdb_store_i;
  1667. static struct MDB_val __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v;
  1668. static struct MDB_val __pyx_v_12lakesuperior_5store_15base_lmdb_store_data_v;
  1669. static MDB_dbi __pyx_v_12lakesuperior_5store_15base_lmdb_store_dbi;
  1670. 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*/
  1671. #define __Pyx_MODULE_NAME "lakesuperior.store.base_lmdb_store"
  1672. extern int __pyx_module_is_main_lakesuperior__store__base_lmdb_store;
  1673. int __pyx_module_is_main_lakesuperior__store__base_lmdb_store = 0;
  1674. /* Implementation of 'lakesuperior.store.base_lmdb_store' */
  1675. static PyObject *__pyx_builtin_MemoryError;
  1676. static PyObject *__pyx_builtin_enumerate;
  1677. static PyObject *__pyx_builtin_RuntimeError;
  1678. static PyObject *__pyx_builtin_TypeError;
  1679. static const char __pyx_k_[] = "";
  1680. static const char __pyx_k_i[] = "i";
  1681. static const char __pyx_k_x[] = "{:x}";
  1682. static const char __pyx_k_RO[] = "RO";
  1683. static const char __pyx_k_RW[] = "RW";
  1684. static const char __pyx_k__4[] = ".";
  1685. static const char __pyx_k__6[] = ": ";
  1686. static const char __pyx_k_os[] = "os";
  1687. static const char __pyx_k_rc[] = "rc";
  1688. static const char __pyx_k_DBI[] = " (DBI ";
  1689. static const char __pyx_k__20[] = ")...";
  1690. static const char __pyx_k_dbi[] = "dbi";
  1691. static const char __pyx_k_doc[] = "__doc__";
  1692. static const char __pyx_k_env[] = "env";
  1693. static const char __pyx_k_get[] = "get";
  1694. static const char __pyx_k_key[] = "key";
  1695. static const char __pyx_k_pid[] = "pid";
  1696. static const char __pyx_k_None[] = "None";
  1697. static const char __pyx_k_args[] = "args";
  1698. static const char __pyx_k_data[] = "data";
  1699. static const char __pyx_k_exit[] = "__exit__";
  1700. static const char __pyx_k_info[] = "info";
  1701. static const char __pyx_k_lock[] = "-lock";
  1702. static const char __pyx_k_main[] = "__main__";
  1703. static const char __pyx_k_mode[] = "mode";
  1704. static const char __pyx_k_name[] = "__name__";
  1705. static const char __pyx_k_path[] = "path";
  1706. static const char __pyx_k_send[] = "send";
  1707. static const char __pyx_k_stat[] = "stat";
  1708. static const char __pyx_k_test[] = "__test__";
  1709. static const char __pyx_k_wsgi[] = "wsgi";
  1710. static const char __pyx_k_abort[] = "abort";
  1711. static const char __pyx_k_close[] = "close";
  1712. static const char __pyx_k_debug[] = "debug";
  1713. static const char __pyx_k_enter[] = "__enter__";
  1714. static const char __pyx_k_flags[] = "flags";
  1715. static const char __pyx_k_index[] = "index";
  1716. static const char __pyx_k_key_v[] = "key_v";
  1717. static const char __pyx_k_stats[] = "stats";
  1718. static const char __pyx_k_throw[] = "throw";
  1719. static const char __pyx_k_write[] = "write";
  1720. static const char __pyx_k_create[] = "create";
  1721. static const char __pyx_k_data_v[] = "data_v";
  1722. static const char __pyx_k_encode[] = "encode";
  1723. static const char __pyx_k_exists[] = "exists";
  1724. static const char __pyx_k_format[] = "format";
  1725. static const char __pyx_k_import[] = "__import__";
  1726. static const char __pyx_k_logger[] = "logger";
  1727. static const char __pyx_k_module[] = "__module__";
  1728. static const char __pyx_k_path_2[] = "_path";
  1729. static const char __pyx_k_reduce[] = "__reduce__";
  1730. static const char __pyx_k_rmtree[] = "rmtree";
  1731. static const char __pyx_k_shutil[] = "shutil";
  1732. static const char __pyx_k_txn_id[] = "txn_id";
  1733. static const char __pyx_k_unlink[] = "unlink";
  1734. static const char __pyx_k_dblabel[] = "dblabel";
  1735. static const char __pyx_k_destroy[] = "destroy";
  1736. static const char __pyx_k_dirname[] = "dirname";
  1737. static const char __pyx_k_getName[] = "getName";
  1738. static const char __pyx_k_is_open[] = "is_open";
  1739. static const char __pyx_k_logging[] = "logging";
  1740. static const char __pyx_k_max_dbs[] = "max_dbs";
  1741. static const char __pyx_k_new_txn[] = "new_txn";
  1742. static const char __pyx_k_options[] = "options";
  1743. static const char __pyx_k_prepare[] = "__prepare__";
  1744. static const char __pyx_k_st_size[] = "st_size";
  1745. static const char __pyx_k_txn_ctx[] = "txn_ctx";
  1746. static const char __pyx_k_warning[] = "warning";
  1747. static const char __pyx_k_workers[] = "workers";
  1748. static const char __pyx_k_db_stats[] = "db_stats";
  1749. static const char __pyx_k_env_path[] = "env_path";
  1750. static const char __pyx_k_env_size[] = "env_size";
  1751. static const char __pyx_k_exist_ok[] = "exist_ok";
  1752. static const char __pyx_k_get_data[] = "get_data";
  1753. static const char __pyx_k_getstate[] = "__getstate__";
  1754. static const char __pyx_k_makedirs[] = "makedirs";
  1755. static const char __pyx_k_map_size[] = "map_size";
  1756. static const char __pyx_k_ms_depth[] = "ms_depth";
  1757. static const char __pyx_k_ms_psize[] = "ms_psize";
  1758. static const char __pyx_k_open_env[] = "open_env";
  1759. static const char __pyx_k_opened_x[] = "...opened @ {:x}.";
  1760. static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
  1761. static const char __pyx_k_qualname[] = "__qualname__";
  1762. static const char __pyx_k_setstate[] = "__setstate__";
  1763. static const char __pyx_k_LmdbError[] = "LmdbError";
  1764. static const char __pyx_k_TypeError[] = "TypeError";
  1765. static const char __pyx_k_close_env[] = "close_env";
  1766. static const char __pyx_k_dbi_flags[] = "dbi_flags";
  1767. static const char __pyx_k_enumerate[] = "enumerate";
  1768. static const char __pyx_k_env_flags[] = "env_flags";
  1769. static const char __pyx_k_env_perms[] = "env_perms";
  1770. static const char __pyx_k_env_stats[] = "env_stats";
  1771. static const char __pyx_k_getLogger[] = "getLogger";
  1772. static const char __pyx_k_is_txn_rw[] = "is_txn_rw";
  1773. static const char __pyx_k_metaclass[] = "__metaclass__";
  1774. static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
  1775. static const char __pyx_k_threading[] = "threading";
  1776. static const char __pyx_k_Created_DB[] = "Created DB ";
  1777. static const char __pyx_k_LMDB_Error[] = "LMDB Error ({}): ";
  1778. static const char __pyx_k_contextlib[] = "contextlib";
  1779. static const char __pyx_k_dbi_labels[] = "dbi_labels";
  1780. static const char __pyx_k_ms_entries[] = "ms_entries";
  1781. static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
  1782. static const char __pyx_k_Max_readers[] = "Max. readers: {}";
  1783. static const char __pyx_k_MemoryError[] = "MemoryError";
  1784. static const char __pyx_k_txn_is_open[] = "txn is open: {}";
  1785. static const char __pyx_k_Creating_DBs[] = "Creating DBs.";
  1786. static const char __pyx_k_RuntimeError[] = "RuntimeError";
  1787. static const char __pyx_k_lakesuperior[] = "lakesuperior";
  1788. static const char __pyx_k_readers_mult[] = "readers_mult";
  1789. static const char __pyx_k_currentThread[] = "currentThread";
  1790. static const char __pyx_k_ms_leaf_pages[] = "ms_leaf_pages";
  1791. static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
  1792. static const char __pyx_k_Internal_error[] = "\nInternal error ({}): ";
  1793. static const char __pyx_k_KeyExistsError[] = "KeyExistsError";
  1794. static const char __pyx_k_contextmanager[] = "contextmanager";
  1795. static const char __pyx_k_max_spare_txns[] = "max_spare_txns";
  1796. static const char __pyx_k_Created_DBenv_x[] = "Created DBenv @ {:x}";
  1797. static const char __pyx_k_DBenv_address_x[] = "DBenv address: {:x}";
  1798. static const char __pyx_k_current_process[] = "current_process";
  1799. static const char __pyx_k_ms_branch_pages[] = "ms_branch_pages";
  1800. static const char __pyx_k_multiprocessing[] = "multiprocessing";
  1801. static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
  1802. static const char __pyx_k_KeyNotFoundError[] = "KeyNotFoundError";
  1803. static const char __pyx_k_Closing_store_env[] = "Closing store env.";
  1804. static const char __pyx_k_FileNotFoundError[] = "FileNotFoundError";
  1805. static const char __pyx_k_Store_is_not_open[] = "Store is not open.";
  1806. static const char __pyx_k_ms_overflow_pages[] = "ms_overflow_pages";
  1807. static const char __pyx_k_Error_putting_data[] = "Error putting data: {}, {}";
  1808. static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
  1809. static const char __pyx_k_Transaction_aborted[] = "Transaction @ {} aborted.";
  1810. static const char __pyx_k_Error_opening_cursor[] = "Error opening cursor: ";
  1811. static const char __pyx_k_Opened_transaction_x[] = "Opened transaction @ {:x}";
  1812. static const char __pyx_k_BaseLmdbStore_txn_ctx[] = "BaseLmdbStore.txn_ctx";
  1813. static const char __pyx_k_Cleaning_up_store_env[] = "Cleaning up store env.";
  1814. static const char __pyx_k_Cleared_stale_readers[] = "Cleared {} stale readers.";
  1815. static const char __pyx_k_Opening_cursor_for_DB[] = "Opening cursor for DB ";
  1816. static const char __pyx_k_Transaction_committed[] = "Transaction @ {} committed.";
  1817. static const char __pyx_k_Error_setting_map_size[] = "Error setting map size: {}";
  1818. static const char __pyx_k_Opening_environment_at[] = "Opening environment at {}.";
  1819. static const char __pyx_k_Environment_already_open[] = "Environment already open.";
  1820. static const char __pyx_k_Error_opening_transaction[] = "Error opening transaction.";
  1821. static const char __pyx_k_Error_setting_max_readers[] = "Error setting max. readers: {}";
  1822. static const char __pyx_k_Getting_DBI_without_label[] = "Getting DBI without label.";
  1823. static const char __pyx_k_Error_getting_data_for_key[] = "Error getting data for key '{}'.";
  1824. static const char __pyx_k_Store_must_be_opened_first[] = "Store must be opened first.";
  1825. static const char __pyx_k_commit_pending_transaction[] = "commit_pending_transaction";
  1826. static const char __pyx_k_Error_getting_datbase_stats[] = "Error getting datbase stats: {}";
  1827. static const char __pyx_k_Error_setting_max_databases[] = "Error setting max. databases: {}";
  1828. static const char __pyx_k_Could_not_create_store_at_Error[] = "Could not create store at {}. Error: {}";
  1829. static const char __pyx_k_Error_creating_DB_environment_ha[] = "Error creating DB environment handle: {}";
  1830. static const char __pyx_k_Error_opening_the_database_envir[] = "Error opening the database environment: ";
  1831. static const char __pyx_k_Opening_transaction_in_PID_threa[] = "Opening {} transaction in PID {}, thread {}";
  1832. static const char __pyx_k_Transaction_is_already_active_No[] = "Transaction is already active. Not opening another one.";
  1833. static const char __pyx_k_lakesuperior_store_base_lmdb_sto[] = "lakesuperior.store.base_lmdb_store";
  1834. 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";
  1835. static PyObject *__pyx_kp_u_;
  1836. static PyObject *__pyx_n_s_BaseLmdbStore_txn_ctx;
  1837. static PyObject *__pyx_kp_u_Cleaning_up_store_env;
  1838. static PyObject *__pyx_kp_u_Cleared_stale_readers;
  1839. static PyObject *__pyx_kp_u_Closing_store_env;
  1840. static PyObject *__pyx_kp_u_Could_not_create_store_at_Error;
  1841. static PyObject *__pyx_kp_u_Created_DB;
  1842. static PyObject *__pyx_kp_u_Created_DBenv_x;
  1843. static PyObject *__pyx_kp_u_Creating_DBs;
  1844. static PyObject *__pyx_kp_u_DBI;
  1845. static PyObject *__pyx_kp_u_DBenv_address_x;
  1846. static PyObject *__pyx_kp_u_Environment_already_open;
  1847. static PyObject *__pyx_kp_u_Error_creating_DB_environment_ha;
  1848. static PyObject *__pyx_kp_u_Error_getting_data_for_key;
  1849. static PyObject *__pyx_kp_u_Error_getting_datbase_stats;
  1850. static PyObject *__pyx_kp_u_Error_opening_cursor;
  1851. static PyObject *__pyx_kp_u_Error_opening_the_database_envir;
  1852. static PyObject *__pyx_kp_u_Error_opening_transaction;
  1853. static PyObject *__pyx_kp_u_Error_putting_data;
  1854. static PyObject *__pyx_kp_u_Error_setting_map_size;
  1855. static PyObject *__pyx_kp_u_Error_setting_max_databases;
  1856. static PyObject *__pyx_kp_u_Error_setting_max_readers;
  1857. static PyObject *__pyx_n_s_FileNotFoundError;
  1858. static PyObject *__pyx_kp_u_Getting_DBI_without_label;
  1859. static PyObject *__pyx_kp_u_Internal_error;
  1860. static PyObject *__pyx_n_s_KeyExistsError;
  1861. static PyObject *__pyx_n_s_KeyNotFoundError;
  1862. static PyObject *__pyx_kp_u_LMDB_Error;
  1863. static PyObject *__pyx_n_s_LmdbError;
  1864. static PyObject *__pyx_kp_u_Max_readers;
  1865. static PyObject *__pyx_n_s_MemoryError;
  1866. static PyObject *__pyx_kp_u_None;
  1867. static PyObject *__pyx_kp_u_Opened_transaction_x;
  1868. static PyObject *__pyx_kp_u_Opening_cursor_for_DB;
  1869. static PyObject *__pyx_kp_u_Opening_environment_at;
  1870. static PyObject *__pyx_kp_u_Opening_transaction_in_PID_threa;
  1871. static PyObject *__pyx_n_u_RO;
  1872. static PyObject *__pyx_n_u_RW;
  1873. static PyObject *__pyx_n_s_RuntimeError;
  1874. static PyObject *__pyx_kp_u_Store_is_not_open;
  1875. static PyObject *__pyx_kp_u_Store_must_be_opened_first;
  1876. static PyObject *__pyx_kp_u_Transaction_aborted;
  1877. static PyObject *__pyx_kp_u_Transaction_committed;
  1878. static PyObject *__pyx_kp_u_Transaction_is_already_active_No;
  1879. static PyObject *__pyx_n_s_TypeError;
  1880. static PyObject *__pyx_kp_u__20;
  1881. static PyObject *__pyx_kp_u__4;
  1882. static PyObject *__pyx_kp_u__6;
  1883. static PyObject *__pyx_n_s_abort;
  1884. static PyObject *__pyx_n_s_args;
  1885. static PyObject *__pyx_n_s_cline_in_traceback;
  1886. static PyObject *__pyx_n_s_close;
  1887. static PyObject *__pyx_n_s_close_env;
  1888. static PyObject *__pyx_n_s_commit_pending_transaction;
  1889. static PyObject *__pyx_n_s_contextlib;
  1890. static PyObject *__pyx_n_s_contextmanager;
  1891. static PyObject *__pyx_n_s_create;
  1892. static PyObject *__pyx_n_s_currentThread;
  1893. static PyObject *__pyx_n_s_current_process;
  1894. static PyObject *__pyx_n_s_data;
  1895. static PyObject *__pyx_n_s_data_v;
  1896. static PyObject *__pyx_n_u_db_stats;
  1897. static PyObject *__pyx_n_s_dbi;
  1898. static PyObject *__pyx_n_s_dbi_flags;
  1899. static PyObject *__pyx_n_s_dbi_labels;
  1900. static PyObject *__pyx_n_s_dblabel;
  1901. static PyObject *__pyx_n_s_debug;
  1902. static PyObject *__pyx_n_s_destroy;
  1903. static PyObject *__pyx_n_s_dirname;
  1904. static PyObject *__pyx_n_s_doc;
  1905. static PyObject *__pyx_n_s_encode;
  1906. static PyObject *__pyx_n_s_enter;
  1907. static PyObject *__pyx_n_s_enumerate;
  1908. static PyObject *__pyx_n_s_env;
  1909. static PyObject *__pyx_n_s_env_flags;
  1910. static PyObject *__pyx_n_s_env_path;
  1911. static PyObject *__pyx_n_s_env_perms;
  1912. static PyObject *__pyx_n_u_env_size;
  1913. static PyObject *__pyx_n_u_env_stats;
  1914. static PyObject *__pyx_n_s_exist_ok;
  1915. static PyObject *__pyx_n_s_exists;
  1916. static PyObject *__pyx_n_s_exit;
  1917. static PyObject *__pyx_n_s_flags;
  1918. static PyObject *__pyx_n_s_format;
  1919. static PyObject *__pyx_n_s_get;
  1920. static PyObject *__pyx_n_s_getLogger;
  1921. static PyObject *__pyx_n_s_getName;
  1922. static PyObject *__pyx_n_s_get_data;
  1923. static PyObject *__pyx_n_s_getstate;
  1924. static PyObject *__pyx_n_s_i;
  1925. static PyObject *__pyx_n_s_import;
  1926. static PyObject *__pyx_n_s_index;
  1927. static PyObject *__pyx_n_s_info;
  1928. static PyObject *__pyx_n_s_is_open;
  1929. static PyObject *__pyx_n_s_is_txn_rw;
  1930. static PyObject *__pyx_n_s_key;
  1931. static PyObject *__pyx_n_s_key_v;
  1932. static PyObject *__pyx_n_s_lakesuperior;
  1933. static PyObject *__pyx_n_s_lakesuperior_store_base_lmdb_sto;
  1934. static PyObject *__pyx_kp_u_lock;
  1935. static PyObject *__pyx_n_s_logger;
  1936. static PyObject *__pyx_n_s_logging;
  1937. static PyObject *__pyx_n_s_main;
  1938. static PyObject *__pyx_n_s_makedirs;
  1939. static PyObject *__pyx_n_u_map_size;
  1940. static PyObject *__pyx_n_u_max_dbs;
  1941. static PyObject *__pyx_n_u_max_spare_txns;
  1942. static PyObject *__pyx_n_s_metaclass;
  1943. static PyObject *__pyx_n_s_mode;
  1944. static PyObject *__pyx_n_s_module;
  1945. static PyObject *__pyx_n_s_ms_branch_pages;
  1946. static PyObject *__pyx_n_s_ms_depth;
  1947. static PyObject *__pyx_n_s_ms_entries;
  1948. static PyObject *__pyx_n_s_ms_leaf_pages;
  1949. static PyObject *__pyx_n_s_ms_overflow_pages;
  1950. static PyObject *__pyx_n_s_ms_psize;
  1951. static PyObject *__pyx_n_s_multiprocessing;
  1952. static PyObject *__pyx_n_s_name;
  1953. static PyObject *__pyx_n_s_new_txn;
  1954. static PyObject *__pyx_n_s_open_env;
  1955. static PyObject *__pyx_kp_u_opened_x;
  1956. static PyObject *__pyx_n_s_options;
  1957. static PyObject *__pyx_n_s_os;
  1958. static PyObject *__pyx_n_s_path;
  1959. static PyObject *__pyx_n_s_path_2;
  1960. static PyObject *__pyx_n_s_pid;
  1961. static PyObject *__pyx_n_s_prepare;
  1962. static PyObject *__pyx_n_s_pyx_capi;
  1963. static PyObject *__pyx_n_s_pyx_vtable;
  1964. static PyObject *__pyx_n_s_qualname;
  1965. static PyObject *__pyx_n_s_rc;
  1966. static PyObject *__pyx_n_s_readers_mult;
  1967. static PyObject *__pyx_n_s_reduce;
  1968. static PyObject *__pyx_n_s_reduce_cython;
  1969. static PyObject *__pyx_n_s_reduce_ex;
  1970. static PyObject *__pyx_n_s_rmtree;
  1971. static PyObject *__pyx_kp_s_self_curs_self_dbenv_self_dbis_s;
  1972. static PyObject *__pyx_n_s_send;
  1973. static PyObject *__pyx_n_s_setstate;
  1974. static PyObject *__pyx_n_s_setstate_cython;
  1975. static PyObject *__pyx_n_s_shutil;
  1976. static PyObject *__pyx_n_s_st_size;
  1977. static PyObject *__pyx_n_s_stat;
  1978. static PyObject *__pyx_n_s_stats;
  1979. static PyObject *__pyx_n_s_test;
  1980. static PyObject *__pyx_n_s_threading;
  1981. static PyObject *__pyx_n_s_throw;
  1982. static PyObject *__pyx_n_s_txn_ctx;
  1983. static PyObject *__pyx_n_s_txn_id;
  1984. static PyObject *__pyx_kp_u_txn_is_open;
  1985. static PyObject *__pyx_n_s_unlink;
  1986. static PyObject *__pyx_n_s_warning;
  1987. static PyObject *__pyx_n_s_workers;
  1988. static PyObject *__pyx_n_s_write;
  1989. static PyObject *__pyx_n_s_wsgi;
  1990. static PyObject *__pyx_kp_u_x;
  1991. 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 */
  1992. 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 */
  1993. 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 */
  1994. 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 */
  1995. 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 */
  1996. 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 */
  1997. 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 */
  1998. 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 */
  1999. 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 */
  2000. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2001. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2002. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2003. 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 */
  2004. 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 */
  2005. 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 */
  2006. 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 */
  2007. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2008. 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 */
  2009. 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 */
  2010. 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 */
  2011. 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 */
  2012. 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 */
  2013. 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 */
  2014. 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 */
  2015. static PyObject *__pyx_tp_new_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2016. static PyObject *__pyx_tp_new_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2017. static PyObject *__pyx_int_0;
  2018. static PyObject *__pyx_int_1;
  2019. static PyObject *__pyx_int_4;
  2020. static PyObject *__pyx_int_416;
  2021. static PyObject *__pyx_int_488;
  2022. static PyObject *__pyx_int_1073741824;
  2023. static unsigned char *__pyx_k__14;
  2024. static unsigned char *__pyx_k__15;
  2025. static unsigned char *__pyx_k__16;
  2026. static unsigned char *__pyx_k__17;
  2027. static PyObject *__pyx_tuple__2;
  2028. static PyObject *__pyx_tuple__3;
  2029. static PyObject *__pyx_tuple__5;
  2030. static PyObject *__pyx_tuple__7;
  2031. static PyObject *__pyx_tuple__8;
  2032. static PyObject *__pyx_tuple__9;
  2033. static PyObject *__pyx_tuple__10;
  2034. static PyObject *__pyx_tuple__11;
  2035. static PyObject *__pyx_tuple__12;
  2036. static PyObject *__pyx_tuple__13;
  2037. static PyObject *__pyx_tuple__18;
  2038. static PyObject *__pyx_tuple__19;
  2039. static PyObject *__pyx_tuple__21;
  2040. static PyObject *__pyx_tuple__22;
  2041. /* Late includes */
  2042. /* "lakesuperior/store/base_lmdb_store.pyx":22
  2043. *
  2044. *
  2045. * cdef void _check(int rc, str message='') except *: # <<<<<<<<<<<<<<
  2046. * """
  2047. * Check return code.
  2048. */
  2049. 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) {
  2050. PyObject *__pyx_v_message = ((PyObject*)__pyx_kp_u_);
  2051. PyObject *__pyx_v_out_msg = NULL;
  2052. __Pyx_TraceDeclarations
  2053. __Pyx_RefNannyDeclarations
  2054. int __pyx_t_1;
  2055. PyObject *__pyx_t_2 = NULL;
  2056. PyObject *__pyx_t_3 = NULL;
  2057. PyObject *__pyx_t_4 = NULL;
  2058. Py_ssize_t __pyx_t_5;
  2059. PyObject *__pyx_t_6 = NULL;
  2060. PyObject *__pyx_t_7 = NULL;
  2061. PyObject *__pyx_t_8 = NULL;
  2062. char *__pyx_t_9;
  2063. __Pyx_RefNannySetupContext("_check", 0);
  2064. __Pyx_TraceCall("_check", __pyx_f[0], 22, 0, __PYX_ERR(0, 22, __pyx_L1_error));
  2065. if (__pyx_optional_args) {
  2066. if (__pyx_optional_args->__pyx_n > 0) {
  2067. __pyx_v_message = __pyx_optional_args->message;
  2068. }
  2069. }
  2070. /* "lakesuperior/store/base_lmdb_store.pyx":26
  2071. * Check return code.
  2072. * """
  2073. * if rc == lmdb.MDB_NOTFOUND: # <<<<<<<<<<<<<<
  2074. * raise KeyNotFoundError()
  2075. * if rc == lmdb.MDB_KEYEXIST:
  2076. */
  2077. __pyx_t_1 = ((__pyx_v_rc == MDB_NOTFOUND) != 0);
  2078. if (unlikely(__pyx_t_1)) {
  2079. /* "lakesuperior/store/base_lmdb_store.pyx":27
  2080. * """
  2081. * if rc == lmdb.MDB_NOTFOUND:
  2082. * raise KeyNotFoundError() # <<<<<<<<<<<<<<
  2083. * if rc == lmdb.MDB_KEYEXIST:
  2084. * raise KeyExistsError()
  2085. */
  2086. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error)
  2087. __Pyx_GOTREF(__pyx_t_3);
  2088. __pyx_t_4 = NULL;
  2089. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  2090. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  2091. if (likely(__pyx_t_4)) {
  2092. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2093. __Pyx_INCREF(__pyx_t_4);
  2094. __Pyx_INCREF(function);
  2095. __Pyx_DECREF_SET(__pyx_t_3, function);
  2096. }
  2097. }
  2098. if (__pyx_t_4) {
  2099. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
  2100. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2101. } else {
  2102. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
  2103. }
  2104. __Pyx_GOTREF(__pyx_t_2);
  2105. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2106. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  2107. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2108. __PYX_ERR(0, 27, __pyx_L1_error)
  2109. /* "lakesuperior/store/base_lmdb_store.pyx":26
  2110. * Check return code.
  2111. * """
  2112. * if rc == lmdb.MDB_NOTFOUND: # <<<<<<<<<<<<<<
  2113. * raise KeyNotFoundError()
  2114. * if rc == lmdb.MDB_KEYEXIST:
  2115. */
  2116. }
  2117. /* "lakesuperior/store/base_lmdb_store.pyx":28
  2118. * if rc == lmdb.MDB_NOTFOUND:
  2119. * raise KeyNotFoundError()
  2120. * if rc == lmdb.MDB_KEYEXIST: # <<<<<<<<<<<<<<
  2121. * raise KeyExistsError()
  2122. * if rc != lmdb.MDB_SUCCESS:
  2123. */
  2124. __pyx_t_1 = ((__pyx_v_rc == MDB_KEYEXIST) != 0);
  2125. if (unlikely(__pyx_t_1)) {
  2126. /* "lakesuperior/store/base_lmdb_store.pyx":29
  2127. * raise KeyNotFoundError()
  2128. * if rc == lmdb.MDB_KEYEXIST:
  2129. * raise KeyExistsError() # <<<<<<<<<<<<<<
  2130. * if rc != lmdb.MDB_SUCCESS:
  2131. * out_msg = (
  2132. */
  2133. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyExistsError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error)
  2134. __Pyx_GOTREF(__pyx_t_3);
  2135. __pyx_t_4 = NULL;
  2136. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  2137. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  2138. if (likely(__pyx_t_4)) {
  2139. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2140. __Pyx_INCREF(__pyx_t_4);
  2141. __Pyx_INCREF(function);
  2142. __Pyx_DECREF_SET(__pyx_t_3, function);
  2143. }
  2144. }
  2145. if (__pyx_t_4) {
  2146. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  2147. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2148. } else {
  2149. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  2150. }
  2151. __Pyx_GOTREF(__pyx_t_2);
  2152. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2153. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  2154. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2155. __PYX_ERR(0, 29, __pyx_L1_error)
  2156. /* "lakesuperior/store/base_lmdb_store.pyx":28
  2157. * if rc == lmdb.MDB_NOTFOUND:
  2158. * raise KeyNotFoundError()
  2159. * if rc == lmdb.MDB_KEYEXIST: # <<<<<<<<<<<<<<
  2160. * raise KeyExistsError()
  2161. * if rc != lmdb.MDB_SUCCESS:
  2162. */
  2163. }
  2164. /* "lakesuperior/store/base_lmdb_store.pyx":30
  2165. * if rc == lmdb.MDB_KEYEXIST:
  2166. * raise KeyExistsError()
  2167. * if rc != lmdb.MDB_SUCCESS: # <<<<<<<<<<<<<<
  2168. * out_msg = (
  2169. * message + '\nInternal error ({}): '.format(rc)
  2170. */
  2171. __pyx_t_1 = ((__pyx_v_rc != MDB_SUCCESS) != 0);
  2172. if (unlikely(__pyx_t_1)) {
  2173. /* "lakesuperior/store/base_lmdb_store.pyx":33
  2174. * out_msg = (
  2175. * message + '\nInternal error ({}): '.format(rc)
  2176. * if len(message) else 'LMDB Error ({}): '.format(rc)) # <<<<<<<<<<<<<<
  2177. * out_msg += lmdb.mdb_strerror(rc).decode()
  2178. * raise LmdbError(out_msg)
  2179. */
  2180. if (unlikely(__pyx_v_message == Py_None)) {
  2181. PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
  2182. __PYX_ERR(0, 33, __pyx_L1_error)
  2183. }
  2184. __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)
  2185. if ((__pyx_t_5 != 0)) {
  2186. /* "lakesuperior/store/base_lmdb_store.pyx":32
  2187. * if rc != lmdb.MDB_SUCCESS:
  2188. * out_msg = (
  2189. * message + '\nInternal error ({}): '.format(rc) # <<<<<<<<<<<<<<
  2190. * if len(message) else 'LMDB Error ({}): '.format(rc))
  2191. * out_msg += lmdb.mdb_strerror(rc).decode()
  2192. */
  2193. __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)
  2194. __Pyx_GOTREF(__pyx_t_4);
  2195. __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 32, __pyx_L1_error)
  2196. __Pyx_GOTREF(__pyx_t_6);
  2197. __pyx_t_7 = NULL;
  2198. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  2199. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
  2200. if (likely(__pyx_t_7)) {
  2201. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2202. __Pyx_INCREF(__pyx_t_7);
  2203. __Pyx_INCREF(function);
  2204. __Pyx_DECREF_SET(__pyx_t_4, function);
  2205. }
  2206. }
  2207. if (!__pyx_t_7) {
  2208. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error)
  2209. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2210. __Pyx_GOTREF(__pyx_t_3);
  2211. } else {
  2212. #if CYTHON_FAST_PYCALL
  2213. if (PyFunction_Check(__pyx_t_4)) {
  2214. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  2215. __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)
  2216. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  2217. __Pyx_GOTREF(__pyx_t_3);
  2218. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2219. } else
  2220. #endif
  2221. #if CYTHON_FAST_PYCCALL
  2222. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  2223. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  2224. __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)
  2225. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  2226. __Pyx_GOTREF(__pyx_t_3);
  2227. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2228. } else
  2229. #endif
  2230. {
  2231. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 32, __pyx_L1_error)
  2232. __Pyx_GOTREF(__pyx_t_8);
  2233. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  2234. __Pyx_GIVEREF(__pyx_t_6);
  2235. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
  2236. __pyx_t_6 = 0;
  2237. __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)
  2238. __Pyx_GOTREF(__pyx_t_3);
  2239. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2240. }
  2241. }
  2242. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2243. __pyx_t_4 = PyNumber_Add(__pyx_v_message, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 32, __pyx_L1_error)
  2244. __Pyx_GOTREF(__pyx_t_4);
  2245. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2246. __pyx_t_2 = __pyx_t_4;
  2247. __pyx_t_4 = 0;
  2248. } else {
  2249. /* "lakesuperior/store/base_lmdb_store.pyx":33
  2250. * out_msg = (
  2251. * message + '\nInternal error ({}): '.format(rc)
  2252. * if len(message) else 'LMDB Error ({}): '.format(rc)) # <<<<<<<<<<<<<<
  2253. * out_msg += lmdb.mdb_strerror(rc).decode()
  2254. * raise LmdbError(out_msg)
  2255. */
  2256. __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)
  2257. __Pyx_GOTREF(__pyx_t_3);
  2258. __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 33, __pyx_L1_error)
  2259. __Pyx_GOTREF(__pyx_t_8);
  2260. __pyx_t_6 = NULL;
  2261. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  2262. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
  2263. if (likely(__pyx_t_6)) {
  2264. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2265. __Pyx_INCREF(__pyx_t_6);
  2266. __Pyx_INCREF(function);
  2267. __Pyx_DECREF_SET(__pyx_t_3, function);
  2268. }
  2269. }
  2270. if (!__pyx_t_6) {
  2271. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error)
  2272. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2273. __Pyx_GOTREF(__pyx_t_4);
  2274. } else {
  2275. #if CYTHON_FAST_PYCALL
  2276. if (PyFunction_Check(__pyx_t_3)) {
  2277. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_8};
  2278. __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)
  2279. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2280. __Pyx_GOTREF(__pyx_t_4);
  2281. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2282. } else
  2283. #endif
  2284. #if CYTHON_FAST_PYCCALL
  2285. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  2286. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_8};
  2287. __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)
  2288. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2289. __Pyx_GOTREF(__pyx_t_4);
  2290. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2291. } else
  2292. #endif
  2293. {
  2294. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 33, __pyx_L1_error)
  2295. __Pyx_GOTREF(__pyx_t_7);
  2296. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
  2297. __Pyx_GIVEREF(__pyx_t_8);
  2298. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_8);
  2299. __pyx_t_8 = 0;
  2300. __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)
  2301. __Pyx_GOTREF(__pyx_t_4);
  2302. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2303. }
  2304. }
  2305. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2306. __pyx_t_2 = __pyx_t_4;
  2307. __pyx_t_4 = 0;
  2308. }
  2309. __pyx_v_out_msg = __pyx_t_2;
  2310. __pyx_t_2 = 0;
  2311. /* "lakesuperior/store/base_lmdb_store.pyx":34
  2312. * message + '\nInternal error ({}): '.format(rc)
  2313. * if len(message) else 'LMDB Error ({}): '.format(rc))
  2314. * out_msg += lmdb.mdb_strerror(rc).decode() # <<<<<<<<<<<<<<
  2315. * raise LmdbError(out_msg)
  2316. *
  2317. */
  2318. __pyx_t_9 = mdb_strerror(__pyx_v_rc);
  2319. __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)
  2320. __Pyx_GOTREF(__pyx_t_2);
  2321. __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_out_msg, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error)
  2322. __Pyx_GOTREF(__pyx_t_4);
  2323. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2324. __Pyx_DECREF_SET(__pyx_v_out_msg, __pyx_t_4);
  2325. __pyx_t_4 = 0;
  2326. /* "lakesuperior/store/base_lmdb_store.pyx":35
  2327. * if len(message) else 'LMDB Error ({}): '.format(rc))
  2328. * out_msg += lmdb.mdb_strerror(rc).decode()
  2329. * raise LmdbError(out_msg) # <<<<<<<<<<<<<<
  2330. *
  2331. *
  2332. */
  2333. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
  2334. __Pyx_GOTREF(__pyx_t_2);
  2335. __pyx_t_3 = NULL;
  2336. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  2337. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  2338. if (likely(__pyx_t_3)) {
  2339. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  2340. __Pyx_INCREF(__pyx_t_3);
  2341. __Pyx_INCREF(function);
  2342. __Pyx_DECREF_SET(__pyx_t_2, function);
  2343. }
  2344. }
  2345. if (!__pyx_t_3) {
  2346. __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)
  2347. __Pyx_GOTREF(__pyx_t_4);
  2348. } else {
  2349. #if CYTHON_FAST_PYCALL
  2350. if (PyFunction_Check(__pyx_t_2)) {
  2351. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_out_msg};
  2352. __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)
  2353. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2354. __Pyx_GOTREF(__pyx_t_4);
  2355. } else
  2356. #endif
  2357. #if CYTHON_FAST_PYCCALL
  2358. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  2359. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_out_msg};
  2360. __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)
  2361. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2362. __Pyx_GOTREF(__pyx_t_4);
  2363. } else
  2364. #endif
  2365. {
  2366. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 35, __pyx_L1_error)
  2367. __Pyx_GOTREF(__pyx_t_7);
  2368. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
  2369. __Pyx_INCREF(__pyx_v_out_msg);
  2370. __Pyx_GIVEREF(__pyx_v_out_msg);
  2371. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_out_msg);
  2372. __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)
  2373. __Pyx_GOTREF(__pyx_t_4);
  2374. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2375. }
  2376. }
  2377. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2378. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  2379. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2380. __PYX_ERR(0, 35, __pyx_L1_error)
  2381. /* "lakesuperior/store/base_lmdb_store.pyx":30
  2382. * if rc == lmdb.MDB_KEYEXIST:
  2383. * raise KeyExistsError()
  2384. * if rc != lmdb.MDB_SUCCESS: # <<<<<<<<<<<<<<
  2385. * out_msg = (
  2386. * message + '\nInternal error ({}): '.format(rc)
  2387. */
  2388. }
  2389. /* "lakesuperior/store/base_lmdb_store.pyx":22
  2390. *
  2391. *
  2392. * cdef void _check(int rc, str message='') except *: # <<<<<<<<<<<<<<
  2393. * """
  2394. * Check return code.
  2395. */
  2396. /* function exit code */
  2397. goto __pyx_L0;
  2398. __pyx_L1_error:;
  2399. __Pyx_XDECREF(__pyx_t_2);
  2400. __Pyx_XDECREF(__pyx_t_3);
  2401. __Pyx_XDECREF(__pyx_t_4);
  2402. __Pyx_XDECREF(__pyx_t_6);
  2403. __Pyx_XDECREF(__pyx_t_7);
  2404. __Pyx_XDECREF(__pyx_t_8);
  2405. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store._check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2406. __pyx_L0:;
  2407. __Pyx_XDECREF(__pyx_v_out_msg);
  2408. __Pyx_TraceReturn(Py_None, 0);
  2409. __Pyx_RefNannyFinishContext();
  2410. }
  2411. /* "lakesuperior/store/base_lmdb_store.pyx":129
  2412. * ### INIT & TEARDOWN ###
  2413. *
  2414. * def __init__(self, env_path, open_env=True, create=True): # <<<<<<<<<<<<<<
  2415. * """
  2416. * Initialize DB environment and databases.
  2417. */
  2418. /* Python wrapper */
  2419. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2420. 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 ";
  2421. #if CYTHON_COMPILING_IN_CPYTHON
  2422. struct wrapperbase __pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__;
  2423. #endif
  2424. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2425. PyObject *__pyx_v_env_path = 0;
  2426. PyObject *__pyx_v_open_env = 0;
  2427. PyObject *__pyx_v_create = 0;
  2428. int __pyx_r;
  2429. __Pyx_RefNannyDeclarations
  2430. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  2431. {
  2432. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_env_path,&__pyx_n_s_open_env,&__pyx_n_s_create,0};
  2433. PyObject* values[3] = {0,0,0};
  2434. values[1] = ((PyObject *)Py_True);
  2435. values[2] = ((PyObject *)Py_True);
  2436. if (unlikely(__pyx_kwds)) {
  2437. Py_ssize_t kw_args;
  2438. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2439. switch (pos_args) {
  2440. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2441. CYTHON_FALLTHROUGH;
  2442. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2443. CYTHON_FALLTHROUGH;
  2444. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2445. CYTHON_FALLTHROUGH;
  2446. case 0: break;
  2447. default: goto __pyx_L5_argtuple_error;
  2448. }
  2449. kw_args = PyDict_Size(__pyx_kwds);
  2450. switch (pos_args) {
  2451. case 0:
  2452. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_env_path)) != 0)) kw_args--;
  2453. else goto __pyx_L5_argtuple_error;
  2454. CYTHON_FALLTHROUGH;
  2455. case 1:
  2456. if (kw_args > 0) {
  2457. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_open_env);
  2458. if (value) { values[1] = value; kw_args--; }
  2459. }
  2460. CYTHON_FALLTHROUGH;
  2461. case 2:
  2462. if (kw_args > 0) {
  2463. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_create);
  2464. if (value) { values[2] = value; kw_args--; }
  2465. }
  2466. }
  2467. if (unlikely(kw_args > 0)) {
  2468. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 129, __pyx_L3_error)
  2469. }
  2470. } else {
  2471. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2472. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2473. CYTHON_FALLTHROUGH;
  2474. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2475. CYTHON_FALLTHROUGH;
  2476. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2477. break;
  2478. default: goto __pyx_L5_argtuple_error;
  2479. }
  2480. }
  2481. __pyx_v_env_path = values[0];
  2482. __pyx_v_open_env = values[1];
  2483. __pyx_v_create = values[2];
  2484. }
  2485. goto __pyx_L4_argument_unpacking_done;
  2486. __pyx_L5_argtuple_error:;
  2487. __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 129, __pyx_L3_error)
  2488. __pyx_L3_error:;
  2489. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2490. __Pyx_RefNannyFinishContext();
  2491. return -1;
  2492. __pyx_L4_argument_unpacking_done:;
  2493. __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);
  2494. /* function exit code */
  2495. __Pyx_RefNannyFinishContext();
  2496. return __pyx_r;
  2497. }
  2498. 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) {
  2499. int __pyx_r;
  2500. __Pyx_TraceDeclarations
  2501. __Pyx_RefNannyDeclarations
  2502. PyObject *__pyx_t_1 = NULL;
  2503. int __pyx_t_2;
  2504. PyObject *__pyx_t_3 = NULL;
  2505. PyObject *__pyx_t_4 = NULL;
  2506. PyObject *__pyx_t_5 = NULL;
  2507. __Pyx_RefNannySetupContext("__init__", 0);
  2508. __Pyx_TraceCall("__init__", __pyx_f[0], 129, 0, __PYX_ERR(0, 129, __pyx_L1_error));
  2509. /* "lakesuperior/store/base_lmdb_store.pyx":139
  2510. * be created if the store is opened immediately.
  2511. * """
  2512. * self._open = False # <<<<<<<<<<<<<<
  2513. * self.is_txn_open = False
  2514. * self.env_path = env_path
  2515. */
  2516. __pyx_v_self->_open = 0;
  2517. /* "lakesuperior/store/base_lmdb_store.pyx":140
  2518. * """
  2519. * self._open = False
  2520. * self.is_txn_open = False # <<<<<<<<<<<<<<
  2521. * self.env_path = env_path
  2522. * if open_env:
  2523. */
  2524. __pyx_v_self->is_txn_open = 0;
  2525. /* "lakesuperior/store/base_lmdb_store.pyx":141
  2526. * self._open = False
  2527. * self.is_txn_open = False
  2528. * self.env_path = env_path # <<<<<<<<<<<<<<
  2529. * if open_env:
  2530. * self.open_env(create)
  2531. */
  2532. 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)
  2533. __pyx_t_1 = __pyx_v_env_path;
  2534. __Pyx_INCREF(__pyx_t_1);
  2535. __Pyx_GIVEREF(__pyx_t_1);
  2536. __Pyx_GOTREF(__pyx_v_self->env_path);
  2537. __Pyx_DECREF(__pyx_v_self->env_path);
  2538. __pyx_v_self->env_path = ((PyObject*)__pyx_t_1);
  2539. __pyx_t_1 = 0;
  2540. /* "lakesuperior/store/base_lmdb_store.pyx":142
  2541. * self.is_txn_open = False
  2542. * self.env_path = env_path
  2543. * if open_env: # <<<<<<<<<<<<<<
  2544. * self.open_env(create)
  2545. * #logger.info('Init DB with path: {}'.format(self.env_path))
  2546. */
  2547. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_open_env); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 142, __pyx_L1_error)
  2548. if (__pyx_t_2) {
  2549. /* "lakesuperior/store/base_lmdb_store.pyx":143
  2550. * self.env_path = env_path
  2551. * if open_env:
  2552. * self.open_env(create) # <<<<<<<<<<<<<<
  2553. * #logger.info('Init DB with path: {}'.format(self.env_path))
  2554. *
  2555. */
  2556. __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)
  2557. __Pyx_GOTREF(__pyx_t_3);
  2558. __pyx_t_4 = NULL;
  2559. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  2560. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  2561. if (likely(__pyx_t_4)) {
  2562. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2563. __Pyx_INCREF(__pyx_t_4);
  2564. __Pyx_INCREF(function);
  2565. __Pyx_DECREF_SET(__pyx_t_3, function);
  2566. }
  2567. }
  2568. if (!__pyx_t_4) {
  2569. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_create); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
  2570. __Pyx_GOTREF(__pyx_t_1);
  2571. } else {
  2572. #if CYTHON_FAST_PYCALL
  2573. if (PyFunction_Check(__pyx_t_3)) {
  2574. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_create};
  2575. __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)
  2576. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2577. __Pyx_GOTREF(__pyx_t_1);
  2578. } else
  2579. #endif
  2580. #if CYTHON_FAST_PYCCALL
  2581. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  2582. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_create};
  2583. __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)
  2584. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2585. __Pyx_GOTREF(__pyx_t_1);
  2586. } else
  2587. #endif
  2588. {
  2589. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error)
  2590. __Pyx_GOTREF(__pyx_t_5);
  2591. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  2592. __Pyx_INCREF(__pyx_v_create);
  2593. __Pyx_GIVEREF(__pyx_v_create);
  2594. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_create);
  2595. __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)
  2596. __Pyx_GOTREF(__pyx_t_1);
  2597. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2598. }
  2599. }
  2600. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2601. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2602. /* "lakesuperior/store/base_lmdb_store.pyx":142
  2603. * self.is_txn_open = False
  2604. * self.env_path = env_path
  2605. * if open_env: # <<<<<<<<<<<<<<
  2606. * self.open_env(create)
  2607. * #logger.info('Init DB with path: {}'.format(self.env_path))
  2608. */
  2609. }
  2610. /* "lakesuperior/store/base_lmdb_store.pyx":129
  2611. * ### INIT & TEARDOWN ###
  2612. *
  2613. * def __init__(self, env_path, open_env=True, create=True): # <<<<<<<<<<<<<<
  2614. * """
  2615. * Initialize DB environment and databases.
  2616. */
  2617. /* function exit code */
  2618. __pyx_r = 0;
  2619. goto __pyx_L0;
  2620. __pyx_L1_error:;
  2621. __Pyx_XDECREF(__pyx_t_1);
  2622. __Pyx_XDECREF(__pyx_t_3);
  2623. __Pyx_XDECREF(__pyx_t_4);
  2624. __Pyx_XDECREF(__pyx_t_5);
  2625. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2626. __pyx_r = -1;
  2627. __pyx_L0:;
  2628. __Pyx_TraceReturn(Py_None, 0);
  2629. __Pyx_RefNannyFinishContext();
  2630. return __pyx_r;
  2631. }
  2632. /* "lakesuperior/store/base_lmdb_store.pyx":147
  2633. *
  2634. *
  2635. * def __dealloc__(self): # <<<<<<<<<<<<<<
  2636. * self.close_env()
  2637. *
  2638. */
  2639. /* Python wrapper */
  2640. static void __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
  2641. static void __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_3__dealloc__(PyObject *__pyx_v_self) {
  2642. __Pyx_RefNannyDeclarations
  2643. __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  2644. __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_2__dealloc__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  2645. /* function exit code */
  2646. __Pyx_RefNannyFinishContext();
  2647. }
  2648. static void __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_2__dealloc__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  2649. __Pyx_TraceDeclarations
  2650. __Pyx_RefNannyDeclarations
  2651. __Pyx_RefNannySetupContext("__dealloc__", 0);
  2652. __Pyx_TraceCall("__dealloc__", __pyx_f[0], 147, 0, __PYX_ERR(0, 147, __pyx_L1_error));
  2653. /* "lakesuperior/store/base_lmdb_store.pyx":148
  2654. *
  2655. * def __dealloc__(self):
  2656. * self.close_env() # <<<<<<<<<<<<<<
  2657. *
  2658. *
  2659. */
  2660. ((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)
  2661. /* "lakesuperior/store/base_lmdb_store.pyx":147
  2662. *
  2663. *
  2664. * def __dealloc__(self): # <<<<<<<<<<<<<<
  2665. * self.close_env()
  2666. *
  2667. */
  2668. /* function exit code */
  2669. goto __pyx_L0;
  2670. __pyx_L1_error:;
  2671. __Pyx_WriteUnraisable("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  2672. __pyx_L0:;
  2673. __Pyx_TraceReturn(Py_None, 0);
  2674. __Pyx_RefNannyFinishContext();
  2675. }
  2676. /* "lakesuperior/store/base_lmdb_store.pyx":152
  2677. *
  2678. * @property
  2679. * def is_open(self): # <<<<<<<<<<<<<<
  2680. * return self._open
  2681. *
  2682. */
  2683. /* Python wrapper */
  2684. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open_1__get__(PyObject *__pyx_v_self); /*proto*/
  2685. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open_1__get__(PyObject *__pyx_v_self) {
  2686. PyObject *__pyx_r = 0;
  2687. __Pyx_RefNannyDeclarations
  2688. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  2689. __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));
  2690. /* function exit code */
  2691. __Pyx_RefNannyFinishContext();
  2692. return __pyx_r;
  2693. }
  2694. 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) {
  2695. PyObject *__pyx_r = NULL;
  2696. __Pyx_TraceDeclarations
  2697. __Pyx_RefNannyDeclarations
  2698. PyObject *__pyx_t_1 = NULL;
  2699. __Pyx_RefNannySetupContext("__get__", 0);
  2700. __Pyx_TraceCall("__get__", __pyx_f[0], 152, 0, __PYX_ERR(0, 152, __pyx_L1_error));
  2701. /* "lakesuperior/store/base_lmdb_store.pyx":153
  2702. * @property
  2703. * def is_open(self):
  2704. * return self._open # <<<<<<<<<<<<<<
  2705. *
  2706. *
  2707. */
  2708. __Pyx_XDECREF(__pyx_r);
  2709. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
  2710. __Pyx_GOTREF(__pyx_t_1);
  2711. __pyx_r = __pyx_t_1;
  2712. __pyx_t_1 = 0;
  2713. goto __pyx_L0;
  2714. /* "lakesuperior/store/base_lmdb_store.pyx":152
  2715. *
  2716. * @property
  2717. * def is_open(self): # <<<<<<<<<<<<<<
  2718. * return self._open
  2719. *
  2720. */
  2721. /* function exit code */
  2722. __pyx_L1_error:;
  2723. __Pyx_XDECREF(__pyx_t_1);
  2724. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.is_open.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2725. __pyx_r = NULL;
  2726. __pyx_L0:;
  2727. __Pyx_XGIVEREF(__pyx_r);
  2728. __Pyx_TraceReturn(__pyx_r, 0);
  2729. __Pyx_RefNannyFinishContext();
  2730. return __pyx_r;
  2731. }
  2732. /* "lakesuperior/store/base_lmdb_store.pyx":157
  2733. *
  2734. * @property
  2735. * def readers(self): # <<<<<<<<<<<<<<
  2736. * return self._readers
  2737. *
  2738. */
  2739. /* Python wrapper */
  2740. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers_1__get__(PyObject *__pyx_v_self); /*proto*/
  2741. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers_1__get__(PyObject *__pyx_v_self) {
  2742. PyObject *__pyx_r = 0;
  2743. __Pyx_RefNannyDeclarations
  2744. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  2745. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers___get__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  2746. /* function exit code */
  2747. __Pyx_RefNannyFinishContext();
  2748. return __pyx_r;
  2749. }
  2750. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  2751. PyObject *__pyx_r = NULL;
  2752. __Pyx_TraceDeclarations
  2753. __Pyx_RefNannyDeclarations
  2754. PyObject *__pyx_t_1 = NULL;
  2755. __Pyx_RefNannySetupContext("__get__", 0);
  2756. __Pyx_TraceCall("__get__", __pyx_f[0], 157, 0, __PYX_ERR(0, 157, __pyx_L1_error));
  2757. /* "lakesuperior/store/base_lmdb_store.pyx":158
  2758. * @property
  2759. * def readers(self):
  2760. * return self._readers # <<<<<<<<<<<<<<
  2761. *
  2762. *
  2763. */
  2764. __Pyx_XDECREF(__pyx_r);
  2765. __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->_readers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error)
  2766. __Pyx_GOTREF(__pyx_t_1);
  2767. __pyx_r = __pyx_t_1;
  2768. __pyx_t_1 = 0;
  2769. goto __pyx_L0;
  2770. /* "lakesuperior/store/base_lmdb_store.pyx":157
  2771. *
  2772. * @property
  2773. * def readers(self): # <<<<<<<<<<<<<<
  2774. * return self._readers
  2775. *
  2776. */
  2777. /* function exit code */
  2778. __pyx_L1_error:;
  2779. __Pyx_XDECREF(__pyx_t_1);
  2780. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.readers.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2781. __pyx_r = NULL;
  2782. __pyx_L0:;
  2783. __Pyx_XGIVEREF(__pyx_r);
  2784. __Pyx_TraceReturn(__pyx_r, 0);
  2785. __Pyx_RefNannyFinishContext();
  2786. return __pyx_r;
  2787. }
  2788. /* "lakesuperior/store/base_lmdb_store.pyx":161
  2789. *
  2790. *
  2791. * def open_env(self, create): # <<<<<<<<<<<<<<
  2792. * """
  2793. * Open, and optionally create, store environment.
  2794. */
  2795. /* Python wrapper */
  2796. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5open_env(PyObject *__pyx_v_self, PyObject *__pyx_v_create); /*proto*/
  2797. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_4open_env[] = "\n Open, and optionally create, store environment.\n ";
  2798. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5open_env(PyObject *__pyx_v_self, PyObject *__pyx_v_create) {
  2799. PyObject *__pyx_r = 0;
  2800. __Pyx_RefNannyDeclarations
  2801. __Pyx_RefNannySetupContext("open_env (wrapper)", 0);
  2802. __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));
  2803. /* function exit code */
  2804. __Pyx_RefNannyFinishContext();
  2805. return __pyx_r;
  2806. }
  2807. 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) {
  2808. PyObject *__pyx_v_parent_path = NULL;
  2809. PyObject *__pyx_v_e = NULL;
  2810. PyObject *__pyx_v_max_dbs = NULL;
  2811. PyObject *__pyx_r = NULL;
  2812. __Pyx_TraceDeclarations
  2813. __Pyx_RefNannyDeclarations
  2814. PyObject *__pyx_t_1 = NULL;
  2815. int __pyx_t_2;
  2816. PyObject *__pyx_t_3 = NULL;
  2817. PyObject *__pyx_t_4 = NULL;
  2818. PyObject *__pyx_t_5 = NULL;
  2819. PyObject *__pyx_t_6 = NULL;
  2820. PyObject *__pyx_t_7 = NULL;
  2821. int __pyx_t_8;
  2822. PyObject *__pyx_t_9 = NULL;
  2823. PyObject *__pyx_t_10 = NULL;
  2824. PyObject *__pyx_t_11 = NULL;
  2825. int __pyx_t_12;
  2826. PyObject *__pyx_t_13 = NULL;
  2827. PyObject *__pyx_t_14 = NULL;
  2828. PyObject *__pyx_t_15 = NULL;
  2829. int __pyx_t_16;
  2830. char const *__pyx_t_17;
  2831. PyObject *__pyx_t_18 = NULL;
  2832. PyObject *__pyx_t_19 = NULL;
  2833. PyObject *__pyx_t_20 = NULL;
  2834. PyObject *__pyx_t_21 = NULL;
  2835. PyObject *__pyx_t_22 = NULL;
  2836. PyObject *__pyx_t_23 = NULL;
  2837. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_24;
  2838. size_t __pyx_t_25;
  2839. Py_ssize_t __pyx_t_26;
  2840. MDB_dbi __pyx_t_27;
  2841. unsigned int __pyx_t_28;
  2842. char const *__pyx_t_29;
  2843. mdb_mode_t __pyx_t_30;
  2844. Py_UCS4 __pyx_t_31;
  2845. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis __pyx_t_32;
  2846. __Pyx_RefNannySetupContext("open_env", 0);
  2847. __Pyx_TraceCall("open_env", __pyx_f[0], 161, 0, __PYX_ERR(0, 161, __pyx_L1_error));
  2848. /* "lakesuperior/store/base_lmdb_store.pyx":165
  2849. * Open, and optionally create, store environment.
  2850. * """
  2851. * if self.is_open: # <<<<<<<<<<<<<<
  2852. * logger.warning('Environment already open.')
  2853. * return
  2854. */
  2855. __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)
  2856. __Pyx_GOTREF(__pyx_t_1);
  2857. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 165, __pyx_L1_error)
  2858. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2859. if (__pyx_t_2) {
  2860. /* "lakesuperior/store/base_lmdb_store.pyx":166
  2861. * """
  2862. * if self.is_open:
  2863. * logger.warning('Environment already open.') # <<<<<<<<<<<<<<
  2864. * return
  2865. *
  2866. */
  2867. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
  2868. __Pyx_GOTREF(__pyx_t_1);
  2869. __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)
  2870. __Pyx_GOTREF(__pyx_t_3);
  2871. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2872. __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)
  2873. __Pyx_GOTREF(__pyx_t_1);
  2874. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2875. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2876. /* "lakesuperior/store/base_lmdb_store.pyx":167
  2877. * if self.is_open:
  2878. * logger.warning('Environment already open.')
  2879. * return # <<<<<<<<<<<<<<
  2880. *
  2881. * logger.debug('Opening environment at {}.'.format(self.env_path))
  2882. */
  2883. __Pyx_XDECREF(__pyx_r);
  2884. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2885. goto __pyx_L0;
  2886. /* "lakesuperior/store/base_lmdb_store.pyx":165
  2887. * Open, and optionally create, store environment.
  2888. * """
  2889. * if self.is_open: # <<<<<<<<<<<<<<
  2890. * logger.warning('Environment already open.')
  2891. * return
  2892. */
  2893. }
  2894. /* "lakesuperior/store/base_lmdb_store.pyx":169
  2895. * return
  2896. *
  2897. * logger.debug('Opening environment at {}.'.format(self.env_path)) # <<<<<<<<<<<<<<
  2898. * if create:
  2899. * #logger.info('Creating db env at {}'.format(self.env_path))
  2900. */
  2901. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
  2902. __Pyx_GOTREF(__pyx_t_3);
  2903. __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)
  2904. __Pyx_GOTREF(__pyx_t_4);
  2905. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2906. __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)
  2907. __Pyx_GOTREF(__pyx_t_5);
  2908. __pyx_t_6 = NULL;
  2909. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  2910. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
  2911. if (likely(__pyx_t_6)) {
  2912. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  2913. __Pyx_INCREF(__pyx_t_6);
  2914. __Pyx_INCREF(function);
  2915. __Pyx_DECREF_SET(__pyx_t_5, function);
  2916. }
  2917. }
  2918. if (!__pyx_t_6) {
  2919. __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)
  2920. __Pyx_GOTREF(__pyx_t_3);
  2921. } else {
  2922. #if CYTHON_FAST_PYCALL
  2923. if (PyFunction_Check(__pyx_t_5)) {
  2924. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->env_path};
  2925. __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)
  2926. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2927. __Pyx_GOTREF(__pyx_t_3);
  2928. } else
  2929. #endif
  2930. #if CYTHON_FAST_PYCCALL
  2931. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  2932. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->env_path};
  2933. __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)
  2934. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2935. __Pyx_GOTREF(__pyx_t_3);
  2936. } else
  2937. #endif
  2938. {
  2939. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 169, __pyx_L1_error)
  2940. __Pyx_GOTREF(__pyx_t_7);
  2941. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
  2942. __Pyx_INCREF(__pyx_v_self->env_path);
  2943. __Pyx_GIVEREF(__pyx_v_self->env_path);
  2944. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_self->env_path);
  2945. __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)
  2946. __Pyx_GOTREF(__pyx_t_3);
  2947. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2948. }
  2949. }
  2950. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2951. __pyx_t_5 = NULL;
  2952. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  2953. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  2954. if (likely(__pyx_t_5)) {
  2955. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2956. __Pyx_INCREF(__pyx_t_5);
  2957. __Pyx_INCREF(function);
  2958. __Pyx_DECREF_SET(__pyx_t_4, function);
  2959. }
  2960. }
  2961. if (!__pyx_t_5) {
  2962. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
  2963. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2964. __Pyx_GOTREF(__pyx_t_1);
  2965. } else {
  2966. #if CYTHON_FAST_PYCALL
  2967. if (PyFunction_Check(__pyx_t_4)) {
  2968. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  2969. __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)
  2970. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2971. __Pyx_GOTREF(__pyx_t_1);
  2972. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2973. } else
  2974. #endif
  2975. #if CYTHON_FAST_PYCCALL
  2976. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  2977. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  2978. __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)
  2979. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2980. __Pyx_GOTREF(__pyx_t_1);
  2981. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2982. } else
  2983. #endif
  2984. {
  2985. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 169, __pyx_L1_error)
  2986. __Pyx_GOTREF(__pyx_t_7);
  2987. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  2988. __Pyx_GIVEREF(__pyx_t_3);
  2989. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3);
  2990. __pyx_t_3 = 0;
  2991. __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)
  2992. __Pyx_GOTREF(__pyx_t_1);
  2993. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2994. }
  2995. }
  2996. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2997. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2998. /* "lakesuperior/store/base_lmdb_store.pyx":170
  2999. *
  3000. * logger.debug('Opening environment at {}.'.format(self.env_path))
  3001. * if create: # <<<<<<<<<<<<<<
  3002. * #logger.info('Creating db env at {}'.format(self.env_path))
  3003. * parent_path = (
  3004. */
  3005. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_create); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 170, __pyx_L1_error)
  3006. if (__pyx_t_2) {
  3007. /* "lakesuperior/store/base_lmdb_store.pyx":174
  3008. * parent_path = (
  3009. * path.dirname(self.env_path)
  3010. * if lmdb.MDB_NOSUBDIR & self.flags # <<<<<<<<<<<<<<
  3011. * else self.env_path)
  3012. *
  3013. */
  3014. __pyx_t_4 = __Pyx_PyInt_From_int(MDB_NOSUBDIR); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
  3015. __Pyx_GOTREF(__pyx_t_4);
  3016. __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)
  3017. __Pyx_GOTREF(__pyx_t_7);
  3018. __pyx_t_3 = PyNumber_And(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
  3019. __Pyx_GOTREF(__pyx_t_3);
  3020. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3021. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3022. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 174, __pyx_L1_error)
  3023. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3024. if (__pyx_t_2) {
  3025. /* "lakesuperior/store/base_lmdb_store.pyx":173
  3026. * #logger.info('Creating db env at {}'.format(self.env_path))
  3027. * parent_path = (
  3028. * path.dirname(self.env_path) # <<<<<<<<<<<<<<
  3029. * if lmdb.MDB_NOSUBDIR & self.flags
  3030. * else self.env_path)
  3031. */
  3032. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 173, __pyx_L1_error)
  3033. __Pyx_GOTREF(__pyx_t_7);
  3034. __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)
  3035. __Pyx_GOTREF(__pyx_t_4);
  3036. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3037. __pyx_t_7 = NULL;
  3038. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  3039. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
  3040. if (likely(__pyx_t_7)) {
  3041. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  3042. __Pyx_INCREF(__pyx_t_7);
  3043. __Pyx_INCREF(function);
  3044. __Pyx_DECREF_SET(__pyx_t_4, function);
  3045. }
  3046. }
  3047. if (!__pyx_t_7) {
  3048. __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)
  3049. __Pyx_GOTREF(__pyx_t_3);
  3050. } else {
  3051. #if CYTHON_FAST_PYCALL
  3052. if (PyFunction_Check(__pyx_t_4)) {
  3053. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_self->env_path};
  3054. __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)
  3055. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3056. __Pyx_GOTREF(__pyx_t_3);
  3057. } else
  3058. #endif
  3059. #if CYTHON_FAST_PYCCALL
  3060. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  3061. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_self->env_path};
  3062. __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)
  3063. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3064. __Pyx_GOTREF(__pyx_t_3);
  3065. } else
  3066. #endif
  3067. {
  3068. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 173, __pyx_L1_error)
  3069. __Pyx_GOTREF(__pyx_t_5);
  3070. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
  3071. __Pyx_INCREF(__pyx_v_self->env_path);
  3072. __Pyx_GIVEREF(__pyx_v_self->env_path);
  3073. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_self->env_path);
  3074. __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)
  3075. __Pyx_GOTREF(__pyx_t_3);
  3076. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3077. }
  3078. }
  3079. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3080. __pyx_t_1 = __pyx_t_3;
  3081. __pyx_t_3 = 0;
  3082. } else {
  3083. /* "lakesuperior/store/base_lmdb_store.pyx":175
  3084. * path.dirname(self.env_path)
  3085. * if lmdb.MDB_NOSUBDIR & self.flags
  3086. * else self.env_path) # <<<<<<<<<<<<<<
  3087. *
  3088. * if not path.exists(parent_path):
  3089. */
  3090. __Pyx_INCREF(__pyx_v_self->env_path);
  3091. __pyx_t_1 = __pyx_v_self->env_path;
  3092. }
  3093. __pyx_v_parent_path = __pyx_t_1;
  3094. __pyx_t_1 = 0;
  3095. /* "lakesuperior/store/base_lmdb_store.pyx":177
  3096. * else self.env_path)
  3097. *
  3098. * if not path.exists(parent_path): # <<<<<<<<<<<<<<
  3099. * #logger.info(
  3100. * # 'Creating store directory at {}'.format(parent_path))
  3101. */
  3102. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
  3103. __Pyx_GOTREF(__pyx_t_3);
  3104. __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)
  3105. __Pyx_GOTREF(__pyx_t_4);
  3106. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3107. __pyx_t_3 = NULL;
  3108. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  3109. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
  3110. if (likely(__pyx_t_3)) {
  3111. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  3112. __Pyx_INCREF(__pyx_t_3);
  3113. __Pyx_INCREF(function);
  3114. __Pyx_DECREF_SET(__pyx_t_4, function);
  3115. }
  3116. }
  3117. if (!__pyx_t_3) {
  3118. __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)
  3119. __Pyx_GOTREF(__pyx_t_1);
  3120. } else {
  3121. #if CYTHON_FAST_PYCALL
  3122. if (PyFunction_Check(__pyx_t_4)) {
  3123. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_parent_path};
  3124. __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)
  3125. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3126. __Pyx_GOTREF(__pyx_t_1);
  3127. } else
  3128. #endif
  3129. #if CYTHON_FAST_PYCCALL
  3130. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  3131. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_parent_path};
  3132. __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)
  3133. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3134. __Pyx_GOTREF(__pyx_t_1);
  3135. } else
  3136. #endif
  3137. {
  3138. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 177, __pyx_L1_error)
  3139. __Pyx_GOTREF(__pyx_t_5);
  3140. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  3141. __Pyx_INCREF(__pyx_v_parent_path);
  3142. __Pyx_GIVEREF(__pyx_v_parent_path);
  3143. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_parent_path);
  3144. __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)
  3145. __Pyx_GOTREF(__pyx_t_1);
  3146. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3147. }
  3148. }
  3149. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3150. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 177, __pyx_L1_error)
  3151. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3152. __pyx_t_8 = ((!__pyx_t_2) != 0);
  3153. if (__pyx_t_8) {
  3154. /* "lakesuperior/store/base_lmdb_store.pyx":180
  3155. * #logger.info(
  3156. * # 'Creating store directory at {}'.format(parent_path))
  3157. * try: # <<<<<<<<<<<<<<
  3158. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3159. * except Exception as e:
  3160. */
  3161. {
  3162. __Pyx_PyThreadState_declare
  3163. __Pyx_PyThreadState_assign
  3164. __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
  3165. __Pyx_XGOTREF(__pyx_t_9);
  3166. __Pyx_XGOTREF(__pyx_t_10);
  3167. __Pyx_XGOTREF(__pyx_t_11);
  3168. /*try:*/ {
  3169. /* "lakesuperior/store/base_lmdb_store.pyx":181
  3170. * # 'Creating store directory at {}'.format(parent_path))
  3171. * try:
  3172. * makedirs(parent_path, mode=0o750, exist_ok=True) # <<<<<<<<<<<<<<
  3173. * except Exception as e:
  3174. * raise LmdbError(
  3175. */
  3176. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_makedirs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L6_error)
  3177. __Pyx_GOTREF(__pyx_t_1);
  3178. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L6_error)
  3179. __Pyx_GOTREF(__pyx_t_4);
  3180. __Pyx_INCREF(__pyx_v_parent_path);
  3181. __Pyx_GIVEREF(__pyx_v_parent_path);
  3182. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_parent_path);
  3183. __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L6_error)
  3184. __Pyx_GOTREF(__pyx_t_5);
  3185. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_mode, __pyx_int_488) < 0) __PYX_ERR(0, 181, __pyx_L6_error)
  3186. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_exist_ok, Py_True) < 0) __PYX_ERR(0, 181, __pyx_L6_error)
  3187. __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)
  3188. __Pyx_GOTREF(__pyx_t_3);
  3189. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3190. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3191. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3192. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3193. /* "lakesuperior/store/base_lmdb_store.pyx":180
  3194. * #logger.info(
  3195. * # 'Creating store directory at {}'.format(parent_path))
  3196. * try: # <<<<<<<<<<<<<<
  3197. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3198. * except Exception as e:
  3199. */
  3200. }
  3201. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3202. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3203. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  3204. goto __pyx_L11_try_end;
  3205. __pyx_L6_error:;
  3206. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3207. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3208. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3209. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  3210. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3211. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3212. /* "lakesuperior/store/base_lmdb_store.pyx":182
  3213. * try:
  3214. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3215. * except Exception as e: # <<<<<<<<<<<<<<
  3216. * raise LmdbError(
  3217. * 'Could not create store at {}. Error: {}'.format(
  3218. */
  3219. __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  3220. if (__pyx_t_12) {
  3221. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.open_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3222. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(0, 182, __pyx_L8_except_error)
  3223. __Pyx_GOTREF(__pyx_t_3);
  3224. __Pyx_GOTREF(__pyx_t_5);
  3225. __Pyx_GOTREF(__pyx_t_4);
  3226. __Pyx_INCREF(__pyx_t_5);
  3227. __pyx_v_e = __pyx_t_5;
  3228. /*try:*/ {
  3229. /* "lakesuperior/store/base_lmdb_store.pyx":183
  3230. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3231. * except Exception as e:
  3232. * raise LmdbError( # <<<<<<<<<<<<<<
  3233. * 'Could not create store at {}. Error: {}'.format(
  3234. * self.env_path, e))
  3235. */
  3236. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 183, __pyx_L17_error)
  3237. __Pyx_GOTREF(__pyx_t_7);
  3238. /* "lakesuperior/store/base_lmdb_store.pyx":184
  3239. * except Exception as e:
  3240. * raise LmdbError(
  3241. * 'Could not create store at {}. Error: {}'.format( # <<<<<<<<<<<<<<
  3242. * self.env_path, e))
  3243. *
  3244. */
  3245. __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)
  3246. __Pyx_GOTREF(__pyx_t_13);
  3247. /* "lakesuperior/store/base_lmdb_store.pyx":185
  3248. * raise LmdbError(
  3249. * 'Could not create store at {}. Error: {}'.format(
  3250. * self.env_path, e)) # <<<<<<<<<<<<<<
  3251. *
  3252. * # Create environment handle.
  3253. */
  3254. __pyx_t_14 = NULL;
  3255. __pyx_t_12 = 0;
  3256. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  3257. __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
  3258. if (likely(__pyx_t_14)) {
  3259. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  3260. __Pyx_INCREF(__pyx_t_14);
  3261. __Pyx_INCREF(function);
  3262. __Pyx_DECREF_SET(__pyx_t_13, function);
  3263. __pyx_t_12 = 1;
  3264. }
  3265. }
  3266. #if CYTHON_FAST_PYCALL
  3267. if (PyFunction_Check(__pyx_t_13)) {
  3268. PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_self->env_path, __pyx_v_e};
  3269. __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)
  3270. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  3271. __Pyx_GOTREF(__pyx_t_6);
  3272. } else
  3273. #endif
  3274. #if CYTHON_FAST_PYCCALL
  3275. if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
  3276. PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_self->env_path, __pyx_v_e};
  3277. __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)
  3278. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  3279. __Pyx_GOTREF(__pyx_t_6);
  3280. } else
  3281. #endif
  3282. {
  3283. __pyx_t_15 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 184, __pyx_L17_error)
  3284. __Pyx_GOTREF(__pyx_t_15);
  3285. if (__pyx_t_14) {
  3286. __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
  3287. }
  3288. __Pyx_INCREF(__pyx_v_self->env_path);
  3289. __Pyx_GIVEREF(__pyx_v_self->env_path);
  3290. PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_12, __pyx_v_self->env_path);
  3291. __Pyx_INCREF(__pyx_v_e);
  3292. __Pyx_GIVEREF(__pyx_v_e);
  3293. PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_12, __pyx_v_e);
  3294. __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)
  3295. __Pyx_GOTREF(__pyx_t_6);
  3296. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3297. }
  3298. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3299. __pyx_t_13 = NULL;
  3300. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
  3301. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
  3302. if (likely(__pyx_t_13)) {
  3303. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  3304. __Pyx_INCREF(__pyx_t_13);
  3305. __Pyx_INCREF(function);
  3306. __Pyx_DECREF_SET(__pyx_t_7, function);
  3307. }
  3308. }
  3309. if (!__pyx_t_13) {
  3310. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L17_error)
  3311. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3312. __Pyx_GOTREF(__pyx_t_1);
  3313. } else {
  3314. #if CYTHON_FAST_PYCALL
  3315. if (PyFunction_Check(__pyx_t_7)) {
  3316. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  3317. __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)
  3318. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3319. __Pyx_GOTREF(__pyx_t_1);
  3320. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3321. } else
  3322. #endif
  3323. #if CYTHON_FAST_PYCCALL
  3324. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  3325. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  3326. __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)
  3327. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3328. __Pyx_GOTREF(__pyx_t_1);
  3329. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3330. } else
  3331. #endif
  3332. {
  3333. __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 183, __pyx_L17_error)
  3334. __Pyx_GOTREF(__pyx_t_15);
  3335. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
  3336. __Pyx_GIVEREF(__pyx_t_6);
  3337. PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_6);
  3338. __pyx_t_6 = 0;
  3339. __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)
  3340. __Pyx_GOTREF(__pyx_t_1);
  3341. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3342. }
  3343. }
  3344. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3345. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  3346. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3347. __PYX_ERR(0, 183, __pyx_L17_error)
  3348. }
  3349. /* "lakesuperior/store/base_lmdb_store.pyx":182
  3350. * try:
  3351. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3352. * except Exception as e: # <<<<<<<<<<<<<<
  3353. * raise LmdbError(
  3354. * 'Could not create store at {}. Error: {}'.format(
  3355. */
  3356. /*finally:*/ {
  3357. __pyx_L17_error:;
  3358. /*exception exit:*/{
  3359. __Pyx_PyThreadState_declare
  3360. __Pyx_PyThreadState_assign
  3361. __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
  3362. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  3363. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3364. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3365. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  3366. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3367. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3368. if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
  3369. 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);
  3370. __Pyx_XGOTREF(__pyx_t_18);
  3371. __Pyx_XGOTREF(__pyx_t_19);
  3372. __Pyx_XGOTREF(__pyx_t_20);
  3373. __Pyx_XGOTREF(__pyx_t_21);
  3374. __Pyx_XGOTREF(__pyx_t_22);
  3375. __Pyx_XGOTREF(__pyx_t_23);
  3376. __pyx_t_12 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
  3377. {
  3378. __Pyx_DECREF(__pyx_v_e);
  3379. __pyx_v_e = NULL;
  3380. }
  3381. if (PY_MAJOR_VERSION >= 3) {
  3382. __Pyx_XGIVEREF(__pyx_t_21);
  3383. __Pyx_XGIVEREF(__pyx_t_22);
  3384. __Pyx_XGIVEREF(__pyx_t_23);
  3385. __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
  3386. }
  3387. __Pyx_XGIVEREF(__pyx_t_18);
  3388. __Pyx_XGIVEREF(__pyx_t_19);
  3389. __Pyx_XGIVEREF(__pyx_t_20);
  3390. __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
  3391. __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
  3392. __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
  3393. goto __pyx_L8_except_error;
  3394. }
  3395. }
  3396. }
  3397. goto __pyx_L8_except_error;
  3398. __pyx_L8_except_error:;
  3399. /* "lakesuperior/store/base_lmdb_store.pyx":180
  3400. * #logger.info(
  3401. * # 'Creating store directory at {}'.format(parent_path))
  3402. * try: # <<<<<<<<<<<<<<
  3403. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3404. * except Exception as e:
  3405. */
  3406. __Pyx_XGIVEREF(__pyx_t_9);
  3407. __Pyx_XGIVEREF(__pyx_t_10);
  3408. __Pyx_XGIVEREF(__pyx_t_11);
  3409. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
  3410. goto __pyx_L1_error;
  3411. __pyx_L11_try_end:;
  3412. }
  3413. /* "lakesuperior/store/base_lmdb_store.pyx":177
  3414. * else self.env_path)
  3415. *
  3416. * if not path.exists(parent_path): # <<<<<<<<<<<<<<
  3417. * #logger.info(
  3418. * # 'Creating store directory at {}'.format(parent_path))
  3419. */
  3420. }
  3421. /* "lakesuperior/store/base_lmdb_store.pyx":170
  3422. *
  3423. * logger.debug('Opening environment at {}.'.format(self.env_path))
  3424. * if create: # <<<<<<<<<<<<<<
  3425. * #logger.info('Creating db env at {}'.format(self.env_path))
  3426. * parent_path = (
  3427. */
  3428. }
  3429. /* "lakesuperior/store/base_lmdb_store.pyx":188
  3430. *
  3431. * # Create environment handle.
  3432. * _check( # <<<<<<<<<<<<<<
  3433. * lmdb.mdb_env_create(&self.dbenv),
  3434. * 'Error creating DB environment handle: {}')
  3435. */
  3436. __pyx_t_24.__pyx_n = 1;
  3437. __pyx_t_24.message = __pyx_kp_u_Error_creating_DB_environment_ha;
  3438. __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)
  3439. /* "lakesuperior/store/base_lmdb_store.pyx":191
  3440. * lmdb.mdb_env_create(&self.dbenv),
  3441. * 'Error creating DB environment handle: {}')
  3442. * logger.debug('Created DBenv @ {:x}'.format(<unsigned long>self.dbenv)) # <<<<<<<<<<<<<<
  3443. *
  3444. * # Set map size.
  3445. */
  3446. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error)
  3447. __Pyx_GOTREF(__pyx_t_5);
  3448. __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)
  3449. __Pyx_GOTREF(__pyx_t_3);
  3450. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3451. __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)
  3452. __Pyx_GOTREF(__pyx_t_1);
  3453. __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)
  3454. __Pyx_GOTREF(__pyx_t_7);
  3455. __pyx_t_15 = NULL;
  3456. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  3457. __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
  3458. if (likely(__pyx_t_15)) {
  3459. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  3460. __Pyx_INCREF(__pyx_t_15);
  3461. __Pyx_INCREF(function);
  3462. __Pyx_DECREF_SET(__pyx_t_1, function);
  3463. }
  3464. }
  3465. if (!__pyx_t_15) {
  3466. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error)
  3467. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3468. __Pyx_GOTREF(__pyx_t_5);
  3469. } else {
  3470. #if CYTHON_FAST_PYCALL
  3471. if (PyFunction_Check(__pyx_t_1)) {
  3472. PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_7};
  3473. __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)
  3474. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  3475. __Pyx_GOTREF(__pyx_t_5);
  3476. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3477. } else
  3478. #endif
  3479. #if CYTHON_FAST_PYCCALL
  3480. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  3481. PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_7};
  3482. __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)
  3483. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  3484. __Pyx_GOTREF(__pyx_t_5);
  3485. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3486. } else
  3487. #endif
  3488. {
  3489. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 191, __pyx_L1_error)
  3490. __Pyx_GOTREF(__pyx_t_6);
  3491. __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_15); __pyx_t_15 = NULL;
  3492. __Pyx_GIVEREF(__pyx_t_7);
  3493. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_7);
  3494. __pyx_t_7 = 0;
  3495. __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)
  3496. __Pyx_GOTREF(__pyx_t_5);
  3497. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3498. }
  3499. }
  3500. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3501. __pyx_t_1 = NULL;
  3502. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  3503. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
  3504. if (likely(__pyx_t_1)) {
  3505. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  3506. __Pyx_INCREF(__pyx_t_1);
  3507. __Pyx_INCREF(function);
  3508. __Pyx_DECREF_SET(__pyx_t_3, function);
  3509. }
  3510. }
  3511. if (!__pyx_t_1) {
  3512. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 191, __pyx_L1_error)
  3513. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3514. __Pyx_GOTREF(__pyx_t_4);
  3515. } else {
  3516. #if CYTHON_FAST_PYCALL
  3517. if (PyFunction_Check(__pyx_t_3)) {
  3518. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
  3519. __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)
  3520. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3521. __Pyx_GOTREF(__pyx_t_4);
  3522. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3523. } else
  3524. #endif
  3525. #if CYTHON_FAST_PYCCALL
  3526. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  3527. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
  3528. __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)
  3529. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3530. __Pyx_GOTREF(__pyx_t_4);
  3531. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3532. } else
  3533. #endif
  3534. {
  3535. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 191, __pyx_L1_error)
  3536. __Pyx_GOTREF(__pyx_t_6);
  3537. __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
  3538. __Pyx_GIVEREF(__pyx_t_5);
  3539. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
  3540. __pyx_t_5 = 0;
  3541. __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)
  3542. __Pyx_GOTREF(__pyx_t_4);
  3543. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3544. }
  3545. }
  3546. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3547. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3548. /* "lakesuperior/store/base_lmdb_store.pyx":195
  3549. * # Set map size.
  3550. * _check(
  3551. * lmdb.mdb_env_set_mapsize(self.dbenv, self.options.get( # <<<<<<<<<<<<<<
  3552. * 'map_size', 1024 ** 3)),
  3553. * 'Error setting map size: {}')
  3554. */
  3555. __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)
  3556. __Pyx_GOTREF(__pyx_t_4);
  3557. __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)
  3558. __Pyx_GOTREF(__pyx_t_3);
  3559. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3560. __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)
  3561. __Pyx_GOTREF(__pyx_t_4);
  3562. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3563. __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)
  3564. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3565. /* "lakesuperior/store/base_lmdb_store.pyx":194
  3566. *
  3567. * # Set map size.
  3568. * _check( # <<<<<<<<<<<<<<
  3569. * lmdb.mdb_env_set_mapsize(self.dbenv, self.options.get(
  3570. * 'map_size', 1024 ** 3)),
  3571. */
  3572. __pyx_t_24.__pyx_n = 1;
  3573. __pyx_t_24.message = __pyx_kp_u_Error_setting_map_size;
  3574. __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)
  3575. /* "lakesuperior/store/base_lmdb_store.pyx":200
  3576. *
  3577. * # Set max databases.
  3578. * max_dbs = self.options.get('max_dbs', len(self.dbi_labels)) # <<<<<<<<<<<<<<
  3579. * _check(
  3580. * lmdb.mdb_env_set_maxdbs(self.dbenv, max_dbs),
  3581. */
  3582. __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)
  3583. __Pyx_GOTREF(__pyx_t_3);
  3584. __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)
  3585. __Pyx_GOTREF(__pyx_t_6);
  3586. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3587. __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)
  3588. __Pyx_GOTREF(__pyx_t_3);
  3589. __pyx_t_26 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_26 == ((Py_ssize_t)-1))) __PYX_ERR(0, 200, __pyx_L1_error)
  3590. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3591. __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_26); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
  3592. __Pyx_GOTREF(__pyx_t_3);
  3593. __pyx_t_5 = NULL;
  3594. __pyx_t_16 = 0;
  3595. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  3596. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
  3597. if (likely(__pyx_t_5)) {
  3598. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  3599. __Pyx_INCREF(__pyx_t_5);
  3600. __Pyx_INCREF(function);
  3601. __Pyx_DECREF_SET(__pyx_t_6, function);
  3602. __pyx_t_16 = 1;
  3603. }
  3604. }
  3605. #if CYTHON_FAST_PYCALL
  3606. if (PyFunction_Check(__pyx_t_6)) {
  3607. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_n_u_max_dbs, __pyx_t_3};
  3608. __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)
  3609. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3610. __Pyx_GOTREF(__pyx_t_4);
  3611. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3612. } else
  3613. #endif
  3614. #if CYTHON_FAST_PYCCALL
  3615. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  3616. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_n_u_max_dbs, __pyx_t_3};
  3617. __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)
  3618. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3619. __Pyx_GOTREF(__pyx_t_4);
  3620. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3621. } else
  3622. #endif
  3623. {
  3624. __pyx_t_1 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
  3625. __Pyx_GOTREF(__pyx_t_1);
  3626. if (__pyx_t_5) {
  3627. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL;
  3628. }
  3629. __Pyx_INCREF(__pyx_n_u_max_dbs);
  3630. __Pyx_GIVEREF(__pyx_n_u_max_dbs);
  3631. PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_16, __pyx_n_u_max_dbs);
  3632. __Pyx_GIVEREF(__pyx_t_3);
  3633. PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_16, __pyx_t_3);
  3634. __pyx_t_3 = 0;
  3635. __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)
  3636. __Pyx_GOTREF(__pyx_t_4);
  3637. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3638. }
  3639. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3640. __pyx_v_max_dbs = __pyx_t_4;
  3641. __pyx_t_4 = 0;
  3642. /* "lakesuperior/store/base_lmdb_store.pyx":202
  3643. * max_dbs = self.options.get('max_dbs', len(self.dbi_labels))
  3644. * _check(
  3645. * lmdb.mdb_env_set_maxdbs(self.dbenv, max_dbs), # <<<<<<<<<<<<<<
  3646. * 'Error setting max. databases: {}')
  3647. *
  3648. */
  3649. __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)
  3650. /* "lakesuperior/store/base_lmdb_store.pyx":201
  3651. * # Set max databases.
  3652. * max_dbs = self.options.get('max_dbs', len(self.dbi_labels))
  3653. * _check( # <<<<<<<<<<<<<<
  3654. * lmdb.mdb_env_set_maxdbs(self.dbenv, max_dbs),
  3655. * 'Error setting max. databases: {}')
  3656. */
  3657. __pyx_t_24.__pyx_n = 1;
  3658. __pyx_t_24.message = __pyx_kp_u_Error_setting_max_databases;
  3659. __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)
  3660. /* "lakesuperior/store/base_lmdb_store.pyx":206
  3661. *
  3662. * # Set max readers.
  3663. * self._readers = self.options.get( # <<<<<<<<<<<<<<
  3664. * 'max_spare_txns', wsgi.workers * self.readers_mult)
  3665. * _check(
  3666. */
  3667. __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)
  3668. __Pyx_GOTREF(__pyx_t_6);
  3669. __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)
  3670. __Pyx_GOTREF(__pyx_t_1);
  3671. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3672. /* "lakesuperior/store/base_lmdb_store.pyx":207
  3673. * # Set max readers.
  3674. * self._readers = self.options.get(
  3675. * 'max_spare_txns', wsgi.workers * self.readers_mult) # <<<<<<<<<<<<<<
  3676. * _check(
  3677. * lmdb.mdb_env_set_maxreaders(self.dbenv, self._readers),
  3678. */
  3679. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_wsgi); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 207, __pyx_L1_error)
  3680. __Pyx_GOTREF(__pyx_t_6);
  3681. __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)
  3682. __Pyx_GOTREF(__pyx_t_3);
  3683. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3684. __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)
  3685. __Pyx_GOTREF(__pyx_t_6);
  3686. __pyx_t_5 = PyNumber_Multiply(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error)
  3687. __Pyx_GOTREF(__pyx_t_5);
  3688. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3689. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3690. __pyx_t_6 = NULL;
  3691. __pyx_t_16 = 0;
  3692. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  3693. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
  3694. if (likely(__pyx_t_6)) {
  3695. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  3696. __Pyx_INCREF(__pyx_t_6);
  3697. __Pyx_INCREF(function);
  3698. __Pyx_DECREF_SET(__pyx_t_1, function);
  3699. __pyx_t_16 = 1;
  3700. }
  3701. }
  3702. #if CYTHON_FAST_PYCALL
  3703. if (PyFunction_Check(__pyx_t_1)) {
  3704. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_n_u_max_spare_txns, __pyx_t_5};
  3705. __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)
  3706. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3707. __Pyx_GOTREF(__pyx_t_4);
  3708. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3709. } else
  3710. #endif
  3711. #if CYTHON_FAST_PYCCALL
  3712. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  3713. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_n_u_max_spare_txns, __pyx_t_5};
  3714. __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)
  3715. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3716. __Pyx_GOTREF(__pyx_t_4);
  3717. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3718. } else
  3719. #endif
  3720. {
  3721. __pyx_t_3 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 206, __pyx_L1_error)
  3722. __Pyx_GOTREF(__pyx_t_3);
  3723. if (__pyx_t_6) {
  3724. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
  3725. }
  3726. __Pyx_INCREF(__pyx_n_u_max_spare_txns);
  3727. __Pyx_GIVEREF(__pyx_n_u_max_spare_txns);
  3728. PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_16, __pyx_n_u_max_spare_txns);
  3729. __Pyx_GIVEREF(__pyx_t_5);
  3730. PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_16, __pyx_t_5);
  3731. __pyx_t_5 = 0;
  3732. __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)
  3733. __Pyx_GOTREF(__pyx_t_4);
  3734. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3735. }
  3736. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3737. /* "lakesuperior/store/base_lmdb_store.pyx":206
  3738. *
  3739. * # Set max readers.
  3740. * self._readers = self.options.get( # <<<<<<<<<<<<<<
  3741. * 'max_spare_txns', wsgi.workers * self.readers_mult)
  3742. * _check(
  3743. */
  3744. __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)
  3745. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3746. __pyx_v_self->_readers = __pyx_t_28;
  3747. /* "lakesuperior/store/base_lmdb_store.pyx":208
  3748. * self._readers = self.options.get(
  3749. * 'max_spare_txns', wsgi.workers * self.readers_mult)
  3750. * _check( # <<<<<<<<<<<<<<
  3751. * lmdb.mdb_env_set_maxreaders(self.dbenv, self._readers),
  3752. * 'Error setting max. readers: {}')
  3753. */
  3754. __pyx_t_24.__pyx_n = 1;
  3755. __pyx_t_24.message = __pyx_kp_u_Error_setting_max_readers;
  3756. __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)
  3757. /* "lakesuperior/store/base_lmdb_store.pyx":211
  3758. * lmdb.mdb_env_set_maxreaders(self.dbenv, self._readers),
  3759. * 'Error setting max. readers: {}')
  3760. * logger.debug('Max. readers: {}'.format(self._readers)) # <<<<<<<<<<<<<<
  3761. *
  3762. * # Clear stale readers.
  3763. */
  3764. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
  3765. __Pyx_GOTREF(__pyx_t_1);
  3766. __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)
  3767. __Pyx_GOTREF(__pyx_t_3);
  3768. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3769. __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)
  3770. __Pyx_GOTREF(__pyx_t_5);
  3771. __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->_readers); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 211, __pyx_L1_error)
  3772. __Pyx_GOTREF(__pyx_t_6);
  3773. __pyx_t_7 = NULL;
  3774. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  3775. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  3776. if (likely(__pyx_t_7)) {
  3777. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  3778. __Pyx_INCREF(__pyx_t_7);
  3779. __Pyx_INCREF(function);
  3780. __Pyx_DECREF_SET(__pyx_t_5, function);
  3781. }
  3782. }
  3783. if (!__pyx_t_7) {
  3784. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
  3785. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3786. __Pyx_GOTREF(__pyx_t_1);
  3787. } else {
  3788. #if CYTHON_FAST_PYCALL
  3789. if (PyFunction_Check(__pyx_t_5)) {
  3790. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  3791. __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)
  3792. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3793. __Pyx_GOTREF(__pyx_t_1);
  3794. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3795. } else
  3796. #endif
  3797. #if CYTHON_FAST_PYCCALL
  3798. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  3799. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  3800. __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)
  3801. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3802. __Pyx_GOTREF(__pyx_t_1);
  3803. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3804. } else
  3805. #endif
  3806. {
  3807. __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 211, __pyx_L1_error)
  3808. __Pyx_GOTREF(__pyx_t_15);
  3809. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_7); __pyx_t_7 = NULL;
  3810. __Pyx_GIVEREF(__pyx_t_6);
  3811. PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_6);
  3812. __pyx_t_6 = 0;
  3813. __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)
  3814. __Pyx_GOTREF(__pyx_t_1);
  3815. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3816. }
  3817. }
  3818. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3819. __pyx_t_5 = NULL;
  3820. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  3821. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
  3822. if (likely(__pyx_t_5)) {
  3823. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  3824. __Pyx_INCREF(__pyx_t_5);
  3825. __Pyx_INCREF(function);
  3826. __Pyx_DECREF_SET(__pyx_t_3, function);
  3827. }
  3828. }
  3829. if (!__pyx_t_5) {
  3830. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 211, __pyx_L1_error)
  3831. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3832. __Pyx_GOTREF(__pyx_t_4);
  3833. } else {
  3834. #if CYTHON_FAST_PYCALL
  3835. if (PyFunction_Check(__pyx_t_3)) {
  3836. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1};
  3837. __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)
  3838. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3839. __Pyx_GOTREF(__pyx_t_4);
  3840. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3841. } else
  3842. #endif
  3843. #if CYTHON_FAST_PYCCALL
  3844. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  3845. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1};
  3846. __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)
  3847. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3848. __Pyx_GOTREF(__pyx_t_4);
  3849. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3850. } else
  3851. #endif
  3852. {
  3853. __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 211, __pyx_L1_error)
  3854. __Pyx_GOTREF(__pyx_t_15);
  3855. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_5); __pyx_t_5 = NULL;
  3856. __Pyx_GIVEREF(__pyx_t_1);
  3857. PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_1);
  3858. __pyx_t_1 = 0;
  3859. __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)
  3860. __Pyx_GOTREF(__pyx_t_4);
  3861. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3862. }
  3863. }
  3864. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3865. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3866. /* "lakesuperior/store/base_lmdb_store.pyx":214
  3867. *
  3868. * # Clear stale readers.
  3869. * self._clear_stale_readers() # <<<<<<<<<<<<<<
  3870. *
  3871. * # Open DB environment.
  3872. */
  3873. ((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)
  3874. /* "lakesuperior/store/base_lmdb_store.pyx":217
  3875. *
  3876. * # Open DB environment.
  3877. * logger.debug('DBenv address: {:x}'.format(<unsigned long>self.dbenv)) # <<<<<<<<<<<<<<
  3878. * _check(
  3879. * lmdb.mdb_env_open(
  3880. */
  3881. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  3882. __Pyx_GOTREF(__pyx_t_3);
  3883. __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)
  3884. __Pyx_GOTREF(__pyx_t_15);
  3885. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3886. __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)
  3887. __Pyx_GOTREF(__pyx_t_1);
  3888. __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)
  3889. __Pyx_GOTREF(__pyx_t_5);
  3890. __pyx_t_6 = NULL;
  3891. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  3892. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
  3893. if (likely(__pyx_t_6)) {
  3894. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  3895. __Pyx_INCREF(__pyx_t_6);
  3896. __Pyx_INCREF(function);
  3897. __Pyx_DECREF_SET(__pyx_t_1, function);
  3898. }
  3899. }
  3900. if (!__pyx_t_6) {
  3901. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  3902. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3903. __Pyx_GOTREF(__pyx_t_3);
  3904. } else {
  3905. #if CYTHON_FAST_PYCALL
  3906. if (PyFunction_Check(__pyx_t_1)) {
  3907. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
  3908. __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)
  3909. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3910. __Pyx_GOTREF(__pyx_t_3);
  3911. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3912. } else
  3913. #endif
  3914. #if CYTHON_FAST_PYCCALL
  3915. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  3916. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
  3917. __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)
  3918. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3919. __Pyx_GOTREF(__pyx_t_3);
  3920. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3921. } else
  3922. #endif
  3923. {
  3924. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 217, __pyx_L1_error)
  3925. __Pyx_GOTREF(__pyx_t_7);
  3926. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
  3927. __Pyx_GIVEREF(__pyx_t_5);
  3928. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
  3929. __pyx_t_5 = 0;
  3930. __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)
  3931. __Pyx_GOTREF(__pyx_t_3);
  3932. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3933. }
  3934. }
  3935. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3936. __pyx_t_1 = NULL;
  3937. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
  3938. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
  3939. if (likely(__pyx_t_1)) {
  3940. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
  3941. __Pyx_INCREF(__pyx_t_1);
  3942. __Pyx_INCREF(function);
  3943. __Pyx_DECREF_SET(__pyx_t_15, function);
  3944. }
  3945. }
  3946. if (!__pyx_t_1) {
  3947. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 217, __pyx_L1_error)
  3948. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3949. __Pyx_GOTREF(__pyx_t_4);
  3950. } else {
  3951. #if CYTHON_FAST_PYCALL
  3952. if (PyFunction_Check(__pyx_t_15)) {
  3953. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
  3954. __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)
  3955. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3956. __Pyx_GOTREF(__pyx_t_4);
  3957. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3958. } else
  3959. #endif
  3960. #if CYTHON_FAST_PYCCALL
  3961. if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
  3962. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
  3963. __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)
  3964. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3965. __Pyx_GOTREF(__pyx_t_4);
  3966. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3967. } else
  3968. #endif
  3969. {
  3970. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 217, __pyx_L1_error)
  3971. __Pyx_GOTREF(__pyx_t_7);
  3972. __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
  3973. __Pyx_GIVEREF(__pyx_t_3);
  3974. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3);
  3975. __pyx_t_3 = 0;
  3976. __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)
  3977. __Pyx_GOTREF(__pyx_t_4);
  3978. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3979. }
  3980. }
  3981. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3982. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3983. /* "lakesuperior/store/base_lmdb_store.pyx":220
  3984. * _check(
  3985. * lmdb.mdb_env_open(
  3986. * self.dbenv, self.env_path.encode(), # <<<<<<<<<<<<<<
  3987. * self.env_flags, self.env_perms),
  3988. * f'Error opening the database environment: {self.env_path}.')
  3989. */
  3990. if (unlikely(__pyx_v_self->env_path == Py_None)) {
  3991. PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
  3992. __PYX_ERR(0, 220, __pyx_L1_error)
  3993. }
  3994. __pyx_t_4 = PyUnicode_AsEncodedString(__pyx_v_self->env_path, NULL, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 220, __pyx_L1_error)
  3995. __Pyx_GOTREF(__pyx_t_4);
  3996. __pyx_t_29 = __Pyx_PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_29) && PyErr_Occurred())) __PYX_ERR(0, 220, __pyx_L1_error)
  3997. /* "lakesuperior/store/base_lmdb_store.pyx":221
  3998. * lmdb.mdb_env_open(
  3999. * self.dbenv, self.env_path.encode(),
  4000. * self.env_flags, self.env_perms), # <<<<<<<<<<<<<<
  4001. * f'Error opening the database environment: {self.env_path}.')
  4002. *
  4003. */
  4004. __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)
  4005. __Pyx_GOTREF(__pyx_t_15);
  4006. __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)
  4007. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4008. __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)
  4009. __Pyx_GOTREF(__pyx_t_15);
  4010. __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)
  4011. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4012. /* "lakesuperior/store/base_lmdb_store.pyx":222
  4013. * self.dbenv, self.env_path.encode(),
  4014. * self.env_flags, self.env_perms),
  4015. * f'Error opening the database environment: {self.env_path}.') # <<<<<<<<<<<<<<
  4016. *
  4017. * self._init_dbis(create)
  4018. */
  4019. __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 222, __pyx_L1_error)
  4020. __Pyx_GOTREF(__pyx_t_15);
  4021. __pyx_t_26 = 0;
  4022. __pyx_t_31 = 127;
  4023. __Pyx_INCREF(__pyx_kp_u_Error_opening_the_database_envir);
  4024. __pyx_t_26 += 40;
  4025. __Pyx_GIVEREF(__pyx_kp_u_Error_opening_the_database_envir);
  4026. PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_opening_the_database_envir);
  4027. __pyx_t_7 = __Pyx_PyUnicode_Unicode(__pyx_v_self->env_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 222, __pyx_L1_error)
  4028. __Pyx_GOTREF(__pyx_t_7);
  4029. __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;
  4030. __pyx_t_26 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
  4031. __Pyx_GIVEREF(__pyx_t_7);
  4032. PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_7);
  4033. __pyx_t_7 = 0;
  4034. __Pyx_INCREF(__pyx_kp_u__4);
  4035. __pyx_t_26 += 1;
  4036. __Pyx_GIVEREF(__pyx_kp_u__4);
  4037. PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_kp_u__4);
  4038. __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)
  4039. __Pyx_GOTREF(__pyx_t_7);
  4040. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4041. /* "lakesuperior/store/base_lmdb_store.pyx":218
  4042. * # Open DB environment.
  4043. * logger.debug('DBenv address: {:x}'.format(<unsigned long>self.dbenv))
  4044. * _check( # <<<<<<<<<<<<<<
  4045. * lmdb.mdb_env_open(
  4046. * self.dbenv, self.env_path.encode(),
  4047. */
  4048. __pyx_t_24.__pyx_n = 1;
  4049. __pyx_t_24.message = ((PyObject*)__pyx_t_7);
  4050. __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)
  4051. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4052. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4053. /* "lakesuperior/store/base_lmdb_store.pyx":224
  4054. * f'Error opening the database environment: {self.env_path}.')
  4055. *
  4056. * self._init_dbis(create) # <<<<<<<<<<<<<<
  4057. * self._open = True
  4058. *
  4059. */
  4060. __pyx_t_32.__pyx_n = 1;
  4061. __pyx_t_32.create = __pyx_v_create;
  4062. ((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)
  4063. /* "lakesuperior/store/base_lmdb_store.pyx":225
  4064. *
  4065. * self._init_dbis(create)
  4066. * self._open = True # <<<<<<<<<<<<<<
  4067. *
  4068. *
  4069. */
  4070. __pyx_v_self->_open = 1;
  4071. /* "lakesuperior/store/base_lmdb_store.pyx":161
  4072. *
  4073. *
  4074. * def open_env(self, create): # <<<<<<<<<<<<<<
  4075. * """
  4076. * Open, and optionally create, store environment.
  4077. */
  4078. /* function exit code */
  4079. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4080. goto __pyx_L0;
  4081. __pyx_L1_error:;
  4082. __Pyx_XDECREF(__pyx_t_1);
  4083. __Pyx_XDECREF(__pyx_t_3);
  4084. __Pyx_XDECREF(__pyx_t_4);
  4085. __Pyx_XDECREF(__pyx_t_5);
  4086. __Pyx_XDECREF(__pyx_t_6);
  4087. __Pyx_XDECREF(__pyx_t_7);
  4088. __Pyx_XDECREF(__pyx_t_13);
  4089. __Pyx_XDECREF(__pyx_t_14);
  4090. __Pyx_XDECREF(__pyx_t_15);
  4091. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.open_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4092. __pyx_r = NULL;
  4093. __pyx_L0:;
  4094. __Pyx_XDECREF(__pyx_v_parent_path);
  4095. __Pyx_XDECREF(__pyx_v_e);
  4096. __Pyx_XDECREF(__pyx_v_max_dbs);
  4097. __Pyx_XGIVEREF(__pyx_r);
  4098. __Pyx_TraceReturn(__pyx_r, 0);
  4099. __Pyx_RefNannyFinishContext();
  4100. return __pyx_r;
  4101. }
  4102. /* "lakesuperior/store/base_lmdb_store.pyx":228
  4103. *
  4104. *
  4105. * cdef void _clear_stale_readers(self) except *: # <<<<<<<<<<<<<<
  4106. * """
  4107. * Clear stale readers.
  4108. */
  4109. 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) {
  4110. int __pyx_v_stale_readers;
  4111. __Pyx_TraceDeclarations
  4112. __Pyx_RefNannyDeclarations
  4113. int __pyx_t_1;
  4114. PyObject *__pyx_t_2 = NULL;
  4115. PyObject *__pyx_t_3 = NULL;
  4116. PyObject *__pyx_t_4 = NULL;
  4117. PyObject *__pyx_t_5 = NULL;
  4118. PyObject *__pyx_t_6 = NULL;
  4119. PyObject *__pyx_t_7 = NULL;
  4120. PyObject *__pyx_t_8 = NULL;
  4121. __Pyx_RefNannySetupContext("_clear_stale_readers", 0);
  4122. __Pyx_TraceCall("_clear_stale_readers", __pyx_f[0], 228, 0, __PYX_ERR(0, 228, __pyx_L1_error));
  4123. /* "lakesuperior/store/base_lmdb_store.pyx":234
  4124. * cdef int stale_readers
  4125. *
  4126. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers)) # <<<<<<<<<<<<<<
  4127. * if stale_readers > 0:
  4128. * logger.debug('Cleared {} stale readers.'.format(stale_readers))
  4129. */
  4130. __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)
  4131. /* "lakesuperior/store/base_lmdb_store.pyx":235
  4132. *
  4133. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers))
  4134. * if stale_readers > 0: # <<<<<<<<<<<<<<
  4135. * logger.debug('Cleared {} stale readers.'.format(stale_readers))
  4136. *
  4137. */
  4138. __pyx_t_1 = ((__pyx_v_stale_readers > 0) != 0);
  4139. if (__pyx_t_1) {
  4140. /* "lakesuperior/store/base_lmdb_store.pyx":236
  4141. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers))
  4142. * if stale_readers > 0:
  4143. * logger.debug('Cleared {} stale readers.'.format(stale_readers)) # <<<<<<<<<<<<<<
  4144. *
  4145. *
  4146. */
  4147. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
  4148. __Pyx_GOTREF(__pyx_t_3);
  4149. __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)
  4150. __Pyx_GOTREF(__pyx_t_4);
  4151. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4152. __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)
  4153. __Pyx_GOTREF(__pyx_t_5);
  4154. __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_stale_readers); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 236, __pyx_L1_error)
  4155. __Pyx_GOTREF(__pyx_t_6);
  4156. __pyx_t_7 = NULL;
  4157. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  4158. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  4159. if (likely(__pyx_t_7)) {
  4160. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  4161. __Pyx_INCREF(__pyx_t_7);
  4162. __Pyx_INCREF(function);
  4163. __Pyx_DECREF_SET(__pyx_t_5, function);
  4164. }
  4165. }
  4166. if (!__pyx_t_7) {
  4167. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
  4168. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4169. __Pyx_GOTREF(__pyx_t_3);
  4170. } else {
  4171. #if CYTHON_FAST_PYCALL
  4172. if (PyFunction_Check(__pyx_t_5)) {
  4173. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  4174. __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)
  4175. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4176. __Pyx_GOTREF(__pyx_t_3);
  4177. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4178. } else
  4179. #endif
  4180. #if CYTHON_FAST_PYCCALL
  4181. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  4182. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  4183. __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)
  4184. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4185. __Pyx_GOTREF(__pyx_t_3);
  4186. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4187. } else
  4188. #endif
  4189. {
  4190. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 236, __pyx_L1_error)
  4191. __Pyx_GOTREF(__pyx_t_8);
  4192. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  4193. __Pyx_GIVEREF(__pyx_t_6);
  4194. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
  4195. __pyx_t_6 = 0;
  4196. __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)
  4197. __Pyx_GOTREF(__pyx_t_3);
  4198. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4199. }
  4200. }
  4201. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4202. __pyx_t_5 = NULL;
  4203. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  4204. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  4205. if (likely(__pyx_t_5)) {
  4206. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  4207. __Pyx_INCREF(__pyx_t_5);
  4208. __Pyx_INCREF(function);
  4209. __Pyx_DECREF_SET(__pyx_t_4, function);
  4210. }
  4211. }
  4212. if (!__pyx_t_5) {
  4213. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error)
  4214. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4215. __Pyx_GOTREF(__pyx_t_2);
  4216. } else {
  4217. #if CYTHON_FAST_PYCALL
  4218. if (PyFunction_Check(__pyx_t_4)) {
  4219. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4220. __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)
  4221. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4222. __Pyx_GOTREF(__pyx_t_2);
  4223. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4224. } else
  4225. #endif
  4226. #if CYTHON_FAST_PYCCALL
  4227. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  4228. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4229. __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)
  4230. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4231. __Pyx_GOTREF(__pyx_t_2);
  4232. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4233. } else
  4234. #endif
  4235. {
  4236. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 236, __pyx_L1_error)
  4237. __Pyx_GOTREF(__pyx_t_8);
  4238. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
  4239. __Pyx_GIVEREF(__pyx_t_3);
  4240. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_3);
  4241. __pyx_t_3 = 0;
  4242. __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)
  4243. __Pyx_GOTREF(__pyx_t_2);
  4244. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4245. }
  4246. }
  4247. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4248. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4249. /* "lakesuperior/store/base_lmdb_store.pyx":235
  4250. *
  4251. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers))
  4252. * if stale_readers > 0: # <<<<<<<<<<<<<<
  4253. * logger.debug('Cleared {} stale readers.'.format(stale_readers))
  4254. *
  4255. */
  4256. }
  4257. /* "lakesuperior/store/base_lmdb_store.pyx":228
  4258. *
  4259. *
  4260. * cdef void _clear_stale_readers(self) except *: # <<<<<<<<<<<<<<
  4261. * """
  4262. * Clear stale readers.
  4263. */
  4264. /* function exit code */
  4265. goto __pyx_L0;
  4266. __pyx_L1_error:;
  4267. __Pyx_XDECREF(__pyx_t_2);
  4268. __Pyx_XDECREF(__pyx_t_3);
  4269. __Pyx_XDECREF(__pyx_t_4);
  4270. __Pyx_XDECREF(__pyx_t_5);
  4271. __Pyx_XDECREF(__pyx_t_6);
  4272. __Pyx_XDECREF(__pyx_t_7);
  4273. __Pyx_XDECREF(__pyx_t_8);
  4274. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._clear_stale_readers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4275. __pyx_L0:;
  4276. __Pyx_TraceReturn(Py_None, 0);
  4277. __Pyx_RefNannyFinishContext();
  4278. }
  4279. /* "lakesuperior/store/base_lmdb_store.pyx":239
  4280. *
  4281. *
  4282. * cdef void _init_dbis(self, create=True) except *: # <<<<<<<<<<<<<<
  4283. * """
  4284. * Initialize databases and cursors.
  4285. */
  4286. 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) {
  4287. PyObject *__pyx_v_create = ((PyObject *)Py_True);
  4288. size_t __pyx_v_i;
  4289. MDB_txn *__pyx_v_txn;
  4290. MDB_dbi __pyx_v_dbi;
  4291. long __pyx_v_create_flag;
  4292. long __pyx_v_txn_flags;
  4293. CYTHON_UNUSED int __pyx_v_rc;
  4294. PyObject *__pyx_v_dblabel = NULL;
  4295. PyObject *__pyx_v_flags = NULL;
  4296. __Pyx_TraceDeclarations
  4297. __Pyx_RefNannyDeclarations
  4298. long __pyx_t_1;
  4299. PyObject *__pyx_t_2 = NULL;
  4300. Py_ssize_t __pyx_t_3;
  4301. Py_ssize_t __pyx_t_4;
  4302. int __pyx_t_5;
  4303. PyObject *__pyx_t_6 = NULL;
  4304. PyObject *__pyx_t_7 = NULL;
  4305. PyObject *__pyx_t_8 = NULL;
  4306. PyObject *__pyx_t_9 = NULL;
  4307. size_t __pyx_t_10;
  4308. PyObject *(*__pyx_t_11)(PyObject *);
  4309. PyObject *__pyx_t_12 = NULL;
  4310. PyObject *__pyx_t_13 = NULL;
  4311. int __pyx_t_14;
  4312. PyObject *__pyx_t_15 = NULL;
  4313. char const *__pyx_t_16;
  4314. unsigned int __pyx_t_17;
  4315. Py_UCS4 __pyx_t_18;
  4316. PyObject *__pyx_t_19 = NULL;
  4317. __Pyx_RefNannySetupContext("_init_dbis", 0);
  4318. __Pyx_TraceCall("_init_dbis", __pyx_f[0], 239, 0, __PYX_ERR(0, 239, __pyx_L1_error));
  4319. if (__pyx_optional_args) {
  4320. if (__pyx_optional_args->__pyx_n > 0) {
  4321. __pyx_v_create = __pyx_optional_args->create;
  4322. }
  4323. }
  4324. /* "lakesuperior/store/base_lmdb_store.pyx":249
  4325. *
  4326. * # At least one slot (for environments without a database)
  4327. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc( # <<<<<<<<<<<<<<
  4328. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4329. * if not self.dbis:
  4330. */
  4331. __pyx_t_1 = 1;
  4332. /* "lakesuperior/store/base_lmdb_store.pyx":250
  4333. * # At least one slot (for environments without a database)
  4334. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc(
  4335. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi)) # <<<<<<<<<<<<<<
  4336. * if not self.dbis:
  4337. * raise MemoryError()
  4338. */
  4339. __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)
  4340. __Pyx_GOTREF(__pyx_t_2);
  4341. __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 250, __pyx_L1_error)
  4342. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4343. if (((__pyx_t_1 > __pyx_t_3) != 0)) {
  4344. __pyx_t_4 = __pyx_t_1;
  4345. } else {
  4346. __pyx_t_4 = __pyx_t_3;
  4347. }
  4348. /* "lakesuperior/store/base_lmdb_store.pyx":249
  4349. *
  4350. * # At least one slot (for environments without a database)
  4351. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc( # <<<<<<<<<<<<<<
  4352. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4353. * if not self.dbis:
  4354. */
  4355. __pyx_v_self->dbis = ((MDB_dbi *)PyMem_Malloc((__pyx_t_4 * (sizeof(MDB_dbi)))));
  4356. /* "lakesuperior/store/base_lmdb_store.pyx":251
  4357. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc(
  4358. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4359. * if not self.dbis: # <<<<<<<<<<<<<<
  4360. * raise MemoryError()
  4361. *
  4362. */
  4363. __pyx_t_5 = ((!(__pyx_v_self->dbis != 0)) != 0);
  4364. if (unlikely(__pyx_t_5)) {
  4365. /* "lakesuperior/store/base_lmdb_store.pyx":252
  4366. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4367. * if not self.dbis:
  4368. * raise MemoryError() # <<<<<<<<<<<<<<
  4369. *
  4370. * # DBIs seem to start from 2. We want to map cursor pointers in the
  4371. */
  4372. PyErr_NoMemory(); __PYX_ERR(0, 252, __pyx_L1_error)
  4373. /* "lakesuperior/store/base_lmdb_store.pyx":251
  4374. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc(
  4375. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4376. * if not self.dbis: # <<<<<<<<<<<<<<
  4377. * raise MemoryError()
  4378. *
  4379. */
  4380. }
  4381. /* "lakesuperior/store/base_lmdb_store.pyx":257
  4382. * # array to DBIs, so we need an extra slot.
  4383. * self.curs = <lmdb.MDB_cursor **>PyMem_Malloc(
  4384. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*)) # <<<<<<<<<<<<<<
  4385. * if not self.curs:
  4386. * raise MemoryError()
  4387. */
  4388. __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)
  4389. __Pyx_GOTREF(__pyx_t_2);
  4390. __pyx_t_4 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 257, __pyx_L1_error)
  4391. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4392. /* "lakesuperior/store/base_lmdb_store.pyx":256
  4393. * # DBIs seem to start from 2. We want to map cursor pointers in the
  4394. * # array to DBIs, so we need an extra slot.
  4395. * self.curs = <lmdb.MDB_cursor **>PyMem_Malloc( # <<<<<<<<<<<<<<
  4396. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4397. * if not self.curs:
  4398. */
  4399. __pyx_v_self->curs = ((MDB_cursor **)PyMem_Malloc(((__pyx_t_4 + 2) * (sizeof(MDB_cursor *)))));
  4400. /* "lakesuperior/store/base_lmdb_store.pyx":258
  4401. * self.curs = <lmdb.MDB_cursor **>PyMem_Malloc(
  4402. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4403. * if not self.curs: # <<<<<<<<<<<<<<
  4404. * raise MemoryError()
  4405. *
  4406. */
  4407. __pyx_t_5 = ((!(__pyx_v_self->curs != 0)) != 0);
  4408. if (unlikely(__pyx_t_5)) {
  4409. /* "lakesuperior/store/base_lmdb_store.pyx":259
  4410. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4411. * if not self.curs:
  4412. * raise MemoryError() # <<<<<<<<<<<<<<
  4413. *
  4414. * create_flag = lmdb.MDB_CREATE if create is True else 0
  4415. */
  4416. PyErr_NoMemory(); __PYX_ERR(0, 259, __pyx_L1_error)
  4417. /* "lakesuperior/store/base_lmdb_store.pyx":258
  4418. * self.curs = <lmdb.MDB_cursor **>PyMem_Malloc(
  4419. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4420. * if not self.curs: # <<<<<<<<<<<<<<
  4421. * raise MemoryError()
  4422. *
  4423. */
  4424. }
  4425. /* "lakesuperior/store/base_lmdb_store.pyx":261
  4426. * raise MemoryError()
  4427. *
  4428. * create_flag = lmdb.MDB_CREATE if create is True else 0 # <<<<<<<<<<<<<<
  4429. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  4430. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4431. */
  4432. __pyx_t_5 = (__pyx_v_create == Py_True);
  4433. if ((__pyx_t_5 != 0)) {
  4434. __pyx_t_1 = MDB_CREATE;
  4435. } else {
  4436. __pyx_t_1 = 0;
  4437. }
  4438. __pyx_v_create_flag = __pyx_t_1;
  4439. /* "lakesuperior/store/base_lmdb_store.pyx":262
  4440. *
  4441. * create_flag = lmdb.MDB_CREATE if create is True else 0
  4442. * txn_flags = 0 if create else lmdb.MDB_RDONLY # <<<<<<<<<<<<<<
  4443. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4444. * logger.info(f'Creating DBs.')
  4445. */
  4446. __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_create); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 262, __pyx_L1_error)
  4447. if (__pyx_t_5) {
  4448. __pyx_t_1 = 0;
  4449. } else {
  4450. __pyx_t_1 = MDB_RDONLY;
  4451. }
  4452. __pyx_v_txn_flags = __pyx_t_1;
  4453. /* "lakesuperior/store/base_lmdb_store.pyx":263
  4454. * create_flag = lmdb.MDB_CREATE if create is True else 0
  4455. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  4456. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn) # <<<<<<<<<<<<<<
  4457. * logger.info(f'Creating DBs.')
  4458. * try:
  4459. */
  4460. __pyx_v_rc = mdb_txn_begin(__pyx_v_self->dbenv, NULL, __pyx_v_txn_flags, (&__pyx_v_txn));
  4461. /* "lakesuperior/store/base_lmdb_store.pyx":264
  4462. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  4463. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4464. * logger.info(f'Creating DBs.') # <<<<<<<<<<<<<<
  4465. * try:
  4466. * if len(self.dbi_labels):
  4467. */
  4468. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error)
  4469. __Pyx_GOTREF(__pyx_t_2);
  4470. __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)
  4471. __Pyx_GOTREF(__pyx_t_6);
  4472. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4473. __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)
  4474. __Pyx_GOTREF(__pyx_t_2);
  4475. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4476. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4477. /* "lakesuperior/store/base_lmdb_store.pyx":265
  4478. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4479. * logger.info(f'Creating DBs.')
  4480. * try: # <<<<<<<<<<<<<<
  4481. * if len(self.dbi_labels):
  4482. * for i, dblabel in enumerate(self.dbi_labels):
  4483. */
  4484. {
  4485. __Pyx_PyThreadState_declare
  4486. __Pyx_PyThreadState_assign
  4487. __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
  4488. __Pyx_XGOTREF(__pyx_t_7);
  4489. __Pyx_XGOTREF(__pyx_t_8);
  4490. __Pyx_XGOTREF(__pyx_t_9);
  4491. /*try:*/ {
  4492. /* "lakesuperior/store/base_lmdb_store.pyx":266
  4493. * logger.info(f'Creating DBs.')
  4494. * try:
  4495. * if len(self.dbi_labels): # <<<<<<<<<<<<<<
  4496. * for i, dblabel in enumerate(self.dbi_labels):
  4497. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4498. */
  4499. __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)
  4500. __Pyx_GOTREF(__pyx_t_2);
  4501. __pyx_t_4 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 266, __pyx_L5_error)
  4502. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4503. __pyx_t_5 = (__pyx_t_4 != 0);
  4504. if (__pyx_t_5) {
  4505. /* "lakesuperior/store/base_lmdb_store.pyx":267
  4506. * try:
  4507. * if len(self.dbi_labels):
  4508. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  4509. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4510. * _check(lmdb.mdb_dbi_open(
  4511. */
  4512. __pyx_t_10 = 0;
  4513. __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)
  4514. __Pyx_GOTREF(__pyx_t_2);
  4515. if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
  4516. __pyx_t_6 = __pyx_t_2; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = 0;
  4517. __pyx_t_11 = NULL;
  4518. } else {
  4519. __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 267, __pyx_L5_error)
  4520. __Pyx_GOTREF(__pyx_t_6);
  4521. __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 267, __pyx_L5_error)
  4522. }
  4523. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4524. for (;;) {
  4525. if (likely(!__pyx_t_11)) {
  4526. if (likely(PyList_CheckExact(__pyx_t_6))) {
  4527. if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_6)) break;
  4528. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4529. __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)
  4530. #else
  4531. __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)
  4532. __Pyx_GOTREF(__pyx_t_2);
  4533. #endif
  4534. } else {
  4535. if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
  4536. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4537. __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)
  4538. #else
  4539. __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)
  4540. __Pyx_GOTREF(__pyx_t_2);
  4541. #endif
  4542. }
  4543. } else {
  4544. __pyx_t_2 = __pyx_t_11(__pyx_t_6);
  4545. if (unlikely(!__pyx_t_2)) {
  4546. PyObject* exc_type = PyErr_Occurred();
  4547. if (exc_type) {
  4548. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  4549. else __PYX_ERR(0, 267, __pyx_L5_error)
  4550. }
  4551. break;
  4552. }
  4553. __Pyx_GOTREF(__pyx_t_2);
  4554. }
  4555. __Pyx_XDECREF_SET(__pyx_v_dblabel, __pyx_t_2);
  4556. __pyx_t_2 = 0;
  4557. __pyx_v_i = __pyx_t_10;
  4558. __pyx_t_10 = (__pyx_t_10 + 1);
  4559. /* "lakesuperior/store/base_lmdb_store.pyx":268
  4560. * if len(self.dbi_labels):
  4561. * for i, dblabel in enumerate(self.dbi_labels):
  4562. * flags = self.dbi_flags.get(dblabel, 0) | create_flag # <<<<<<<<<<<<<<
  4563. * _check(lmdb.mdb_dbi_open(
  4564. * txn, dblabel.encode(), flags, self.dbis + i))
  4565. */
  4566. __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)
  4567. __Pyx_GOTREF(__pyx_t_12);
  4568. __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)
  4569. __Pyx_GOTREF(__pyx_t_13);
  4570. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4571. __pyx_t_12 = NULL;
  4572. __pyx_t_14 = 0;
  4573. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  4574. __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
  4575. if (likely(__pyx_t_12)) {
  4576. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  4577. __Pyx_INCREF(__pyx_t_12);
  4578. __Pyx_INCREF(function);
  4579. __Pyx_DECREF_SET(__pyx_t_13, function);
  4580. __pyx_t_14 = 1;
  4581. }
  4582. }
  4583. #if CYTHON_FAST_PYCALL
  4584. if (PyFunction_Check(__pyx_t_13)) {
  4585. PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_dblabel, __pyx_int_0};
  4586. __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)
  4587. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4588. __Pyx_GOTREF(__pyx_t_2);
  4589. } else
  4590. #endif
  4591. #if CYTHON_FAST_PYCCALL
  4592. if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
  4593. PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_dblabel, __pyx_int_0};
  4594. __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)
  4595. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4596. __Pyx_GOTREF(__pyx_t_2);
  4597. } else
  4598. #endif
  4599. {
  4600. __pyx_t_15 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 268, __pyx_L5_error)
  4601. __Pyx_GOTREF(__pyx_t_15);
  4602. if (__pyx_t_12) {
  4603. __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_12); __pyx_t_12 = NULL;
  4604. }
  4605. __Pyx_INCREF(__pyx_v_dblabel);
  4606. __Pyx_GIVEREF(__pyx_v_dblabel);
  4607. PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_v_dblabel);
  4608. __Pyx_INCREF(__pyx_int_0);
  4609. __Pyx_GIVEREF(__pyx_int_0);
  4610. PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_int_0);
  4611. __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)
  4612. __Pyx_GOTREF(__pyx_t_2);
  4613. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4614. }
  4615. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4616. __pyx_t_13 = __Pyx_PyInt_From_long(__pyx_v_create_flag); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 268, __pyx_L5_error)
  4617. __Pyx_GOTREF(__pyx_t_13);
  4618. __pyx_t_15 = PyNumber_Or(__pyx_t_2, __pyx_t_13); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 268, __pyx_L5_error)
  4619. __Pyx_GOTREF(__pyx_t_15);
  4620. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4621. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4622. __Pyx_XDECREF_SET(__pyx_v_flags, __pyx_t_15);
  4623. __pyx_t_15 = 0;
  4624. /* "lakesuperior/store/base_lmdb_store.pyx":270
  4625. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4626. * _check(lmdb.mdb_dbi_open(
  4627. * txn, dblabel.encode(), flags, self.dbis + i)) # <<<<<<<<<<<<<<
  4628. * dbi = self.dbis[i]
  4629. * logger.info(f'Created DB {dblabel}: {dbi}')
  4630. */
  4631. __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)
  4632. __Pyx_GOTREF(__pyx_t_13);
  4633. __pyx_t_2 = NULL;
  4634. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  4635. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_13);
  4636. if (likely(__pyx_t_2)) {
  4637. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  4638. __Pyx_INCREF(__pyx_t_2);
  4639. __Pyx_INCREF(function);
  4640. __Pyx_DECREF_SET(__pyx_t_13, function);
  4641. }
  4642. }
  4643. if (__pyx_t_2) {
  4644. __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 270, __pyx_L5_error)
  4645. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4646. } else {
  4647. __pyx_t_15 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 270, __pyx_L5_error)
  4648. }
  4649. __Pyx_GOTREF(__pyx_t_15);
  4650. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4651. __pyx_t_16 = __Pyx_PyObject_AsString(__pyx_t_15); if (unlikely((!__pyx_t_16) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L5_error)
  4652. __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)
  4653. /* "lakesuperior/store/base_lmdb_store.pyx":269
  4654. * for i, dblabel in enumerate(self.dbi_labels):
  4655. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4656. * _check(lmdb.mdb_dbi_open( # <<<<<<<<<<<<<<
  4657. * txn, dblabel.encode(), flags, self.dbis + i))
  4658. * dbi = self.dbis[i]
  4659. */
  4660. __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)
  4661. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4662. /* "lakesuperior/store/base_lmdb_store.pyx":271
  4663. * _check(lmdb.mdb_dbi_open(
  4664. * txn, dblabel.encode(), flags, self.dbis + i))
  4665. * dbi = self.dbis[i] # <<<<<<<<<<<<<<
  4666. * logger.info(f'Created DB {dblabel}: {dbi}')
  4667. * # Open and close cursor to initialize the memory slot.
  4668. */
  4669. __pyx_v_dbi = (__pyx_v_self->dbis[__pyx_v_i]);
  4670. /* "lakesuperior/store/base_lmdb_store.pyx":272
  4671. * txn, dblabel.encode(), flags, self.dbis + i))
  4672. * dbi = self.dbis[i]
  4673. * logger.info(f'Created DB {dblabel}: {dbi}') # <<<<<<<<<<<<<<
  4674. * # Open and close cursor to initialize the memory slot.
  4675. * _check(lmdb.mdb_cursor_open(
  4676. */
  4677. __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 272, __pyx_L5_error)
  4678. __Pyx_GOTREF(__pyx_t_13);
  4679. __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)
  4680. __Pyx_GOTREF(__pyx_t_2);
  4681. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4682. __pyx_t_13 = PyTuple_New(4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 272, __pyx_L5_error)
  4683. __Pyx_GOTREF(__pyx_t_13);
  4684. __pyx_t_3 = 0;
  4685. __pyx_t_18 = 127;
  4686. __Pyx_INCREF(__pyx_kp_u_Created_DB);
  4687. __pyx_t_3 += 11;
  4688. __Pyx_GIVEREF(__pyx_kp_u_Created_DB);
  4689. PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_kp_u_Created_DB);
  4690. __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_v_dblabel, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L5_error)
  4691. __Pyx_GOTREF(__pyx_t_12);
  4692. __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;
  4693. __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12);
  4694. __Pyx_GIVEREF(__pyx_t_12);
  4695. PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12);
  4696. __pyx_t_12 = 0;
  4697. __Pyx_INCREF(__pyx_kp_u__6);
  4698. __pyx_t_3 += 2;
  4699. __Pyx_GIVEREF(__pyx_kp_u__6);
  4700. PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_kp_u__6);
  4701. __pyx_t_12 = __Pyx_PyInt_From_MDB_dbi(__pyx_v_dbi); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L5_error)
  4702. __Pyx_GOTREF(__pyx_t_12);
  4703. __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_t_12, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 272, __pyx_L5_error)
  4704. __Pyx_GOTREF(__pyx_t_19);
  4705. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4706. __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;
  4707. __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19);
  4708. __Pyx_GIVEREF(__pyx_t_19);
  4709. PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_19);
  4710. __pyx_t_19 = 0;
  4711. __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)
  4712. __Pyx_GOTREF(__pyx_t_19);
  4713. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4714. __pyx_t_13 = NULL;
  4715. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  4716. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
  4717. if (likely(__pyx_t_13)) {
  4718. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  4719. __Pyx_INCREF(__pyx_t_13);
  4720. __Pyx_INCREF(function);
  4721. __Pyx_DECREF_SET(__pyx_t_2, function);
  4722. }
  4723. }
  4724. if (!__pyx_t_13) {
  4725. __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_19); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 272, __pyx_L5_error)
  4726. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  4727. __Pyx_GOTREF(__pyx_t_15);
  4728. } else {
  4729. #if CYTHON_FAST_PYCALL
  4730. if (PyFunction_Check(__pyx_t_2)) {
  4731. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_19};
  4732. __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)
  4733. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4734. __Pyx_GOTREF(__pyx_t_15);
  4735. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  4736. } else
  4737. #endif
  4738. #if CYTHON_FAST_PYCCALL
  4739. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  4740. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_19};
  4741. __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)
  4742. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4743. __Pyx_GOTREF(__pyx_t_15);
  4744. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  4745. } else
  4746. #endif
  4747. {
  4748. __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L5_error)
  4749. __Pyx_GOTREF(__pyx_t_12);
  4750. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL;
  4751. __Pyx_GIVEREF(__pyx_t_19);
  4752. PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_19);
  4753. __pyx_t_19 = 0;
  4754. __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)
  4755. __Pyx_GOTREF(__pyx_t_15);
  4756. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4757. }
  4758. }
  4759. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4760. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4761. /* "lakesuperior/store/base_lmdb_store.pyx":274
  4762. * logger.info(f'Created DB {dblabel}: {dbi}')
  4763. * # Open and close cursor to initialize the memory slot.
  4764. * _check(lmdb.mdb_cursor_open( # <<<<<<<<<<<<<<
  4765. * txn, dbi, self.curs + dbi))
  4766. * #lmdb.mdb_cursor_close(self.curs[dbi])
  4767. */
  4768. __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)
  4769. /* "lakesuperior/store/base_lmdb_store.pyx":267
  4770. * try:
  4771. * if len(self.dbi_labels):
  4772. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  4773. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4774. * _check(lmdb.mdb_dbi_open(
  4775. */
  4776. }
  4777. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4778. /* "lakesuperior/store/base_lmdb_store.pyx":266
  4779. * logger.info(f'Creating DBs.')
  4780. * try:
  4781. * if len(self.dbi_labels): # <<<<<<<<<<<<<<
  4782. * for i, dblabel in enumerate(self.dbi_labels):
  4783. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4784. */
  4785. goto __pyx_L11;
  4786. }
  4787. /* "lakesuperior/store/base_lmdb_store.pyx":278
  4788. * #lmdb.mdb_cursor_close(self.curs[dbi])
  4789. * else:
  4790. * _check(lmdb.mdb_dbi_open(txn, NULL, 0, self.dbis)) # <<<<<<<<<<<<<<
  4791. * _check(lmdb.mdb_cursor_open(txn, self.dbis[0], self.curs))
  4792. * #lmdb.mdb_cursor_close(self.curs[self.dbis[0]])
  4793. */
  4794. /*else*/ {
  4795. __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)
  4796. /* "lakesuperior/store/base_lmdb_store.pyx":279
  4797. * else:
  4798. * _check(lmdb.mdb_dbi_open(txn, NULL, 0, self.dbis))
  4799. * _check(lmdb.mdb_cursor_open(txn, self.dbis[0], self.curs)) # <<<<<<<<<<<<<<
  4800. * #lmdb.mdb_cursor_close(self.curs[self.dbis[0]])
  4801. *
  4802. */
  4803. __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)
  4804. }
  4805. __pyx_L11:;
  4806. /* "lakesuperior/store/base_lmdb_store.pyx":282
  4807. * #lmdb.mdb_cursor_close(self.curs[self.dbis[0]])
  4808. *
  4809. * _check(lmdb.mdb_txn_commit(txn)) # <<<<<<<<<<<<<<
  4810. * except:
  4811. * lmdb.mdb_txn_abort(txn)
  4812. */
  4813. __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)
  4814. /* "lakesuperior/store/base_lmdb_store.pyx":265
  4815. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4816. * logger.info(f'Creating DBs.')
  4817. * try: # <<<<<<<<<<<<<<
  4818. * if len(self.dbi_labels):
  4819. * for i, dblabel in enumerate(self.dbi_labels):
  4820. */
  4821. }
  4822. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4823. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  4824. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  4825. goto __pyx_L10_try_end;
  4826. __pyx_L5_error:;
  4827. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4828. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  4829. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4830. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  4831. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  4832. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4833. /* "lakesuperior/store/base_lmdb_store.pyx":283
  4834. *
  4835. * _check(lmdb.mdb_txn_commit(txn))
  4836. * except: # <<<<<<<<<<<<<<
  4837. * lmdb.mdb_txn_abort(txn)
  4838. * raise
  4839. */
  4840. /*except:*/ {
  4841. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._init_dbis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4842. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_15, &__pyx_t_2) < 0) __PYX_ERR(0, 283, __pyx_L7_except_error)
  4843. __Pyx_GOTREF(__pyx_t_6);
  4844. __Pyx_GOTREF(__pyx_t_15);
  4845. __Pyx_GOTREF(__pyx_t_2);
  4846. /* "lakesuperior/store/base_lmdb_store.pyx":284
  4847. * _check(lmdb.mdb_txn_commit(txn))
  4848. * except:
  4849. * lmdb.mdb_txn_abort(txn) # <<<<<<<<<<<<<<
  4850. * raise
  4851. *
  4852. */
  4853. mdb_txn_abort(__pyx_v_txn);
  4854. /* "lakesuperior/store/base_lmdb_store.pyx":285
  4855. * except:
  4856. * lmdb.mdb_txn_abort(txn)
  4857. * raise # <<<<<<<<<<<<<<
  4858. *
  4859. *
  4860. */
  4861. __Pyx_GIVEREF(__pyx_t_6);
  4862. __Pyx_GIVEREF(__pyx_t_15);
  4863. __Pyx_XGIVEREF(__pyx_t_2);
  4864. __Pyx_ErrRestoreWithState(__pyx_t_6, __pyx_t_15, __pyx_t_2);
  4865. __pyx_t_6 = 0; __pyx_t_15 = 0; __pyx_t_2 = 0;
  4866. __PYX_ERR(0, 285, __pyx_L7_except_error)
  4867. }
  4868. __pyx_L7_except_error:;
  4869. /* "lakesuperior/store/base_lmdb_store.pyx":265
  4870. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4871. * logger.info(f'Creating DBs.')
  4872. * try: # <<<<<<<<<<<<<<
  4873. * if len(self.dbi_labels):
  4874. * for i, dblabel in enumerate(self.dbi_labels):
  4875. */
  4876. __Pyx_XGIVEREF(__pyx_t_7);
  4877. __Pyx_XGIVEREF(__pyx_t_8);
  4878. __Pyx_XGIVEREF(__pyx_t_9);
  4879. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  4880. goto __pyx_L1_error;
  4881. __pyx_L10_try_end:;
  4882. }
  4883. /* "lakesuperior/store/base_lmdb_store.pyx":239
  4884. *
  4885. *
  4886. * cdef void _init_dbis(self, create=True) except *: # <<<<<<<<<<<<<<
  4887. * """
  4888. * Initialize databases and cursors.
  4889. */
  4890. /* function exit code */
  4891. goto __pyx_L0;
  4892. __pyx_L1_error:;
  4893. __Pyx_XDECREF(__pyx_t_2);
  4894. __Pyx_XDECREF(__pyx_t_6);
  4895. __Pyx_XDECREF(__pyx_t_12);
  4896. __Pyx_XDECREF(__pyx_t_13);
  4897. __Pyx_XDECREF(__pyx_t_15);
  4898. __Pyx_XDECREF(__pyx_t_19);
  4899. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._init_dbis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4900. __pyx_L0:;
  4901. __Pyx_XDECREF(__pyx_v_dblabel);
  4902. __Pyx_XDECREF(__pyx_v_flags);
  4903. __Pyx_TraceReturn(Py_None, 0);
  4904. __Pyx_RefNannyFinishContext();
  4905. }
  4906. /* "lakesuperior/store/base_lmdb_store.pyx":288
  4907. *
  4908. *
  4909. * cpdef void close_env(self, bint commit_pending_transaction=False) except *: # <<<<<<<<<<<<<<
  4910. * logger.debug('Cleaning up store env.')
  4911. * if self.is_open:
  4912. */
  4913. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4914. 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) {
  4915. int __pyx_v_commit_pending_transaction = ((int)0);
  4916. __Pyx_TraceDeclarations
  4917. __Pyx_RefNannyDeclarations
  4918. PyObject *__pyx_t_1 = NULL;
  4919. PyObject *__pyx_t_2 = NULL;
  4920. PyObject *__pyx_t_3 = NULL;
  4921. PyObject *__pyx_t_4 = NULL;
  4922. PyObject *__pyx_t_5 = NULL;
  4923. PyObject *__pyx_t_6 = NULL;
  4924. int __pyx_t_7;
  4925. __Pyx_RefNannySetupContext("close_env", 0);
  4926. __Pyx_TraceCall("close_env", __pyx_f[0], 288, 0, __PYX_ERR(0, 288, __pyx_L1_error));
  4927. if (__pyx_optional_args) {
  4928. if (__pyx_optional_args->__pyx_n > 0) {
  4929. __pyx_v_commit_pending_transaction = __pyx_optional_args->commit_pending_transaction;
  4930. }
  4931. }
  4932. /* Check if called by wrapper */
  4933. if (unlikely(__pyx_skip_dispatch)) ;
  4934. /* Check if overridden in Python */
  4935. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  4936. __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)
  4937. __Pyx_GOTREF(__pyx_t_1);
  4938. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env)) {
  4939. __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_commit_pending_transaction); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error)
  4940. __Pyx_GOTREF(__pyx_t_3);
  4941. __Pyx_INCREF(__pyx_t_1);
  4942. __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
  4943. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  4944. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  4945. if (likely(__pyx_t_5)) {
  4946. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  4947. __Pyx_INCREF(__pyx_t_5);
  4948. __Pyx_INCREF(function);
  4949. __Pyx_DECREF_SET(__pyx_t_4, function);
  4950. }
  4951. }
  4952. if (!__pyx_t_5) {
  4953. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
  4954. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4955. __Pyx_GOTREF(__pyx_t_2);
  4956. } else {
  4957. #if CYTHON_FAST_PYCALL
  4958. if (PyFunction_Check(__pyx_t_4)) {
  4959. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4960. __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)
  4961. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4962. __Pyx_GOTREF(__pyx_t_2);
  4963. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4964. } else
  4965. #endif
  4966. #if CYTHON_FAST_PYCCALL
  4967. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  4968. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4969. __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)
  4970. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4971. __Pyx_GOTREF(__pyx_t_2);
  4972. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4973. } else
  4974. #endif
  4975. {
  4976. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error)
  4977. __Pyx_GOTREF(__pyx_t_6);
  4978. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
  4979. __Pyx_GIVEREF(__pyx_t_3);
  4980. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
  4981. __pyx_t_3 = 0;
  4982. __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)
  4983. __Pyx_GOTREF(__pyx_t_2);
  4984. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4985. }
  4986. }
  4987. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4988. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4989. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4990. goto __pyx_L0;
  4991. }
  4992. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4993. }
  4994. /* "lakesuperior/store/base_lmdb_store.pyx":289
  4995. *
  4996. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  4997. * logger.debug('Cleaning up store env.') # <<<<<<<<<<<<<<
  4998. * if self.is_open:
  4999. * logger.debug('Closing store env.')
  5000. */
  5001. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error)
  5002. __Pyx_GOTREF(__pyx_t_1);
  5003. __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)
  5004. __Pyx_GOTREF(__pyx_t_2);
  5005. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5006. __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)
  5007. __Pyx_GOTREF(__pyx_t_1);
  5008. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5009. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5010. /* "lakesuperior/store/base_lmdb_store.pyx":290
  5011. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  5012. * logger.debug('Cleaning up store env.')
  5013. * if self.is_open: # <<<<<<<<<<<<<<
  5014. * logger.debug('Closing store env.')
  5015. * if self.is_txn_open is True:
  5016. */
  5017. __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)
  5018. __Pyx_GOTREF(__pyx_t_1);
  5019. __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 290, __pyx_L1_error)
  5020. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5021. if (__pyx_t_7) {
  5022. /* "lakesuperior/store/base_lmdb_store.pyx":291
  5023. * logger.debug('Cleaning up store env.')
  5024. * if self.is_open:
  5025. * logger.debug('Closing store env.') # <<<<<<<<<<<<<<
  5026. * if self.is_txn_open is True:
  5027. * if commit_pending_transaction:
  5028. */
  5029. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error)
  5030. __Pyx_GOTREF(__pyx_t_1);
  5031. __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)
  5032. __Pyx_GOTREF(__pyx_t_2);
  5033. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5034. __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)
  5035. __Pyx_GOTREF(__pyx_t_1);
  5036. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5037. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5038. /* "lakesuperior/store/base_lmdb_store.pyx":292
  5039. * if self.is_open:
  5040. * logger.debug('Closing store env.')
  5041. * if self.is_txn_open is True: # <<<<<<<<<<<<<<
  5042. * if commit_pending_transaction:
  5043. * self._txn_commit()
  5044. */
  5045. __pyx_t_7 = ((__pyx_v_self->is_txn_open == 1) != 0);
  5046. if (__pyx_t_7) {
  5047. /* "lakesuperior/store/base_lmdb_store.pyx":293
  5048. * logger.debug('Closing store env.')
  5049. * if self.is_txn_open is True:
  5050. * if commit_pending_transaction: # <<<<<<<<<<<<<<
  5051. * self._txn_commit()
  5052. * else:
  5053. */
  5054. __pyx_t_7 = (__pyx_v_commit_pending_transaction != 0);
  5055. if (__pyx_t_7) {
  5056. /* "lakesuperior/store/base_lmdb_store.pyx":294
  5057. * if self.is_txn_open is True:
  5058. * if commit_pending_transaction:
  5059. * self._txn_commit() # <<<<<<<<<<<<<<
  5060. * else:
  5061. * self._txn_abort()
  5062. */
  5063. ((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)
  5064. /* "lakesuperior/store/base_lmdb_store.pyx":293
  5065. * logger.debug('Closing store env.')
  5066. * if self.is_txn_open is True:
  5067. * if commit_pending_transaction: # <<<<<<<<<<<<<<
  5068. * self._txn_commit()
  5069. * else:
  5070. */
  5071. goto __pyx_L5;
  5072. }
  5073. /* "lakesuperior/store/base_lmdb_store.pyx":296
  5074. * self._txn_commit()
  5075. * else:
  5076. * self._txn_abort() # <<<<<<<<<<<<<<
  5077. *
  5078. * self._clear_stale_readers()
  5079. */
  5080. /*else*/ {
  5081. ((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)
  5082. }
  5083. __pyx_L5:;
  5084. /* "lakesuperior/store/base_lmdb_store.pyx":292
  5085. * if self.is_open:
  5086. * logger.debug('Closing store env.')
  5087. * if self.is_txn_open is True: # <<<<<<<<<<<<<<
  5088. * if commit_pending_transaction:
  5089. * self._txn_commit()
  5090. */
  5091. }
  5092. /* "lakesuperior/store/base_lmdb_store.pyx":298
  5093. * self._txn_abort()
  5094. *
  5095. * self._clear_stale_readers() # <<<<<<<<<<<<<<
  5096. *
  5097. * PyMem_Free(self.dbis)
  5098. */
  5099. ((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)
  5100. /* "lakesuperior/store/base_lmdb_store.pyx":300
  5101. * self._clear_stale_readers()
  5102. *
  5103. * PyMem_Free(self.dbis) # <<<<<<<<<<<<<<
  5104. * PyMem_Free(self.curs)
  5105. * lmdb.mdb_env_close(self.dbenv)
  5106. */
  5107. PyMem_Free(__pyx_v_self->dbis);
  5108. /* "lakesuperior/store/base_lmdb_store.pyx":301
  5109. *
  5110. * PyMem_Free(self.dbis)
  5111. * PyMem_Free(self.curs) # <<<<<<<<<<<<<<
  5112. * lmdb.mdb_env_close(self.dbenv)
  5113. *
  5114. */
  5115. PyMem_Free(__pyx_v_self->curs);
  5116. /* "lakesuperior/store/base_lmdb_store.pyx":302
  5117. * PyMem_Free(self.dbis)
  5118. * PyMem_Free(self.curs)
  5119. * lmdb.mdb_env_close(self.dbenv) # <<<<<<<<<<<<<<
  5120. *
  5121. * self._open = False
  5122. */
  5123. mdb_env_close(__pyx_v_self->dbenv);
  5124. /* "lakesuperior/store/base_lmdb_store.pyx":290
  5125. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  5126. * logger.debug('Cleaning up store env.')
  5127. * if self.is_open: # <<<<<<<<<<<<<<
  5128. * logger.debug('Closing store env.')
  5129. * if self.is_txn_open is True:
  5130. */
  5131. }
  5132. /* "lakesuperior/store/base_lmdb_store.pyx":304
  5133. * lmdb.mdb_env_close(self.dbenv)
  5134. *
  5135. * self._open = False # <<<<<<<<<<<<<<
  5136. *
  5137. *
  5138. */
  5139. __pyx_v_self->_open = 0;
  5140. /* "lakesuperior/store/base_lmdb_store.pyx":288
  5141. *
  5142. *
  5143. * cpdef void close_env(self, bint commit_pending_transaction=False) except *: # <<<<<<<<<<<<<<
  5144. * logger.debug('Cleaning up store env.')
  5145. * if self.is_open:
  5146. */
  5147. /* function exit code */
  5148. goto __pyx_L0;
  5149. __pyx_L1_error:;
  5150. __Pyx_XDECREF(__pyx_t_1);
  5151. __Pyx_XDECREF(__pyx_t_2);
  5152. __Pyx_XDECREF(__pyx_t_3);
  5153. __Pyx_XDECREF(__pyx_t_4);
  5154. __Pyx_XDECREF(__pyx_t_5);
  5155. __Pyx_XDECREF(__pyx_t_6);
  5156. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.close_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5157. __pyx_L0:;
  5158. __Pyx_TraceReturn(Py_None, 0);
  5159. __Pyx_RefNannyFinishContext();
  5160. }
  5161. /* Python wrapper */
  5162. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5163. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5164. int __pyx_v_commit_pending_transaction;
  5165. PyObject *__pyx_r = 0;
  5166. __Pyx_RefNannyDeclarations
  5167. __Pyx_RefNannySetupContext("close_env (wrapper)", 0);
  5168. {
  5169. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_commit_pending_transaction,0};
  5170. PyObject* values[1] = {0};
  5171. if (unlikely(__pyx_kwds)) {
  5172. Py_ssize_t kw_args;
  5173. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5174. switch (pos_args) {
  5175. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5176. CYTHON_FALLTHROUGH;
  5177. case 0: break;
  5178. default: goto __pyx_L5_argtuple_error;
  5179. }
  5180. kw_args = PyDict_Size(__pyx_kwds);
  5181. switch (pos_args) {
  5182. case 0:
  5183. if (kw_args > 0) {
  5184. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_commit_pending_transaction);
  5185. if (value) { values[0] = value; kw_args--; }
  5186. }
  5187. }
  5188. if (unlikely(kw_args > 0)) {
  5189. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "close_env") < 0)) __PYX_ERR(0, 288, __pyx_L3_error)
  5190. }
  5191. } else {
  5192. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5193. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5194. CYTHON_FALLTHROUGH;
  5195. case 0: break;
  5196. default: goto __pyx_L5_argtuple_error;
  5197. }
  5198. }
  5199. if (values[0]) {
  5200. __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)
  5201. } else {
  5202. __pyx_v_commit_pending_transaction = ((int)0);
  5203. }
  5204. }
  5205. goto __pyx_L4_argument_unpacking_done;
  5206. __pyx_L5_argtuple_error:;
  5207. __Pyx_RaiseArgtupleInvalid("close_env", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 288, __pyx_L3_error)
  5208. __pyx_L3_error:;
  5209. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.close_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5210. __Pyx_RefNannyFinishContext();
  5211. return NULL;
  5212. __pyx_L4_argument_unpacking_done:;
  5213. __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);
  5214. /* function exit code */
  5215. __Pyx_RefNannyFinishContext();
  5216. return __pyx_r;
  5217. }
  5218. 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) {
  5219. PyObject *__pyx_r = NULL;
  5220. __Pyx_TraceDeclarations
  5221. __Pyx_RefNannyDeclarations
  5222. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env __pyx_t_1;
  5223. PyObject *__pyx_t_2 = NULL;
  5224. __Pyx_RefNannySetupContext("close_env", 0);
  5225. __Pyx_TraceCall("close_env (wrapper)", __pyx_f[0], 288, 0, __PYX_ERR(0, 288, __pyx_L1_error));
  5226. __Pyx_XDECREF(__pyx_r);
  5227. __pyx_t_1.__pyx_n = 1;
  5228. __pyx_t_1.commit_pending_transaction = __pyx_v_commit_pending_transaction;
  5229. __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)
  5230. __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
  5231. __Pyx_GOTREF(__pyx_t_2);
  5232. __pyx_r = __pyx_t_2;
  5233. __pyx_t_2 = 0;
  5234. goto __pyx_L0;
  5235. /* function exit code */
  5236. __pyx_L1_error:;
  5237. __Pyx_XDECREF(__pyx_t_2);
  5238. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.close_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5239. __pyx_r = NULL;
  5240. __pyx_L0:;
  5241. __Pyx_XGIVEREF(__pyx_r);
  5242. __Pyx_TraceReturn(__pyx_r, 0);
  5243. __Pyx_RefNannyFinishContext();
  5244. return __pyx_r;
  5245. }
  5246. /* "lakesuperior/store/base_lmdb_store.pyx":307
  5247. *
  5248. *
  5249. * cpdef void destroy(self, _path='') except *: # <<<<<<<<<<<<<<
  5250. * """
  5251. * Destroy the store.
  5252. */
  5253. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5254. 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) {
  5255. PyObject *__pyx_v__path = ((PyObject *)__pyx_kp_u_);
  5256. __Pyx_TraceDeclarations
  5257. __Pyx_RefNannyDeclarations
  5258. PyObject *__pyx_t_1 = NULL;
  5259. PyObject *__pyx_t_2 = NULL;
  5260. PyObject *__pyx_t_3 = NULL;
  5261. PyObject *__pyx_t_4 = NULL;
  5262. PyObject *__pyx_t_5 = NULL;
  5263. int __pyx_t_6;
  5264. PyObject *__pyx_t_7 = NULL;
  5265. PyObject *__pyx_t_8 = NULL;
  5266. PyObject *__pyx_t_9 = NULL;
  5267. int __pyx_t_10;
  5268. __Pyx_RefNannySetupContext("destroy", 0);
  5269. __Pyx_TraceCall("destroy", __pyx_f[0], 307, 0, __PYX_ERR(0, 307, __pyx_L1_error));
  5270. if (__pyx_optional_args) {
  5271. if (__pyx_optional_args->__pyx_n > 0) {
  5272. __pyx_v__path = __pyx_optional_args->_path;
  5273. }
  5274. }
  5275. /* Check if called by wrapper */
  5276. if (unlikely(__pyx_skip_dispatch)) ;
  5277. /* Check if overridden in Python */
  5278. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  5279. __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)
  5280. __Pyx_GOTREF(__pyx_t_1);
  5281. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy)) {
  5282. __Pyx_INCREF(__pyx_t_1);
  5283. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  5284. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  5285. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  5286. if (likely(__pyx_t_4)) {
  5287. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  5288. __Pyx_INCREF(__pyx_t_4);
  5289. __Pyx_INCREF(function);
  5290. __Pyx_DECREF_SET(__pyx_t_3, function);
  5291. }
  5292. }
  5293. if (!__pyx_t_4) {
  5294. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v__path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
  5295. __Pyx_GOTREF(__pyx_t_2);
  5296. } else {
  5297. #if CYTHON_FAST_PYCALL
  5298. if (PyFunction_Check(__pyx_t_3)) {
  5299. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v__path};
  5300. __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)
  5301. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5302. __Pyx_GOTREF(__pyx_t_2);
  5303. } else
  5304. #endif
  5305. #if CYTHON_FAST_PYCCALL
  5306. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  5307. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v__path};
  5308. __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)
  5309. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5310. __Pyx_GOTREF(__pyx_t_2);
  5311. } else
  5312. #endif
  5313. {
  5314. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 307, __pyx_L1_error)
  5315. __Pyx_GOTREF(__pyx_t_5);
  5316. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  5317. __Pyx_INCREF(__pyx_v__path);
  5318. __Pyx_GIVEREF(__pyx_v__path);
  5319. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v__path);
  5320. __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)
  5321. __Pyx_GOTREF(__pyx_t_2);
  5322. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5323. }
  5324. }
  5325. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5326. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5327. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5328. goto __pyx_L0;
  5329. }
  5330. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5331. }
  5332. /* "lakesuperior/store/base_lmdb_store.pyx":317
  5333. * general-purpose recursive file and folder delete method!)
  5334. * """
  5335. * if path.exists(self.env_path): # <<<<<<<<<<<<<<
  5336. * if lmdb.MDB_NOSUBDIR & self.flags:
  5337. * try:
  5338. */
  5339. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error)
  5340. __Pyx_GOTREF(__pyx_t_2);
  5341. __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)
  5342. __Pyx_GOTREF(__pyx_t_3);
  5343. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5344. __pyx_t_2 = NULL;
  5345. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  5346. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
  5347. if (likely(__pyx_t_2)) {
  5348. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  5349. __Pyx_INCREF(__pyx_t_2);
  5350. __Pyx_INCREF(function);
  5351. __Pyx_DECREF_SET(__pyx_t_3, function);
  5352. }
  5353. }
  5354. if (!__pyx_t_2) {
  5355. __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)
  5356. __Pyx_GOTREF(__pyx_t_1);
  5357. } else {
  5358. #if CYTHON_FAST_PYCALL
  5359. if (PyFunction_Check(__pyx_t_3)) {
  5360. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5361. __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)
  5362. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5363. __Pyx_GOTREF(__pyx_t_1);
  5364. } else
  5365. #endif
  5366. #if CYTHON_FAST_PYCCALL
  5367. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  5368. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5369. __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)
  5370. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5371. __Pyx_GOTREF(__pyx_t_1);
  5372. } else
  5373. #endif
  5374. {
  5375. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 317, __pyx_L1_error)
  5376. __Pyx_GOTREF(__pyx_t_5);
  5377. __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
  5378. __Pyx_INCREF(__pyx_v_self->env_path);
  5379. __Pyx_GIVEREF(__pyx_v_self->env_path);
  5380. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_self->env_path);
  5381. __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)
  5382. __Pyx_GOTREF(__pyx_t_1);
  5383. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5384. }
  5385. }
  5386. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5387. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 317, __pyx_L1_error)
  5388. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5389. if (__pyx_t_6) {
  5390. /* "lakesuperior/store/base_lmdb_store.pyx":318
  5391. * """
  5392. * if path.exists(self.env_path):
  5393. * if lmdb.MDB_NOSUBDIR & self.flags: # <<<<<<<<<<<<<<
  5394. * try:
  5395. * os.unlink(self.env_path)
  5396. */
  5397. __pyx_t_1 = __Pyx_PyInt_From_int(MDB_NOSUBDIR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error)
  5398. __Pyx_GOTREF(__pyx_t_1);
  5399. __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)
  5400. __Pyx_GOTREF(__pyx_t_3);
  5401. __pyx_t_5 = PyNumber_And(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 318, __pyx_L1_error)
  5402. __Pyx_GOTREF(__pyx_t_5);
  5403. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5404. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5405. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 318, __pyx_L1_error)
  5406. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5407. if (__pyx_t_6) {
  5408. /* "lakesuperior/store/base_lmdb_store.pyx":319
  5409. * if path.exists(self.env_path):
  5410. * if lmdb.MDB_NOSUBDIR & self.flags:
  5411. * try: # <<<<<<<<<<<<<<
  5412. * os.unlink(self.env_path)
  5413. * except FileNotFoundError:
  5414. */
  5415. {
  5416. __Pyx_PyThreadState_declare
  5417. __Pyx_PyThreadState_assign
  5418. __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
  5419. __Pyx_XGOTREF(__pyx_t_7);
  5420. __Pyx_XGOTREF(__pyx_t_8);
  5421. __Pyx_XGOTREF(__pyx_t_9);
  5422. /*try:*/ {
  5423. /* "lakesuperior/store/base_lmdb_store.pyx":320
  5424. * if lmdb.MDB_NOSUBDIR & self.flags:
  5425. * try:
  5426. * os.unlink(self.env_path) # <<<<<<<<<<<<<<
  5427. * except FileNotFoundError:
  5428. * pass
  5429. */
  5430. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L5_error)
  5431. __Pyx_GOTREF(__pyx_t_3);
  5432. __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)
  5433. __Pyx_GOTREF(__pyx_t_1);
  5434. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5435. __pyx_t_3 = NULL;
  5436. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  5437. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
  5438. if (likely(__pyx_t_3)) {
  5439. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  5440. __Pyx_INCREF(__pyx_t_3);
  5441. __Pyx_INCREF(function);
  5442. __Pyx_DECREF_SET(__pyx_t_1, function);
  5443. }
  5444. }
  5445. if (!__pyx_t_3) {
  5446. __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)
  5447. __Pyx_GOTREF(__pyx_t_5);
  5448. } else {
  5449. #if CYTHON_FAST_PYCALL
  5450. if (PyFunction_Check(__pyx_t_1)) {
  5451. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->env_path};
  5452. __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)
  5453. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5454. __Pyx_GOTREF(__pyx_t_5);
  5455. } else
  5456. #endif
  5457. #if CYTHON_FAST_PYCCALL
  5458. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  5459. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->env_path};
  5460. __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)
  5461. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5462. __Pyx_GOTREF(__pyx_t_5);
  5463. } else
  5464. #endif
  5465. {
  5466. __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L5_error)
  5467. __Pyx_GOTREF(__pyx_t_2);
  5468. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
  5469. __Pyx_INCREF(__pyx_v_self->env_path);
  5470. __Pyx_GIVEREF(__pyx_v_self->env_path);
  5471. PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_self->env_path);
  5472. __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)
  5473. __Pyx_GOTREF(__pyx_t_5);
  5474. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5475. }
  5476. }
  5477. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5478. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5479. /* "lakesuperior/store/base_lmdb_store.pyx":319
  5480. * if path.exists(self.env_path):
  5481. * if lmdb.MDB_NOSUBDIR & self.flags:
  5482. * try: # <<<<<<<<<<<<<<
  5483. * os.unlink(self.env_path)
  5484. * except FileNotFoundError:
  5485. */
  5486. }
  5487. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5488. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  5489. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  5490. goto __pyx_L10_try_end;
  5491. __pyx_L5_error:;
  5492. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5493. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5494. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5495. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5496. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5497. /* "lakesuperior/store/base_lmdb_store.pyx":321
  5498. * try:
  5499. * os.unlink(self.env_path)
  5500. * except FileNotFoundError: # <<<<<<<<<<<<<<
  5501. * pass
  5502. * try:
  5503. */
  5504. __Pyx_ErrFetch(&__pyx_t_5, &__pyx_t_1, &__pyx_t_2);
  5505. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_FileNotFoundError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L7_except_error)
  5506. __Pyx_GOTREF(__pyx_t_3);
  5507. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_5, __pyx_t_3);
  5508. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5509. __Pyx_ErrRestore(__pyx_t_5, __pyx_t_1, __pyx_t_2);
  5510. __pyx_t_5 = 0; __pyx_t_1 = 0; __pyx_t_2 = 0;
  5511. if (__pyx_t_10) {
  5512. __Pyx_ErrRestore(0,0,0);
  5513. goto __pyx_L6_exception_handled;
  5514. }
  5515. goto __pyx_L7_except_error;
  5516. __pyx_L7_except_error:;
  5517. /* "lakesuperior/store/base_lmdb_store.pyx":319
  5518. * if path.exists(self.env_path):
  5519. * if lmdb.MDB_NOSUBDIR & self.flags:
  5520. * try: # <<<<<<<<<<<<<<
  5521. * os.unlink(self.env_path)
  5522. * except FileNotFoundError:
  5523. */
  5524. __Pyx_XGIVEREF(__pyx_t_7);
  5525. __Pyx_XGIVEREF(__pyx_t_8);
  5526. __Pyx_XGIVEREF(__pyx_t_9);
  5527. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  5528. goto __pyx_L1_error;
  5529. __pyx_L6_exception_handled:;
  5530. __Pyx_XGIVEREF(__pyx_t_7);
  5531. __Pyx_XGIVEREF(__pyx_t_8);
  5532. __Pyx_XGIVEREF(__pyx_t_9);
  5533. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  5534. __pyx_L10_try_end:;
  5535. }
  5536. /* "lakesuperior/store/base_lmdb_store.pyx":323
  5537. * except FileNotFoundError:
  5538. * pass
  5539. * try: # <<<<<<<<<<<<<<
  5540. * os.unlink(self.env_path + '-lock')
  5541. * except FileNotFoundError:
  5542. */
  5543. {
  5544. __Pyx_PyThreadState_declare
  5545. __Pyx_PyThreadState_assign
  5546. __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
  5547. __Pyx_XGOTREF(__pyx_t_9);
  5548. __Pyx_XGOTREF(__pyx_t_8);
  5549. __Pyx_XGOTREF(__pyx_t_7);
  5550. /*try:*/ {
  5551. /* "lakesuperior/store/base_lmdb_store.pyx":324
  5552. * pass
  5553. * try:
  5554. * os.unlink(self.env_path + '-lock') # <<<<<<<<<<<<<<
  5555. * except FileNotFoundError:
  5556. * pass
  5557. */
  5558. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L11_error)
  5559. __Pyx_GOTREF(__pyx_t_1);
  5560. __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)
  5561. __Pyx_GOTREF(__pyx_t_5);
  5562. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5563. __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)
  5564. __Pyx_GOTREF(__pyx_t_1);
  5565. __pyx_t_3 = NULL;
  5566. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  5567. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
  5568. if (likely(__pyx_t_3)) {
  5569. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  5570. __Pyx_INCREF(__pyx_t_3);
  5571. __Pyx_INCREF(function);
  5572. __Pyx_DECREF_SET(__pyx_t_5, function);
  5573. }
  5574. }
  5575. if (!__pyx_t_3) {
  5576. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L11_error)
  5577. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5578. __Pyx_GOTREF(__pyx_t_2);
  5579. } else {
  5580. #if CYTHON_FAST_PYCALL
  5581. if (PyFunction_Check(__pyx_t_5)) {
  5582. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
  5583. __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)
  5584. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5585. __Pyx_GOTREF(__pyx_t_2);
  5586. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5587. } else
  5588. #endif
  5589. #if CYTHON_FAST_PYCCALL
  5590. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  5591. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
  5592. __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)
  5593. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5594. __Pyx_GOTREF(__pyx_t_2);
  5595. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5596. } else
  5597. #endif
  5598. {
  5599. __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 324, __pyx_L11_error)
  5600. __Pyx_GOTREF(__pyx_t_4);
  5601. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
  5602. __Pyx_GIVEREF(__pyx_t_1);
  5603. PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_1);
  5604. __pyx_t_1 = 0;
  5605. __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)
  5606. __Pyx_GOTREF(__pyx_t_2);
  5607. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5608. }
  5609. }
  5610. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5611. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5612. /* "lakesuperior/store/base_lmdb_store.pyx":323
  5613. * except FileNotFoundError:
  5614. * pass
  5615. * try: # <<<<<<<<<<<<<<
  5616. * os.unlink(self.env_path + '-lock')
  5617. * except FileNotFoundError:
  5618. */
  5619. }
  5620. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  5621. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  5622. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5623. goto __pyx_L16_try_end;
  5624. __pyx_L11_error:;
  5625. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5626. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5627. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5628. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5629. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5630. /* "lakesuperior/store/base_lmdb_store.pyx":325
  5631. * try:
  5632. * os.unlink(self.env_path + '-lock')
  5633. * except FileNotFoundError: # <<<<<<<<<<<<<<
  5634. * pass
  5635. * else:
  5636. */
  5637. __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_5, &__pyx_t_4);
  5638. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_FileNotFoundError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L13_except_error)
  5639. __Pyx_GOTREF(__pyx_t_1);
  5640. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_1);
  5641. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5642. __Pyx_ErrRestore(__pyx_t_2, __pyx_t_5, __pyx_t_4);
  5643. __pyx_t_2 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0;
  5644. if (__pyx_t_10) {
  5645. __Pyx_ErrRestore(0,0,0);
  5646. goto __pyx_L12_exception_handled;
  5647. }
  5648. goto __pyx_L13_except_error;
  5649. __pyx_L13_except_error:;
  5650. /* "lakesuperior/store/base_lmdb_store.pyx":323
  5651. * except FileNotFoundError:
  5652. * pass
  5653. * try: # <<<<<<<<<<<<<<
  5654. * os.unlink(self.env_path + '-lock')
  5655. * except FileNotFoundError:
  5656. */
  5657. __Pyx_XGIVEREF(__pyx_t_9);
  5658. __Pyx_XGIVEREF(__pyx_t_8);
  5659. __Pyx_XGIVEREF(__pyx_t_7);
  5660. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7);
  5661. goto __pyx_L1_error;
  5662. __pyx_L12_exception_handled:;
  5663. __Pyx_XGIVEREF(__pyx_t_9);
  5664. __Pyx_XGIVEREF(__pyx_t_8);
  5665. __Pyx_XGIVEREF(__pyx_t_7);
  5666. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7);
  5667. __pyx_L16_try_end:;
  5668. }
  5669. /* "lakesuperior/store/base_lmdb_store.pyx":318
  5670. * """
  5671. * if path.exists(self.env_path):
  5672. * if lmdb.MDB_NOSUBDIR & self.flags: # <<<<<<<<<<<<<<
  5673. * try:
  5674. * os.unlink(self.env_path)
  5675. */
  5676. goto __pyx_L4;
  5677. }
  5678. /* "lakesuperior/store/base_lmdb_store.pyx":328
  5679. * pass
  5680. * else:
  5681. * rmtree(self.env_path) # <<<<<<<<<<<<<<
  5682. *
  5683. *
  5684. */
  5685. /*else*/ {
  5686. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_rmtree); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 328, __pyx_L1_error)
  5687. __Pyx_GOTREF(__pyx_t_5);
  5688. __pyx_t_2 = NULL;
  5689. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  5690. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
  5691. if (likely(__pyx_t_2)) {
  5692. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  5693. __Pyx_INCREF(__pyx_t_2);
  5694. __Pyx_INCREF(function);
  5695. __Pyx_DECREF_SET(__pyx_t_5, function);
  5696. }
  5697. }
  5698. if (!__pyx_t_2) {
  5699. __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)
  5700. __Pyx_GOTREF(__pyx_t_4);
  5701. } else {
  5702. #if CYTHON_FAST_PYCALL
  5703. if (PyFunction_Check(__pyx_t_5)) {
  5704. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5705. __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)
  5706. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5707. __Pyx_GOTREF(__pyx_t_4);
  5708. } else
  5709. #endif
  5710. #if CYTHON_FAST_PYCCALL
  5711. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  5712. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5713. __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)
  5714. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5715. __Pyx_GOTREF(__pyx_t_4);
  5716. } else
  5717. #endif
  5718. {
  5719. __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __pyx_L1_error)
  5720. __Pyx_GOTREF(__pyx_t_1);
  5721. __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
  5722. __Pyx_INCREF(__pyx_v_self->env_path);
  5723. __Pyx_GIVEREF(__pyx_v_self->env_path);
  5724. PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_self->env_path);
  5725. __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)
  5726. __Pyx_GOTREF(__pyx_t_4);
  5727. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5728. }
  5729. }
  5730. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5731. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5732. }
  5733. __pyx_L4:;
  5734. /* "lakesuperior/store/base_lmdb_store.pyx":317
  5735. * general-purpose recursive file and folder delete method!)
  5736. * """
  5737. * if path.exists(self.env_path): # <<<<<<<<<<<<<<
  5738. * if lmdb.MDB_NOSUBDIR & self.flags:
  5739. * try:
  5740. */
  5741. }
  5742. /* "lakesuperior/store/base_lmdb_store.pyx":307
  5743. *
  5744. *
  5745. * cpdef void destroy(self, _path='') except *: # <<<<<<<<<<<<<<
  5746. * """
  5747. * Destroy the store.
  5748. */
  5749. /* function exit code */
  5750. goto __pyx_L0;
  5751. __pyx_L1_error:;
  5752. __Pyx_XDECREF(__pyx_t_1);
  5753. __Pyx_XDECREF(__pyx_t_2);
  5754. __Pyx_XDECREF(__pyx_t_3);
  5755. __Pyx_XDECREF(__pyx_t_4);
  5756. __Pyx_XDECREF(__pyx_t_5);
  5757. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5758. __pyx_L0:;
  5759. __Pyx_TraceReturn(Py_None, 0);
  5760. __Pyx_RefNannyFinishContext();
  5761. }
  5762. /* Python wrapper */
  5763. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5764. 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 ";
  5765. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5766. PyObject *__pyx_v__path = 0;
  5767. PyObject *__pyx_r = 0;
  5768. __Pyx_RefNannyDeclarations
  5769. __Pyx_RefNannySetupContext("destroy (wrapper)", 0);
  5770. {
  5771. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path_2,0};
  5772. PyObject* values[1] = {0};
  5773. values[0] = ((PyObject *)__pyx_kp_u_);
  5774. if (unlikely(__pyx_kwds)) {
  5775. Py_ssize_t kw_args;
  5776. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5777. switch (pos_args) {
  5778. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5779. CYTHON_FALLTHROUGH;
  5780. case 0: break;
  5781. default: goto __pyx_L5_argtuple_error;
  5782. }
  5783. kw_args = PyDict_Size(__pyx_kwds);
  5784. switch (pos_args) {
  5785. case 0:
  5786. if (kw_args > 0) {
  5787. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path_2);
  5788. if (value) { values[0] = value; kw_args--; }
  5789. }
  5790. }
  5791. if (unlikely(kw_args > 0)) {
  5792. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "destroy") < 0)) __PYX_ERR(0, 307, __pyx_L3_error)
  5793. }
  5794. } else {
  5795. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5796. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5797. CYTHON_FALLTHROUGH;
  5798. case 0: break;
  5799. default: goto __pyx_L5_argtuple_error;
  5800. }
  5801. }
  5802. __pyx_v__path = values[0];
  5803. }
  5804. goto __pyx_L4_argument_unpacking_done;
  5805. __pyx_L5_argtuple_error:;
  5806. __Pyx_RaiseArgtupleInvalid("destroy", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 307, __pyx_L3_error)
  5807. __pyx_L3_error:;
  5808. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5809. __Pyx_RefNannyFinishContext();
  5810. return NULL;
  5811. __pyx_L4_argument_unpacking_done:;
  5812. __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);
  5813. /* function exit code */
  5814. __Pyx_RefNannyFinishContext();
  5815. return __pyx_r;
  5816. }
  5817. 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) {
  5818. PyObject *__pyx_r = NULL;
  5819. __Pyx_TraceDeclarations
  5820. __Pyx_RefNannyDeclarations
  5821. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy __pyx_t_1;
  5822. PyObject *__pyx_t_2 = NULL;
  5823. __Pyx_RefNannySetupContext("destroy", 0);
  5824. __Pyx_TraceCall("destroy (wrapper)", __pyx_f[0], 307, 0, __PYX_ERR(0, 307, __pyx_L1_error));
  5825. __Pyx_XDECREF(__pyx_r);
  5826. __pyx_t_1.__pyx_n = 1;
  5827. __pyx_t_1._path = __pyx_v__path;
  5828. __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)
  5829. __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
  5830. __Pyx_GOTREF(__pyx_t_2);
  5831. __pyx_r = __pyx_t_2;
  5832. __pyx_t_2 = 0;
  5833. goto __pyx_L0;
  5834. /* function exit code */
  5835. __pyx_L1_error:;
  5836. __Pyx_XDECREF(__pyx_t_2);
  5837. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5838. __pyx_r = NULL;
  5839. __pyx_L0:;
  5840. __Pyx_XGIVEREF(__pyx_r);
  5841. __Pyx_TraceReturn(__pyx_r, 0);
  5842. __Pyx_RefNannyFinishContext();
  5843. return __pyx_r;
  5844. }
  5845. 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 */
  5846. /* "lakesuperior/store/base_lmdb_store.pyx":334
  5847. *
  5848. * @contextmanager
  5849. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  5850. * """
  5851. * Transaction context manager.
  5852. */
  5853. /* Python wrapper */
  5854. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11txn_ctx(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5855. 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 ";
  5856. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11txn_ctx(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5857. PyObject *__pyx_v_write = 0;
  5858. PyObject *__pyx_r = 0;
  5859. __Pyx_RefNannyDeclarations
  5860. __Pyx_RefNannySetupContext("txn_ctx (wrapper)", 0);
  5861. {
  5862. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_write,0};
  5863. PyObject* values[1] = {0};
  5864. values[0] = ((PyObject *)Py_False);
  5865. if (unlikely(__pyx_kwds)) {
  5866. Py_ssize_t kw_args;
  5867. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5868. switch (pos_args) {
  5869. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5870. CYTHON_FALLTHROUGH;
  5871. case 0: break;
  5872. default: goto __pyx_L5_argtuple_error;
  5873. }
  5874. kw_args = PyDict_Size(__pyx_kwds);
  5875. switch (pos_args) {
  5876. case 0:
  5877. if (kw_args > 0) {
  5878. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_write);
  5879. if (value) { values[0] = value; kw_args--; }
  5880. }
  5881. }
  5882. if (unlikely(kw_args > 0)) {
  5883. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "txn_ctx") < 0)) __PYX_ERR(0, 334, __pyx_L3_error)
  5884. }
  5885. } else {
  5886. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5887. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5888. CYTHON_FALLTHROUGH;
  5889. case 0: break;
  5890. default: goto __pyx_L5_argtuple_error;
  5891. }
  5892. }
  5893. __pyx_v_write = values[0];
  5894. }
  5895. goto __pyx_L4_argument_unpacking_done;
  5896. __pyx_L5_argtuple_error:;
  5897. __Pyx_RaiseArgtupleInvalid("txn_ctx", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 334, __pyx_L3_error)
  5898. __pyx_L3_error:;
  5899. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5900. __Pyx_RefNannyFinishContext();
  5901. return NULL;
  5902. __pyx_L4_argument_unpacking_done:;
  5903. __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);
  5904. /* function exit code */
  5905. __Pyx_RefNannyFinishContext();
  5906. return __pyx_r;
  5907. }
  5908. 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) {
  5909. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *__pyx_cur_scope;
  5910. PyObject *__pyx_r = NULL;
  5911. __Pyx_RefNannyDeclarations
  5912. __Pyx_RefNannySetupContext("txn_ctx", 0);
  5913. __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);
  5914. if (unlikely(!__pyx_cur_scope)) {
  5915. __pyx_cur_scope = ((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *)Py_None);
  5916. __Pyx_INCREF(Py_None);
  5917. __PYX_ERR(0, 334, __pyx_L1_error)
  5918. } else {
  5919. __Pyx_GOTREF(__pyx_cur_scope);
  5920. }
  5921. __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  5922. __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  5923. __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  5924. __pyx_cur_scope->__pyx_v_write = __pyx_v_write;
  5925. __Pyx_INCREF(__pyx_cur_scope->__pyx_v_write);
  5926. __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_write);
  5927. {
  5928. __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)
  5929. __Pyx_DECREF(__pyx_cur_scope);
  5930. __Pyx_RefNannyFinishContext();
  5931. return (PyObject *) gen;
  5932. }
  5933. /* function exit code */
  5934. __pyx_L1_error:;
  5935. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5936. __pyx_r = NULL;
  5937. __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  5938. __Pyx_XGIVEREF(__pyx_r);
  5939. __Pyx_RefNannyFinishContext();
  5940. return __pyx_r;
  5941. }
  5942. 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 */
  5943. {
  5944. 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);
  5945. PyObject *__pyx_r = NULL;
  5946. __Pyx_TraceDeclarations
  5947. PyObject *__pyx_t_1 = NULL;
  5948. int __pyx_t_2;
  5949. int __pyx_t_3;
  5950. PyObject *__pyx_t_4 = NULL;
  5951. PyObject *__pyx_t_5 = NULL;
  5952. PyObject *__pyx_t_6 = NULL;
  5953. PyObject *__pyx_t_7 = NULL;
  5954. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin __pyx_t_8;
  5955. PyObject *__pyx_t_9 = NULL;
  5956. __Pyx_RefNannyDeclarations
  5957. __Pyx_RefNannySetupContext("txn_ctx", 0);
  5958. __Pyx_TraceCall("txn_ctx", __pyx_f[0], 334, 0, __PYX_ERR(0, 334, __pyx_L1_error));
  5959. switch (__pyx_generator->resume_label) {
  5960. case 0: goto __pyx_L3_first_run;
  5961. case 1: goto __pyx_L6_resume_from_yield;
  5962. case 2: goto __pyx_L13_resume_from_yield;
  5963. default: /* CPython raises the right error here */
  5964. __Pyx_TraceReturn(Py_None, 0);
  5965. __Pyx_RefNannyFinishContext();
  5966. return NULL;
  5967. }
  5968. __pyx_L3_first_run:;
  5969. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 334, __pyx_L1_error)
  5970. /* "lakesuperior/store/base_lmdb_store.pyx":342
  5971. * :rtype: lmdb.Transaction
  5972. * """
  5973. * if not self.is_open: # <<<<<<<<<<<<<<
  5974. * raise LmdbError('Store is not open.')
  5975. *
  5976. */
  5977. __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)
  5978. __Pyx_GOTREF(__pyx_t_1);
  5979. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 342, __pyx_L1_error)
  5980. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5981. __pyx_t_3 = ((!__pyx_t_2) != 0);
  5982. if (unlikely(__pyx_t_3)) {
  5983. /* "lakesuperior/store/base_lmdb_store.pyx":343
  5984. * """
  5985. * if not self.is_open:
  5986. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  5987. *
  5988. * if self.is_txn_open:
  5989. */
  5990. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
  5991. __Pyx_GOTREF(__pyx_t_1);
  5992. __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)
  5993. __Pyx_GOTREF(__pyx_t_4);
  5994. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5995. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  5996. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5997. __PYX_ERR(0, 343, __pyx_L1_error)
  5998. /* "lakesuperior/store/base_lmdb_store.pyx":342
  5999. * :rtype: lmdb.Transaction
  6000. * """
  6001. * if not self.is_open: # <<<<<<<<<<<<<<
  6002. * raise LmdbError('Store is not open.')
  6003. *
  6004. */
  6005. }
  6006. /* "lakesuperior/store/base_lmdb_store.pyx":345
  6007. * raise LmdbError('Store is not open.')
  6008. *
  6009. * if self.is_txn_open: # <<<<<<<<<<<<<<
  6010. * logger.debug(
  6011. * 'Transaction is already active. Not opening another one.')
  6012. */
  6013. __pyx_t_3 = (__pyx_cur_scope->__pyx_v_self->is_txn_open != 0);
  6014. if (__pyx_t_3) {
  6015. /* "lakesuperior/store/base_lmdb_store.pyx":346
  6016. *
  6017. * if self.is_txn_open:
  6018. * logger.debug( # <<<<<<<<<<<<<<
  6019. * 'Transaction is already active. Not opening another one.')
  6020. * #logger.debug('before yield')
  6021. */
  6022. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 346, __pyx_L1_error)
  6023. __Pyx_GOTREF(__pyx_t_4);
  6024. __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)
  6025. __Pyx_GOTREF(__pyx_t_1);
  6026. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6027. __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)
  6028. __Pyx_GOTREF(__pyx_t_4);
  6029. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6030. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6031. /* "lakesuperior/store/base_lmdb_store.pyx":349
  6032. * 'Transaction is already active. Not opening another one.')
  6033. * #logger.debug('before yield')
  6034. * yield # <<<<<<<<<<<<<<
  6035. * #logger.debug('after yield')
  6036. * else:
  6037. */
  6038. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6039. __Pyx_XGIVEREF(__pyx_r);
  6040. __Pyx_TraceReturn(__pyx_r, 0);
  6041. __Pyx_RefNannyFinishContext();
  6042. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  6043. /* return from generator, yielding value */
  6044. __pyx_generator->resume_label = 1;
  6045. return __pyx_r;
  6046. __pyx_L6_resume_from_yield:;
  6047. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 349, __pyx_L1_error)
  6048. /* "lakesuperior/store/base_lmdb_store.pyx":345
  6049. * raise LmdbError('Store is not open.')
  6050. *
  6051. * if self.is_txn_open: # <<<<<<<<<<<<<<
  6052. * logger.debug(
  6053. * 'Transaction is already active. Not opening another one.')
  6054. */
  6055. goto __pyx_L5;
  6056. }
  6057. /* "lakesuperior/store/base_lmdb_store.pyx":354
  6058. * #logger.debug('Beginning {} transaction.'.format(
  6059. * # 'RW' if write else 'RO'))
  6060. * try: # <<<<<<<<<<<<<<
  6061. * self._txn_begin(write=write)
  6062. * self.is_txn_rw = write
  6063. */
  6064. /*else*/ {
  6065. {
  6066. __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
  6067. __Pyx_XGOTREF(__pyx_t_5);
  6068. __Pyx_XGOTREF(__pyx_t_6);
  6069. __Pyx_XGOTREF(__pyx_t_7);
  6070. /*try:*/ {
  6071. /* "lakesuperior/store/base_lmdb_store.pyx":355
  6072. * # 'RW' if write else 'RO'))
  6073. * try:
  6074. * self._txn_begin(write=write) # <<<<<<<<<<<<<<
  6075. * self.is_txn_rw = write
  6076. * #logger.debug('In txn_ctx, before yield')
  6077. */
  6078. __pyx_t_8.__pyx_n = 1;
  6079. __pyx_t_8.write = __pyx_cur_scope->__pyx_v_write;
  6080. ((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)
  6081. /* "lakesuperior/store/base_lmdb_store.pyx":356
  6082. * try:
  6083. * self._txn_begin(write=write)
  6084. * self.is_txn_rw = write # <<<<<<<<<<<<<<
  6085. * #logger.debug('In txn_ctx, before yield')
  6086. * yield
  6087. */
  6088. 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)
  6089. /* "lakesuperior/store/base_lmdb_store.pyx":358
  6090. * self.is_txn_rw = write
  6091. * #logger.debug('In txn_ctx, before yield')
  6092. * yield # <<<<<<<<<<<<<<
  6093. * #logger.debug('In txn_ctx, after yield')
  6094. * self._txn_commit()
  6095. */
  6096. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6097. __Pyx_XGIVEREF(__pyx_t_5);
  6098. __pyx_cur_scope->__pyx_t_0 = __pyx_t_5;
  6099. __Pyx_XGIVEREF(__pyx_t_6);
  6100. __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
  6101. __Pyx_XGIVEREF(__pyx_t_7);
  6102. __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
  6103. __Pyx_XGIVEREF(__pyx_r);
  6104. __Pyx_TraceReturn(__pyx_r, 0);
  6105. __Pyx_RefNannyFinishContext();
  6106. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  6107. /* return from generator, yielding value */
  6108. __pyx_generator->resume_label = 2;
  6109. return __pyx_r;
  6110. __pyx_L13_resume_from_yield:;
  6111. __pyx_t_5 = __pyx_cur_scope->__pyx_t_0;
  6112. __pyx_cur_scope->__pyx_t_0 = 0;
  6113. __Pyx_XGOTREF(__pyx_t_5);
  6114. __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
  6115. __pyx_cur_scope->__pyx_t_1 = 0;
  6116. __Pyx_XGOTREF(__pyx_t_6);
  6117. __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
  6118. __pyx_cur_scope->__pyx_t_2 = 0;
  6119. __Pyx_XGOTREF(__pyx_t_7);
  6120. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 358, __pyx_L7_error)
  6121. /* "lakesuperior/store/base_lmdb_store.pyx":360
  6122. * yield
  6123. * #logger.debug('In txn_ctx, after yield')
  6124. * self._txn_commit() # <<<<<<<<<<<<<<
  6125. * #logger.debug('after _txn_commit')
  6126. * except:
  6127. */
  6128. ((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)
  6129. /* "lakesuperior/store/base_lmdb_store.pyx":354
  6130. * #logger.debug('Beginning {} transaction.'.format(
  6131. * # 'RW' if write else 'RO'))
  6132. * try: # <<<<<<<<<<<<<<
  6133. * self._txn_begin(write=write)
  6134. * self.is_txn_rw = write
  6135. */
  6136. }
  6137. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6138. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6139. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6140. goto __pyx_L12_try_end;
  6141. __pyx_L7_error:;
  6142. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  6143. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  6144. /* "lakesuperior/store/base_lmdb_store.pyx":362
  6145. * self._txn_commit()
  6146. * #logger.debug('after _txn_commit')
  6147. * except: # <<<<<<<<<<<<<<
  6148. * self._txn_abort()
  6149. * raise
  6150. */
  6151. /*except:*/ {
  6152. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6153. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_9) < 0) __PYX_ERR(0, 362, __pyx_L9_except_error)
  6154. __Pyx_GOTREF(__pyx_t_4);
  6155. __Pyx_GOTREF(__pyx_t_1);
  6156. __Pyx_GOTREF(__pyx_t_9);
  6157. /* "lakesuperior/store/base_lmdb_store.pyx":363
  6158. * #logger.debug('after _txn_commit')
  6159. * except:
  6160. * self._txn_abort() # <<<<<<<<<<<<<<
  6161. * raise
  6162. *
  6163. */
  6164. ((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)
  6165. /* "lakesuperior/store/base_lmdb_store.pyx":364
  6166. * except:
  6167. * self._txn_abort()
  6168. * raise # <<<<<<<<<<<<<<
  6169. *
  6170. *
  6171. */
  6172. __Pyx_GIVEREF(__pyx_t_4);
  6173. __Pyx_GIVEREF(__pyx_t_1);
  6174. __Pyx_XGIVEREF(__pyx_t_9);
  6175. __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_1, __pyx_t_9);
  6176. __pyx_t_4 = 0; __pyx_t_1 = 0; __pyx_t_9 = 0;
  6177. __PYX_ERR(0, 364, __pyx_L9_except_error)
  6178. }
  6179. __pyx_L9_except_error:;
  6180. /* "lakesuperior/store/base_lmdb_store.pyx":354
  6181. * #logger.debug('Beginning {} transaction.'.format(
  6182. * # 'RW' if write else 'RO'))
  6183. * try: # <<<<<<<<<<<<<<
  6184. * self._txn_begin(write=write)
  6185. * self.is_txn_rw = write
  6186. */
  6187. __Pyx_XGIVEREF(__pyx_t_5);
  6188. __Pyx_XGIVEREF(__pyx_t_6);
  6189. __Pyx_XGIVEREF(__pyx_t_7);
  6190. __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
  6191. goto __pyx_L1_error;
  6192. __pyx_L12_try_end:;
  6193. }
  6194. }
  6195. __pyx_L5:;
  6196. CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
  6197. /* "lakesuperior/store/base_lmdb_store.pyx":334
  6198. *
  6199. * @contextmanager
  6200. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  6201. * """
  6202. * Transaction context manager.
  6203. */
  6204. /* function exit code */
  6205. PyErr_SetNone(PyExc_StopIteration);
  6206. goto __pyx_L0;
  6207. __pyx_L1_error:;
  6208. __Pyx_XDECREF(__pyx_t_1);
  6209. __Pyx_XDECREF(__pyx_t_4);
  6210. __Pyx_XDECREF(__pyx_t_9);
  6211. __Pyx_AddTraceback("txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6212. __pyx_L0:;
  6213. __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  6214. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  6215. __pyx_generator->resume_label = -1;
  6216. __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  6217. __Pyx_TraceReturn(__pyx_r, 0);
  6218. __Pyx_RefNannyFinishContext();
  6219. return __pyx_r;
  6220. }
  6221. /* "lakesuperior/store/base_lmdb_store.pyx":367
  6222. *
  6223. *
  6224. * def begin(self, write=False): # <<<<<<<<<<<<<<
  6225. * """
  6226. * Begin a transaction manually if not already in a txn context.
  6227. */
  6228. /* Python wrapper */
  6229. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_14begin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6230. 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 ";
  6231. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_14begin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6232. PyObject *__pyx_v_write = 0;
  6233. PyObject *__pyx_r = 0;
  6234. __Pyx_RefNannyDeclarations
  6235. __Pyx_RefNannySetupContext("begin (wrapper)", 0);
  6236. {
  6237. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_write,0};
  6238. PyObject* values[1] = {0};
  6239. values[0] = ((PyObject *)Py_False);
  6240. if (unlikely(__pyx_kwds)) {
  6241. Py_ssize_t kw_args;
  6242. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6243. switch (pos_args) {
  6244. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6245. CYTHON_FALLTHROUGH;
  6246. case 0: break;
  6247. default: goto __pyx_L5_argtuple_error;
  6248. }
  6249. kw_args = PyDict_Size(__pyx_kwds);
  6250. switch (pos_args) {
  6251. case 0:
  6252. if (kw_args > 0) {
  6253. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_write);
  6254. if (value) { values[0] = value; kw_args--; }
  6255. }
  6256. }
  6257. if (unlikely(kw_args > 0)) {
  6258. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "begin") < 0)) __PYX_ERR(0, 367, __pyx_L3_error)
  6259. }
  6260. } else {
  6261. switch (PyTuple_GET_SIZE(__pyx_args)) {
  6262. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6263. CYTHON_FALLTHROUGH;
  6264. case 0: break;
  6265. default: goto __pyx_L5_argtuple_error;
  6266. }
  6267. }
  6268. __pyx_v_write = values[0];
  6269. }
  6270. goto __pyx_L4_argument_unpacking_done;
  6271. __pyx_L5_argtuple_error:;
  6272. __Pyx_RaiseArgtupleInvalid("begin", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 367, __pyx_L3_error)
  6273. __pyx_L3_error:;
  6274. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.begin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6275. __Pyx_RefNannyFinishContext();
  6276. return NULL;
  6277. __pyx_L4_argument_unpacking_done:;
  6278. __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);
  6279. /* function exit code */
  6280. __Pyx_RefNannyFinishContext();
  6281. return __pyx_r;
  6282. }
  6283. 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) {
  6284. PyObject *__pyx_r = NULL;
  6285. __Pyx_TraceDeclarations
  6286. __Pyx_RefNannyDeclarations
  6287. PyObject *__pyx_t_1 = NULL;
  6288. int __pyx_t_2;
  6289. int __pyx_t_3;
  6290. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin __pyx_t_4;
  6291. __Pyx_RefNannySetupContext("begin", 0);
  6292. __Pyx_TraceCall("begin", __pyx_f[0], 367, 0, __PYX_ERR(0, 367, __pyx_L1_error));
  6293. /* "lakesuperior/store/base_lmdb_store.pyx":374
  6294. * possible rather than this method.
  6295. * """
  6296. * if not self.is_open: # <<<<<<<<<<<<<<
  6297. * raise RuntimeError('Store must be opened first.')
  6298. * #logger.debug('Beginning a {} transaction.'.format(
  6299. */
  6300. __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)
  6301. __Pyx_GOTREF(__pyx_t_1);
  6302. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 374, __pyx_L1_error)
  6303. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6304. __pyx_t_3 = ((!__pyx_t_2) != 0);
  6305. if (unlikely(__pyx_t_3)) {
  6306. /* "lakesuperior/store/base_lmdb_store.pyx":375
  6307. * """
  6308. * if not self.is_open:
  6309. * raise RuntimeError('Store must be opened first.') # <<<<<<<<<<<<<<
  6310. * #logger.debug('Beginning a {} transaction.'.format(
  6311. * # 'read/write' if write else 'read-only'))
  6312. */
  6313. __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)
  6314. __Pyx_GOTREF(__pyx_t_1);
  6315. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  6316. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6317. __PYX_ERR(0, 375, __pyx_L1_error)
  6318. /* "lakesuperior/store/base_lmdb_store.pyx":374
  6319. * possible rather than this method.
  6320. * """
  6321. * if not self.is_open: # <<<<<<<<<<<<<<
  6322. * raise RuntimeError('Store must be opened first.')
  6323. * #logger.debug('Beginning a {} transaction.'.format(
  6324. */
  6325. }
  6326. /* "lakesuperior/store/base_lmdb_store.pyx":379
  6327. * # 'read/write' if write else 'read-only'))
  6328. *
  6329. * self._txn_begin(write=write) # <<<<<<<<<<<<<<
  6330. *
  6331. *
  6332. */
  6333. __pyx_t_4.__pyx_n = 1;
  6334. __pyx_t_4.write = __pyx_v_write;
  6335. ((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)
  6336. /* "lakesuperior/store/base_lmdb_store.pyx":367
  6337. *
  6338. *
  6339. * def begin(self, write=False): # <<<<<<<<<<<<<<
  6340. * """
  6341. * Begin a transaction manually if not already in a txn context.
  6342. */
  6343. /* function exit code */
  6344. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6345. goto __pyx_L0;
  6346. __pyx_L1_error:;
  6347. __Pyx_XDECREF(__pyx_t_1);
  6348. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.begin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6349. __pyx_r = NULL;
  6350. __pyx_L0:;
  6351. __Pyx_XGIVEREF(__pyx_r);
  6352. __Pyx_TraceReturn(__pyx_r, 0);
  6353. __Pyx_RefNannyFinishContext();
  6354. return __pyx_r;
  6355. }
  6356. /* "lakesuperior/store/base_lmdb_store.pyx":382
  6357. *
  6358. *
  6359. * def commit(self): # <<<<<<<<<<<<<<
  6360. * """Commit main transaction."""
  6361. * #logger.debug('Committing transaction.')
  6362. */
  6363. /* Python wrapper */
  6364. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_16commit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6365. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit[] = "Commit main transaction.";
  6366. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_16commit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  6367. PyObject *__pyx_r = 0;
  6368. __Pyx_RefNannyDeclarations
  6369. __Pyx_RefNannySetupContext("commit (wrapper)", 0);
  6370. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  6371. /* function exit code */
  6372. __Pyx_RefNannyFinishContext();
  6373. return __pyx_r;
  6374. }
  6375. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  6376. PyObject *__pyx_r = NULL;
  6377. __Pyx_TraceDeclarations
  6378. __Pyx_RefNannyDeclarations
  6379. __Pyx_RefNannySetupContext("commit", 0);
  6380. __Pyx_TraceCall("commit", __pyx_f[0], 382, 0, __PYX_ERR(0, 382, __pyx_L1_error));
  6381. /* "lakesuperior/store/base_lmdb_store.pyx":385
  6382. * """Commit main transaction."""
  6383. * #logger.debug('Committing transaction.')
  6384. * self._txn_commit() # <<<<<<<<<<<<<<
  6385. *
  6386. *
  6387. */
  6388. ((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)
  6389. /* "lakesuperior/store/base_lmdb_store.pyx":382
  6390. *
  6391. *
  6392. * def commit(self): # <<<<<<<<<<<<<<
  6393. * """Commit main transaction."""
  6394. * #logger.debug('Committing transaction.')
  6395. */
  6396. /* function exit code */
  6397. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6398. goto __pyx_L0;
  6399. __pyx_L1_error:;
  6400. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.commit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6401. __pyx_r = NULL;
  6402. __pyx_L0:;
  6403. __Pyx_XGIVEREF(__pyx_r);
  6404. __Pyx_TraceReturn(__pyx_r, 0);
  6405. __Pyx_RefNannyFinishContext();
  6406. return __pyx_r;
  6407. }
  6408. /* "lakesuperior/store/base_lmdb_store.pyx":388
  6409. *
  6410. *
  6411. * def abort(self): # <<<<<<<<<<<<<<
  6412. * """Abort main transaction."""
  6413. * #logger.debug('Rolling back transaction.')
  6414. */
  6415. /* Python wrapper */
  6416. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_18abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6417. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort[] = "Abort main transaction.";
  6418. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_18abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  6419. PyObject *__pyx_r = 0;
  6420. __Pyx_RefNannyDeclarations
  6421. __Pyx_RefNannySetupContext("abort (wrapper)", 0);
  6422. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  6423. /* function exit code */
  6424. __Pyx_RefNannyFinishContext();
  6425. return __pyx_r;
  6426. }
  6427. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  6428. PyObject *__pyx_r = NULL;
  6429. __Pyx_TraceDeclarations
  6430. __Pyx_RefNannyDeclarations
  6431. __Pyx_RefNannySetupContext("abort", 0);
  6432. __Pyx_TraceCall("abort", __pyx_f[0], 388, 0, __PYX_ERR(0, 388, __pyx_L1_error));
  6433. /* "lakesuperior/store/base_lmdb_store.pyx":391
  6434. * """Abort main transaction."""
  6435. * #logger.debug('Rolling back transaction.')
  6436. * self._txn_abort() # <<<<<<<<<<<<<<
  6437. *
  6438. *
  6439. */
  6440. ((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)
  6441. /* "lakesuperior/store/base_lmdb_store.pyx":388
  6442. *
  6443. *
  6444. * def abort(self): # <<<<<<<<<<<<<<
  6445. * """Abort main transaction."""
  6446. * #logger.debug('Rolling back transaction.')
  6447. */
  6448. /* function exit code */
  6449. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6450. goto __pyx_L0;
  6451. __pyx_L1_error:;
  6452. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.abort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6453. __pyx_r = NULL;
  6454. __pyx_L0:;
  6455. __Pyx_XGIVEREF(__pyx_r);
  6456. __Pyx_TraceReturn(__pyx_r, 0);
  6457. __Pyx_RefNannyFinishContext();
  6458. return __pyx_r;
  6459. }
  6460. /* "lakesuperior/store/base_lmdb_store.pyx":394
  6461. *
  6462. *
  6463. * def rollback(self): # <<<<<<<<<<<<<<
  6464. * """Alias for :py:meth:`abort`"""
  6465. * self.abort()
  6466. */
  6467. /* Python wrapper */
  6468. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_20rollback(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6469. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback[] = "Alias for :py:meth:`abort`";
  6470. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_20rollback(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  6471. PyObject *__pyx_r = 0;
  6472. __Pyx_RefNannyDeclarations
  6473. __Pyx_RefNannySetupContext("rollback (wrapper)", 0);
  6474. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  6475. /* function exit code */
  6476. __Pyx_RefNannyFinishContext();
  6477. return __pyx_r;
  6478. }
  6479. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  6480. PyObject *__pyx_r = NULL;
  6481. __Pyx_TraceDeclarations
  6482. __Pyx_RefNannyDeclarations
  6483. PyObject *__pyx_t_1 = NULL;
  6484. PyObject *__pyx_t_2 = NULL;
  6485. PyObject *__pyx_t_3 = NULL;
  6486. __Pyx_RefNannySetupContext("rollback", 0);
  6487. __Pyx_TraceCall("rollback", __pyx_f[0], 394, 0, __PYX_ERR(0, 394, __pyx_L1_error));
  6488. /* "lakesuperior/store/base_lmdb_store.pyx":396
  6489. * def rollback(self):
  6490. * """Alias for :py:meth:`abort`"""
  6491. * self.abort() # <<<<<<<<<<<<<<
  6492. *
  6493. *
  6494. */
  6495. __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)
  6496. __Pyx_GOTREF(__pyx_t_2);
  6497. __pyx_t_3 = NULL;
  6498. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6499. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  6500. if (likely(__pyx_t_3)) {
  6501. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6502. __Pyx_INCREF(__pyx_t_3);
  6503. __Pyx_INCREF(function);
  6504. __Pyx_DECREF_SET(__pyx_t_2, function);
  6505. }
  6506. }
  6507. if (__pyx_t_3) {
  6508. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  6509. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6510. } else {
  6511. __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  6512. }
  6513. __Pyx_GOTREF(__pyx_t_1);
  6514. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6515. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6516. /* "lakesuperior/store/base_lmdb_store.pyx":394
  6517. *
  6518. *
  6519. * def rollback(self): # <<<<<<<<<<<<<<
  6520. * """Alias for :py:meth:`abort`"""
  6521. * self.abort()
  6522. */
  6523. /* function exit code */
  6524. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6525. goto __pyx_L0;
  6526. __pyx_L1_error:;
  6527. __Pyx_XDECREF(__pyx_t_1);
  6528. __Pyx_XDECREF(__pyx_t_2);
  6529. __Pyx_XDECREF(__pyx_t_3);
  6530. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.rollback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6531. __pyx_r = NULL;
  6532. __pyx_L0:;
  6533. __Pyx_XGIVEREF(__pyx_r);
  6534. __Pyx_TraceReturn(__pyx_r, 0);
  6535. __Pyx_RefNannyFinishContext();
  6536. return __pyx_r;
  6537. }
  6538. /* "lakesuperior/store/base_lmdb_store.pyx":399
  6539. *
  6540. *
  6541. * def key_exists(self, key, dblabel='', new_txn=True): # <<<<<<<<<<<<<<
  6542. * """
  6543. * Return whether a key exists in a database (Python-facing method).
  6544. */
  6545. /* Python wrapper */
  6546. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_22key_exists(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6547. 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 ";
  6548. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_22key_exists(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6549. PyObject *__pyx_v_key = 0;
  6550. PyObject *__pyx_v_dblabel = 0;
  6551. PyObject *__pyx_v_new_txn = 0;
  6552. PyObject *__pyx_r = 0;
  6553. __Pyx_RefNannyDeclarations
  6554. __Pyx_RefNannySetupContext("key_exists (wrapper)", 0);
  6555. {
  6556. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_dblabel,&__pyx_n_s_new_txn,0};
  6557. PyObject* values[3] = {0,0,0};
  6558. values[1] = ((PyObject *)__pyx_kp_u_);
  6559. values[2] = ((PyObject *)Py_True);
  6560. if (unlikely(__pyx_kwds)) {
  6561. Py_ssize_t kw_args;
  6562. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6563. switch (pos_args) {
  6564. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6565. CYTHON_FALLTHROUGH;
  6566. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6567. CYTHON_FALLTHROUGH;
  6568. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6569. CYTHON_FALLTHROUGH;
  6570. case 0: break;
  6571. default: goto __pyx_L5_argtuple_error;
  6572. }
  6573. kw_args = PyDict_Size(__pyx_kwds);
  6574. switch (pos_args) {
  6575. case 0:
  6576. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  6577. else goto __pyx_L5_argtuple_error;
  6578. CYTHON_FALLTHROUGH;
  6579. case 1:
  6580. if (kw_args > 0) {
  6581. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  6582. if (value) { values[1] = value; kw_args--; }
  6583. }
  6584. CYTHON_FALLTHROUGH;
  6585. case 2:
  6586. if (kw_args > 0) {
  6587. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_new_txn);
  6588. if (value) { values[2] = value; kw_args--; }
  6589. }
  6590. }
  6591. if (unlikely(kw_args > 0)) {
  6592. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "key_exists") < 0)) __PYX_ERR(0, 399, __pyx_L3_error)
  6593. }
  6594. } else {
  6595. switch (PyTuple_GET_SIZE(__pyx_args)) {
  6596. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6597. CYTHON_FALLTHROUGH;
  6598. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6599. CYTHON_FALLTHROUGH;
  6600. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6601. break;
  6602. default: goto __pyx_L5_argtuple_error;
  6603. }
  6604. }
  6605. __pyx_v_key = values[0];
  6606. __pyx_v_dblabel = values[1];
  6607. __pyx_v_new_txn = values[2];
  6608. }
  6609. goto __pyx_L4_argument_unpacking_done;
  6610. __pyx_L5_argtuple_error:;
  6611. __Pyx_RaiseArgtupleInvalid("key_exists", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 399, __pyx_L3_error)
  6612. __pyx_L3_error:;
  6613. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6614. __Pyx_RefNannyFinishContext();
  6615. return NULL;
  6616. __pyx_L4_argument_unpacking_done:;
  6617. __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);
  6618. /* function exit code */
  6619. __Pyx_RefNannyFinishContext();
  6620. return __pyx_r;
  6621. }
  6622. 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) {
  6623. PyObject *__pyx_r = NULL;
  6624. __Pyx_TraceDeclarations
  6625. __Pyx_RefNannyDeclarations
  6626. int __pyx_t_1;
  6627. int __pyx_t_2;
  6628. PyObject *__pyx_t_3 = NULL;
  6629. PyObject *__pyx_t_4 = NULL;
  6630. PyObject *__pyx_t_5 = NULL;
  6631. PyObject *__pyx_t_6 = NULL;
  6632. PyObject *__pyx_t_7 = NULL;
  6633. PyObject *__pyx_t_8 = NULL;
  6634. PyObject *__pyx_t_9 = NULL;
  6635. PyObject *__pyx_t_10 = NULL;
  6636. unsigned char *__pyx_t_11;
  6637. Py_ssize_t __pyx_t_12;
  6638. unsigned char *__pyx_t_13;
  6639. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists __pyx_t_14;
  6640. PyObject *__pyx_t_15 = NULL;
  6641. __Pyx_RefNannySetupContext("key_exists", 0);
  6642. __Pyx_TraceCall("key_exists", __pyx_f[0], 399, 0, __PYX_ERR(0, 399, __pyx_L1_error));
  6643. /* "lakesuperior/store/base_lmdb_store.pyx":406
  6644. * opened.
  6645. * """
  6646. * if new_txn is True: # <<<<<<<<<<<<<<
  6647. * with self.txn_ctx():
  6648. * return self._key_exists(
  6649. */
  6650. __pyx_t_1 = (__pyx_v_new_txn == Py_True);
  6651. __pyx_t_2 = (__pyx_t_1 != 0);
  6652. if (__pyx_t_2) {
  6653. /* "lakesuperior/store/base_lmdb_store.pyx":407
  6654. * """
  6655. * if new_txn is True:
  6656. * with self.txn_ctx(): # <<<<<<<<<<<<<<
  6657. * return self._key_exists(
  6658. * key, len(key), dblabel=dblabel.encode())
  6659. */
  6660. /*with:*/ {
  6661. __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)
  6662. __Pyx_GOTREF(__pyx_t_4);
  6663. __pyx_t_5 = NULL;
  6664. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  6665. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  6666. if (likely(__pyx_t_5)) {
  6667. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  6668. __Pyx_INCREF(__pyx_t_5);
  6669. __Pyx_INCREF(function);
  6670. __Pyx_DECREF_SET(__pyx_t_4, function);
  6671. }
  6672. }
  6673. if (__pyx_t_5) {
  6674. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error)
  6675. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6676. } else {
  6677. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error)
  6678. }
  6679. __Pyx_GOTREF(__pyx_t_3);
  6680. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6681. __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)
  6682. __Pyx_GOTREF(__pyx_t_6);
  6683. __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)
  6684. __Pyx_GOTREF(__pyx_t_5);
  6685. __pyx_t_7 = NULL;
  6686. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  6687. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  6688. if (likely(__pyx_t_7)) {
  6689. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  6690. __Pyx_INCREF(__pyx_t_7);
  6691. __Pyx_INCREF(function);
  6692. __Pyx_DECREF_SET(__pyx_t_5, function);
  6693. }
  6694. }
  6695. if (__pyx_t_7) {
  6696. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 407, __pyx_L4_error)
  6697. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6698. } else {
  6699. __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 407, __pyx_L4_error)
  6700. }
  6701. __Pyx_GOTREF(__pyx_t_4);
  6702. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6703. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6704. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6705. /*try:*/ {
  6706. {
  6707. __Pyx_PyThreadState_declare
  6708. __Pyx_PyThreadState_assign
  6709. __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
  6710. __Pyx_XGOTREF(__pyx_t_8);
  6711. __Pyx_XGOTREF(__pyx_t_9);
  6712. __Pyx_XGOTREF(__pyx_t_10);
  6713. /*try:*/ {
  6714. /* "lakesuperior/store/base_lmdb_store.pyx":408
  6715. * if new_txn is True:
  6716. * with self.txn_ctx():
  6717. * return self._key_exists( # <<<<<<<<<<<<<<
  6718. * key, len(key), dblabel=dblabel.encode())
  6719. * else:
  6720. */
  6721. __Pyx_XDECREF(__pyx_r);
  6722. /* "lakesuperior/store/base_lmdb_store.pyx":409
  6723. * with self.txn_ctx():
  6724. * return self._key_exists(
  6725. * key, len(key), dblabel=dblabel.encode()) # <<<<<<<<<<<<<<
  6726. * else:
  6727. * return self._key_exists(key, len(key), dblabel=dblabel.encode())
  6728. */
  6729. __pyx_t_11 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 409, __pyx_L8_error)
  6730. __pyx_t_12 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 409, __pyx_L8_error)
  6731. __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)
  6732. __Pyx_GOTREF(__pyx_t_4);
  6733. __pyx_t_5 = NULL;
  6734. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  6735. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  6736. if (likely(__pyx_t_5)) {
  6737. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  6738. __Pyx_INCREF(__pyx_t_5);
  6739. __Pyx_INCREF(function);
  6740. __Pyx_DECREF_SET(__pyx_t_4, function);
  6741. }
  6742. }
  6743. if (__pyx_t_5) {
  6744. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L8_error)
  6745. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6746. } else {
  6747. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L8_error)
  6748. }
  6749. __Pyx_GOTREF(__pyx_t_3);
  6750. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6751. __pyx_t_13 = __Pyx_PyObject_AsWritableUString(__pyx_t_3); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 409, __pyx_L8_error)
  6752. /* "lakesuperior/store/base_lmdb_store.pyx":408
  6753. * if new_txn is True:
  6754. * with self.txn_ctx():
  6755. * return self._key_exists( # <<<<<<<<<<<<<<
  6756. * key, len(key), dblabel=dblabel.encode())
  6757. * else:
  6758. */
  6759. __pyx_t_14.__pyx_n = 1;
  6760. __pyx_t_14.dblabel = __pyx_t_13;
  6761. __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)
  6762. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6763. __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 408, __pyx_L8_error)
  6764. __Pyx_GOTREF(__pyx_t_3);
  6765. __pyx_r = __pyx_t_3;
  6766. __pyx_t_3 = 0;
  6767. goto __pyx_L12_try_return;
  6768. /* "lakesuperior/store/base_lmdb_store.pyx":407
  6769. * """
  6770. * if new_txn is True:
  6771. * with self.txn_ctx(): # <<<<<<<<<<<<<<
  6772. * return self._key_exists(
  6773. * key, len(key), dblabel=dblabel.encode())
  6774. */
  6775. }
  6776. __pyx_L8_error:;
  6777. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6778. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6779. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  6780. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6781. /*except:*/ {
  6782. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6783. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5) < 0) __PYX_ERR(0, 407, __pyx_L10_except_error)
  6784. __Pyx_GOTREF(__pyx_t_3);
  6785. __Pyx_GOTREF(__pyx_t_4);
  6786. __Pyx_GOTREF(__pyx_t_5);
  6787. __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)
  6788. __Pyx_GOTREF(__pyx_t_7);
  6789. __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL);
  6790. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6791. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6792. if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 407, __pyx_L10_except_error)
  6793. __Pyx_GOTREF(__pyx_t_15);
  6794. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_15);
  6795. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  6796. if (__pyx_t_2 < 0) __PYX_ERR(0, 407, __pyx_L10_except_error)
  6797. __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
  6798. if (__pyx_t_1) {
  6799. __Pyx_GIVEREF(__pyx_t_3);
  6800. __Pyx_GIVEREF(__pyx_t_4);
  6801. __Pyx_XGIVEREF(__pyx_t_5);
  6802. __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_4, __pyx_t_5);
  6803. __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0;
  6804. __PYX_ERR(0, 407, __pyx_L10_except_error)
  6805. }
  6806. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6807. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6808. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6809. goto __pyx_L9_exception_handled;
  6810. }
  6811. __pyx_L10_except_error:;
  6812. __Pyx_XGIVEREF(__pyx_t_8);
  6813. __Pyx_XGIVEREF(__pyx_t_9);
  6814. __Pyx_XGIVEREF(__pyx_t_10);
  6815. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  6816. goto __pyx_L1_error;
  6817. __pyx_L12_try_return:;
  6818. __Pyx_XGIVEREF(__pyx_t_8);
  6819. __Pyx_XGIVEREF(__pyx_t_9);
  6820. __Pyx_XGIVEREF(__pyx_t_10);
  6821. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  6822. goto __pyx_L5_return;
  6823. __pyx_L9_exception_handled:;
  6824. __Pyx_XGIVEREF(__pyx_t_8);
  6825. __Pyx_XGIVEREF(__pyx_t_9);
  6826. __Pyx_XGIVEREF(__pyx_t_10);
  6827. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  6828. }
  6829. }
  6830. /*finally:*/ {
  6831. /*normal exit:*/{
  6832. if (__pyx_t_6) {
  6833. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__12, NULL);
  6834. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6835. if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 407, __pyx_L1_error)
  6836. __Pyx_GOTREF(__pyx_t_10);
  6837. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  6838. }
  6839. goto __pyx_L7;
  6840. }
  6841. __pyx_L5_return: {
  6842. __pyx_t_10 = __pyx_r;
  6843. __pyx_r = 0;
  6844. if (__pyx_t_6) {
  6845. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__13, NULL);
  6846. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6847. if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 407, __pyx_L1_error)
  6848. __Pyx_GOTREF(__pyx_t_9);
  6849. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6850. }
  6851. __pyx_r = __pyx_t_10;
  6852. __pyx_t_10 = 0;
  6853. goto __pyx_L0;
  6854. }
  6855. __pyx_L7:;
  6856. }
  6857. goto __pyx_L17;
  6858. __pyx_L4_error:;
  6859. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6860. goto __pyx_L1_error;
  6861. __pyx_L17:;
  6862. }
  6863. /* "lakesuperior/store/base_lmdb_store.pyx":406
  6864. * opened.
  6865. * """
  6866. * if new_txn is True: # <<<<<<<<<<<<<<
  6867. * with self.txn_ctx():
  6868. * return self._key_exists(
  6869. */
  6870. goto __pyx_L3;
  6871. }
  6872. /* "lakesuperior/store/base_lmdb_store.pyx":411
  6873. * key, len(key), dblabel=dblabel.encode())
  6874. * else:
  6875. * return self._key_exists(key, len(key), dblabel=dblabel.encode()) # <<<<<<<<<<<<<<
  6876. *
  6877. *
  6878. */
  6879. /*else*/ {
  6880. __Pyx_XDECREF(__pyx_r);
  6881. __pyx_t_13 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 411, __pyx_L1_error)
  6882. __pyx_t_12 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 411, __pyx_L1_error)
  6883. __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)
  6884. __Pyx_GOTREF(__pyx_t_4);
  6885. __pyx_t_3 = NULL;
  6886. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  6887. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
  6888. if (likely(__pyx_t_3)) {
  6889. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  6890. __Pyx_INCREF(__pyx_t_3);
  6891. __Pyx_INCREF(function);
  6892. __Pyx_DECREF_SET(__pyx_t_4, function);
  6893. }
  6894. }
  6895. if (__pyx_t_3) {
  6896. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 411, __pyx_L1_error)
  6897. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6898. } else {
  6899. __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 411, __pyx_L1_error)
  6900. }
  6901. __Pyx_GOTREF(__pyx_t_5);
  6902. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6903. __pyx_t_11 = __Pyx_PyObject_AsWritableUString(__pyx_t_5); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 411, __pyx_L1_error)
  6904. __pyx_t_14.__pyx_n = 1;
  6905. __pyx_t_14.dblabel = __pyx_t_11;
  6906. __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)
  6907. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6908. __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 411, __pyx_L1_error)
  6909. __Pyx_GOTREF(__pyx_t_5);
  6910. __pyx_r = __pyx_t_5;
  6911. __pyx_t_5 = 0;
  6912. goto __pyx_L0;
  6913. }
  6914. __pyx_L3:;
  6915. /* "lakesuperior/store/base_lmdb_store.pyx":399
  6916. *
  6917. *
  6918. * def key_exists(self, key, dblabel='', new_txn=True): # <<<<<<<<<<<<<<
  6919. * """
  6920. * Return whether a key exists in a database (Python-facing method).
  6921. */
  6922. /* function exit code */
  6923. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6924. goto __pyx_L0;
  6925. __pyx_L1_error:;
  6926. __Pyx_XDECREF(__pyx_t_3);
  6927. __Pyx_XDECREF(__pyx_t_4);
  6928. __Pyx_XDECREF(__pyx_t_5);
  6929. __Pyx_XDECREF(__pyx_t_7);
  6930. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6931. __pyx_r = NULL;
  6932. __pyx_L0:;
  6933. __Pyx_XGIVEREF(__pyx_r);
  6934. __Pyx_TraceReturn(__pyx_r, 0);
  6935. __Pyx_RefNannyFinishContext();
  6936. return __pyx_r;
  6937. }
  6938. /* "lakesuperior/store/base_lmdb_store.pyx":414
  6939. *
  6940. *
  6941. * cdef inline bint _key_exists( # <<<<<<<<<<<<<<
  6942. * self, unsigned char *key, unsigned char klen,
  6943. * unsigned char *dblabel=b'') except -1:
  6944. */
  6945. 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) {
  6946. unsigned char *__pyx_v_dblabel = __pyx_k__14;
  6947. struct MDB_val __pyx_v_key_v;
  6948. struct MDB_val __pyx_v_data_v;
  6949. int __pyx_r;
  6950. __Pyx_TraceDeclarations
  6951. __Pyx_RefNannyDeclarations
  6952. PyObject *__pyx_t_1 = NULL;
  6953. PyObject *__pyx_t_2 = NULL;
  6954. PyObject *__pyx_t_3 = NULL;
  6955. MDB_dbi __pyx_t_4;
  6956. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_5;
  6957. PyObject *__pyx_t_6 = NULL;
  6958. PyObject *__pyx_t_7 = NULL;
  6959. PyObject *__pyx_t_8 = NULL;
  6960. PyObject *__pyx_t_9 = NULL;
  6961. int __pyx_t_10;
  6962. __Pyx_RefNannySetupContext("_key_exists", 0);
  6963. __Pyx_TraceCall("_key_exists", __pyx_f[0], 414, 0, __PYX_ERR(0, 414, __pyx_L1_error));
  6964. if (__pyx_optional_args) {
  6965. if (__pyx_optional_args->__pyx_n > 0) {
  6966. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  6967. }
  6968. }
  6969. /* "lakesuperior/store/base_lmdb_store.pyx":424
  6970. * cdef lmdb.MDB_val key_v, data_v
  6971. *
  6972. * key_v.mv_data = key # <<<<<<<<<<<<<<
  6973. * key_v.mv_size = klen
  6974. * #logger.debug(
  6975. */
  6976. __pyx_v_key_v.mv_data = __pyx_v_key;
  6977. /* "lakesuperior/store/base_lmdb_store.pyx":425
  6978. *
  6979. * key_v.mv_data = key
  6980. * key_v.mv_size = klen # <<<<<<<<<<<<<<
  6981. * #logger.debug(
  6982. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  6983. */
  6984. __pyx_v_key_v.mv_size = __pyx_v_klen;
  6985. /* "lakesuperior/store/base_lmdb_store.pyx":428
  6986. * #logger.debug(
  6987. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  6988. * try: # <<<<<<<<<<<<<<
  6989. * _check(lmdb.mdb_get(
  6990. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  6991. */
  6992. {
  6993. __Pyx_PyThreadState_declare
  6994. __Pyx_PyThreadState_assign
  6995. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  6996. __Pyx_XGOTREF(__pyx_t_1);
  6997. __Pyx_XGOTREF(__pyx_t_2);
  6998. __Pyx_XGOTREF(__pyx_t_3);
  6999. /*try:*/ {
  7000. /* "lakesuperior/store/base_lmdb_store.pyx":430
  7001. * try:
  7002. * _check(lmdb.mdb_get(
  7003. * self.txn, self.get_dbi(dblabel), &key_v, &data_v)) # <<<<<<<<<<<<<<
  7004. * except KeyNotFoundError:
  7005. * #logger.debug('...no.')
  7006. */
  7007. __pyx_t_5.__pyx_n = 1;
  7008. __pyx_t_5.dblabel = __pyx_v_dblabel;
  7009. __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);
  7010. /* "lakesuperior/store/base_lmdb_store.pyx":429
  7011. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  7012. * try:
  7013. * _check(lmdb.mdb_get( # <<<<<<<<<<<<<<
  7014. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7015. * except KeyNotFoundError:
  7016. */
  7017. __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)
  7018. /* "lakesuperior/store/base_lmdb_store.pyx":428
  7019. * #logger.debug(
  7020. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  7021. * try: # <<<<<<<<<<<<<<
  7022. * _check(lmdb.mdb_get(
  7023. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7024. */
  7025. }
  7026. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  7027. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  7028. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7029. goto __pyx_L8_try_end;
  7030. __pyx_L3_error:;
  7031. /* "lakesuperior/store/base_lmdb_store.pyx":431
  7032. * _check(lmdb.mdb_get(
  7033. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7034. * except KeyNotFoundError: # <<<<<<<<<<<<<<
  7035. * #logger.debug('...no.')
  7036. * return False
  7037. */
  7038. __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
  7039. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 431, __pyx_L5_except_error)
  7040. __Pyx_GOTREF(__pyx_t_9);
  7041. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_6, __pyx_t_9);
  7042. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  7043. __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  7044. __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0;
  7045. if (__pyx_t_10) {
  7046. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7047. if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0) __PYX_ERR(0, 431, __pyx_L5_except_error)
  7048. __Pyx_GOTREF(__pyx_t_8);
  7049. __Pyx_GOTREF(__pyx_t_7);
  7050. __Pyx_GOTREF(__pyx_t_6);
  7051. /* "lakesuperior/store/base_lmdb_store.pyx":433
  7052. * except KeyNotFoundError:
  7053. * #logger.debug('...no.')
  7054. * return False # <<<<<<<<<<<<<<
  7055. * #logger.debug('...yes.')
  7056. * return True
  7057. */
  7058. __pyx_r = 0;
  7059. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7060. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7061. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7062. goto __pyx_L6_except_return;
  7063. }
  7064. goto __pyx_L5_except_error;
  7065. __pyx_L5_except_error:;
  7066. /* "lakesuperior/store/base_lmdb_store.pyx":428
  7067. * #logger.debug(
  7068. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  7069. * try: # <<<<<<<<<<<<<<
  7070. * _check(lmdb.mdb_get(
  7071. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7072. */
  7073. __Pyx_XGIVEREF(__pyx_t_1);
  7074. __Pyx_XGIVEREF(__pyx_t_2);
  7075. __Pyx_XGIVEREF(__pyx_t_3);
  7076. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7077. goto __pyx_L1_error;
  7078. __pyx_L6_except_return:;
  7079. __Pyx_XGIVEREF(__pyx_t_1);
  7080. __Pyx_XGIVEREF(__pyx_t_2);
  7081. __Pyx_XGIVEREF(__pyx_t_3);
  7082. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7083. goto __pyx_L0;
  7084. __pyx_L8_try_end:;
  7085. }
  7086. /* "lakesuperior/store/base_lmdb_store.pyx":435
  7087. * return False
  7088. * #logger.debug('...yes.')
  7089. * return True # <<<<<<<<<<<<<<
  7090. *
  7091. *
  7092. */
  7093. __pyx_r = 1;
  7094. goto __pyx_L0;
  7095. /* "lakesuperior/store/base_lmdb_store.pyx":414
  7096. *
  7097. *
  7098. * cdef inline bint _key_exists( # <<<<<<<<<<<<<<
  7099. * self, unsigned char *key, unsigned char klen,
  7100. * unsigned char *dblabel=b'') except -1:
  7101. */
  7102. /* function exit code */
  7103. __pyx_L1_error:;
  7104. __Pyx_XDECREF(__pyx_t_6);
  7105. __Pyx_XDECREF(__pyx_t_7);
  7106. __Pyx_XDECREF(__pyx_t_8);
  7107. __Pyx_XDECREF(__pyx_t_9);
  7108. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7109. __pyx_r = -1;
  7110. __pyx_L0:;
  7111. __Pyx_TraceReturn(Py_None, 0);
  7112. __Pyx_RefNannyFinishContext();
  7113. return __pyx_r;
  7114. }
  7115. /* "lakesuperior/store/base_lmdb_store.pyx":438
  7116. *
  7117. *
  7118. * def put(self, key, data, dblabel='', flags=0): # <<<<<<<<<<<<<<
  7119. * """
  7120. * Put one key/value pair (Python-facing method).
  7121. */
  7122. /* Python wrapper */
  7123. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_24put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7124. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_23put[] = "\n Put one key/value pair (Python-facing method).\n ";
  7125. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_24put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  7126. PyObject *__pyx_v_key = 0;
  7127. PyObject *__pyx_v_data = 0;
  7128. PyObject *__pyx_v_dblabel = 0;
  7129. PyObject *__pyx_v_flags = 0;
  7130. PyObject *__pyx_r = 0;
  7131. __Pyx_RefNannyDeclarations
  7132. __Pyx_RefNannySetupContext("put (wrapper)", 0);
  7133. {
  7134. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_data,&__pyx_n_s_dblabel,&__pyx_n_s_flags,0};
  7135. PyObject* values[4] = {0,0,0,0};
  7136. values[2] = ((PyObject *)__pyx_kp_u_);
  7137. values[3] = ((PyObject *)__pyx_int_0);
  7138. if (unlikely(__pyx_kwds)) {
  7139. Py_ssize_t kw_args;
  7140. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  7141. switch (pos_args) {
  7142. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  7143. CYTHON_FALLTHROUGH;
  7144. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  7145. CYTHON_FALLTHROUGH;
  7146. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7147. CYTHON_FALLTHROUGH;
  7148. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7149. CYTHON_FALLTHROUGH;
  7150. case 0: break;
  7151. default: goto __pyx_L5_argtuple_error;
  7152. }
  7153. kw_args = PyDict_Size(__pyx_kwds);
  7154. switch (pos_args) {
  7155. case 0:
  7156. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  7157. else goto __pyx_L5_argtuple_error;
  7158. CYTHON_FALLTHROUGH;
  7159. case 1:
  7160. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
  7161. else {
  7162. __Pyx_RaiseArgtupleInvalid("put", 0, 2, 4, 1); __PYX_ERR(0, 438, __pyx_L3_error)
  7163. }
  7164. CYTHON_FALLTHROUGH;
  7165. case 2:
  7166. if (kw_args > 0) {
  7167. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  7168. if (value) { values[2] = value; kw_args--; }
  7169. }
  7170. CYTHON_FALLTHROUGH;
  7171. case 3:
  7172. if (kw_args > 0) {
  7173. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags);
  7174. if (value) { values[3] = value; kw_args--; }
  7175. }
  7176. }
  7177. if (unlikely(kw_args > 0)) {
  7178. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "put") < 0)) __PYX_ERR(0, 438, __pyx_L3_error)
  7179. }
  7180. } else {
  7181. switch (PyTuple_GET_SIZE(__pyx_args)) {
  7182. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  7183. CYTHON_FALLTHROUGH;
  7184. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  7185. CYTHON_FALLTHROUGH;
  7186. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7187. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7188. break;
  7189. default: goto __pyx_L5_argtuple_error;
  7190. }
  7191. }
  7192. __pyx_v_key = values[0];
  7193. __pyx_v_data = values[1];
  7194. __pyx_v_dblabel = values[2];
  7195. __pyx_v_flags = values[3];
  7196. }
  7197. goto __pyx_L4_argument_unpacking_done;
  7198. __pyx_L5_argtuple_error:;
  7199. __Pyx_RaiseArgtupleInvalid("put", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 438, __pyx_L3_error)
  7200. __pyx_L3_error:;
  7201. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7202. __Pyx_RefNannyFinishContext();
  7203. return NULL;
  7204. __pyx_L4_argument_unpacking_done:;
  7205. __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);
  7206. /* function exit code */
  7207. __Pyx_RefNannyFinishContext();
  7208. return __pyx_r;
  7209. }
  7210. 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) {
  7211. PyObject *__pyx_r = NULL;
  7212. __Pyx_TraceDeclarations
  7213. __Pyx_RefNannyDeclarations
  7214. unsigned char *__pyx_t_1;
  7215. Py_ssize_t __pyx_t_2;
  7216. unsigned char *__pyx_t_3;
  7217. Py_ssize_t __pyx_t_4;
  7218. PyObject *__pyx_t_5 = NULL;
  7219. PyObject *__pyx_t_6 = NULL;
  7220. PyObject *__pyx_t_7 = NULL;
  7221. unsigned char *__pyx_t_8;
  7222. unsigned int __pyx_t_9;
  7223. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put __pyx_t_10;
  7224. __Pyx_RefNannySetupContext("put", 0);
  7225. __Pyx_TraceCall("put", __pyx_f[0], 438, 0, __PYX_ERR(0, 438, __pyx_L1_error));
  7226. /* "lakesuperior/store/base_lmdb_store.pyx":443
  7227. * """
  7228. * self._put(
  7229. * key, len(key), data, len(data), dblabel=dblabel.encode(), # <<<<<<<<<<<<<<
  7230. * txn=self.txn, flags=flags)
  7231. *
  7232. */
  7233. __pyx_t_1 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 443, __pyx_L1_error)
  7234. __pyx_t_2 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 443, __pyx_L1_error)
  7235. __pyx_t_3 = __Pyx_PyObject_AsWritableUString(__pyx_v_data); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 443, __pyx_L1_error)
  7236. __pyx_t_4 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 443, __pyx_L1_error)
  7237. __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)
  7238. __Pyx_GOTREF(__pyx_t_6);
  7239. __pyx_t_7 = NULL;
  7240. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  7241. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  7242. if (likely(__pyx_t_7)) {
  7243. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  7244. __Pyx_INCREF(__pyx_t_7);
  7245. __Pyx_INCREF(function);
  7246. __Pyx_DECREF_SET(__pyx_t_6, function);
  7247. }
  7248. }
  7249. if (__pyx_t_7) {
  7250. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 443, __pyx_L1_error)
  7251. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7252. } else {
  7253. __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 443, __pyx_L1_error)
  7254. }
  7255. __Pyx_GOTREF(__pyx_t_5);
  7256. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7257. __pyx_t_8 = __Pyx_PyObject_AsWritableUString(__pyx_t_5); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 443, __pyx_L1_error)
  7258. /* "lakesuperior/store/base_lmdb_store.pyx":444
  7259. * self._put(
  7260. * key, len(key), data, len(data), dblabel=dblabel.encode(),
  7261. * txn=self.txn, flags=flags) # <<<<<<<<<<<<<<
  7262. *
  7263. *
  7264. */
  7265. __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)
  7266. /* "lakesuperior/store/base_lmdb_store.pyx":442
  7267. * Put one key/value pair (Python-facing method).
  7268. * """
  7269. * self._put( # <<<<<<<<<<<<<<
  7270. * key, len(key), data, len(data), dblabel=dblabel.encode(),
  7271. * txn=self.txn, flags=flags)
  7272. */
  7273. __pyx_t_10.__pyx_n = 3;
  7274. __pyx_t_10.dblabel = __pyx_t_8;
  7275. __pyx_t_10.txn = __pyx_v_self->txn;
  7276. __pyx_t_10.flags = __pyx_t_9;
  7277. ((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)
  7278. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7279. /* "lakesuperior/store/base_lmdb_store.pyx":438
  7280. *
  7281. *
  7282. * def put(self, key, data, dblabel='', flags=0): # <<<<<<<<<<<<<<
  7283. * """
  7284. * Put one key/value pair (Python-facing method).
  7285. */
  7286. /* function exit code */
  7287. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7288. goto __pyx_L0;
  7289. __pyx_L1_error:;
  7290. __Pyx_XDECREF(__pyx_t_5);
  7291. __Pyx_XDECREF(__pyx_t_6);
  7292. __Pyx_XDECREF(__pyx_t_7);
  7293. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7294. __pyx_r = NULL;
  7295. __pyx_L0:;
  7296. __Pyx_XGIVEREF(__pyx_r);
  7297. __Pyx_TraceReturn(__pyx_r, 0);
  7298. __Pyx_RefNannyFinishContext();
  7299. return __pyx_r;
  7300. }
  7301. /* "lakesuperior/store/base_lmdb_store.pyx":447
  7302. *
  7303. *
  7304. * cdef void _put( # <<<<<<<<<<<<<<
  7305. * self, unsigned char *key, size_t key_size, unsigned char *data,
  7306. * size_t data_size, unsigned char *dblabel='',
  7307. */
  7308. 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) {
  7309. unsigned char *__pyx_v_dblabel = __pyx_k__15;
  7310. /* "lakesuperior/store/base_lmdb_store.pyx":450
  7311. * self, unsigned char *key, size_t key_size, unsigned char *data,
  7312. * size_t data_size, unsigned char *dblabel='',
  7313. * lmdb.MDB_txn *txn=NULL, unsigned int flags=0) except *: # <<<<<<<<<<<<<<
  7314. * """
  7315. * Put one key/value pair.
  7316. */
  7317. MDB_txn *__pyx_v_txn = ((MDB_txn *)NULL);
  7318. unsigned int __pyx_v_flags = ((unsigned int)0);
  7319. int __pyx_v_rc;
  7320. __Pyx_TraceDeclarations
  7321. __Pyx_RefNannyDeclarations
  7322. int __pyx_t_1;
  7323. MDB_txn *__pyx_t_2;
  7324. MDB_dbi __pyx_t_3;
  7325. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_4;
  7326. PyObject *__pyx_t_5 = NULL;
  7327. PyObject *__pyx_t_6 = NULL;
  7328. PyObject *__pyx_t_7 = NULL;
  7329. PyObject *__pyx_t_8 = NULL;
  7330. PyObject *__pyx_t_9 = NULL;
  7331. int __pyx_t_10;
  7332. PyObject *__pyx_t_11 = NULL;
  7333. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_12;
  7334. __Pyx_RefNannySetupContext("_put", 0);
  7335. __Pyx_TraceCall("_put", __pyx_f[0], 447, 0, __PYX_ERR(0, 447, __pyx_L1_error));
  7336. if (__pyx_optional_args) {
  7337. if (__pyx_optional_args->__pyx_n > 0) {
  7338. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  7339. if (__pyx_optional_args->__pyx_n > 1) {
  7340. __pyx_v_txn = __pyx_optional_args->txn;
  7341. if (__pyx_optional_args->__pyx_n > 2) {
  7342. __pyx_v_flags = __pyx_optional_args->flags;
  7343. }
  7344. }
  7345. }
  7346. }
  7347. /* "lakesuperior/store/base_lmdb_store.pyx":454
  7348. * Put one key/value pair.
  7349. * """
  7350. * if txn is NULL: # <<<<<<<<<<<<<<
  7351. * txn = self.txn
  7352. *
  7353. */
  7354. __pyx_t_1 = ((__pyx_v_txn == NULL) != 0);
  7355. if (__pyx_t_1) {
  7356. /* "lakesuperior/store/base_lmdb_store.pyx":455
  7357. * """
  7358. * if txn is NULL:
  7359. * txn = self.txn # <<<<<<<<<<<<<<
  7360. *
  7361. * key_v.mv_data = key
  7362. */
  7363. __pyx_t_2 = __pyx_v_self->txn;
  7364. __pyx_v_txn = __pyx_t_2;
  7365. /* "lakesuperior/store/base_lmdb_store.pyx":454
  7366. * Put one key/value pair.
  7367. * """
  7368. * if txn is NULL: # <<<<<<<<<<<<<<
  7369. * txn = self.txn
  7370. *
  7371. */
  7372. }
  7373. /* "lakesuperior/store/base_lmdb_store.pyx":457
  7374. * txn = self.txn
  7375. *
  7376. * key_v.mv_data = key # <<<<<<<<<<<<<<
  7377. * key_v.mv_size = key_size
  7378. * data_v.mv_data = data
  7379. */
  7380. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_data = __pyx_v_key;
  7381. /* "lakesuperior/store/base_lmdb_store.pyx":458
  7382. *
  7383. * key_v.mv_data = key
  7384. * key_v.mv_size = key_size # <<<<<<<<<<<<<<
  7385. * data_v.mv_data = data
  7386. * data_v.mv_size = data_size
  7387. */
  7388. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_size = __pyx_v_key_size;
  7389. /* "lakesuperior/store/base_lmdb_store.pyx":459
  7390. * key_v.mv_data = key
  7391. * key_v.mv_size = key_size
  7392. * data_v.mv_data = data # <<<<<<<<<<<<<<
  7393. * data_v.mv_size = data_size
  7394. *
  7395. */
  7396. __pyx_v_12lakesuperior_5store_15base_lmdb_store_data_v.mv_data = __pyx_v_data;
  7397. /* "lakesuperior/store/base_lmdb_store.pyx":460
  7398. * key_v.mv_size = key_size
  7399. * data_v.mv_data = data
  7400. * data_v.mv_size = data_size # <<<<<<<<<<<<<<
  7401. *
  7402. * #logger.debug('Putting: {}, {} into DB {}'.format(key[: key_size],
  7403. */
  7404. __pyx_v_12lakesuperior_5store_15base_lmdb_store_data_v.mv_size = __pyx_v_data_size;
  7405. /* "lakesuperior/store/base_lmdb_store.pyx":464
  7406. * #logger.debug('Putting: {}, {} into DB {}'.format(key[: key_size],
  7407. * # data[: data_size], dblabel))
  7408. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags) # <<<<<<<<<<<<<<
  7409. * _check(rc, 'Error putting data: {}, {}'.format(
  7410. * key[: key_size], data[: data_size]))
  7411. */
  7412. __pyx_t_4.__pyx_n = 1;
  7413. __pyx_t_4.dblabel = __pyx_v_dblabel;
  7414. __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);
  7415. __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);
  7416. /* "lakesuperior/store/base_lmdb_store.pyx":465
  7417. * # data[: data_size], dblabel))
  7418. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags)
  7419. * _check(rc, 'Error putting data: {}, {}'.format( # <<<<<<<<<<<<<<
  7420. * key[: key_size], data[: data_size]))
  7421. *
  7422. */
  7423. __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)
  7424. __Pyx_GOTREF(__pyx_t_6);
  7425. /* "lakesuperior/store/base_lmdb_store.pyx":466
  7426. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags)
  7427. * _check(rc, 'Error putting data: {}, {}'.format(
  7428. * key[: key_size], data[: data_size])) # <<<<<<<<<<<<<<
  7429. *
  7430. *
  7431. */
  7432. __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)
  7433. __Pyx_GOTREF(__pyx_t_7);
  7434. __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)
  7435. __Pyx_GOTREF(__pyx_t_8);
  7436. __pyx_t_9 = NULL;
  7437. __pyx_t_10 = 0;
  7438. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  7439. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
  7440. if (likely(__pyx_t_9)) {
  7441. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  7442. __Pyx_INCREF(__pyx_t_9);
  7443. __Pyx_INCREF(function);
  7444. __Pyx_DECREF_SET(__pyx_t_6, function);
  7445. __pyx_t_10 = 1;
  7446. }
  7447. }
  7448. #if CYTHON_FAST_PYCALL
  7449. if (PyFunction_Check(__pyx_t_6)) {
  7450. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_7, __pyx_t_8};
  7451. __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)
  7452. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  7453. __Pyx_GOTREF(__pyx_t_5);
  7454. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7455. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7456. } else
  7457. #endif
  7458. #if CYTHON_FAST_PYCCALL
  7459. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  7460. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_7, __pyx_t_8};
  7461. __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)
  7462. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  7463. __Pyx_GOTREF(__pyx_t_5);
  7464. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7465. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7466. } else
  7467. #endif
  7468. {
  7469. __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 465, __pyx_L1_error)
  7470. __Pyx_GOTREF(__pyx_t_11);
  7471. if (__pyx_t_9) {
  7472. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
  7473. }
  7474. __Pyx_GIVEREF(__pyx_t_7);
  7475. PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_7);
  7476. __Pyx_GIVEREF(__pyx_t_8);
  7477. PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_8);
  7478. __pyx_t_7 = 0;
  7479. __pyx_t_8 = 0;
  7480. __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)
  7481. __Pyx_GOTREF(__pyx_t_5);
  7482. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  7483. }
  7484. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7485. /* "lakesuperior/store/base_lmdb_store.pyx":465
  7486. * # data[: data_size], dblabel))
  7487. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags)
  7488. * _check(rc, 'Error putting data: {}, {}'.format( # <<<<<<<<<<<<<<
  7489. * key[: key_size], data[: data_size]))
  7490. *
  7491. */
  7492. 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)
  7493. __pyx_t_12.__pyx_n = 1;
  7494. __pyx_t_12.message = ((PyObject*)__pyx_t_5);
  7495. __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)
  7496. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7497. /* "lakesuperior/store/base_lmdb_store.pyx":447
  7498. *
  7499. *
  7500. * cdef void _put( # <<<<<<<<<<<<<<
  7501. * self, unsigned char *key, size_t key_size, unsigned char *data,
  7502. * size_t data_size, unsigned char *dblabel='',
  7503. */
  7504. /* function exit code */
  7505. goto __pyx_L0;
  7506. __pyx_L1_error:;
  7507. __Pyx_XDECREF(__pyx_t_5);
  7508. __Pyx_XDECREF(__pyx_t_6);
  7509. __Pyx_XDECREF(__pyx_t_7);
  7510. __Pyx_XDECREF(__pyx_t_8);
  7511. __Pyx_XDECREF(__pyx_t_9);
  7512. __Pyx_XDECREF(__pyx_t_11);
  7513. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7514. __pyx_L0:;
  7515. __Pyx_TraceReturn(Py_None, 0);
  7516. __Pyx_RefNannyFinishContext();
  7517. }
  7518. /* "lakesuperior/store/base_lmdb_store.pyx":469
  7519. *
  7520. *
  7521. * cpdef bytes get_data(self, key, dblabel=''): # <<<<<<<<<<<<<<
  7522. * """
  7523. * Get a single value (non-dup) for a key (Python-facing method).
  7524. */
  7525. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7526. 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) {
  7527. PyObject *__pyx_v_dblabel = ((PyObject *)__pyx_kp_u_);
  7528. struct MDB_val __pyx_v_rv;
  7529. PyObject *__pyx_r = NULL;
  7530. __Pyx_TraceDeclarations
  7531. __Pyx_RefNannyDeclarations
  7532. PyObject *__pyx_t_1 = NULL;
  7533. PyObject *__pyx_t_2 = NULL;
  7534. PyObject *__pyx_t_3 = NULL;
  7535. PyObject *__pyx_t_4 = NULL;
  7536. int __pyx_t_5;
  7537. PyObject *__pyx_t_6 = NULL;
  7538. PyObject *__pyx_t_7 = NULL;
  7539. PyObject *__pyx_t_8 = NULL;
  7540. PyObject *__pyx_t_9 = NULL;
  7541. unsigned char *__pyx_t_10;
  7542. Py_ssize_t __pyx_t_11;
  7543. unsigned char *__pyx_t_12;
  7544. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data __pyx_t_13;
  7545. __Pyx_RefNannySetupContext("get_data", 0);
  7546. __Pyx_TraceCall("get_data", __pyx_f[0], 469, 0, __PYX_ERR(0, 469, __pyx_L1_error));
  7547. if (__pyx_optional_args) {
  7548. if (__pyx_optional_args->__pyx_n > 0) {
  7549. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  7550. }
  7551. }
  7552. /* Check if called by wrapper */
  7553. if (unlikely(__pyx_skip_dispatch)) ;
  7554. /* Check if overridden in Python */
  7555. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  7556. __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)
  7557. __Pyx_GOTREF(__pyx_t_1);
  7558. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data)) {
  7559. __Pyx_XDECREF(__pyx_r);
  7560. __Pyx_INCREF(__pyx_t_1);
  7561. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  7562. __pyx_t_5 = 0;
  7563. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  7564. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  7565. if (likely(__pyx_t_4)) {
  7566. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  7567. __Pyx_INCREF(__pyx_t_4);
  7568. __Pyx_INCREF(function);
  7569. __Pyx_DECREF_SET(__pyx_t_3, function);
  7570. __pyx_t_5 = 1;
  7571. }
  7572. }
  7573. #if CYTHON_FAST_PYCALL
  7574. if (PyFunction_Check(__pyx_t_3)) {
  7575. PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_key, __pyx_v_dblabel};
  7576. __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)
  7577. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7578. __Pyx_GOTREF(__pyx_t_2);
  7579. } else
  7580. #endif
  7581. #if CYTHON_FAST_PYCCALL
  7582. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  7583. PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_key, __pyx_v_dblabel};
  7584. __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)
  7585. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7586. __Pyx_GOTREF(__pyx_t_2);
  7587. } else
  7588. #endif
  7589. {
  7590. __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L1_error)
  7591. __Pyx_GOTREF(__pyx_t_6);
  7592. if (__pyx_t_4) {
  7593. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  7594. }
  7595. __Pyx_INCREF(__pyx_v_key);
  7596. __Pyx_GIVEREF(__pyx_v_key);
  7597. PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_key);
  7598. __Pyx_INCREF(__pyx_v_dblabel);
  7599. __Pyx_GIVEREF(__pyx_v_dblabel);
  7600. PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_dblabel);
  7601. __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)
  7602. __Pyx_GOTREF(__pyx_t_2);
  7603. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7604. }
  7605. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7606. 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)
  7607. __pyx_r = ((PyObject*)__pyx_t_2);
  7608. __pyx_t_2 = 0;
  7609. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7610. goto __pyx_L0;
  7611. }
  7612. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7613. }
  7614. /* "lakesuperior/store/base_lmdb_store.pyx":474
  7615. * """
  7616. * cdef lmdb.MDB_val rv
  7617. * try: # <<<<<<<<<<<<<<
  7618. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7619. *
  7620. */
  7621. {
  7622. __Pyx_PyThreadState_declare
  7623. __Pyx_PyThreadState_assign
  7624. __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
  7625. __Pyx_XGOTREF(__pyx_t_7);
  7626. __Pyx_XGOTREF(__pyx_t_8);
  7627. __Pyx_XGOTREF(__pyx_t_9);
  7628. /*try:*/ {
  7629. /* "lakesuperior/store/base_lmdb_store.pyx":475
  7630. * cdef lmdb.MDB_val rv
  7631. * try:
  7632. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode()) # <<<<<<<<<<<<<<
  7633. *
  7634. * return (<unsigned char *>rv.mv_data)[: rv.mv_size]
  7635. */
  7636. __pyx_t_10 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) __PYX_ERR(0, 475, __pyx_L3_error)
  7637. __pyx_t_11 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 475, __pyx_L3_error)
  7638. __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)
  7639. __Pyx_GOTREF(__pyx_t_2);
  7640. __pyx_t_3 = NULL;
  7641. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  7642. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  7643. if (likely(__pyx_t_3)) {
  7644. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  7645. __Pyx_INCREF(__pyx_t_3);
  7646. __Pyx_INCREF(function);
  7647. __Pyx_DECREF_SET(__pyx_t_2, function);
  7648. }
  7649. }
  7650. if (__pyx_t_3) {
  7651. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 475, __pyx_L3_error)
  7652. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7653. } else {
  7654. __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 475, __pyx_L3_error)
  7655. }
  7656. __Pyx_GOTREF(__pyx_t_1);
  7657. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7658. __pyx_t_12 = __Pyx_PyObject_AsWritableUString(__pyx_t_1); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 475, __pyx_L3_error)
  7659. __pyx_t_13.__pyx_n = 1;
  7660. __pyx_t_13.dblabel = __pyx_t_12;
  7661. ((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)
  7662. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7663. /* "lakesuperior/store/base_lmdb_store.pyx":477
  7664. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7665. *
  7666. * return (<unsigned char *>rv.mv_data)[: rv.mv_size] # <<<<<<<<<<<<<<
  7667. * except KeyNotFoundError:
  7668. * return None
  7669. */
  7670. __Pyx_XDECREF(__pyx_r);
  7671. __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)
  7672. __Pyx_GOTREF(__pyx_t_1);
  7673. __pyx_r = ((PyObject*)__pyx_t_1);
  7674. __pyx_t_1 = 0;
  7675. goto __pyx_L7_try_return;
  7676. /* "lakesuperior/store/base_lmdb_store.pyx":474
  7677. * """
  7678. * cdef lmdb.MDB_val rv
  7679. * try: # <<<<<<<<<<<<<<
  7680. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7681. *
  7682. */
  7683. }
  7684. __pyx_L3_error:;
  7685. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7686. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  7687. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7688. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  7689. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  7690. /* "lakesuperior/store/base_lmdb_store.pyx":478
  7691. *
  7692. * return (<unsigned char *>rv.mv_data)[: rv.mv_size]
  7693. * except KeyNotFoundError: # <<<<<<<<<<<<<<
  7694. * return None
  7695. *
  7696. */
  7697. __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  7698. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 478, __pyx_L5_except_error)
  7699. __Pyx_GOTREF(__pyx_t_6);
  7700. __pyx_t_5 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
  7701. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7702. __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7703. __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0;
  7704. if (__pyx_t_5) {
  7705. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7706. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 478, __pyx_L5_except_error)
  7707. __Pyx_GOTREF(__pyx_t_3);
  7708. __Pyx_GOTREF(__pyx_t_2);
  7709. __Pyx_GOTREF(__pyx_t_1);
  7710. /* "lakesuperior/store/base_lmdb_store.pyx":479
  7711. * return (<unsigned char *>rv.mv_data)[: rv.mv_size]
  7712. * except KeyNotFoundError:
  7713. * return None # <<<<<<<<<<<<<<
  7714. *
  7715. *
  7716. */
  7717. __Pyx_XDECREF(__pyx_r);
  7718. __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  7719. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7720. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7721. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7722. goto __pyx_L6_except_return;
  7723. }
  7724. goto __pyx_L5_except_error;
  7725. __pyx_L5_except_error:;
  7726. /* "lakesuperior/store/base_lmdb_store.pyx":474
  7727. * """
  7728. * cdef lmdb.MDB_val rv
  7729. * try: # <<<<<<<<<<<<<<
  7730. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7731. *
  7732. */
  7733. __Pyx_XGIVEREF(__pyx_t_7);
  7734. __Pyx_XGIVEREF(__pyx_t_8);
  7735. __Pyx_XGIVEREF(__pyx_t_9);
  7736. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  7737. goto __pyx_L1_error;
  7738. __pyx_L7_try_return:;
  7739. __Pyx_XGIVEREF(__pyx_t_7);
  7740. __Pyx_XGIVEREF(__pyx_t_8);
  7741. __Pyx_XGIVEREF(__pyx_t_9);
  7742. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  7743. goto __pyx_L0;
  7744. __pyx_L6_except_return:;
  7745. __Pyx_XGIVEREF(__pyx_t_7);
  7746. __Pyx_XGIVEREF(__pyx_t_8);
  7747. __Pyx_XGIVEREF(__pyx_t_9);
  7748. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  7749. goto __pyx_L0;
  7750. }
  7751. /* "lakesuperior/store/base_lmdb_store.pyx":469
  7752. *
  7753. *
  7754. * cpdef bytes get_data(self, key, dblabel=''): # <<<<<<<<<<<<<<
  7755. * """
  7756. * Get a single value (non-dup) for a key (Python-facing method).
  7757. */
  7758. /* function exit code */
  7759. __pyx_L1_error:;
  7760. __Pyx_XDECREF(__pyx_t_1);
  7761. __Pyx_XDECREF(__pyx_t_2);
  7762. __Pyx_XDECREF(__pyx_t_3);
  7763. __Pyx_XDECREF(__pyx_t_4);
  7764. __Pyx_XDECREF(__pyx_t_6);
  7765. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7766. __pyx_r = 0;
  7767. __pyx_L0:;
  7768. __Pyx_XGIVEREF(__pyx_r);
  7769. __Pyx_TraceReturn(__pyx_r, 0);
  7770. __Pyx_RefNannyFinishContext();
  7771. return __pyx_r;
  7772. }
  7773. /* Python wrapper */
  7774. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7775. 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 ";
  7776. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  7777. PyObject *__pyx_v_key = 0;
  7778. PyObject *__pyx_v_dblabel = 0;
  7779. PyObject *__pyx_r = 0;
  7780. __Pyx_RefNannyDeclarations
  7781. __Pyx_RefNannySetupContext("get_data (wrapper)", 0);
  7782. {
  7783. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_dblabel,0};
  7784. PyObject* values[2] = {0,0};
  7785. values[1] = ((PyObject *)__pyx_kp_u_);
  7786. if (unlikely(__pyx_kwds)) {
  7787. Py_ssize_t kw_args;
  7788. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  7789. switch (pos_args) {
  7790. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7791. CYTHON_FALLTHROUGH;
  7792. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7793. CYTHON_FALLTHROUGH;
  7794. case 0: break;
  7795. default: goto __pyx_L5_argtuple_error;
  7796. }
  7797. kw_args = PyDict_Size(__pyx_kwds);
  7798. switch (pos_args) {
  7799. case 0:
  7800. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  7801. else goto __pyx_L5_argtuple_error;
  7802. CYTHON_FALLTHROUGH;
  7803. case 1:
  7804. if (kw_args > 0) {
  7805. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  7806. if (value) { values[1] = value; kw_args--; }
  7807. }
  7808. }
  7809. if (unlikely(kw_args > 0)) {
  7810. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_data") < 0)) __PYX_ERR(0, 469, __pyx_L3_error)
  7811. }
  7812. } else {
  7813. switch (PyTuple_GET_SIZE(__pyx_args)) {
  7814. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7815. CYTHON_FALLTHROUGH;
  7816. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7817. break;
  7818. default: goto __pyx_L5_argtuple_error;
  7819. }
  7820. }
  7821. __pyx_v_key = values[0];
  7822. __pyx_v_dblabel = values[1];
  7823. }
  7824. goto __pyx_L4_argument_unpacking_done;
  7825. __pyx_L5_argtuple_error:;
  7826. __Pyx_RaiseArgtupleInvalid("get_data", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 469, __pyx_L3_error)
  7827. __pyx_L3_error:;
  7828. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7829. __Pyx_RefNannyFinishContext();
  7830. return NULL;
  7831. __pyx_L4_argument_unpacking_done:;
  7832. __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);
  7833. /* function exit code */
  7834. __Pyx_RefNannyFinishContext();
  7835. return __pyx_r;
  7836. }
  7837. 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) {
  7838. PyObject *__pyx_r = NULL;
  7839. __Pyx_TraceDeclarations
  7840. __Pyx_RefNannyDeclarations
  7841. PyObject *__pyx_t_1 = NULL;
  7842. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data __pyx_t_2;
  7843. __Pyx_RefNannySetupContext("get_data", 0);
  7844. __Pyx_TraceCall("get_data (wrapper)", __pyx_f[0], 469, 0, __PYX_ERR(0, 469, __pyx_L1_error));
  7845. __Pyx_XDECREF(__pyx_r);
  7846. __pyx_t_2.__pyx_n = 1;
  7847. __pyx_t_2.dblabel = __pyx_v_dblabel;
  7848. __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)
  7849. __Pyx_GOTREF(__pyx_t_1);
  7850. __pyx_r = __pyx_t_1;
  7851. __pyx_t_1 = 0;
  7852. goto __pyx_L0;
  7853. /* function exit code */
  7854. __pyx_L1_error:;
  7855. __Pyx_XDECREF(__pyx_t_1);
  7856. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7857. __pyx_r = NULL;
  7858. __pyx_L0:;
  7859. __Pyx_XGIVEREF(__pyx_r);
  7860. __Pyx_TraceReturn(__pyx_r, 0);
  7861. __Pyx_RefNannyFinishContext();
  7862. return __pyx_r;
  7863. }
  7864. /* "lakesuperior/store/base_lmdb_store.pyx":482
  7865. *
  7866. *
  7867. * cdef void _get_data( # <<<<<<<<<<<<<<
  7868. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  7869. * unsigned char *dblabel='') except *:
  7870. */
  7871. 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) {
  7872. unsigned char *__pyx_v_dblabel = __pyx_k__16;
  7873. __Pyx_TraceDeclarations
  7874. __Pyx_RefNannyDeclarations
  7875. size_t __pyx_t_1;
  7876. MDB_dbi __pyx_t_2;
  7877. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_3;
  7878. PyObject *__pyx_t_4 = NULL;
  7879. PyObject *__pyx_t_5 = NULL;
  7880. PyObject *__pyx_t_6 = NULL;
  7881. PyObject *__pyx_t_7 = NULL;
  7882. PyObject *__pyx_t_8 = NULL;
  7883. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_9;
  7884. __Pyx_RefNannySetupContext("_get_data", 0);
  7885. __Pyx_TraceCall("_get_data", __pyx_f[0], 482, 0, __PYX_ERR(0, 482, __pyx_L1_error));
  7886. if (__pyx_optional_args) {
  7887. if (__pyx_optional_args->__pyx_n > 0) {
  7888. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  7889. }
  7890. }
  7891. /* "lakesuperior/store/base_lmdb_store.pyx":491
  7892. * unsigned char *ret
  7893. *
  7894. * key_v.mv_data = key # <<<<<<<<<<<<<<
  7895. * key_v.mv_size = len(key)
  7896. *
  7897. */
  7898. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_data = __pyx_v_key;
  7899. /* "lakesuperior/store/base_lmdb_store.pyx":492
  7900. *
  7901. * key_v.mv_data = key
  7902. * key_v.mv_size = len(key) # <<<<<<<<<<<<<<
  7903. *
  7904. * _check(
  7905. */
  7906. __pyx_t_1 = strlen(((char const *)__pyx_v_key));
  7907. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_size = __pyx_t_1;
  7908. /* "lakesuperior/store/base_lmdb_store.pyx":495
  7909. *
  7910. * _check(
  7911. * lmdb.mdb_get(self.txn, self.get_dbi(dblabel), &key_v, rv), # <<<<<<<<<<<<<<
  7912. * 'Error getting data for key \'{}\'.'.format(key.decode()))
  7913. *
  7914. */
  7915. __pyx_t_3.__pyx_n = 1;
  7916. __pyx_t_3.dblabel = __pyx_v_dblabel;
  7917. __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);
  7918. /* "lakesuperior/store/base_lmdb_store.pyx":496
  7919. * _check(
  7920. * lmdb.mdb_get(self.txn, self.get_dbi(dblabel), &key_v, rv),
  7921. * 'Error getting data for key \'{}\'.'.format(key.decode())) # <<<<<<<<<<<<<<
  7922. *
  7923. *
  7924. */
  7925. __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)
  7926. __Pyx_GOTREF(__pyx_t_5);
  7927. __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)
  7928. __Pyx_GOTREF(__pyx_t_6);
  7929. __pyx_t_7 = NULL;
  7930. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  7931. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  7932. if (likely(__pyx_t_7)) {
  7933. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  7934. __Pyx_INCREF(__pyx_t_7);
  7935. __Pyx_INCREF(function);
  7936. __Pyx_DECREF_SET(__pyx_t_5, function);
  7937. }
  7938. }
  7939. if (!__pyx_t_7) {
  7940. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 496, __pyx_L1_error)
  7941. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7942. __Pyx_GOTREF(__pyx_t_4);
  7943. } else {
  7944. #if CYTHON_FAST_PYCALL
  7945. if (PyFunction_Check(__pyx_t_5)) {
  7946. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  7947. __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)
  7948. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7949. __Pyx_GOTREF(__pyx_t_4);
  7950. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7951. } else
  7952. #endif
  7953. #if CYTHON_FAST_PYCCALL
  7954. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  7955. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  7956. __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)
  7957. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7958. __Pyx_GOTREF(__pyx_t_4);
  7959. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7960. } else
  7961. #endif
  7962. {
  7963. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 496, __pyx_L1_error)
  7964. __Pyx_GOTREF(__pyx_t_8);
  7965. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  7966. __Pyx_GIVEREF(__pyx_t_6);
  7967. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
  7968. __pyx_t_6 = 0;
  7969. __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)
  7970. __Pyx_GOTREF(__pyx_t_4);
  7971. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7972. }
  7973. }
  7974. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7975. 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)
  7976. /* "lakesuperior/store/base_lmdb_store.pyx":494
  7977. * key_v.mv_size = len(key)
  7978. *
  7979. * _check( # <<<<<<<<<<<<<<
  7980. * lmdb.mdb_get(self.txn, self.get_dbi(dblabel), &key_v, rv),
  7981. * 'Error getting data for key \'{}\'.'.format(key.decode()))
  7982. */
  7983. __pyx_t_9.__pyx_n = 1;
  7984. __pyx_t_9.message = ((PyObject*)__pyx_t_4);
  7985. __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)
  7986. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7987. /* "lakesuperior/store/base_lmdb_store.pyx":482
  7988. *
  7989. *
  7990. * cdef void _get_data( # <<<<<<<<<<<<<<
  7991. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  7992. * unsigned char *dblabel='') except *:
  7993. */
  7994. /* function exit code */
  7995. goto __pyx_L0;
  7996. __pyx_L1_error:;
  7997. __Pyx_XDECREF(__pyx_t_4);
  7998. __Pyx_XDECREF(__pyx_t_5);
  7999. __Pyx_XDECREF(__pyx_t_6);
  8000. __Pyx_XDECREF(__pyx_t_7);
  8001. __Pyx_XDECREF(__pyx_t_8);
  8002. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8003. __pyx_L0:;
  8004. __Pyx_TraceReturn(Py_None, 0);
  8005. __Pyx_RefNannyFinishContext();
  8006. }
  8007. /* "lakesuperior/store/base_lmdb_store.pyx":499
  8008. *
  8009. *
  8010. * def delete(self, key, dblabel=''): # <<<<<<<<<<<<<<
  8011. * """
  8012. * Delete one single value by key. Python-facing method.
  8013. */
  8014. /* Python wrapper */
  8015. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_28delete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  8016. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_27delete[] = "\n Delete one single value by key. Python-facing method.\n ";
  8017. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_28delete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  8018. PyObject *__pyx_v_key = 0;
  8019. PyObject *__pyx_v_dblabel = 0;
  8020. PyObject *__pyx_r = 0;
  8021. __Pyx_RefNannyDeclarations
  8022. __Pyx_RefNannySetupContext("delete (wrapper)", 0);
  8023. {
  8024. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_dblabel,0};
  8025. PyObject* values[2] = {0,0};
  8026. values[1] = ((PyObject *)__pyx_kp_u_);
  8027. if (unlikely(__pyx_kwds)) {
  8028. Py_ssize_t kw_args;
  8029. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  8030. switch (pos_args) {
  8031. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  8032. CYTHON_FALLTHROUGH;
  8033. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8034. CYTHON_FALLTHROUGH;
  8035. case 0: break;
  8036. default: goto __pyx_L5_argtuple_error;
  8037. }
  8038. kw_args = PyDict_Size(__pyx_kwds);
  8039. switch (pos_args) {
  8040. case 0:
  8041. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  8042. else goto __pyx_L5_argtuple_error;
  8043. CYTHON_FALLTHROUGH;
  8044. case 1:
  8045. if (kw_args > 0) {
  8046. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  8047. if (value) { values[1] = value; kw_args--; }
  8048. }
  8049. }
  8050. if (unlikely(kw_args > 0)) {
  8051. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "delete") < 0)) __PYX_ERR(0, 499, __pyx_L3_error)
  8052. }
  8053. } else {
  8054. switch (PyTuple_GET_SIZE(__pyx_args)) {
  8055. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  8056. CYTHON_FALLTHROUGH;
  8057. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8058. break;
  8059. default: goto __pyx_L5_argtuple_error;
  8060. }
  8061. }
  8062. __pyx_v_key = values[0];
  8063. __pyx_v_dblabel = values[1];
  8064. }
  8065. goto __pyx_L4_argument_unpacking_done;
  8066. __pyx_L5_argtuple_error:;
  8067. __Pyx_RaiseArgtupleInvalid("delete", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 499, __pyx_L3_error)
  8068. __pyx_L3_error:;
  8069. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8070. __Pyx_RefNannyFinishContext();
  8071. return NULL;
  8072. __pyx_L4_argument_unpacking_done:;
  8073. __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);
  8074. /* function exit code */
  8075. __Pyx_RefNannyFinishContext();
  8076. return __pyx_r;
  8077. }
  8078. 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) {
  8079. PyObject *__pyx_r = NULL;
  8080. __Pyx_TraceDeclarations
  8081. __Pyx_RefNannyDeclarations
  8082. unsigned char *__pyx_t_1;
  8083. Py_ssize_t __pyx_t_2;
  8084. PyObject *__pyx_t_3 = NULL;
  8085. PyObject *__pyx_t_4 = NULL;
  8086. PyObject *__pyx_t_5 = NULL;
  8087. unsigned char *__pyx_t_6;
  8088. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete __pyx_t_7;
  8089. __Pyx_RefNannySetupContext("delete", 0);
  8090. __Pyx_TraceCall("delete", __pyx_f[0], 499, 0, __PYX_ERR(0, 499, __pyx_L1_error));
  8091. /* "lakesuperior/store/base_lmdb_store.pyx":503
  8092. * Delete one single value by key. Python-facing method.
  8093. * """
  8094. * self._delete(key, len(key), dblabel.encode()) # <<<<<<<<<<<<<<
  8095. *
  8096. *
  8097. */
  8098. __pyx_t_1 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 503, __pyx_L1_error)
  8099. __pyx_t_2 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 503, __pyx_L1_error)
  8100. __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)
  8101. __Pyx_GOTREF(__pyx_t_4);
  8102. __pyx_t_5 = NULL;
  8103. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  8104. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  8105. if (likely(__pyx_t_5)) {
  8106. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  8107. __Pyx_INCREF(__pyx_t_5);
  8108. __Pyx_INCREF(function);
  8109. __Pyx_DECREF_SET(__pyx_t_4, function);
  8110. }
  8111. }
  8112. if (__pyx_t_5) {
  8113. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __pyx_L1_error)
  8114. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8115. } else {
  8116. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __pyx_L1_error)
  8117. }
  8118. __Pyx_GOTREF(__pyx_t_3);
  8119. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8120. __pyx_t_6 = __Pyx_PyObject_AsWritableUString(__pyx_t_3); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 503, __pyx_L1_error)
  8121. __pyx_t_7.__pyx_n = 1;
  8122. __pyx_t_7.dblabel = __pyx_t_6;
  8123. ((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)
  8124. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8125. /* "lakesuperior/store/base_lmdb_store.pyx":499
  8126. *
  8127. *
  8128. * def delete(self, key, dblabel=''): # <<<<<<<<<<<<<<
  8129. * """
  8130. * Delete one single value by key. Python-facing method.
  8131. */
  8132. /* function exit code */
  8133. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  8134. goto __pyx_L0;
  8135. __pyx_L1_error:;
  8136. __Pyx_XDECREF(__pyx_t_3);
  8137. __Pyx_XDECREF(__pyx_t_4);
  8138. __Pyx_XDECREF(__pyx_t_5);
  8139. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8140. __pyx_r = NULL;
  8141. __pyx_L0:;
  8142. __Pyx_XGIVEREF(__pyx_r);
  8143. __Pyx_TraceReturn(__pyx_r, 0);
  8144. __Pyx_RefNannyFinishContext();
  8145. return __pyx_r;
  8146. }
  8147. /* "lakesuperior/store/base_lmdb_store.pyx":506
  8148. *
  8149. *
  8150. * cdef void _delete( # <<<<<<<<<<<<<<
  8151. * self, unsigned char *key, size_t klen,
  8152. * unsigned char *dblabel=b'') except *:
  8153. */
  8154. 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) {
  8155. unsigned char *__pyx_v_dblabel = __pyx_k__17;
  8156. __Pyx_TraceDeclarations
  8157. __Pyx_RefNannyDeclarations
  8158. PyObject *__pyx_t_1 = NULL;
  8159. PyObject *__pyx_t_2 = NULL;
  8160. PyObject *__pyx_t_3 = NULL;
  8161. MDB_dbi __pyx_t_4;
  8162. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_5;
  8163. PyObject *__pyx_t_6 = NULL;
  8164. PyObject *__pyx_t_7 = NULL;
  8165. PyObject *__pyx_t_8 = NULL;
  8166. PyObject *__pyx_t_9 = NULL;
  8167. int __pyx_t_10;
  8168. __Pyx_RefNannySetupContext("_delete", 0);
  8169. __Pyx_TraceCall("_delete", __pyx_f[0], 506, 0, __PYX_ERR(0, 506, __pyx_L1_error));
  8170. if (__pyx_optional_args) {
  8171. if (__pyx_optional_args->__pyx_n > 0) {
  8172. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  8173. }
  8174. }
  8175. /* "lakesuperior/store/base_lmdb_store.pyx":514
  8176. * TODO Allow deleting duplicate keys.
  8177. * """
  8178. * key_v.mv_data = key # <<<<<<<<<<<<<<
  8179. * key_v.mv_size = klen
  8180. * try:
  8181. */
  8182. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_data = __pyx_v_key;
  8183. /* "lakesuperior/store/base_lmdb_store.pyx":515
  8184. * """
  8185. * key_v.mv_data = key
  8186. * key_v.mv_size = klen # <<<<<<<<<<<<<<
  8187. * try:
  8188. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8189. */
  8190. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_size = __pyx_v_klen;
  8191. /* "lakesuperior/store/base_lmdb_store.pyx":516
  8192. * key_v.mv_data = key
  8193. * key_v.mv_size = klen
  8194. * try: # <<<<<<<<<<<<<<
  8195. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8196. * except KeyNotFoundError:
  8197. */
  8198. {
  8199. __Pyx_PyThreadState_declare
  8200. __Pyx_PyThreadState_assign
  8201. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  8202. __Pyx_XGOTREF(__pyx_t_1);
  8203. __Pyx_XGOTREF(__pyx_t_2);
  8204. __Pyx_XGOTREF(__pyx_t_3);
  8205. /*try:*/ {
  8206. /* "lakesuperior/store/base_lmdb_store.pyx":517
  8207. * key_v.mv_size = klen
  8208. * try:
  8209. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL)) # <<<<<<<<<<<<<<
  8210. * except KeyNotFoundError:
  8211. * pass
  8212. */
  8213. __pyx_t_5.__pyx_n = 1;
  8214. __pyx_t_5.dblabel = __pyx_v_dblabel;
  8215. __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);
  8216. __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)
  8217. /* "lakesuperior/store/base_lmdb_store.pyx":516
  8218. * key_v.mv_data = key
  8219. * key_v.mv_size = klen
  8220. * try: # <<<<<<<<<<<<<<
  8221. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8222. * except KeyNotFoundError:
  8223. */
  8224. }
  8225. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  8226. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  8227. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  8228. goto __pyx_L8_try_end;
  8229. __pyx_L3_error:;
  8230. /* "lakesuperior/store/base_lmdb_store.pyx":518
  8231. * try:
  8232. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8233. * except KeyNotFoundError: # <<<<<<<<<<<<<<
  8234. * pass
  8235. *
  8236. */
  8237. __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
  8238. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 518, __pyx_L5_except_error)
  8239. __Pyx_GOTREF(__pyx_t_9);
  8240. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_6, __pyx_t_9);
  8241. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8242. __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  8243. __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0;
  8244. if (__pyx_t_10) {
  8245. __Pyx_ErrRestore(0,0,0);
  8246. goto __pyx_L4_exception_handled;
  8247. }
  8248. goto __pyx_L5_except_error;
  8249. __pyx_L5_except_error:;
  8250. /* "lakesuperior/store/base_lmdb_store.pyx":516
  8251. * key_v.mv_data = key
  8252. * key_v.mv_size = klen
  8253. * try: # <<<<<<<<<<<<<<
  8254. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8255. * except KeyNotFoundError:
  8256. */
  8257. __Pyx_XGIVEREF(__pyx_t_1);
  8258. __Pyx_XGIVEREF(__pyx_t_2);
  8259. __Pyx_XGIVEREF(__pyx_t_3);
  8260. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8261. goto __pyx_L1_error;
  8262. __pyx_L4_exception_handled:;
  8263. __Pyx_XGIVEREF(__pyx_t_1);
  8264. __Pyx_XGIVEREF(__pyx_t_2);
  8265. __Pyx_XGIVEREF(__pyx_t_3);
  8266. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8267. __pyx_L8_try_end:;
  8268. }
  8269. /* "lakesuperior/store/base_lmdb_store.pyx":506
  8270. *
  8271. *
  8272. * cdef void _delete( # <<<<<<<<<<<<<<
  8273. * self, unsigned char *key, size_t klen,
  8274. * unsigned char *dblabel=b'') except *:
  8275. */
  8276. /* function exit code */
  8277. goto __pyx_L0;
  8278. __pyx_L1_error:;
  8279. __Pyx_XDECREF(__pyx_t_6);
  8280. __Pyx_XDECREF(__pyx_t_7);
  8281. __Pyx_XDECREF(__pyx_t_8);
  8282. __Pyx_XDECREF(__pyx_t_9);
  8283. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8284. __pyx_L0:;
  8285. __Pyx_TraceReturn(Py_None, 0);
  8286. __Pyx_RefNannyFinishContext();
  8287. }
  8288. /* "lakesuperior/store/base_lmdb_store.pyx":522
  8289. *
  8290. *
  8291. * cpdef dict stats(self): # <<<<<<<<<<<<<<
  8292. * """Gather statistics about the database."""
  8293. * return self._stats()
  8294. */
  8295. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  8296. 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) {
  8297. PyObject *__pyx_r = NULL;
  8298. __Pyx_TraceDeclarations
  8299. __Pyx_RefNannyDeclarations
  8300. PyObject *__pyx_t_1 = NULL;
  8301. PyObject *__pyx_t_2 = NULL;
  8302. PyObject *__pyx_t_3 = NULL;
  8303. PyObject *__pyx_t_4 = NULL;
  8304. __Pyx_RefNannySetupContext("stats", 0);
  8305. __Pyx_TraceCall("stats", __pyx_f[0], 522, 0, __PYX_ERR(0, 522, __pyx_L1_error));
  8306. /* Check if called by wrapper */
  8307. if (unlikely(__pyx_skip_dispatch)) ;
  8308. /* Check if overridden in Python */
  8309. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  8310. __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)
  8311. __Pyx_GOTREF(__pyx_t_1);
  8312. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats)) {
  8313. __Pyx_XDECREF(__pyx_r);
  8314. __Pyx_INCREF(__pyx_t_1);
  8315. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  8316. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  8317. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  8318. if (likely(__pyx_t_4)) {
  8319. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  8320. __Pyx_INCREF(__pyx_t_4);
  8321. __Pyx_INCREF(function);
  8322. __Pyx_DECREF_SET(__pyx_t_3, function);
  8323. }
  8324. }
  8325. if (__pyx_t_4) {
  8326. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 522, __pyx_L1_error)
  8327. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8328. } else {
  8329. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 522, __pyx_L1_error)
  8330. }
  8331. __Pyx_GOTREF(__pyx_t_2);
  8332. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8333. 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)
  8334. __pyx_r = ((PyObject*)__pyx_t_2);
  8335. __pyx_t_2 = 0;
  8336. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8337. goto __pyx_L0;
  8338. }
  8339. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8340. }
  8341. /* "lakesuperior/store/base_lmdb_store.pyx":524
  8342. * cpdef dict stats(self):
  8343. * """Gather statistics about the database."""
  8344. * return self._stats() # <<<<<<<<<<<<<<
  8345. *
  8346. *
  8347. */
  8348. __Pyx_XDECREF(__pyx_r);
  8349. __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)
  8350. __Pyx_GOTREF(__pyx_t_1);
  8351. __pyx_r = ((PyObject*)__pyx_t_1);
  8352. __pyx_t_1 = 0;
  8353. goto __pyx_L0;
  8354. /* "lakesuperior/store/base_lmdb_store.pyx":522
  8355. *
  8356. *
  8357. * cpdef dict stats(self): # <<<<<<<<<<<<<<
  8358. * """Gather statistics about the database."""
  8359. * return self._stats()
  8360. */
  8361. /* function exit code */
  8362. __pyx_L1_error:;
  8363. __Pyx_XDECREF(__pyx_t_1);
  8364. __Pyx_XDECREF(__pyx_t_2);
  8365. __Pyx_XDECREF(__pyx_t_3);
  8366. __Pyx_XDECREF(__pyx_t_4);
  8367. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8368. __pyx_r = 0;
  8369. __pyx_L0:;
  8370. __Pyx_XGIVEREF(__pyx_r);
  8371. __Pyx_TraceReturn(__pyx_r, 0);
  8372. __Pyx_RefNannyFinishContext();
  8373. return __pyx_r;
  8374. }
  8375. /* Python wrapper */
  8376. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  8377. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats[] = "Gather statistics about the database.";
  8378. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  8379. PyObject *__pyx_r = 0;
  8380. __Pyx_RefNannyDeclarations
  8381. __Pyx_RefNannySetupContext("stats (wrapper)", 0);
  8382. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  8383. /* function exit code */
  8384. __Pyx_RefNannyFinishContext();
  8385. return __pyx_r;
  8386. }
  8387. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  8388. PyObject *__pyx_r = NULL;
  8389. __Pyx_TraceDeclarations
  8390. __Pyx_RefNannyDeclarations
  8391. PyObject *__pyx_t_1 = NULL;
  8392. __Pyx_RefNannySetupContext("stats", 0);
  8393. __Pyx_TraceCall("stats (wrapper)", __pyx_f[0], 522, 0, __PYX_ERR(0, 522, __pyx_L1_error));
  8394. __Pyx_XDECREF(__pyx_r);
  8395. __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)
  8396. __Pyx_GOTREF(__pyx_t_1);
  8397. __pyx_r = __pyx_t_1;
  8398. __pyx_t_1 = 0;
  8399. goto __pyx_L0;
  8400. /* function exit code */
  8401. __pyx_L1_error:;
  8402. __Pyx_XDECREF(__pyx_t_1);
  8403. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8404. __pyx_r = NULL;
  8405. __pyx_L0:;
  8406. __Pyx_XGIVEREF(__pyx_r);
  8407. __Pyx_TraceReturn(__pyx_r, 0);
  8408. __Pyx_RefNannyFinishContext();
  8409. return __pyx_r;
  8410. }
  8411. /* "lakesuperior/store/base_lmdb_store.pyx":527
  8412. *
  8413. *
  8414. * cdef dict _stats(self): # <<<<<<<<<<<<<<
  8415. * """
  8416. * Gather statistics about the database.
  8417. */
  8418. static PyObject *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  8419. struct MDB_stat __pyx_v_stat;
  8420. CYTHON_UNUSED size_t __pyx_v_entries;
  8421. PyObject *__pyx_v_env_stats = NULL;
  8422. PyObject *__pyx_v_db_stats = NULL;
  8423. PyObject *__pyx_v_i = NULL;
  8424. PyObject *__pyx_v_dblabel = NULL;
  8425. PyObject *__pyx_7genexpr__pyx_v_db_label = NULL;
  8426. PyObject *__pyx_r = NULL;
  8427. __Pyx_TraceDeclarations
  8428. __Pyx_RefNannyDeclarations
  8429. PyObject *__pyx_t_1 = NULL;
  8430. PyObject *__pyx_t_2 = NULL;
  8431. PyObject *__pyx_t_3 = NULL;
  8432. Py_ssize_t __pyx_t_4;
  8433. PyObject *(*__pyx_t_5)(PyObject *);
  8434. Py_ssize_t __pyx_t_6;
  8435. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_7;
  8436. size_t __pyx_t_8;
  8437. PyObject *__pyx_t_9 = NULL;
  8438. PyObject *__pyx_t_10 = NULL;
  8439. PyObject *__pyx_t_11 = NULL;
  8440. __Pyx_RefNannySetupContext("_stats", 0);
  8441. __Pyx_TraceCall("_stats", __pyx_f[0], 527, 0, __PYX_ERR(0, 527, __pyx_L1_error));
  8442. /* "lakesuperior/store/base_lmdb_store.pyx":537
  8443. * size_t entries
  8444. *
  8445. * lmdb.mdb_env_stat(self.dbenv, &stat) # <<<<<<<<<<<<<<
  8446. * env_stats = <dict>stat
  8447. *
  8448. */
  8449. (void)(mdb_env_stat(__pyx_v_self->dbenv, (&__pyx_v_stat)));
  8450. /* "lakesuperior/store/base_lmdb_store.pyx":538
  8451. *
  8452. * lmdb.mdb_env_stat(self.dbenv, &stat)
  8453. * env_stats = <dict>stat # <<<<<<<<<<<<<<
  8454. *
  8455. * db_stats = {}
  8456. */
  8457. __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)
  8458. __Pyx_GOTREF(__pyx_t_1);
  8459. 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)
  8460. __pyx_t_2 = __pyx_t_1;
  8461. __Pyx_INCREF(__pyx_t_2);
  8462. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8463. __pyx_v_env_stats = ((PyObject*)__pyx_t_2);
  8464. __pyx_t_2 = 0;
  8465. /* "lakesuperior/store/base_lmdb_store.pyx":540
  8466. * env_stats = <dict>stat
  8467. *
  8468. * db_stats = {} # <<<<<<<<<<<<<<
  8469. * for i, dblabel in enumerate(self.dbi_labels):
  8470. * _check(
  8471. */
  8472. __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 540, __pyx_L1_error)
  8473. __Pyx_GOTREF(__pyx_t_2);
  8474. __pyx_v_db_stats = ((PyObject*)__pyx_t_2);
  8475. __pyx_t_2 = 0;
  8476. /* "lakesuperior/store/base_lmdb_store.pyx":541
  8477. *
  8478. * db_stats = {}
  8479. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  8480. * _check(
  8481. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8482. */
  8483. __Pyx_INCREF(__pyx_int_0);
  8484. __pyx_t_2 = __pyx_int_0;
  8485. __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)
  8486. __Pyx_GOTREF(__pyx_t_1);
  8487. if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
  8488. __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  8489. __pyx_t_5 = NULL;
  8490. } else {
  8491. __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 541, __pyx_L1_error)
  8492. __Pyx_GOTREF(__pyx_t_3);
  8493. __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 541, __pyx_L1_error)
  8494. }
  8495. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8496. for (;;) {
  8497. if (likely(!__pyx_t_5)) {
  8498. if (likely(PyList_CheckExact(__pyx_t_3))) {
  8499. if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
  8500. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8501. __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)
  8502. #else
  8503. __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)
  8504. __Pyx_GOTREF(__pyx_t_1);
  8505. #endif
  8506. } else {
  8507. if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
  8508. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8509. __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)
  8510. #else
  8511. __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)
  8512. __Pyx_GOTREF(__pyx_t_1);
  8513. #endif
  8514. }
  8515. } else {
  8516. __pyx_t_1 = __pyx_t_5(__pyx_t_3);
  8517. if (unlikely(!__pyx_t_1)) {
  8518. PyObject* exc_type = PyErr_Occurred();
  8519. if (exc_type) {
  8520. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  8521. else __PYX_ERR(0, 541, __pyx_L1_error)
  8522. }
  8523. break;
  8524. }
  8525. __Pyx_GOTREF(__pyx_t_1);
  8526. }
  8527. __Pyx_XDECREF_SET(__pyx_v_dblabel, __pyx_t_1);
  8528. __pyx_t_1 = 0;
  8529. __Pyx_INCREF(__pyx_t_2);
  8530. __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
  8531. __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)
  8532. __Pyx_GOTREF(__pyx_t_1);
  8533. __Pyx_DECREF(__pyx_t_2);
  8534. __pyx_t_2 = __pyx_t_1;
  8535. __pyx_t_1 = 0;
  8536. /* "lakesuperior/store/base_lmdb_store.pyx":543
  8537. * for i, dblabel in enumerate(self.dbi_labels):
  8538. * _check(
  8539. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat), # <<<<<<<<<<<<<<
  8540. * 'Error getting datbase stats: {}')
  8541. * entries = stat.ms_entries
  8542. */
  8543. __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)
  8544. /* "lakesuperior/store/base_lmdb_store.pyx":542
  8545. * db_stats = {}
  8546. * for i, dblabel in enumerate(self.dbi_labels):
  8547. * _check( # <<<<<<<<<<<<<<
  8548. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8549. * 'Error getting datbase stats: {}')
  8550. */
  8551. __pyx_t_7.__pyx_n = 1;
  8552. __pyx_t_7.message = __pyx_kp_u_Error_getting_datbase_stats;
  8553. __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)
  8554. /* "lakesuperior/store/base_lmdb_store.pyx":545
  8555. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8556. * 'Error getting datbase stats: {}')
  8557. * entries = stat.ms_entries # <<<<<<<<<<<<<<
  8558. * db_stats[dblabel.encode()] = <dict>stat
  8559. *
  8560. */
  8561. __pyx_t_8 = __pyx_v_stat.ms_entries;
  8562. __pyx_v_entries = __pyx_t_8;
  8563. /* "lakesuperior/store/base_lmdb_store.pyx":546
  8564. * 'Error getting datbase stats: {}')
  8565. * entries = stat.ms_entries
  8566. * db_stats[dblabel.encode()] = <dict>stat # <<<<<<<<<<<<<<
  8567. *
  8568. * return {
  8569. */
  8570. __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)
  8571. __Pyx_GOTREF(__pyx_t_1);
  8572. 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)
  8573. __pyx_t_9 = __pyx_t_1;
  8574. __Pyx_INCREF(__pyx_t_9);
  8575. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8576. __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)
  8577. __Pyx_GOTREF(__pyx_t_10);
  8578. __pyx_t_11 = NULL;
  8579. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
  8580. __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
  8581. if (likely(__pyx_t_11)) {
  8582. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  8583. __Pyx_INCREF(__pyx_t_11);
  8584. __Pyx_INCREF(function);
  8585. __Pyx_DECREF_SET(__pyx_t_10, function);
  8586. }
  8587. }
  8588. if (__pyx_t_11) {
  8589. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error)
  8590. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  8591. } else {
  8592. __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error)
  8593. }
  8594. __Pyx_GOTREF(__pyx_t_1);
  8595. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8596. if (unlikely(PyDict_SetItem(__pyx_v_db_stats, __pyx_t_1, __pyx_t_9) < 0)) __PYX_ERR(0, 546, __pyx_L1_error)
  8597. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8598. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8599. /* "lakesuperior/store/base_lmdb_store.pyx":541
  8600. *
  8601. * db_stats = {}
  8602. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  8603. * _check(
  8604. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8605. */
  8606. }
  8607. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8608. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8609. /* "lakesuperior/store/base_lmdb_store.pyx":548
  8610. * db_stats[dblabel.encode()] = <dict>stat
  8611. *
  8612. * return { # <<<<<<<<<<<<<<
  8613. * 'env_stats': env_stats,
  8614. * 'env_size': os.stat(self.env_path).st_size,
  8615. */
  8616. __Pyx_XDECREF(__pyx_r);
  8617. /* "lakesuperior/store/base_lmdb_store.pyx":549
  8618. *
  8619. * return {
  8620. * 'env_stats': env_stats, # <<<<<<<<<<<<<<
  8621. * 'env_size': os.stat(self.env_path).st_size,
  8622. * 'db_stats': {
  8623. */
  8624. __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 549, __pyx_L1_error)
  8625. __Pyx_GOTREF(__pyx_t_2);
  8626. if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_env_stats, __pyx_v_env_stats) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  8627. /* "lakesuperior/store/base_lmdb_store.pyx":550
  8628. * return {
  8629. * 'env_stats': env_stats,
  8630. * 'env_size': os.stat(self.env_path).st_size, # <<<<<<<<<<<<<<
  8631. * 'db_stats': {
  8632. * db_label: db_stats[db_label.encode()]
  8633. */
  8634. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 550, __pyx_L1_error)
  8635. __Pyx_GOTREF(__pyx_t_9);
  8636. __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)
  8637. __Pyx_GOTREF(__pyx_t_1);
  8638. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8639. __pyx_t_9 = NULL;
  8640. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  8641. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
  8642. if (likely(__pyx_t_9)) {
  8643. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  8644. __Pyx_INCREF(__pyx_t_9);
  8645. __Pyx_INCREF(function);
  8646. __Pyx_DECREF_SET(__pyx_t_1, function);
  8647. }
  8648. }
  8649. if (!__pyx_t_9) {
  8650. __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)
  8651. __Pyx_GOTREF(__pyx_t_3);
  8652. } else {
  8653. #if CYTHON_FAST_PYCALL
  8654. if (PyFunction_Check(__pyx_t_1)) {
  8655. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_self->env_path};
  8656. __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)
  8657. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  8658. __Pyx_GOTREF(__pyx_t_3);
  8659. } else
  8660. #endif
  8661. #if CYTHON_FAST_PYCCALL
  8662. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  8663. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_self->env_path};
  8664. __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)
  8665. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  8666. __Pyx_GOTREF(__pyx_t_3);
  8667. } else
  8668. #endif
  8669. {
  8670. __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 550, __pyx_L1_error)
  8671. __Pyx_GOTREF(__pyx_t_10);
  8672. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
  8673. __Pyx_INCREF(__pyx_v_self->env_path);
  8674. __Pyx_GIVEREF(__pyx_v_self->env_path);
  8675. PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_self->env_path);
  8676. __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)
  8677. __Pyx_GOTREF(__pyx_t_3);
  8678. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8679. }
  8680. }
  8681. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8682. __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)
  8683. __Pyx_GOTREF(__pyx_t_1);
  8684. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8685. if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_env_size, __pyx_t_1) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  8686. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8687. { /* enter inner scope */
  8688. /* "lakesuperior/store/base_lmdb_store.pyx":551
  8689. * 'env_stats': env_stats,
  8690. * 'env_size': os.stat(self.env_path).st_size,
  8691. * 'db_stats': { # <<<<<<<<<<<<<<
  8692. * db_label: db_stats[db_label.encode()]
  8693. * for db_label in self.dbi_labels
  8694. */
  8695. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 551, __pyx_L7_error)
  8696. __Pyx_GOTREF(__pyx_t_1);
  8697. /* "lakesuperior/store/base_lmdb_store.pyx":553
  8698. * 'db_stats': {
  8699. * db_label: db_stats[db_label.encode()]
  8700. * for db_label in self.dbi_labels # <<<<<<<<<<<<<<
  8701. * },
  8702. * }
  8703. */
  8704. __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)
  8705. __Pyx_GOTREF(__pyx_t_3);
  8706. if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
  8707. __pyx_t_10 = __pyx_t_3; __Pyx_INCREF(__pyx_t_10); __pyx_t_4 = 0;
  8708. __pyx_t_5 = NULL;
  8709. } else {
  8710. __pyx_t_4 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 553, __pyx_L7_error)
  8711. __Pyx_GOTREF(__pyx_t_10);
  8712. __pyx_t_5 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 553, __pyx_L7_error)
  8713. }
  8714. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8715. for (;;) {
  8716. if (likely(!__pyx_t_5)) {
  8717. if (likely(PyList_CheckExact(__pyx_t_10))) {
  8718. if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_10)) break;
  8719. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8720. __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)
  8721. #else
  8722. __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)
  8723. __Pyx_GOTREF(__pyx_t_3);
  8724. #endif
  8725. } else {
  8726. if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
  8727. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8728. __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)
  8729. #else
  8730. __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)
  8731. __Pyx_GOTREF(__pyx_t_3);
  8732. #endif
  8733. }
  8734. } else {
  8735. __pyx_t_3 = __pyx_t_5(__pyx_t_10);
  8736. if (unlikely(!__pyx_t_3)) {
  8737. PyObject* exc_type = PyErr_Occurred();
  8738. if (exc_type) {
  8739. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  8740. else __PYX_ERR(0, 553, __pyx_L7_error)
  8741. }
  8742. break;
  8743. }
  8744. __Pyx_GOTREF(__pyx_t_3);
  8745. }
  8746. __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_db_label, __pyx_t_3);
  8747. __pyx_t_3 = 0;
  8748. /* "lakesuperior/store/base_lmdb_store.pyx":552
  8749. * 'env_size': os.stat(self.env_path).st_size,
  8750. * 'db_stats': {
  8751. * db_label: db_stats[db_label.encode()] # <<<<<<<<<<<<<<
  8752. * for db_label in self.dbi_labels
  8753. * },
  8754. */
  8755. __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)
  8756. __Pyx_GOTREF(__pyx_t_9);
  8757. __pyx_t_11 = NULL;
  8758. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
  8759. __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
  8760. if (likely(__pyx_t_11)) {
  8761. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
  8762. __Pyx_INCREF(__pyx_t_11);
  8763. __Pyx_INCREF(function);
  8764. __Pyx_DECREF_SET(__pyx_t_9, function);
  8765. }
  8766. }
  8767. if (__pyx_t_11) {
  8768. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L7_error)
  8769. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  8770. } else {
  8771. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L7_error)
  8772. }
  8773. __Pyx_GOTREF(__pyx_t_3);
  8774. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8775. __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)
  8776. __Pyx_GOTREF(__pyx_t_9);
  8777. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8778. 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)
  8779. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8780. /* "lakesuperior/store/base_lmdb_store.pyx":553
  8781. * 'db_stats': {
  8782. * db_label: db_stats[db_label.encode()]
  8783. * for db_label in self.dbi_labels # <<<<<<<<<<<<<<
  8784. * },
  8785. * }
  8786. */
  8787. }
  8788. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8789. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_db_label); __pyx_7genexpr__pyx_v_db_label = 0;
  8790. goto __pyx_L10_exit_scope;
  8791. __pyx_L7_error:;
  8792. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_db_label); __pyx_7genexpr__pyx_v_db_label = 0;
  8793. goto __pyx_L1_error;
  8794. __pyx_L10_exit_scope:;
  8795. } /* exit inner scope */
  8796. if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_db_stats, __pyx_t_1) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  8797. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8798. __pyx_r = ((PyObject*)__pyx_t_2);
  8799. __pyx_t_2 = 0;
  8800. goto __pyx_L0;
  8801. /* "lakesuperior/store/base_lmdb_store.pyx":527
  8802. *
  8803. *
  8804. * cdef dict _stats(self): # <<<<<<<<<<<<<<
  8805. * """
  8806. * Gather statistics about the database.
  8807. */
  8808. /* function exit code */
  8809. __pyx_L1_error:;
  8810. __Pyx_XDECREF(__pyx_t_1);
  8811. __Pyx_XDECREF(__pyx_t_2);
  8812. __Pyx_XDECREF(__pyx_t_3);
  8813. __Pyx_XDECREF(__pyx_t_9);
  8814. __Pyx_XDECREF(__pyx_t_10);
  8815. __Pyx_XDECREF(__pyx_t_11);
  8816. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8817. __pyx_r = 0;
  8818. __pyx_L0:;
  8819. __Pyx_XDECREF(__pyx_v_env_stats);
  8820. __Pyx_XDECREF(__pyx_v_db_stats);
  8821. __Pyx_XDECREF(__pyx_v_i);
  8822. __Pyx_XDECREF(__pyx_v_dblabel);
  8823. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_db_label);
  8824. __Pyx_XGIVEREF(__pyx_r);
  8825. __Pyx_TraceReturn(__pyx_r, 0);
  8826. __Pyx_RefNannyFinishContext();
  8827. return __pyx_r;
  8828. }
  8829. /* "lakesuperior/store/base_lmdb_store.pyx":606
  8830. * ### CYTHON METHODS ###
  8831. *
  8832. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *: # <<<<<<<<<<<<<<
  8833. * if not self.is_open:
  8834. * raise LmdbError('Store is not open.')
  8835. */
  8836. 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) {
  8837. PyObject *__pyx_v_write = ((PyObject *)Py_True);
  8838. MDB_txn *__pyx_v_parent = ((MDB_txn *)NULL);
  8839. unsigned int __pyx_v_flags;
  8840. int __pyx_v_rc;
  8841. __Pyx_TraceDeclarations
  8842. __Pyx_RefNannyDeclarations
  8843. PyObject *__pyx_t_1 = NULL;
  8844. int __pyx_t_2;
  8845. int __pyx_t_3;
  8846. PyObject *__pyx_t_4 = NULL;
  8847. unsigned int __pyx_t_5;
  8848. PyObject *__pyx_t_6 = NULL;
  8849. PyObject *__pyx_t_7 = NULL;
  8850. PyObject *__pyx_t_8 = NULL;
  8851. PyObject *__pyx_t_9 = NULL;
  8852. PyObject *__pyx_t_10 = NULL;
  8853. PyObject *__pyx_t_11 = NULL;
  8854. PyObject *__pyx_t_12 = NULL;
  8855. PyObject *__pyx_t_13 = NULL;
  8856. int __pyx_t_14;
  8857. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_15;
  8858. __Pyx_RefNannySetupContext("_txn_begin", 0);
  8859. __Pyx_TraceCall("_txn_begin", __pyx_f[0], 606, 0, __PYX_ERR(0, 606, __pyx_L1_error));
  8860. if (__pyx_optional_args) {
  8861. if (__pyx_optional_args->__pyx_n > 0) {
  8862. __pyx_v_write = __pyx_optional_args->write;
  8863. if (__pyx_optional_args->__pyx_n > 1) {
  8864. __pyx_v_parent = __pyx_optional_args->parent;
  8865. }
  8866. }
  8867. }
  8868. /* "lakesuperior/store/base_lmdb_store.pyx":607
  8869. *
  8870. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  8871. * if not self.is_open: # <<<<<<<<<<<<<<
  8872. * raise LmdbError('Store is not open.')
  8873. *
  8874. */
  8875. __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)
  8876. __Pyx_GOTREF(__pyx_t_1);
  8877. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 607, __pyx_L1_error)
  8878. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8879. __pyx_t_3 = ((!__pyx_t_2) != 0);
  8880. if (unlikely(__pyx_t_3)) {
  8881. /* "lakesuperior/store/base_lmdb_store.pyx":608
  8882. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  8883. * if not self.is_open:
  8884. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  8885. *
  8886. * cdef:
  8887. */
  8888. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
  8889. __Pyx_GOTREF(__pyx_t_1);
  8890. __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)
  8891. __Pyx_GOTREF(__pyx_t_4);
  8892. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8893. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  8894. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8895. __PYX_ERR(0, 608, __pyx_L1_error)
  8896. /* "lakesuperior/store/base_lmdb_store.pyx":607
  8897. *
  8898. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  8899. * if not self.is_open: # <<<<<<<<<<<<<<
  8900. * raise LmdbError('Store is not open.')
  8901. *
  8902. */
  8903. }
  8904. /* "lakesuperior/store/base_lmdb_store.pyx":613
  8905. * unsigned int flags
  8906. *
  8907. * flags = 0 if write else lmdb.MDB_RDONLY # <<<<<<<<<<<<<<
  8908. *
  8909. * logger.debug('Opening {} transaction in PID {}, thread {}'.format(
  8910. */
  8911. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_write); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 613, __pyx_L1_error)
  8912. if (__pyx_t_3) {
  8913. __pyx_t_5 = 0;
  8914. } else {
  8915. __pyx_t_5 = MDB_RDONLY;
  8916. }
  8917. __pyx_v_flags = __pyx_t_5;
  8918. /* "lakesuperior/store/base_lmdb_store.pyx":615
  8919. * flags = 0 if write else lmdb.MDB_RDONLY
  8920. *
  8921. * logger.debug('Opening {} transaction in PID {}, thread {}'.format( # <<<<<<<<<<<<<<
  8922. * 'RW' if write else 'RO',
  8923. * multiprocessing.current_process().pid,
  8924. */
  8925. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 615, __pyx_L1_error)
  8926. __Pyx_GOTREF(__pyx_t_1);
  8927. __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)
  8928. __Pyx_GOTREF(__pyx_t_6);
  8929. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8930. __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)
  8931. __Pyx_GOTREF(__pyx_t_7);
  8932. /* "lakesuperior/store/base_lmdb_store.pyx":616
  8933. *
  8934. * logger.debug('Opening {} transaction in PID {}, thread {}'.format(
  8935. * 'RW' if write else 'RO', # <<<<<<<<<<<<<<
  8936. * multiprocessing.current_process().pid,
  8937. * threading.currentThread().getName()))
  8938. */
  8939. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_write); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 616, __pyx_L1_error)
  8940. if (__pyx_t_3) {
  8941. __Pyx_INCREF(__pyx_n_u_RW);
  8942. __pyx_t_8 = __pyx_n_u_RW;
  8943. } else {
  8944. __Pyx_INCREF(__pyx_n_u_RO);
  8945. __pyx_t_8 = __pyx_n_u_RO;
  8946. }
  8947. /* "lakesuperior/store/base_lmdb_store.pyx":617
  8948. * logger.debug('Opening {} transaction in PID {}, thread {}'.format(
  8949. * 'RW' if write else 'RO',
  8950. * multiprocessing.current_process().pid, # <<<<<<<<<<<<<<
  8951. * threading.currentThread().getName()))
  8952. * #logger.debug('Readers: {}'.format(self.reader_list()))
  8953. */
  8954. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiprocessing); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 617, __pyx_L1_error)
  8955. __Pyx_GOTREF(__pyx_t_10);
  8956. __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)
  8957. __Pyx_GOTREF(__pyx_t_11);
  8958. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8959. __pyx_t_10 = NULL;
  8960. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
  8961. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
  8962. if (likely(__pyx_t_10)) {
  8963. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
  8964. __Pyx_INCREF(__pyx_t_10);
  8965. __Pyx_INCREF(function);
  8966. __Pyx_DECREF_SET(__pyx_t_11, function);
  8967. }
  8968. }
  8969. if (__pyx_t_10) {
  8970. __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 617, __pyx_L1_error)
  8971. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8972. } else {
  8973. __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 617, __pyx_L1_error)
  8974. }
  8975. __Pyx_GOTREF(__pyx_t_9);
  8976. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  8977. __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)
  8978. __Pyx_GOTREF(__pyx_t_11);
  8979. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8980. /* "lakesuperior/store/base_lmdb_store.pyx":618
  8981. * 'RW' if write else 'RO',
  8982. * multiprocessing.current_process().pid,
  8983. * threading.currentThread().getName())) # <<<<<<<<<<<<<<
  8984. * #logger.debug('Readers: {}'.format(self.reader_list()))
  8985. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn)
  8986. */
  8987. __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 618, __pyx_L1_error)
  8988. __Pyx_GOTREF(__pyx_t_12);
  8989. __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)
  8990. __Pyx_GOTREF(__pyx_t_13);
  8991. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  8992. __pyx_t_12 = NULL;
  8993. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
  8994. __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
  8995. if (likely(__pyx_t_12)) {
  8996. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  8997. __Pyx_INCREF(__pyx_t_12);
  8998. __Pyx_INCREF(function);
  8999. __Pyx_DECREF_SET(__pyx_t_13, function);
  9000. }
  9001. }
  9002. if (__pyx_t_12) {
  9003. __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 618, __pyx_L1_error)
  9004. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  9005. } else {
  9006. __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 618, __pyx_L1_error)
  9007. }
  9008. __Pyx_GOTREF(__pyx_t_10);
  9009. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  9010. __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)
  9011. __Pyx_GOTREF(__pyx_t_13);
  9012. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9013. __pyx_t_10 = NULL;
  9014. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  9015. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_13);
  9016. if (likely(__pyx_t_10)) {
  9017. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  9018. __Pyx_INCREF(__pyx_t_10);
  9019. __Pyx_INCREF(function);
  9020. __Pyx_DECREF_SET(__pyx_t_13, function);
  9021. }
  9022. }
  9023. if (__pyx_t_10) {
  9024. __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 618, __pyx_L1_error)
  9025. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9026. } else {
  9027. __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 618, __pyx_L1_error)
  9028. }
  9029. __Pyx_GOTREF(__pyx_t_9);
  9030. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  9031. __pyx_t_13 = NULL;
  9032. __pyx_t_14 = 0;
  9033. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
  9034. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
  9035. if (likely(__pyx_t_13)) {
  9036. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  9037. __Pyx_INCREF(__pyx_t_13);
  9038. __Pyx_INCREF(function);
  9039. __Pyx_DECREF_SET(__pyx_t_7, function);
  9040. __pyx_t_14 = 1;
  9041. }
  9042. }
  9043. #if CYTHON_FAST_PYCALL
  9044. if (PyFunction_Check(__pyx_t_7)) {
  9045. PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_8, __pyx_t_11, __pyx_t_9};
  9046. __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)
  9047. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  9048. __Pyx_GOTREF(__pyx_t_1);
  9049. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  9050. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9051. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9052. } else
  9053. #endif
  9054. #if CYTHON_FAST_PYCCALL
  9055. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  9056. PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_8, __pyx_t_11, __pyx_t_9};
  9057. __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)
  9058. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  9059. __Pyx_GOTREF(__pyx_t_1);
  9060. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  9061. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9062. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9063. } else
  9064. #endif
  9065. {
  9066. __pyx_t_10 = PyTuple_New(3+__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 615, __pyx_L1_error)
  9067. __Pyx_GOTREF(__pyx_t_10);
  9068. if (__pyx_t_13) {
  9069. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_13); __pyx_t_13 = NULL;
  9070. }
  9071. __Pyx_GIVEREF(__pyx_t_8);
  9072. PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_14, __pyx_t_8);
  9073. __Pyx_GIVEREF(__pyx_t_11);
  9074. PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_14, __pyx_t_11);
  9075. __Pyx_GIVEREF(__pyx_t_9);
  9076. PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_14, __pyx_t_9);
  9077. __pyx_t_8 = 0;
  9078. __pyx_t_11 = 0;
  9079. __pyx_t_9 = 0;
  9080. __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)
  9081. __Pyx_GOTREF(__pyx_t_1);
  9082. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9083. }
  9084. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9085. __pyx_t_7 = NULL;
  9086. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
  9087. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  9088. if (likely(__pyx_t_7)) {
  9089. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  9090. __Pyx_INCREF(__pyx_t_7);
  9091. __Pyx_INCREF(function);
  9092. __Pyx_DECREF_SET(__pyx_t_6, function);
  9093. }
  9094. }
  9095. if (!__pyx_t_7) {
  9096. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error)
  9097. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9098. __Pyx_GOTREF(__pyx_t_4);
  9099. } else {
  9100. #if CYTHON_FAST_PYCALL
  9101. if (PyFunction_Check(__pyx_t_6)) {
  9102. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9103. __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)
  9104. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9105. __Pyx_GOTREF(__pyx_t_4);
  9106. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9107. } else
  9108. #endif
  9109. #if CYTHON_FAST_PYCCALL
  9110. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  9111. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9112. __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)
  9113. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9114. __Pyx_GOTREF(__pyx_t_4);
  9115. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9116. } else
  9117. #endif
  9118. {
  9119. __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 615, __pyx_L1_error)
  9120. __Pyx_GOTREF(__pyx_t_10);
  9121. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
  9122. __Pyx_GIVEREF(__pyx_t_1);
  9123. PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_1);
  9124. __pyx_t_1 = 0;
  9125. __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)
  9126. __Pyx_GOTREF(__pyx_t_4);
  9127. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9128. }
  9129. }
  9130. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9131. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9132. /* "lakesuperior/store/base_lmdb_store.pyx":620
  9133. * threading.currentThread().getName()))
  9134. * #logger.debug('Readers: {}'.format(self.reader_list()))
  9135. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn) # <<<<<<<<<<<<<<
  9136. * _check(rc, 'Error opening transaction.')
  9137. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn))
  9138. */
  9139. __pyx_v_rc = mdb_txn_begin(__pyx_v_self->dbenv, __pyx_v_parent, __pyx_v_flags, (&__pyx_v_self->txn));
  9140. /* "lakesuperior/store/base_lmdb_store.pyx":621
  9141. * #logger.debug('Readers: {}'.format(self.reader_list()))
  9142. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn)
  9143. * _check(rc, 'Error opening transaction.') # <<<<<<<<<<<<<<
  9144. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn))
  9145. *
  9146. */
  9147. __pyx_t_15.__pyx_n = 1;
  9148. __pyx_t_15.message = __pyx_kp_u_Error_opening_transaction;
  9149. __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)
  9150. /* "lakesuperior/store/base_lmdb_store.pyx":622
  9151. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn)
  9152. * _check(rc, 'Error opening transaction.')
  9153. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn)) # <<<<<<<<<<<<<<
  9154. *
  9155. * self.is_txn_open = True
  9156. */
  9157. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 622, __pyx_L1_error)
  9158. __Pyx_GOTREF(__pyx_t_6);
  9159. __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)
  9160. __Pyx_GOTREF(__pyx_t_10);
  9161. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9162. __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)
  9163. __Pyx_GOTREF(__pyx_t_1);
  9164. __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)
  9165. __Pyx_GOTREF(__pyx_t_7);
  9166. __pyx_t_9 = NULL;
  9167. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  9168. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
  9169. if (likely(__pyx_t_9)) {
  9170. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  9171. __Pyx_INCREF(__pyx_t_9);
  9172. __Pyx_INCREF(function);
  9173. __Pyx_DECREF_SET(__pyx_t_1, function);
  9174. }
  9175. }
  9176. if (!__pyx_t_9) {
  9177. __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 622, __pyx_L1_error)
  9178. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9179. __Pyx_GOTREF(__pyx_t_6);
  9180. } else {
  9181. #if CYTHON_FAST_PYCALL
  9182. if (PyFunction_Check(__pyx_t_1)) {
  9183. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
  9184. __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)
  9185. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  9186. __Pyx_GOTREF(__pyx_t_6);
  9187. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9188. } else
  9189. #endif
  9190. #if CYTHON_FAST_PYCCALL
  9191. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  9192. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
  9193. __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)
  9194. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  9195. __Pyx_GOTREF(__pyx_t_6);
  9196. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9197. } else
  9198. #endif
  9199. {
  9200. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 622, __pyx_L1_error)
  9201. __Pyx_GOTREF(__pyx_t_11);
  9202. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
  9203. __Pyx_GIVEREF(__pyx_t_7);
  9204. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_7);
  9205. __pyx_t_7 = 0;
  9206. __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)
  9207. __Pyx_GOTREF(__pyx_t_6);
  9208. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9209. }
  9210. }
  9211. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9212. __pyx_t_1 = NULL;
  9213. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
  9214. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
  9215. if (likely(__pyx_t_1)) {
  9216. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  9217. __Pyx_INCREF(__pyx_t_1);
  9218. __Pyx_INCREF(function);
  9219. __Pyx_DECREF_SET(__pyx_t_10, function);
  9220. }
  9221. }
  9222. if (!__pyx_t_1) {
  9223. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 622, __pyx_L1_error)
  9224. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9225. __Pyx_GOTREF(__pyx_t_4);
  9226. } else {
  9227. #if CYTHON_FAST_PYCALL
  9228. if (PyFunction_Check(__pyx_t_10)) {
  9229. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6};
  9230. __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)
  9231. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9232. __Pyx_GOTREF(__pyx_t_4);
  9233. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9234. } else
  9235. #endif
  9236. #if CYTHON_FAST_PYCCALL
  9237. if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
  9238. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6};
  9239. __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)
  9240. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9241. __Pyx_GOTREF(__pyx_t_4);
  9242. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9243. } else
  9244. #endif
  9245. {
  9246. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 622, __pyx_L1_error)
  9247. __Pyx_GOTREF(__pyx_t_11);
  9248. __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL;
  9249. __Pyx_GIVEREF(__pyx_t_6);
  9250. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_6);
  9251. __pyx_t_6 = 0;
  9252. __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)
  9253. __Pyx_GOTREF(__pyx_t_4);
  9254. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9255. }
  9256. }
  9257. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9258. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9259. /* "lakesuperior/store/base_lmdb_store.pyx":624
  9260. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn))
  9261. *
  9262. * self.is_txn_open = True # <<<<<<<<<<<<<<
  9263. * self.is_txn_rw = write
  9264. * logger.debug('txn is open: {}'.format(self.is_txn_open))
  9265. */
  9266. __pyx_v_self->is_txn_open = 1;
  9267. /* "lakesuperior/store/base_lmdb_store.pyx":625
  9268. *
  9269. * self.is_txn_open = True
  9270. * self.is_txn_rw = write # <<<<<<<<<<<<<<
  9271. * logger.debug('txn is open: {}'.format(self.is_txn_open))
  9272. *
  9273. */
  9274. 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)
  9275. /* "lakesuperior/store/base_lmdb_store.pyx":626
  9276. * self.is_txn_open = True
  9277. * self.is_txn_rw = write
  9278. * logger.debug('txn is open: {}'.format(self.is_txn_open)) # <<<<<<<<<<<<<<
  9279. *
  9280. *
  9281. */
  9282. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 626, __pyx_L1_error)
  9283. __Pyx_GOTREF(__pyx_t_10);
  9284. __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)
  9285. __Pyx_GOTREF(__pyx_t_11);
  9286. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9287. __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)
  9288. __Pyx_GOTREF(__pyx_t_6);
  9289. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_txn_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L1_error)
  9290. __Pyx_GOTREF(__pyx_t_1);
  9291. __pyx_t_7 = NULL;
  9292. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  9293. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  9294. if (likely(__pyx_t_7)) {
  9295. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  9296. __Pyx_INCREF(__pyx_t_7);
  9297. __Pyx_INCREF(function);
  9298. __Pyx_DECREF_SET(__pyx_t_6, function);
  9299. }
  9300. }
  9301. if (!__pyx_t_7) {
  9302. __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 626, __pyx_L1_error)
  9303. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9304. __Pyx_GOTREF(__pyx_t_10);
  9305. } else {
  9306. #if CYTHON_FAST_PYCALL
  9307. if (PyFunction_Check(__pyx_t_6)) {
  9308. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9309. __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)
  9310. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9311. __Pyx_GOTREF(__pyx_t_10);
  9312. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9313. } else
  9314. #endif
  9315. #if CYTHON_FAST_PYCCALL
  9316. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  9317. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9318. __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)
  9319. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9320. __Pyx_GOTREF(__pyx_t_10);
  9321. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9322. } else
  9323. #endif
  9324. {
  9325. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 626, __pyx_L1_error)
  9326. __Pyx_GOTREF(__pyx_t_9);
  9327. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
  9328. __Pyx_GIVEREF(__pyx_t_1);
  9329. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_1);
  9330. __pyx_t_1 = 0;
  9331. __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)
  9332. __Pyx_GOTREF(__pyx_t_10);
  9333. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9334. }
  9335. }
  9336. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9337. __pyx_t_6 = NULL;
  9338. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
  9339. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11);
  9340. if (likely(__pyx_t_6)) {
  9341. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
  9342. __Pyx_INCREF(__pyx_t_6);
  9343. __Pyx_INCREF(function);
  9344. __Pyx_DECREF_SET(__pyx_t_11, function);
  9345. }
  9346. }
  9347. if (!__pyx_t_6) {
  9348. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 626, __pyx_L1_error)
  9349. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9350. __Pyx_GOTREF(__pyx_t_4);
  9351. } else {
  9352. #if CYTHON_FAST_PYCALL
  9353. if (PyFunction_Check(__pyx_t_11)) {
  9354. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  9355. __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)
  9356. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  9357. __Pyx_GOTREF(__pyx_t_4);
  9358. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9359. } else
  9360. #endif
  9361. #if CYTHON_FAST_PYCCALL
  9362. if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
  9363. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  9364. __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)
  9365. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  9366. __Pyx_GOTREF(__pyx_t_4);
  9367. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9368. } else
  9369. #endif
  9370. {
  9371. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 626, __pyx_L1_error)
  9372. __Pyx_GOTREF(__pyx_t_9);
  9373. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
  9374. __Pyx_GIVEREF(__pyx_t_10);
  9375. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_10);
  9376. __pyx_t_10 = 0;
  9377. __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)
  9378. __Pyx_GOTREF(__pyx_t_4);
  9379. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9380. }
  9381. }
  9382. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9383. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9384. /* "lakesuperior/store/base_lmdb_store.pyx":606
  9385. * ### CYTHON METHODS ###
  9386. *
  9387. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *: # <<<<<<<<<<<<<<
  9388. * if not self.is_open:
  9389. * raise LmdbError('Store is not open.')
  9390. */
  9391. /* function exit code */
  9392. goto __pyx_L0;
  9393. __pyx_L1_error:;
  9394. __Pyx_XDECREF(__pyx_t_1);
  9395. __Pyx_XDECREF(__pyx_t_4);
  9396. __Pyx_XDECREF(__pyx_t_6);
  9397. __Pyx_XDECREF(__pyx_t_7);
  9398. __Pyx_XDECREF(__pyx_t_8);
  9399. __Pyx_XDECREF(__pyx_t_9);
  9400. __Pyx_XDECREF(__pyx_t_10);
  9401. __Pyx_XDECREF(__pyx_t_11);
  9402. __Pyx_XDECREF(__pyx_t_12);
  9403. __Pyx_XDECREF(__pyx_t_13);
  9404. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_begin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9405. __pyx_L0:;
  9406. __Pyx_TraceReturn(Py_None, 0);
  9407. __Pyx_RefNannyFinishContext();
  9408. }
  9409. /* "lakesuperior/store/base_lmdb_store.pyx":629
  9410. *
  9411. *
  9412. * cdef void _txn_commit(self) except *: # <<<<<<<<<<<<<<
  9413. * txid = '{:x}'.format(<unsigned long>self.txn)
  9414. * try:
  9415. */
  9416. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_commit(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  9417. PyObject *__pyx_v_txid = NULL;
  9418. __Pyx_TraceDeclarations
  9419. __Pyx_RefNannyDeclarations
  9420. PyObject *__pyx_t_1 = NULL;
  9421. PyObject *__pyx_t_2 = NULL;
  9422. PyObject *__pyx_t_3 = NULL;
  9423. PyObject *__pyx_t_4 = NULL;
  9424. PyObject *__pyx_t_5 = NULL;
  9425. PyObject *__pyx_t_6 = NULL;
  9426. PyObject *__pyx_t_7 = NULL;
  9427. PyObject *__pyx_t_8 = NULL;
  9428. PyObject *__pyx_t_9 = NULL;
  9429. __Pyx_RefNannySetupContext("_txn_commit", 0);
  9430. __Pyx_TraceCall("_txn_commit", __pyx_f[0], 629, 0, __PYX_ERR(0, 629, __pyx_L1_error));
  9431. /* "lakesuperior/store/base_lmdb_store.pyx":630
  9432. *
  9433. * cdef void _txn_commit(self) except *:
  9434. * txid = '{:x}'.format(<unsigned long>self.txn) # <<<<<<<<<<<<<<
  9435. * try:
  9436. * _check(lmdb.mdb_txn_commit(self.txn))
  9437. */
  9438. __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)
  9439. __Pyx_GOTREF(__pyx_t_2);
  9440. __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)
  9441. __Pyx_GOTREF(__pyx_t_3);
  9442. __pyx_t_4 = NULL;
  9443. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  9444. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
  9445. if (likely(__pyx_t_4)) {
  9446. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  9447. __Pyx_INCREF(__pyx_t_4);
  9448. __Pyx_INCREF(function);
  9449. __Pyx_DECREF_SET(__pyx_t_2, function);
  9450. }
  9451. }
  9452. if (!__pyx_t_4) {
  9453. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error)
  9454. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9455. __Pyx_GOTREF(__pyx_t_1);
  9456. } else {
  9457. #if CYTHON_FAST_PYCALL
  9458. if (PyFunction_Check(__pyx_t_2)) {
  9459. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9460. __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)
  9461. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9462. __Pyx_GOTREF(__pyx_t_1);
  9463. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9464. } else
  9465. #endif
  9466. #if CYTHON_FAST_PYCCALL
  9467. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  9468. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9469. __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)
  9470. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9471. __Pyx_GOTREF(__pyx_t_1);
  9472. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9473. } else
  9474. #endif
  9475. {
  9476. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 630, __pyx_L1_error)
  9477. __Pyx_GOTREF(__pyx_t_5);
  9478. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9479. __Pyx_GIVEREF(__pyx_t_3);
  9480. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
  9481. __pyx_t_3 = 0;
  9482. __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)
  9483. __Pyx_GOTREF(__pyx_t_1);
  9484. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  9485. }
  9486. }
  9487. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9488. __pyx_v_txid = __pyx_t_1;
  9489. __pyx_t_1 = 0;
  9490. /* "lakesuperior/store/base_lmdb_store.pyx":631
  9491. * cdef void _txn_commit(self) except *:
  9492. * txid = '{:x}'.format(<unsigned long>self.txn)
  9493. * try: # <<<<<<<<<<<<<<
  9494. * _check(lmdb.mdb_txn_commit(self.txn))
  9495. * logger.debug('Transaction @ {} committed.'.format(txid))
  9496. */
  9497. {
  9498. __Pyx_PyThreadState_declare
  9499. __Pyx_PyThreadState_assign
  9500. __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
  9501. __Pyx_XGOTREF(__pyx_t_6);
  9502. __Pyx_XGOTREF(__pyx_t_7);
  9503. __Pyx_XGOTREF(__pyx_t_8);
  9504. /*try:*/ {
  9505. /* "lakesuperior/store/base_lmdb_store.pyx":632
  9506. * txid = '{:x}'.format(<unsigned long>self.txn)
  9507. * try:
  9508. * _check(lmdb.mdb_txn_commit(self.txn)) # <<<<<<<<<<<<<<
  9509. * logger.debug('Transaction @ {} committed.'.format(txid))
  9510. * self.is_txn_open = False
  9511. */
  9512. __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)
  9513. /* "lakesuperior/store/base_lmdb_store.pyx":633
  9514. * try:
  9515. * _check(lmdb.mdb_txn_commit(self.txn))
  9516. * logger.debug('Transaction @ {} committed.'.format(txid)) # <<<<<<<<<<<<<<
  9517. * self.is_txn_open = False
  9518. * self.is_txn_rw = False
  9519. */
  9520. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L3_error)
  9521. __Pyx_GOTREF(__pyx_t_2);
  9522. __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)
  9523. __Pyx_GOTREF(__pyx_t_5);
  9524. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9525. __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)
  9526. __Pyx_GOTREF(__pyx_t_3);
  9527. __pyx_t_4 = NULL;
  9528. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  9529. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  9530. if (likely(__pyx_t_4)) {
  9531. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  9532. __Pyx_INCREF(__pyx_t_4);
  9533. __Pyx_INCREF(function);
  9534. __Pyx_DECREF_SET(__pyx_t_3, function);
  9535. }
  9536. }
  9537. if (!__pyx_t_4) {
  9538. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_txid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L3_error)
  9539. __Pyx_GOTREF(__pyx_t_2);
  9540. } else {
  9541. #if CYTHON_FAST_PYCALL
  9542. if (PyFunction_Check(__pyx_t_3)) {
  9543. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9544. __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)
  9545. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9546. __Pyx_GOTREF(__pyx_t_2);
  9547. } else
  9548. #endif
  9549. #if CYTHON_FAST_PYCCALL
  9550. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  9551. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9552. __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)
  9553. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9554. __Pyx_GOTREF(__pyx_t_2);
  9555. } else
  9556. #endif
  9557. {
  9558. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 633, __pyx_L3_error)
  9559. __Pyx_GOTREF(__pyx_t_9);
  9560. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9561. __Pyx_INCREF(__pyx_v_txid);
  9562. __Pyx_GIVEREF(__pyx_v_txid);
  9563. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_txid);
  9564. __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)
  9565. __Pyx_GOTREF(__pyx_t_2);
  9566. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9567. }
  9568. }
  9569. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9570. __pyx_t_3 = NULL;
  9571. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  9572. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
  9573. if (likely(__pyx_t_3)) {
  9574. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  9575. __Pyx_INCREF(__pyx_t_3);
  9576. __Pyx_INCREF(function);
  9577. __Pyx_DECREF_SET(__pyx_t_5, function);
  9578. }
  9579. }
  9580. if (!__pyx_t_3) {
  9581. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L3_error)
  9582. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9583. __Pyx_GOTREF(__pyx_t_1);
  9584. } else {
  9585. #if CYTHON_FAST_PYCALL
  9586. if (PyFunction_Check(__pyx_t_5)) {
  9587. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  9588. __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)
  9589. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9590. __Pyx_GOTREF(__pyx_t_1);
  9591. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9592. } else
  9593. #endif
  9594. #if CYTHON_FAST_PYCCALL
  9595. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  9596. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  9597. __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)
  9598. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9599. __Pyx_GOTREF(__pyx_t_1);
  9600. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9601. } else
  9602. #endif
  9603. {
  9604. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 633, __pyx_L3_error)
  9605. __Pyx_GOTREF(__pyx_t_9);
  9606. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = NULL;
  9607. __Pyx_GIVEREF(__pyx_t_2);
  9608. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_2);
  9609. __pyx_t_2 = 0;
  9610. __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)
  9611. __Pyx_GOTREF(__pyx_t_1);
  9612. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9613. }
  9614. }
  9615. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  9616. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9617. /* "lakesuperior/store/base_lmdb_store.pyx":634
  9618. * _check(lmdb.mdb_txn_commit(self.txn))
  9619. * logger.debug('Transaction @ {} committed.'.format(txid))
  9620. * self.is_txn_open = False # <<<<<<<<<<<<<<
  9621. * self.is_txn_rw = False
  9622. * except:
  9623. */
  9624. __pyx_v_self->is_txn_open = 0;
  9625. /* "lakesuperior/store/base_lmdb_store.pyx":635
  9626. * logger.debug('Transaction @ {} committed.'.format(txid))
  9627. * self.is_txn_open = False
  9628. * self.is_txn_rw = False # <<<<<<<<<<<<<<
  9629. * except:
  9630. * self._txn_abort()
  9631. */
  9632. if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_txn_rw, Py_False) < 0) __PYX_ERR(0, 635, __pyx_L3_error)
  9633. /* "lakesuperior/store/base_lmdb_store.pyx":631
  9634. * cdef void _txn_commit(self) except *:
  9635. * txid = '{:x}'.format(<unsigned long>self.txn)
  9636. * try: # <<<<<<<<<<<<<<
  9637. * _check(lmdb.mdb_txn_commit(self.txn))
  9638. * logger.debug('Transaction @ {} committed.'.format(txid))
  9639. */
  9640. }
  9641. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  9642. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9643. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  9644. goto __pyx_L8_try_end;
  9645. __pyx_L3_error:;
  9646. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9647. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9648. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  9649. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  9650. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  9651. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9652. /* "lakesuperior/store/base_lmdb_store.pyx":636
  9653. * self.is_txn_open = False
  9654. * self.is_txn_rw = False
  9655. * except: # <<<<<<<<<<<<<<
  9656. * self._txn_abort()
  9657. * raise
  9658. */
  9659. /*except:*/ {
  9660. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_commit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9661. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) __PYX_ERR(0, 636, __pyx_L5_except_error)
  9662. __Pyx_GOTREF(__pyx_t_1);
  9663. __Pyx_GOTREF(__pyx_t_5);
  9664. __Pyx_GOTREF(__pyx_t_9);
  9665. /* "lakesuperior/store/base_lmdb_store.pyx":637
  9666. * self.is_txn_rw = False
  9667. * except:
  9668. * self._txn_abort() # <<<<<<<<<<<<<<
  9669. * raise
  9670. *
  9671. */
  9672. ((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)
  9673. /* "lakesuperior/store/base_lmdb_store.pyx":638
  9674. * except:
  9675. * self._txn_abort()
  9676. * raise # <<<<<<<<<<<<<<
  9677. *
  9678. *
  9679. */
  9680. __Pyx_GIVEREF(__pyx_t_1);
  9681. __Pyx_GIVEREF(__pyx_t_5);
  9682. __Pyx_XGIVEREF(__pyx_t_9);
  9683. __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_5, __pyx_t_9);
  9684. __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
  9685. __PYX_ERR(0, 638, __pyx_L5_except_error)
  9686. }
  9687. __pyx_L5_except_error:;
  9688. /* "lakesuperior/store/base_lmdb_store.pyx":631
  9689. * cdef void _txn_commit(self) except *:
  9690. * txid = '{:x}'.format(<unsigned long>self.txn)
  9691. * try: # <<<<<<<<<<<<<<
  9692. * _check(lmdb.mdb_txn_commit(self.txn))
  9693. * logger.debug('Transaction @ {} committed.'.format(txid))
  9694. */
  9695. __Pyx_XGIVEREF(__pyx_t_6);
  9696. __Pyx_XGIVEREF(__pyx_t_7);
  9697. __Pyx_XGIVEREF(__pyx_t_8);
  9698. __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  9699. goto __pyx_L1_error;
  9700. __pyx_L8_try_end:;
  9701. }
  9702. /* "lakesuperior/store/base_lmdb_store.pyx":629
  9703. *
  9704. *
  9705. * cdef void _txn_commit(self) except *: # <<<<<<<<<<<<<<
  9706. * txid = '{:x}'.format(<unsigned long>self.txn)
  9707. * try:
  9708. */
  9709. /* function exit code */
  9710. goto __pyx_L0;
  9711. __pyx_L1_error:;
  9712. __Pyx_XDECREF(__pyx_t_1);
  9713. __Pyx_XDECREF(__pyx_t_2);
  9714. __Pyx_XDECREF(__pyx_t_3);
  9715. __Pyx_XDECREF(__pyx_t_4);
  9716. __Pyx_XDECREF(__pyx_t_5);
  9717. __Pyx_XDECREF(__pyx_t_9);
  9718. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_commit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9719. __pyx_L0:;
  9720. __Pyx_XDECREF(__pyx_v_txid);
  9721. __Pyx_TraceReturn(Py_None, 0);
  9722. __Pyx_RefNannyFinishContext();
  9723. }
  9724. /* "lakesuperior/store/base_lmdb_store.pyx":641
  9725. *
  9726. *
  9727. * cdef void _txn_abort(self) except *: # <<<<<<<<<<<<<<
  9728. * txid = '{:x}'.format(<unsigned long>self.txn)
  9729. * lmdb.mdb_txn_abort(self.txn)
  9730. */
  9731. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_abort(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  9732. PyObject *__pyx_v_txid = NULL;
  9733. __Pyx_TraceDeclarations
  9734. __Pyx_RefNannyDeclarations
  9735. PyObject *__pyx_t_1 = NULL;
  9736. PyObject *__pyx_t_2 = NULL;
  9737. PyObject *__pyx_t_3 = NULL;
  9738. PyObject *__pyx_t_4 = NULL;
  9739. PyObject *__pyx_t_5 = NULL;
  9740. PyObject *__pyx_t_6 = NULL;
  9741. __Pyx_RefNannySetupContext("_txn_abort", 0);
  9742. __Pyx_TraceCall("_txn_abort", __pyx_f[0], 641, 0, __PYX_ERR(0, 641, __pyx_L1_error));
  9743. /* "lakesuperior/store/base_lmdb_store.pyx":642
  9744. *
  9745. * cdef void _txn_abort(self) except *:
  9746. * txid = '{:x}'.format(<unsigned long>self.txn) # <<<<<<<<<<<<<<
  9747. * lmdb.mdb_txn_abort(self.txn)
  9748. * self.is_txn_open = False
  9749. */
  9750. __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)
  9751. __Pyx_GOTREF(__pyx_t_2);
  9752. __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)
  9753. __Pyx_GOTREF(__pyx_t_3);
  9754. __pyx_t_4 = NULL;
  9755. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  9756. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
  9757. if (likely(__pyx_t_4)) {
  9758. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  9759. __Pyx_INCREF(__pyx_t_4);
  9760. __Pyx_INCREF(function);
  9761. __Pyx_DECREF_SET(__pyx_t_2, function);
  9762. }
  9763. }
  9764. if (!__pyx_t_4) {
  9765. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error)
  9766. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9767. __Pyx_GOTREF(__pyx_t_1);
  9768. } else {
  9769. #if CYTHON_FAST_PYCALL
  9770. if (PyFunction_Check(__pyx_t_2)) {
  9771. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9772. __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)
  9773. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9774. __Pyx_GOTREF(__pyx_t_1);
  9775. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9776. } else
  9777. #endif
  9778. #if CYTHON_FAST_PYCCALL
  9779. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  9780. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9781. __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)
  9782. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9783. __Pyx_GOTREF(__pyx_t_1);
  9784. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9785. } else
  9786. #endif
  9787. {
  9788. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 642, __pyx_L1_error)
  9789. __Pyx_GOTREF(__pyx_t_5);
  9790. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9791. __Pyx_GIVEREF(__pyx_t_3);
  9792. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
  9793. __pyx_t_3 = 0;
  9794. __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)
  9795. __Pyx_GOTREF(__pyx_t_1);
  9796. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  9797. }
  9798. }
  9799. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9800. __pyx_v_txid = __pyx_t_1;
  9801. __pyx_t_1 = 0;
  9802. /* "lakesuperior/store/base_lmdb_store.pyx":643
  9803. * cdef void _txn_abort(self) except *:
  9804. * txid = '{:x}'.format(<unsigned long>self.txn)
  9805. * lmdb.mdb_txn_abort(self.txn) # <<<<<<<<<<<<<<
  9806. * self.is_txn_open = False
  9807. * self.is_txn_rw = False
  9808. */
  9809. mdb_txn_abort(__pyx_v_self->txn);
  9810. /* "lakesuperior/store/base_lmdb_store.pyx":644
  9811. * txid = '{:x}'.format(<unsigned long>self.txn)
  9812. * lmdb.mdb_txn_abort(self.txn)
  9813. * self.is_txn_open = False # <<<<<<<<<<<<<<
  9814. * self.is_txn_rw = False
  9815. * logger.info('Transaction @ {} aborted.'.format(txid))
  9816. */
  9817. __pyx_v_self->is_txn_open = 0;
  9818. /* "lakesuperior/store/base_lmdb_store.pyx":645
  9819. * lmdb.mdb_txn_abort(self.txn)
  9820. * self.is_txn_open = False
  9821. * self.is_txn_rw = False # <<<<<<<<<<<<<<
  9822. * logger.info('Transaction @ {} aborted.'.format(txid))
  9823. *
  9824. */
  9825. if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_txn_rw, Py_False) < 0) __PYX_ERR(0, 645, __pyx_L1_error)
  9826. /* "lakesuperior/store/base_lmdb_store.pyx":646
  9827. * self.is_txn_open = False
  9828. * self.is_txn_rw = False
  9829. * logger.info('Transaction @ {} aborted.'.format(txid)) # <<<<<<<<<<<<<<
  9830. *
  9831. *
  9832. */
  9833. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
  9834. __Pyx_GOTREF(__pyx_t_2);
  9835. __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)
  9836. __Pyx_GOTREF(__pyx_t_5);
  9837. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9838. __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)
  9839. __Pyx_GOTREF(__pyx_t_3);
  9840. __pyx_t_4 = NULL;
  9841. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  9842. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  9843. if (likely(__pyx_t_4)) {
  9844. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  9845. __Pyx_INCREF(__pyx_t_4);
  9846. __Pyx_INCREF(function);
  9847. __Pyx_DECREF_SET(__pyx_t_3, function);
  9848. }
  9849. }
  9850. if (!__pyx_t_4) {
  9851. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_txid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
  9852. __Pyx_GOTREF(__pyx_t_2);
  9853. } else {
  9854. #if CYTHON_FAST_PYCALL
  9855. if (PyFunction_Check(__pyx_t_3)) {
  9856. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9857. __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)
  9858. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9859. __Pyx_GOTREF(__pyx_t_2);
  9860. } else
  9861. #endif
  9862. #if CYTHON_FAST_PYCCALL
  9863. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  9864. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9865. __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)
  9866. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9867. __Pyx_GOTREF(__pyx_t_2);
  9868. } else
  9869. #endif
  9870. {
  9871. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 646, __pyx_L1_error)
  9872. __Pyx_GOTREF(__pyx_t_6);
  9873. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9874. __Pyx_INCREF(__pyx_v_txid);
  9875. __Pyx_GIVEREF(__pyx_v_txid);
  9876. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_txid);
  9877. __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)
  9878. __Pyx_GOTREF(__pyx_t_2);
  9879. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9880. }
  9881. }
  9882. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9883. __pyx_t_3 = NULL;
  9884. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  9885. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
  9886. if (likely(__pyx_t_3)) {
  9887. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  9888. __Pyx_INCREF(__pyx_t_3);
  9889. __Pyx_INCREF(function);
  9890. __Pyx_DECREF_SET(__pyx_t_5, function);
  9891. }
  9892. }
  9893. if (!__pyx_t_3) {
  9894. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
  9895. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9896. __Pyx_GOTREF(__pyx_t_1);
  9897. } else {
  9898. #if CYTHON_FAST_PYCALL
  9899. if (PyFunction_Check(__pyx_t_5)) {
  9900. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  9901. __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)
  9902. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9903. __Pyx_GOTREF(__pyx_t_1);
  9904. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9905. } else
  9906. #endif
  9907. #if CYTHON_FAST_PYCCALL
  9908. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  9909. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  9910. __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)
  9911. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9912. __Pyx_GOTREF(__pyx_t_1);
  9913. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9914. } else
  9915. #endif
  9916. {
  9917. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 646, __pyx_L1_error)
  9918. __Pyx_GOTREF(__pyx_t_6);
  9919. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
  9920. __Pyx_GIVEREF(__pyx_t_2);
  9921. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_2);
  9922. __pyx_t_2 = 0;
  9923. __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)
  9924. __Pyx_GOTREF(__pyx_t_1);
  9925. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9926. }
  9927. }
  9928. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  9929. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9930. /* "lakesuperior/store/base_lmdb_store.pyx":641
  9931. *
  9932. *
  9933. * cdef void _txn_abort(self) except *: # <<<<<<<<<<<<<<
  9934. * txid = '{:x}'.format(<unsigned long>self.txn)
  9935. * lmdb.mdb_txn_abort(self.txn)
  9936. */
  9937. /* function exit code */
  9938. goto __pyx_L0;
  9939. __pyx_L1_error:;
  9940. __Pyx_XDECREF(__pyx_t_1);
  9941. __Pyx_XDECREF(__pyx_t_2);
  9942. __Pyx_XDECREF(__pyx_t_3);
  9943. __Pyx_XDECREF(__pyx_t_4);
  9944. __Pyx_XDECREF(__pyx_t_5);
  9945. __Pyx_XDECREF(__pyx_t_6);
  9946. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_abort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9947. __pyx_L0:;
  9948. __Pyx_XDECREF(__pyx_v_txid);
  9949. __Pyx_TraceReturn(Py_None, 0);
  9950. __Pyx_RefNannyFinishContext();
  9951. }
  9952. /* "lakesuperior/store/base_lmdb_store.pyx":649
  9953. *
  9954. *
  9955. * cpdef int txn_id(self): # <<<<<<<<<<<<<<
  9956. * return self._txn_id()
  9957. *
  9958. */
  9959. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  9960. 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) {
  9961. int __pyx_r;
  9962. __Pyx_TraceDeclarations
  9963. __Pyx_RefNannyDeclarations
  9964. PyObject *__pyx_t_1 = NULL;
  9965. PyObject *__pyx_t_2 = NULL;
  9966. PyObject *__pyx_t_3 = NULL;
  9967. PyObject *__pyx_t_4 = NULL;
  9968. int __pyx_t_5;
  9969. size_t __pyx_t_6;
  9970. __Pyx_RefNannySetupContext("txn_id", 0);
  9971. __Pyx_TraceCall("txn_id", __pyx_f[0], 649, 0, __PYX_ERR(0, 649, __pyx_L1_error));
  9972. /* Check if called by wrapper */
  9973. if (unlikely(__pyx_skip_dispatch)) ;
  9974. /* Check if overridden in Python */
  9975. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  9976. __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)
  9977. __Pyx_GOTREF(__pyx_t_1);
  9978. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id)) {
  9979. __Pyx_INCREF(__pyx_t_1);
  9980. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  9981. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  9982. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  9983. if (likely(__pyx_t_4)) {
  9984. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  9985. __Pyx_INCREF(__pyx_t_4);
  9986. __Pyx_INCREF(function);
  9987. __Pyx_DECREF_SET(__pyx_t_3, function);
  9988. }
  9989. }
  9990. if (__pyx_t_4) {
  9991. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error)
  9992. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9993. } else {
  9994. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error)
  9995. }
  9996. __Pyx_GOTREF(__pyx_t_2);
  9997. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9998. __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)
  9999. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  10000. __pyx_r = __pyx_t_5;
  10001. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10002. goto __pyx_L0;
  10003. }
  10004. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10005. }
  10006. /* "lakesuperior/store/base_lmdb_store.pyx":650
  10007. *
  10008. * cpdef int txn_id(self):
  10009. * return self._txn_id() # <<<<<<<<<<<<<<
  10010. *
  10011. *
  10012. */
  10013. __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)
  10014. __pyx_r = __pyx_t_6;
  10015. goto __pyx_L0;
  10016. /* "lakesuperior/store/base_lmdb_store.pyx":649
  10017. *
  10018. *
  10019. * cpdef int txn_id(self): # <<<<<<<<<<<<<<
  10020. * return self._txn_id()
  10021. *
  10022. */
  10023. /* function exit code */
  10024. __pyx_L1_error:;
  10025. __Pyx_XDECREF(__pyx_t_1);
  10026. __Pyx_XDECREF(__pyx_t_2);
  10027. __Pyx_XDECREF(__pyx_t_3);
  10028. __Pyx_XDECREF(__pyx_t_4);
  10029. __Pyx_WriteUnraisable("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_id", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  10030. __pyx_r = 0;
  10031. __pyx_L0:;
  10032. __Pyx_TraceReturn(Py_None, 0);
  10033. __Pyx_RefNannyFinishContext();
  10034. return __pyx_r;
  10035. }
  10036. /* Python wrapper */
  10037. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  10038. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  10039. PyObject *__pyx_r = 0;
  10040. __Pyx_RefNannyDeclarations
  10041. __Pyx_RefNannySetupContext("txn_id (wrapper)", 0);
  10042. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_31txn_id(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  10043. /* function exit code */
  10044. __Pyx_RefNannyFinishContext();
  10045. return __pyx_r;
  10046. }
  10047. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_31txn_id(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  10048. PyObject *__pyx_r = NULL;
  10049. __Pyx_TraceDeclarations
  10050. __Pyx_RefNannyDeclarations
  10051. PyObject *__pyx_t_1 = NULL;
  10052. __Pyx_RefNannySetupContext("txn_id", 0);
  10053. __Pyx_TraceCall("txn_id (wrapper)", __pyx_f[0], 649, 0, __PYX_ERR(0, 649, __pyx_L1_error));
  10054. __Pyx_XDECREF(__pyx_r);
  10055. __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)
  10056. __Pyx_GOTREF(__pyx_t_1);
  10057. __pyx_r = __pyx_t_1;
  10058. __pyx_t_1 = 0;
  10059. goto __pyx_L0;
  10060. /* function exit code */
  10061. __pyx_L1_error:;
  10062. __Pyx_XDECREF(__pyx_t_1);
  10063. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10064. __pyx_r = NULL;
  10065. __pyx_L0:;
  10066. __Pyx_XGIVEREF(__pyx_r);
  10067. __Pyx_TraceReturn(__pyx_r, 0);
  10068. __Pyx_RefNannyFinishContext();
  10069. return __pyx_r;
  10070. }
  10071. /* "lakesuperior/store/base_lmdb_store.pyx":653
  10072. *
  10073. *
  10074. * cdef size_t _txn_id(self) except -1: # <<<<<<<<<<<<<<
  10075. * return lmdb.mdb_txn_id(self.txn)
  10076. *
  10077. */
  10078. 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) {
  10079. size_t __pyx_r;
  10080. __Pyx_TraceDeclarations
  10081. __Pyx_RefNannyDeclarations
  10082. __Pyx_RefNannySetupContext("_txn_id", 0);
  10083. __Pyx_TraceCall("_txn_id", __pyx_f[0], 653, 0, __PYX_ERR(0, 653, __pyx_L1_error));
  10084. /* "lakesuperior/store/base_lmdb_store.pyx":654
  10085. *
  10086. * cdef size_t _txn_id(self) except -1:
  10087. * return lmdb.mdb_txn_id(self.txn) # <<<<<<<<<<<<<<
  10088. *
  10089. *
  10090. */
  10091. __pyx_r = mdb_txn_id(__pyx_v_self->txn);
  10092. goto __pyx_L0;
  10093. /* "lakesuperior/store/base_lmdb_store.pyx":653
  10094. *
  10095. *
  10096. * cdef size_t _txn_id(self) except -1: # <<<<<<<<<<<<<<
  10097. * return lmdb.mdb_txn_id(self.txn)
  10098. *
  10099. */
  10100. /* function exit code */
  10101. __pyx_L1_error:;
  10102. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10103. __pyx_r = -1L;
  10104. __pyx_L0:;
  10105. __Pyx_TraceReturn(Py_None, 0);
  10106. __Pyx_RefNannyFinishContext();
  10107. return __pyx_r;
  10108. }
  10109. /* "lakesuperior/store/base_lmdb_store.pyx":657
  10110. *
  10111. *
  10112. * cdef lmdb.MDB_dbi get_dbi( # <<<<<<<<<<<<<<
  10113. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL):
  10114. * """
  10115. */
  10116. 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) {
  10117. /* "lakesuperior/store/base_lmdb_store.pyx":658
  10118. *
  10119. * cdef lmdb.MDB_dbi get_dbi(
  10120. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL): # <<<<<<<<<<<<<<
  10121. * """
  10122. * Return a DB handle by database name.
  10123. */
  10124. unsigned char *__pyx_v_dblabel = ((unsigned char *)NULL);
  10125. MDB_txn *__pyx_v_txn = ((MDB_txn *)NULL);
  10126. size_t __pyx_v_dbidx;
  10127. MDB_dbi __pyx_r;
  10128. __Pyx_TraceDeclarations
  10129. __Pyx_RefNannyDeclarations
  10130. int __pyx_t_1;
  10131. MDB_txn *__pyx_t_2;
  10132. PyObject *__pyx_t_3 = NULL;
  10133. PyObject *__pyx_t_4 = NULL;
  10134. size_t __pyx_t_5;
  10135. PyObject *__pyx_t_6 = NULL;
  10136. PyObject *__pyx_t_7 = NULL;
  10137. PyObject *__pyx_t_8 = NULL;
  10138. size_t __pyx_t_9;
  10139. __Pyx_RefNannySetupContext("get_dbi", 0);
  10140. __Pyx_TraceCall("get_dbi", __pyx_f[0], 657, 0, __PYX_ERR(0, 657, __pyx_L1_error));
  10141. if (__pyx_optional_args) {
  10142. if (__pyx_optional_args->__pyx_n > 0) {
  10143. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  10144. if (__pyx_optional_args->__pyx_n > 1) {
  10145. __pyx_v_txn = __pyx_optional_args->txn;
  10146. }
  10147. }
  10148. }
  10149. /* "lakesuperior/store/base_lmdb_store.pyx":664
  10150. * cdef size_t dbidx
  10151. *
  10152. * if txn is NULL: # <<<<<<<<<<<<<<
  10153. * txn = self.txn
  10154. *
  10155. */
  10156. __pyx_t_1 = ((__pyx_v_txn == NULL) != 0);
  10157. if (__pyx_t_1) {
  10158. /* "lakesuperior/store/base_lmdb_store.pyx":665
  10159. *
  10160. * if txn is NULL:
  10161. * txn = self.txn # <<<<<<<<<<<<<<
  10162. *
  10163. * if dblabel is NULL:
  10164. */
  10165. __pyx_t_2 = __pyx_v_self->txn;
  10166. __pyx_v_txn = __pyx_t_2;
  10167. /* "lakesuperior/store/base_lmdb_store.pyx":664
  10168. * cdef size_t dbidx
  10169. *
  10170. * if txn is NULL: # <<<<<<<<<<<<<<
  10171. * txn = self.txn
  10172. *
  10173. */
  10174. }
  10175. /* "lakesuperior/store/base_lmdb_store.pyx":667
  10176. * txn = self.txn
  10177. *
  10178. * if dblabel is NULL: # <<<<<<<<<<<<<<
  10179. * logger.debug('Getting DBI without label.')
  10180. * dbidx = (
  10181. */
  10182. __pyx_t_1 = ((__pyx_v_dblabel == NULL) != 0);
  10183. if (__pyx_t_1) {
  10184. /* "lakesuperior/store/base_lmdb_store.pyx":668
  10185. *
  10186. * if dblabel is NULL:
  10187. * logger.debug('Getting DBI without label.') # <<<<<<<<<<<<<<
  10188. * dbidx = (
  10189. * 0 if dblabel is NULL
  10190. */
  10191. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 668, __pyx_L1_error)
  10192. __Pyx_GOTREF(__pyx_t_3);
  10193. __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)
  10194. __Pyx_GOTREF(__pyx_t_4);
  10195. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  10196. __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)
  10197. __Pyx_GOTREF(__pyx_t_3);
  10198. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10199. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  10200. /* "lakesuperior/store/base_lmdb_store.pyx":667
  10201. * txn = self.txn
  10202. *
  10203. * if dblabel is NULL: # <<<<<<<<<<<<<<
  10204. * logger.debug('Getting DBI without label.')
  10205. * dbidx = (
  10206. */
  10207. }
  10208. /* "lakesuperior/store/base_lmdb_store.pyx":670
  10209. * logger.debug('Getting DBI without label.')
  10210. * dbidx = (
  10211. * 0 if dblabel is NULL # <<<<<<<<<<<<<<
  10212. * else self.dbi_labels.index(dblabel.decode()))
  10213. * #logger.debug(
  10214. */
  10215. if (((__pyx_v_dblabel == NULL) != 0)) {
  10216. __pyx_t_5 = 0;
  10217. } else {
  10218. /* "lakesuperior/store/base_lmdb_store.pyx":671
  10219. * dbidx = (
  10220. * 0 if dblabel is NULL
  10221. * else self.dbi_labels.index(dblabel.decode())) # <<<<<<<<<<<<<<
  10222. * #logger.debug(
  10223. * # f'Got DBI {self.dbis[dbidx]} with label {dblabel} '
  10224. */
  10225. __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)
  10226. __Pyx_GOTREF(__pyx_t_4);
  10227. __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)
  10228. __Pyx_GOTREF(__pyx_t_6);
  10229. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10230. __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)
  10231. __Pyx_GOTREF(__pyx_t_4);
  10232. __pyx_t_7 = NULL;
  10233. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  10234. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  10235. if (likely(__pyx_t_7)) {
  10236. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  10237. __Pyx_INCREF(__pyx_t_7);
  10238. __Pyx_INCREF(function);
  10239. __Pyx_DECREF_SET(__pyx_t_6, function);
  10240. }
  10241. }
  10242. if (!__pyx_t_7) {
  10243. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 671, __pyx_L1_error)
  10244. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10245. __Pyx_GOTREF(__pyx_t_3);
  10246. } else {
  10247. #if CYTHON_FAST_PYCALL
  10248. if (PyFunction_Check(__pyx_t_6)) {
  10249. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
  10250. __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)
  10251. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  10252. __Pyx_GOTREF(__pyx_t_3);
  10253. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10254. } else
  10255. #endif
  10256. #if CYTHON_FAST_PYCCALL
  10257. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  10258. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
  10259. __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)
  10260. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  10261. __Pyx_GOTREF(__pyx_t_3);
  10262. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10263. } else
  10264. #endif
  10265. {
  10266. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 671, __pyx_L1_error)
  10267. __Pyx_GOTREF(__pyx_t_8);
  10268. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  10269. __Pyx_GIVEREF(__pyx_t_4);
  10270. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4);
  10271. __pyx_t_4 = 0;
  10272. __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)
  10273. __Pyx_GOTREF(__pyx_t_3);
  10274. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  10275. }
  10276. }
  10277. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10278. __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)
  10279. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  10280. __pyx_t_5 = __pyx_t_9;
  10281. }
  10282. __pyx_v_dbidx = __pyx_t_5;
  10283. /* "lakesuperior/store/base_lmdb_store.pyx":676
  10284. * # f'and index #{dbidx}')
  10285. *
  10286. * return self.dbis[dbidx] # <<<<<<<<<<<<<<
  10287. *
  10288. *
  10289. */
  10290. __pyx_r = (__pyx_v_self->dbis[__pyx_v_dbidx]);
  10291. goto __pyx_L0;
  10292. /* "lakesuperior/store/base_lmdb_store.pyx":657
  10293. *
  10294. *
  10295. * cdef lmdb.MDB_dbi get_dbi( # <<<<<<<<<<<<<<
  10296. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL):
  10297. * """
  10298. */
  10299. /* function exit code */
  10300. __pyx_L1_error:;
  10301. __Pyx_XDECREF(__pyx_t_3);
  10302. __Pyx_XDECREF(__pyx_t_4);
  10303. __Pyx_XDECREF(__pyx_t_6);
  10304. __Pyx_XDECREF(__pyx_t_7);
  10305. __Pyx_XDECREF(__pyx_t_8);
  10306. __Pyx_WriteUnraisable("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_dbi", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  10307. __pyx_r = 0;
  10308. __pyx_L0:;
  10309. __Pyx_TraceReturn(Py_None, 0);
  10310. __Pyx_RefNannyFinishContext();
  10311. return __pyx_r;
  10312. }
  10313. /* "lakesuperior/store/base_lmdb_store.pyx":679
  10314. *
  10315. *
  10316. * cdef lmdb.MDB_cursor *_cur_open( # <<<<<<<<<<<<<<
  10317. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL) except *:
  10318. * cdef:
  10319. */
  10320. 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) {
  10321. /* "lakesuperior/store/base_lmdb_store.pyx":680
  10322. *
  10323. * cdef lmdb.MDB_cursor *_cur_open(
  10324. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL) except *: # <<<<<<<<<<<<<<
  10325. * cdef:
  10326. * lmdb.MDB_dbi dbi
  10327. */
  10328. unsigned char *__pyx_v_dblabel = ((unsigned char *)NULL);
  10329. MDB_txn *__pyx_v_txn = ((MDB_txn *)NULL);
  10330. MDB_dbi __pyx_v_dbi;
  10331. MDB_cursor *__pyx_r;
  10332. __Pyx_TraceDeclarations
  10333. __Pyx_RefNannyDeclarations
  10334. int __pyx_t_1;
  10335. MDB_txn *__pyx_t_2;
  10336. MDB_dbi __pyx_t_3;
  10337. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_4;
  10338. PyObject *__pyx_t_5 = NULL;
  10339. PyObject *__pyx_t_6 = NULL;
  10340. PyObject *__pyx_t_7 = NULL;
  10341. Py_ssize_t __pyx_t_8;
  10342. Py_UCS4 __pyx_t_9;
  10343. PyObject *__pyx_t_10 = NULL;
  10344. PyObject *__pyx_t_11 = NULL;
  10345. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_12;
  10346. PyObject *__pyx_t_13 = NULL;
  10347. PyObject *__pyx_t_14 = NULL;
  10348. __Pyx_RefNannySetupContext("_cur_open", 0);
  10349. __Pyx_TraceCall("_cur_open", __pyx_f[0], 679, 0, __PYX_ERR(0, 679, __pyx_L1_error));
  10350. if (__pyx_optional_args) {
  10351. if (__pyx_optional_args->__pyx_n > 0) {
  10352. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  10353. if (__pyx_optional_args->__pyx_n > 1) {
  10354. __pyx_v_txn = __pyx_optional_args->txn;
  10355. }
  10356. }
  10357. }
  10358. /* "lakesuperior/store/base_lmdb_store.pyx":684
  10359. * lmdb.MDB_dbi dbi
  10360. *
  10361. * if txn is NULL: # <<<<<<<<<<<<<<
  10362. * txn = self.txn
  10363. *
  10364. */
  10365. __pyx_t_1 = ((__pyx_v_txn == NULL) != 0);
  10366. if (__pyx_t_1) {
  10367. /* "lakesuperior/store/base_lmdb_store.pyx":685
  10368. *
  10369. * if txn is NULL:
  10370. * txn = self.txn # <<<<<<<<<<<<<<
  10371. *
  10372. * dbi = self.get_dbi(dblabel, txn=txn)
  10373. */
  10374. __pyx_t_2 = __pyx_v_self->txn;
  10375. __pyx_v_txn = __pyx_t_2;
  10376. /* "lakesuperior/store/base_lmdb_store.pyx":684
  10377. * lmdb.MDB_dbi dbi
  10378. *
  10379. * if txn is NULL: # <<<<<<<<<<<<<<
  10380. * txn = self.txn
  10381. *
  10382. */
  10383. }
  10384. /* "lakesuperior/store/base_lmdb_store.pyx":687
  10385. * txn = self.txn
  10386. *
  10387. * dbi = self.get_dbi(dblabel, txn=txn) # <<<<<<<<<<<<<<
  10388. *
  10389. * logger.debug(f'Opening cursor for DB {dblabel} (DBI {dbi})...')
  10390. */
  10391. __pyx_t_4.__pyx_n = 2;
  10392. __pyx_t_4.dblabel = __pyx_v_dblabel;
  10393. __pyx_t_4.txn = __pyx_v_txn;
  10394. __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);
  10395. __pyx_v_dbi = __pyx_t_3;
  10396. /* "lakesuperior/store/base_lmdb_store.pyx":689
  10397. * dbi = self.get_dbi(dblabel, txn=txn)
  10398. *
  10399. * logger.debug(f'Opening cursor for DB {dblabel} (DBI {dbi})...') # <<<<<<<<<<<<<<
  10400. * #try:
  10401. * # # FIXME Either reuse the cursor, if it works, or remove this code.
  10402. */
  10403. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 689, __pyx_L1_error)
  10404. __Pyx_GOTREF(__pyx_t_6);
  10405. __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)
  10406. __Pyx_GOTREF(__pyx_t_7);
  10407. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10408. __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 689, __pyx_L1_error)
  10409. __Pyx_GOTREF(__pyx_t_6);
  10410. __pyx_t_8 = 0;
  10411. __pyx_t_9 = 127;
  10412. __Pyx_INCREF(__pyx_kp_u_Opening_cursor_for_DB);
  10413. __pyx_t_8 += 22;
  10414. __Pyx_GIVEREF(__pyx_kp_u_Opening_cursor_for_DB);
  10415. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_Opening_cursor_for_DB);
  10416. __pyx_t_10 = __Pyx_PyBytes_FromCString(__pyx_v_dblabel); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 689, __pyx_L1_error)
  10417. __Pyx_GOTREF(__pyx_t_10);
  10418. __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_t_10, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L1_error)
  10419. __Pyx_GOTREF(__pyx_t_11);
  10420. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10421. __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;
  10422. __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11);
  10423. __Pyx_GIVEREF(__pyx_t_11);
  10424. PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_11);
  10425. __pyx_t_11 = 0;
  10426. __Pyx_INCREF(__pyx_kp_u_DBI);
  10427. __pyx_t_8 += 6;
  10428. __Pyx_GIVEREF(__pyx_kp_u_DBI);
  10429. PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u_DBI);
  10430. __pyx_t_11 = __Pyx_PyInt_From_MDB_dbi(__pyx_v_dbi); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L1_error)
  10431. __Pyx_GOTREF(__pyx_t_11);
  10432. __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_t_11, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 689, __pyx_L1_error)
  10433. __Pyx_GOTREF(__pyx_t_10);
  10434. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  10435. __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;
  10436. __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10);
  10437. __Pyx_GIVEREF(__pyx_t_10);
  10438. PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_10);
  10439. __pyx_t_10 = 0;
  10440. __Pyx_INCREF(__pyx_kp_u__20);
  10441. __pyx_t_8 += 4;
  10442. __Pyx_GIVEREF(__pyx_kp_u__20);
  10443. PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_kp_u__20);
  10444. __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)
  10445. __Pyx_GOTREF(__pyx_t_10);
  10446. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10447. __pyx_t_6 = NULL;
  10448. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
  10449. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
  10450. if (likely(__pyx_t_6)) {
  10451. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  10452. __Pyx_INCREF(__pyx_t_6);
  10453. __Pyx_INCREF(function);
  10454. __Pyx_DECREF_SET(__pyx_t_7, function);
  10455. }
  10456. }
  10457. if (!__pyx_t_6) {
  10458. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error)
  10459. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10460. __Pyx_GOTREF(__pyx_t_5);
  10461. } else {
  10462. #if CYTHON_FAST_PYCALL
  10463. if (PyFunction_Check(__pyx_t_7)) {
  10464. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  10465. __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)
  10466. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  10467. __Pyx_GOTREF(__pyx_t_5);
  10468. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10469. } else
  10470. #endif
  10471. #if CYTHON_FAST_PYCCALL
  10472. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  10473. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  10474. __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)
  10475. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  10476. __Pyx_GOTREF(__pyx_t_5);
  10477. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10478. } else
  10479. #endif
  10480. {
  10481. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L1_error)
  10482. __Pyx_GOTREF(__pyx_t_11);
  10483. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
  10484. __Pyx_GIVEREF(__pyx_t_10);
  10485. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_10);
  10486. __pyx_t_10 = 0;
  10487. __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)
  10488. __Pyx_GOTREF(__pyx_t_5);
  10489. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  10490. }
  10491. }
  10492. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10493. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10494. /* "lakesuperior/store/base_lmdb_store.pyx":701
  10495. * _check(
  10496. * lmdb.mdb_cursor_open(txn, dbi, self.curs + dbi),
  10497. * f'Error opening cursor: {dblabel}') # <<<<<<<<<<<<<<
  10498. * logger.debug('...opened @ {:x}.'.format(<unsigned long>self.curs[dbi]))
  10499. *
  10500. */
  10501. __pyx_t_5 = __Pyx_PyBytes_FromCString(__pyx_v_dblabel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 701, __pyx_L1_error)
  10502. __Pyx_GOTREF(__pyx_t_5);
  10503. __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 701, __pyx_L1_error)
  10504. __Pyx_GOTREF(__pyx_t_7);
  10505. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10506. __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)
  10507. __Pyx_GOTREF(__pyx_t_5);
  10508. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10509. /* "lakesuperior/store/base_lmdb_store.pyx":699
  10510. * # f'Error opening cursor: {dblabel}')
  10511. * # logger.debug(f'Created brand new cursor for DBI {dbi}.')
  10512. * _check( # <<<<<<<<<<<<<<
  10513. * lmdb.mdb_cursor_open(txn, dbi, self.curs + dbi),
  10514. * f'Error opening cursor: {dblabel}')
  10515. */
  10516. __pyx_t_12.__pyx_n = 1;
  10517. __pyx_t_12.message = ((PyObject*)__pyx_t_5);
  10518. __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)
  10519. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10520. /* "lakesuperior/store/base_lmdb_store.pyx":702
  10521. * lmdb.mdb_cursor_open(txn, dbi, self.curs + dbi),
  10522. * f'Error opening cursor: {dblabel}')
  10523. * logger.debug('...opened @ {:x}.'.format(<unsigned long>self.curs[dbi])) # <<<<<<<<<<<<<<
  10524. *
  10525. * return self.curs[dbi]
  10526. */
  10527. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 702, __pyx_L1_error)
  10528. __Pyx_GOTREF(__pyx_t_7);
  10529. __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)
  10530. __Pyx_GOTREF(__pyx_t_11);
  10531. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10532. __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)
  10533. __Pyx_GOTREF(__pyx_t_10);
  10534. __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)
  10535. __Pyx_GOTREF(__pyx_t_6);
  10536. __pyx_t_13 = NULL;
  10537. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
  10538. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10);
  10539. if (likely(__pyx_t_13)) {
  10540. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  10541. __Pyx_INCREF(__pyx_t_13);
  10542. __Pyx_INCREF(function);
  10543. __Pyx_DECREF_SET(__pyx_t_10, function);
  10544. }
  10545. }
  10546. if (!__pyx_t_13) {
  10547. __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 702, __pyx_L1_error)
  10548. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10549. __Pyx_GOTREF(__pyx_t_7);
  10550. } else {
  10551. #if CYTHON_FAST_PYCALL
  10552. if (PyFunction_Check(__pyx_t_10)) {
  10553. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  10554. __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)
  10555. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  10556. __Pyx_GOTREF(__pyx_t_7);
  10557. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10558. } else
  10559. #endif
  10560. #if CYTHON_FAST_PYCCALL
  10561. if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
  10562. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  10563. __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)
  10564. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  10565. __Pyx_GOTREF(__pyx_t_7);
  10566. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10567. } else
  10568. #endif
  10569. {
  10570. __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 702, __pyx_L1_error)
  10571. __Pyx_GOTREF(__pyx_t_14);
  10572. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
  10573. __Pyx_GIVEREF(__pyx_t_6);
  10574. PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_6);
  10575. __pyx_t_6 = 0;
  10576. __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)
  10577. __Pyx_GOTREF(__pyx_t_7);
  10578. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  10579. }
  10580. }
  10581. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10582. __pyx_t_10 = NULL;
  10583. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
  10584. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
  10585. if (likely(__pyx_t_10)) {
  10586. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
  10587. __Pyx_INCREF(__pyx_t_10);
  10588. __Pyx_INCREF(function);
  10589. __Pyx_DECREF_SET(__pyx_t_11, function);
  10590. }
  10591. }
  10592. if (!__pyx_t_10) {
  10593. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 702, __pyx_L1_error)
  10594. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10595. __Pyx_GOTREF(__pyx_t_5);
  10596. } else {
  10597. #if CYTHON_FAST_PYCALL
  10598. if (PyFunction_Check(__pyx_t_11)) {
  10599. PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_7};
  10600. __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)
  10601. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  10602. __Pyx_GOTREF(__pyx_t_5);
  10603. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10604. } else
  10605. #endif
  10606. #if CYTHON_FAST_PYCCALL
  10607. if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
  10608. PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_7};
  10609. __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)
  10610. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  10611. __Pyx_GOTREF(__pyx_t_5);
  10612. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10613. } else
  10614. #endif
  10615. {
  10616. __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 702, __pyx_L1_error)
  10617. __Pyx_GOTREF(__pyx_t_14);
  10618. __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_10); __pyx_t_10 = NULL;
  10619. __Pyx_GIVEREF(__pyx_t_7);
  10620. PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_7);
  10621. __pyx_t_7 = 0;
  10622. __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)
  10623. __Pyx_GOTREF(__pyx_t_5);
  10624. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  10625. }
  10626. }
  10627. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  10628. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10629. /* "lakesuperior/store/base_lmdb_store.pyx":704
  10630. * logger.debug('...opened @ {:x}.'.format(<unsigned long>self.curs[dbi]))
  10631. *
  10632. * return self.curs[dbi] # <<<<<<<<<<<<<<
  10633. *
  10634. *
  10635. */
  10636. __pyx_r = (__pyx_v_self->curs[__pyx_v_dbi]);
  10637. goto __pyx_L0;
  10638. /* "lakesuperior/store/base_lmdb_store.pyx":679
  10639. *
  10640. *
  10641. * cdef lmdb.MDB_cursor *_cur_open( # <<<<<<<<<<<<<<
  10642. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL) except *:
  10643. * cdef:
  10644. */
  10645. /* function exit code */
  10646. __pyx_L1_error:;
  10647. __Pyx_XDECREF(__pyx_t_5);
  10648. __Pyx_XDECREF(__pyx_t_6);
  10649. __Pyx_XDECREF(__pyx_t_7);
  10650. __Pyx_XDECREF(__pyx_t_10);
  10651. __Pyx_XDECREF(__pyx_t_11);
  10652. __Pyx_XDECREF(__pyx_t_13);
  10653. __Pyx_XDECREF(__pyx_t_14);
  10654. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._cur_open", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10655. __pyx_r = 0;
  10656. __pyx_L0:;
  10657. __Pyx_TraceReturn(Py_None, 0);
  10658. __Pyx_RefNannyFinishContext();
  10659. return __pyx_r;
  10660. }
  10661. /* "lakesuperior/store/base_lmdb_store.pyx":707
  10662. *
  10663. *
  10664. * cdef void _cur_close(self, lmdb.MDB_cursor *cur) except *: # <<<<<<<<<<<<<<
  10665. * """Close a cursor."""
  10666. * #logger.info('Closing cursor @ {:x} for DBI {}...'.format(
  10667. */
  10668. 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) {
  10669. __Pyx_TraceDeclarations
  10670. __Pyx_RefNannyDeclarations
  10671. __Pyx_RefNannySetupContext("_cur_close", 0);
  10672. __Pyx_TraceCall("_cur_close", __pyx_f[0], 707, 0, __PYX_ERR(0, 707, __pyx_L1_error));
  10673. /* "lakesuperior/store/base_lmdb_store.pyx":711
  10674. * #logger.info('Closing cursor @ {:x} for DBI {}...'.format(
  10675. * # <unsigned long>cur, lmdb.mdb_cursor_dbi(cur) ))
  10676. * lmdb.mdb_cursor_close(cur) # <<<<<<<<<<<<<<
  10677. * #logger.info('...closed.')
  10678. *
  10679. */
  10680. mdb_cursor_close(__pyx_v_cur);
  10681. /* "lakesuperior/store/base_lmdb_store.pyx":707
  10682. *
  10683. *
  10684. * cdef void _cur_close(self, lmdb.MDB_cursor *cur) except *: # <<<<<<<<<<<<<<
  10685. * """Close a cursor."""
  10686. * #logger.info('Closing cursor @ {:x} for DBI {}...'.format(
  10687. */
  10688. /* function exit code */
  10689. goto __pyx_L0;
  10690. __pyx_L1_error:;
  10691. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._cur_close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10692. __pyx_L0:;
  10693. __Pyx_TraceReturn(Py_None, 0);
  10694. __Pyx_RefNannyFinishContext();
  10695. }
  10696. /* "lakesuperior/store/base_lmdb_store.pxd":15
  10697. * cdef class BaseLmdbStore:
  10698. * cdef:
  10699. * readonly bint is_txn_open # <<<<<<<<<<<<<<
  10700. * public bint _open
  10701. * unsigned int _readers
  10702. */
  10703. /* Python wrapper */
  10704. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open_1__get__(PyObject *__pyx_v_self); /*proto*/
  10705. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open_1__get__(PyObject *__pyx_v_self) {
  10706. PyObject *__pyx_r = 0;
  10707. __Pyx_RefNannyDeclarations
  10708. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  10709. __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));
  10710. /* function exit code */
  10711. __Pyx_RefNannyFinishContext();
  10712. return __pyx_r;
  10713. }
  10714. 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) {
  10715. PyObject *__pyx_r = NULL;
  10716. __Pyx_TraceDeclarations
  10717. __Pyx_RefNannyDeclarations
  10718. PyObject *__pyx_t_1 = NULL;
  10719. __Pyx_RefNannySetupContext("__get__", 0);
  10720. __Pyx_TraceCall("__get__", __pyx_f[2], 15, 0, __PYX_ERR(2, 15, __pyx_L1_error));
  10721. __Pyx_XDECREF(__pyx_r);
  10722. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_txn_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  10723. __Pyx_GOTREF(__pyx_t_1);
  10724. __pyx_r = __pyx_t_1;
  10725. __pyx_t_1 = 0;
  10726. goto __pyx_L0;
  10727. /* function exit code */
  10728. __pyx_L1_error:;
  10729. __Pyx_XDECREF(__pyx_t_1);
  10730. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.is_txn_open.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10731. __pyx_r = NULL;
  10732. __pyx_L0:;
  10733. __Pyx_XGIVEREF(__pyx_r);
  10734. __Pyx_TraceReturn(__pyx_r, 0);
  10735. __Pyx_RefNannyFinishContext();
  10736. return __pyx_r;
  10737. }
  10738. /* "lakesuperior/store/base_lmdb_store.pxd":16
  10739. * cdef:
  10740. * readonly bint is_txn_open
  10741. * public bint _open # <<<<<<<<<<<<<<
  10742. * unsigned int _readers
  10743. * readonly str env_path
  10744. */
  10745. /* Python wrapper */
  10746. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_1__get__(PyObject *__pyx_v_self); /*proto*/
  10747. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_1__get__(PyObject *__pyx_v_self) {
  10748. PyObject *__pyx_r = 0;
  10749. __Pyx_RefNannyDeclarations
  10750. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  10751. __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));
  10752. /* function exit code */
  10753. __Pyx_RefNannyFinishContext();
  10754. return __pyx_r;
  10755. }
  10756. 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) {
  10757. PyObject *__pyx_r = NULL;
  10758. __Pyx_TraceDeclarations
  10759. __Pyx_RefNannyDeclarations
  10760. PyObject *__pyx_t_1 = NULL;
  10761. __Pyx_RefNannySetupContext("__get__", 0);
  10762. __Pyx_TraceCall("__get__", __pyx_f[2], 16, 0, __PYX_ERR(2, 16, __pyx_L1_error));
  10763. __Pyx_XDECREF(__pyx_r);
  10764. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 16, __pyx_L1_error)
  10765. __Pyx_GOTREF(__pyx_t_1);
  10766. __pyx_r = __pyx_t_1;
  10767. __pyx_t_1 = 0;
  10768. goto __pyx_L0;
  10769. /* function exit code */
  10770. __pyx_L1_error:;
  10771. __Pyx_XDECREF(__pyx_t_1);
  10772. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._open.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10773. __pyx_r = NULL;
  10774. __pyx_L0:;
  10775. __Pyx_XGIVEREF(__pyx_r);
  10776. __Pyx_TraceReturn(__pyx_r, 0);
  10777. __Pyx_RefNannyFinishContext();
  10778. return __pyx_r;
  10779. }
  10780. /* Python wrapper */
  10781. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
  10782. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  10783. int __pyx_r;
  10784. __Pyx_RefNannyDeclarations
  10785. __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  10786. __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));
  10787. /* function exit code */
  10788. __Pyx_RefNannyFinishContext();
  10789. return __pyx_r;
  10790. }
  10791. 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) {
  10792. int __pyx_r;
  10793. __Pyx_TraceDeclarations
  10794. __Pyx_RefNannyDeclarations
  10795. int __pyx_t_1;
  10796. __Pyx_RefNannySetupContext("__set__", 0);
  10797. __Pyx_TraceCall("__set__", __pyx_f[2], 16, 0, __PYX_ERR(2, 16, __pyx_L1_error));
  10798. __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)
  10799. __pyx_v_self->_open = __pyx_t_1;
  10800. /* function exit code */
  10801. __pyx_r = 0;
  10802. goto __pyx_L0;
  10803. __pyx_L1_error:;
  10804. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._open.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10805. __pyx_r = -1;
  10806. __pyx_L0:;
  10807. __Pyx_TraceReturn(Py_None, 0);
  10808. __Pyx_RefNannyFinishContext();
  10809. return __pyx_r;
  10810. }
  10811. /* "lakesuperior/store/base_lmdb_store.pxd":18
  10812. * public bint _open
  10813. * unsigned int _readers
  10814. * readonly str env_path # <<<<<<<<<<<<<<
  10815. * lmdb.MDB_dbi *dbis
  10816. * lmdb.MDB_env *dbenv
  10817. */
  10818. /* Python wrapper */
  10819. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path_1__get__(PyObject *__pyx_v_self); /*proto*/
  10820. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path_1__get__(PyObject *__pyx_v_self) {
  10821. PyObject *__pyx_r = 0;
  10822. __Pyx_RefNannyDeclarations
  10823. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  10824. __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));
  10825. /* function exit code */
  10826. __Pyx_RefNannyFinishContext();
  10827. return __pyx_r;
  10828. }
  10829. 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) {
  10830. PyObject *__pyx_r = NULL;
  10831. __Pyx_TraceDeclarations
  10832. __Pyx_RefNannyDeclarations
  10833. __Pyx_RefNannySetupContext("__get__", 0);
  10834. __Pyx_TraceCall("__get__", __pyx_f[2], 18, 0, __PYX_ERR(2, 18, __pyx_L1_error));
  10835. __Pyx_XDECREF(__pyx_r);
  10836. __Pyx_INCREF(__pyx_v_self->env_path);
  10837. __pyx_r = __pyx_v_self->env_path;
  10838. goto __pyx_L0;
  10839. /* function exit code */
  10840. __pyx_L1_error:;
  10841. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.env_path.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10842. __pyx_r = NULL;
  10843. __pyx_L0:;
  10844. __Pyx_XGIVEREF(__pyx_r);
  10845. __Pyx_TraceReturn(__pyx_r, 0);
  10846. __Pyx_RefNannyFinishContext();
  10847. return __pyx_r;
  10848. }
  10849. /* "(tree fragment)":1
  10850. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  10851. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10852. * def __setstate_cython__(self, __pyx_state):
  10853. */
  10854. /* Python wrapper */
  10855. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_34__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  10856. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_34__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  10857. PyObject *__pyx_r = 0;
  10858. __Pyx_RefNannyDeclarations
  10859. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  10860. __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));
  10861. /* function exit code */
  10862. __Pyx_RefNannyFinishContext();
  10863. return __pyx_r;
  10864. }
  10865. 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) {
  10866. PyObject *__pyx_r = NULL;
  10867. __Pyx_TraceDeclarations
  10868. __Pyx_RefNannyDeclarations
  10869. PyObject *__pyx_t_1 = NULL;
  10870. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  10871. __Pyx_TraceCall("__reduce_cython__", __pyx_f[1], 1, 0, __PYX_ERR(1, 1, __pyx_L1_error));
  10872. /* "(tree fragment)":2
  10873. * def __reduce_cython__(self):
  10874. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  10875. * def __setstate_cython__(self, __pyx_state):
  10876. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10877. */
  10878. __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)
  10879. __Pyx_GOTREF(__pyx_t_1);
  10880. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  10881. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10882. __PYX_ERR(1, 2, __pyx_L1_error)
  10883. /* "(tree fragment)":1
  10884. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  10885. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10886. * def __setstate_cython__(self, __pyx_state):
  10887. */
  10888. /* function exit code */
  10889. __pyx_L1_error:;
  10890. __Pyx_XDECREF(__pyx_t_1);
  10891. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10892. __pyx_r = NULL;
  10893. __Pyx_XGIVEREF(__pyx_r);
  10894. __Pyx_TraceReturn(__pyx_r, 0);
  10895. __Pyx_RefNannyFinishContext();
  10896. return __pyx_r;
  10897. }
  10898. /* "(tree fragment)":3
  10899. * def __reduce_cython__(self):
  10900. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10901. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  10902. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10903. */
  10904. /* Python wrapper */
  10905. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_36__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  10906. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_36__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  10907. PyObject *__pyx_r = 0;
  10908. __Pyx_RefNannyDeclarations
  10909. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  10910. __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));
  10911. /* function exit code */
  10912. __Pyx_RefNannyFinishContext();
  10913. return __pyx_r;
  10914. }
  10915. 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) {
  10916. PyObject *__pyx_r = NULL;
  10917. __Pyx_TraceDeclarations
  10918. __Pyx_RefNannyDeclarations
  10919. PyObject *__pyx_t_1 = NULL;
  10920. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  10921. __Pyx_TraceCall("__setstate_cython__", __pyx_f[1], 3, 0, __PYX_ERR(1, 3, __pyx_L1_error));
  10922. /* "(tree fragment)":4
  10923. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10924. * def __setstate_cython__(self, __pyx_state):
  10925. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  10926. */
  10927. __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)
  10928. __Pyx_GOTREF(__pyx_t_1);
  10929. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  10930. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10931. __PYX_ERR(1, 4, __pyx_L1_error)
  10932. /* "(tree fragment)":3
  10933. * def __reduce_cython__(self):
  10934. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10935. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  10936. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10937. */
  10938. /* function exit code */
  10939. __pyx_L1_error:;
  10940. __Pyx_XDECREF(__pyx_t_1);
  10941. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10942. __pyx_r = NULL;
  10943. __Pyx_XGIVEREF(__pyx_r);
  10944. __Pyx_TraceReturn(__pyx_r, 0);
  10945. __Pyx_RefNannyFinishContext();
  10946. return __pyx_r;
  10947. }
  10948. static struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  10949. static PyObject *__pyx_tp_new_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  10950. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *p;
  10951. PyObject *o;
  10952. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  10953. o = (*t->tp_alloc)(t, 0);
  10954. } else {
  10955. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  10956. }
  10957. if (unlikely(!o)) return 0;
  10958. p = ((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)o);
  10959. p->__pyx_vtab = __pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  10960. p->env_path = ((PyObject*)Py_None); Py_INCREF(Py_None);
  10961. return o;
  10962. }
  10963. static void __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore(PyObject *o) {
  10964. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *p = (struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)o;
  10965. #if CYTHON_USE_TP_FINALIZE
  10966. 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))) {
  10967. if (PyObject_CallFinalizerFromDealloc(o)) return;
  10968. }
  10969. #endif
  10970. {
  10971. PyObject *etype, *eval, *etb;
  10972. PyErr_Fetch(&etype, &eval, &etb);
  10973. ++Py_REFCNT(o);
  10974. __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_3__dealloc__(o);
  10975. --Py_REFCNT(o);
  10976. PyErr_Restore(etype, eval, etb);
  10977. }
  10978. Py_CLEAR(p->env_path);
  10979. (*Py_TYPE(o)->tp_free)(o);
  10980. }
  10981. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_open(PyObject *o, CYTHON_UNUSED void *x) {
  10982. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open_1__get__(o);
  10983. }
  10984. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_readers(PyObject *o, CYTHON_UNUSED void *x) {
  10985. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers_1__get__(o);
  10986. }
  10987. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_txn_open(PyObject *o, CYTHON_UNUSED void *x) {
  10988. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open_1__get__(o);
  10989. }
  10990. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open(PyObject *o, CYTHON_UNUSED void *x) {
  10991. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_1__get__(o);
  10992. }
  10993. static int __pyx_setprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  10994. if (v) {
  10995. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_3__set__(o, v);
  10996. }
  10997. else {
  10998. PyErr_SetString(PyExc_NotImplementedError, "__del__");
  10999. return -1;
  11000. }
  11001. }
  11002. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_env_path(PyObject *o, CYTHON_UNUSED void *x) {
  11003. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path_1__get__(o);
  11004. }
  11005. static PyMethodDef __pyx_methods_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore[] = {
  11006. {"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},
  11007. {"close_env", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env, METH_VARARGS|METH_KEYWORDS, 0},
  11008. {"destroy", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8destroy},
  11009. {"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},
  11010. {"begin", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_14begin, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_13begin},
  11011. {"commit", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_16commit, METH_NOARGS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit},
  11012. {"abort", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_18abort, METH_NOARGS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort},
  11013. {"rollback", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_20rollback, METH_NOARGS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback},
  11014. {"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},
  11015. {"put", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_24put, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_23put},
  11016. {"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},
  11017. {"delete", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_28delete, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_27delete},
  11018. {"stats", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats, METH_NOARGS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats},
  11019. {"txn_id", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id, METH_NOARGS, 0},
  11020. {"__reduce_cython__", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_34__reduce_cython__, METH_NOARGS, 0},
  11021. {"__setstate_cython__", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_36__setstate_cython__, METH_O, 0},
  11022. {0, 0, 0, 0}
  11023. };
  11024. static struct PyGetSetDef __pyx_getsets_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore[] = {
  11025. {(char *)"is_open", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_open, 0, (char *)0, 0},
  11026. {(char *)"readers", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_readers, 0, (char *)0, 0},
  11027. {(char *)"is_txn_open", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_txn_open, 0, (char *)0, 0},
  11028. {(char *)"_open", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open, __pyx_setprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open, (char *)0, 0},
  11029. {(char *)"env_path", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_env_path, 0, (char *)0, 0},
  11030. {0, 0, 0, 0, 0}
  11031. };
  11032. static PyTypeObject __pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = {
  11033. PyVarObject_HEAD_INIT(0, 0)
  11034. "lakesuperior.store.base_lmdb_store.BaseLmdbStore", /*tp_name*/
  11035. sizeof(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore), /*tp_basicsize*/
  11036. 0, /*tp_itemsize*/
  11037. __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_dealloc*/
  11038. 0, /*tp_print*/
  11039. 0, /*tp_getattr*/
  11040. 0, /*tp_setattr*/
  11041. #if PY_MAJOR_VERSION < 3
  11042. 0, /*tp_compare*/
  11043. #endif
  11044. #if PY_MAJOR_VERSION >= 3
  11045. 0, /*tp_as_async*/
  11046. #endif
  11047. 0, /*tp_repr*/
  11048. 0, /*tp_as_number*/
  11049. 0, /*tp_as_sequence*/
  11050. 0, /*tp_as_mapping*/
  11051. 0, /*tp_hash*/
  11052. 0, /*tp_call*/
  11053. 0, /*tp_str*/
  11054. 0, /*tp_getattro*/
  11055. 0, /*tp_setattro*/
  11056. 0, /*tp_as_buffer*/
  11057. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  11058. "\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*/
  11059. 0, /*tp_traverse*/
  11060. 0, /*tp_clear*/
  11061. 0, /*tp_richcompare*/
  11062. 0, /*tp_weaklistoffset*/
  11063. 0, /*tp_iter*/
  11064. 0, /*tp_iternext*/
  11065. __pyx_methods_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_methods*/
  11066. 0, /*tp_members*/
  11067. __pyx_getsets_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_getset*/
  11068. 0, /*tp_base*/
  11069. 0, /*tp_dict*/
  11070. 0, /*tp_descr_get*/
  11071. 0, /*tp_descr_set*/
  11072. 0, /*tp_dictoffset*/
  11073. __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_1__init__, /*tp_init*/
  11074. 0, /*tp_alloc*/
  11075. __pyx_tp_new_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_new*/
  11076. 0, /*tp_free*/
  11077. 0, /*tp_is_gc*/
  11078. 0, /*tp_bases*/
  11079. 0, /*tp_mro*/
  11080. 0, /*tp_cache*/
  11081. 0, /*tp_subclasses*/
  11082. 0, /*tp_weaklist*/
  11083. 0, /*tp_del*/
  11084. 0, /*tp_version_tag*/
  11085. #if PY_VERSION_HEX >= 0x030400a1
  11086. 0, /*tp_finalize*/
  11087. #endif
  11088. };
  11089. 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];
  11090. static int __pyx_freecount_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = 0;
  11091. 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) {
  11092. PyObject *o;
  11093. 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)))) {
  11094. 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];
  11095. memset(o, 0, sizeof(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx));
  11096. (void) PyObject_INIT(o, t);
  11097. PyObject_GC_Track(o);
  11098. } else {
  11099. o = (*t->tp_alloc)(t, 0);
  11100. if (unlikely(!o)) return 0;
  11101. }
  11102. return o;
  11103. }
  11104. static void __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx(PyObject *o) {
  11105. 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;
  11106. PyObject_GC_UnTrack(o);
  11107. Py_CLEAR(p->__pyx_v_self);
  11108. Py_CLEAR(p->__pyx_v_write);
  11109. Py_CLEAR(p->__pyx_t_0);
  11110. Py_CLEAR(p->__pyx_t_1);
  11111. Py_CLEAR(p->__pyx_t_2);
  11112. 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)))) {
  11113. __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);
  11114. } else {
  11115. (*Py_TYPE(o)->tp_free)(o);
  11116. }
  11117. }
  11118. static int __pyx_tp_traverse_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx(PyObject *o, visitproc v, void *a) {
  11119. int e;
  11120. 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;
  11121. if (p->__pyx_v_self) {
  11122. e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  11123. }
  11124. if (p->__pyx_v_write) {
  11125. e = (*v)(p->__pyx_v_write, a); if (e) return e;
  11126. }
  11127. if (p->__pyx_t_0) {
  11128. e = (*v)(p->__pyx_t_0, a); if (e) return e;
  11129. }
  11130. if (p->__pyx_t_1) {
  11131. e = (*v)(p->__pyx_t_1, a); if (e) return e;
  11132. }
  11133. if (p->__pyx_t_2) {
  11134. e = (*v)(p->__pyx_t_2, a); if (e) return e;
  11135. }
  11136. return 0;
  11137. }
  11138. static PyTypeObject __pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = {
  11139. PyVarObject_HEAD_INIT(0, 0)
  11140. "lakesuperior.store.base_lmdb_store.__pyx_scope_struct__txn_ctx", /*tp_name*/
  11141. sizeof(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx), /*tp_basicsize*/
  11142. 0, /*tp_itemsize*/
  11143. __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx, /*tp_dealloc*/
  11144. 0, /*tp_print*/
  11145. 0, /*tp_getattr*/
  11146. 0, /*tp_setattr*/
  11147. #if PY_MAJOR_VERSION < 3
  11148. 0, /*tp_compare*/
  11149. #endif
  11150. #if PY_MAJOR_VERSION >= 3
  11151. 0, /*tp_as_async*/
  11152. #endif
  11153. 0, /*tp_repr*/
  11154. 0, /*tp_as_number*/
  11155. 0, /*tp_as_sequence*/
  11156. 0, /*tp_as_mapping*/
  11157. 0, /*tp_hash*/
  11158. 0, /*tp_call*/
  11159. 0, /*tp_str*/
  11160. 0, /*tp_getattro*/
  11161. 0, /*tp_setattro*/
  11162. 0, /*tp_as_buffer*/
  11163. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  11164. 0, /*tp_doc*/
  11165. __pyx_tp_traverse_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx, /*tp_traverse*/
  11166. 0, /*tp_clear*/
  11167. 0, /*tp_richcompare*/
  11168. 0, /*tp_weaklistoffset*/
  11169. 0, /*tp_iter*/
  11170. 0, /*tp_iternext*/
  11171. 0, /*tp_methods*/
  11172. 0, /*tp_members*/
  11173. 0, /*tp_getset*/
  11174. 0, /*tp_base*/
  11175. 0, /*tp_dict*/
  11176. 0, /*tp_descr_get*/
  11177. 0, /*tp_descr_set*/
  11178. 0, /*tp_dictoffset*/
  11179. 0, /*tp_init*/
  11180. 0, /*tp_alloc*/
  11181. __pyx_tp_new_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx, /*tp_new*/
  11182. 0, /*tp_free*/
  11183. 0, /*tp_is_gc*/
  11184. 0, /*tp_bases*/
  11185. 0, /*tp_mro*/
  11186. 0, /*tp_cache*/
  11187. 0, /*tp_subclasses*/
  11188. 0, /*tp_weaklist*/
  11189. 0, /*tp_del*/
  11190. 0, /*tp_version_tag*/
  11191. #if PY_VERSION_HEX >= 0x030400a1
  11192. 0, /*tp_finalize*/
  11193. #endif
  11194. };
  11195. static PyMethodDef __pyx_methods[] = {
  11196. {0, 0, 0, 0}
  11197. };
  11198. #if PY_MAJOR_VERSION >= 3
  11199. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11200. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  11201. static int __pyx_pymod_exec_base_lmdb_store(PyObject* module); /*proto*/
  11202. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  11203. {Py_mod_create, (void*)__pyx_pymod_create},
  11204. {Py_mod_exec, (void*)__pyx_pymod_exec_base_lmdb_store},
  11205. {0, NULL}
  11206. };
  11207. #endif
  11208. static struct PyModuleDef __pyx_moduledef = {
  11209. PyModuleDef_HEAD_INIT,
  11210. "base_lmdb_store",
  11211. 0, /* m_doc */
  11212. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11213. 0, /* m_size */
  11214. #else
  11215. -1, /* m_size */
  11216. #endif
  11217. __pyx_methods /* m_methods */,
  11218. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11219. __pyx_moduledef_slots, /* m_slots */
  11220. #else
  11221. NULL, /* m_reload */
  11222. #endif
  11223. NULL, /* m_traverse */
  11224. NULL, /* m_clear */
  11225. NULL /* m_free */
  11226. };
  11227. #endif
  11228. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  11229. {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
  11230. {&__pyx_n_s_BaseLmdbStore_txn_ctx, __pyx_k_BaseLmdbStore_txn_ctx, sizeof(__pyx_k_BaseLmdbStore_txn_ctx), 0, 0, 1, 1},
  11231. {&__pyx_kp_u_Cleaning_up_store_env, __pyx_k_Cleaning_up_store_env, sizeof(__pyx_k_Cleaning_up_store_env), 0, 1, 0, 0},
  11232. {&__pyx_kp_u_Cleared_stale_readers, __pyx_k_Cleared_stale_readers, sizeof(__pyx_k_Cleared_stale_readers), 0, 1, 0, 0},
  11233. {&__pyx_kp_u_Closing_store_env, __pyx_k_Closing_store_env, sizeof(__pyx_k_Closing_store_env), 0, 1, 0, 0},
  11234. {&__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},
  11235. {&__pyx_kp_u_Created_DB, __pyx_k_Created_DB, sizeof(__pyx_k_Created_DB), 0, 1, 0, 0},
  11236. {&__pyx_kp_u_Created_DBenv_x, __pyx_k_Created_DBenv_x, sizeof(__pyx_k_Created_DBenv_x), 0, 1, 0, 0},
  11237. {&__pyx_kp_u_Creating_DBs, __pyx_k_Creating_DBs, sizeof(__pyx_k_Creating_DBs), 0, 1, 0, 0},
  11238. {&__pyx_kp_u_DBI, __pyx_k_DBI, sizeof(__pyx_k_DBI), 0, 1, 0, 0},
  11239. {&__pyx_kp_u_DBenv_address_x, __pyx_k_DBenv_address_x, sizeof(__pyx_k_DBenv_address_x), 0, 1, 0, 0},
  11240. {&__pyx_kp_u_Environment_already_open, __pyx_k_Environment_already_open, sizeof(__pyx_k_Environment_already_open), 0, 1, 0, 0},
  11241. {&__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},
  11242. {&__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},
  11243. {&__pyx_kp_u_Error_getting_datbase_stats, __pyx_k_Error_getting_datbase_stats, sizeof(__pyx_k_Error_getting_datbase_stats), 0, 1, 0, 0},
  11244. {&__pyx_kp_u_Error_opening_cursor, __pyx_k_Error_opening_cursor, sizeof(__pyx_k_Error_opening_cursor), 0, 1, 0, 0},
  11245. {&__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},
  11246. {&__pyx_kp_u_Error_opening_transaction, __pyx_k_Error_opening_transaction, sizeof(__pyx_k_Error_opening_transaction), 0, 1, 0, 0},
  11247. {&__pyx_kp_u_Error_putting_data, __pyx_k_Error_putting_data, sizeof(__pyx_k_Error_putting_data), 0, 1, 0, 0},
  11248. {&__pyx_kp_u_Error_setting_map_size, __pyx_k_Error_setting_map_size, sizeof(__pyx_k_Error_setting_map_size), 0, 1, 0, 0},
  11249. {&__pyx_kp_u_Error_setting_max_databases, __pyx_k_Error_setting_max_databases, sizeof(__pyx_k_Error_setting_max_databases), 0, 1, 0, 0},
  11250. {&__pyx_kp_u_Error_setting_max_readers, __pyx_k_Error_setting_max_readers, sizeof(__pyx_k_Error_setting_max_readers), 0, 1, 0, 0},
  11251. {&__pyx_n_s_FileNotFoundError, __pyx_k_FileNotFoundError, sizeof(__pyx_k_FileNotFoundError), 0, 0, 1, 1},
  11252. {&__pyx_kp_u_Getting_DBI_without_label, __pyx_k_Getting_DBI_without_label, sizeof(__pyx_k_Getting_DBI_without_label), 0, 1, 0, 0},
  11253. {&__pyx_kp_u_Internal_error, __pyx_k_Internal_error, sizeof(__pyx_k_Internal_error), 0, 1, 0, 0},
  11254. {&__pyx_n_s_KeyExistsError, __pyx_k_KeyExistsError, sizeof(__pyx_k_KeyExistsError), 0, 0, 1, 1},
  11255. {&__pyx_n_s_KeyNotFoundError, __pyx_k_KeyNotFoundError, sizeof(__pyx_k_KeyNotFoundError), 0, 0, 1, 1},
  11256. {&__pyx_kp_u_LMDB_Error, __pyx_k_LMDB_Error, sizeof(__pyx_k_LMDB_Error), 0, 1, 0, 0},
  11257. {&__pyx_n_s_LmdbError, __pyx_k_LmdbError, sizeof(__pyx_k_LmdbError), 0, 0, 1, 1},
  11258. {&__pyx_kp_u_Max_readers, __pyx_k_Max_readers, sizeof(__pyx_k_Max_readers), 0, 1, 0, 0},
  11259. {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  11260. {&__pyx_kp_u_None, __pyx_k_None, sizeof(__pyx_k_None), 0, 1, 0, 0},
  11261. {&__pyx_kp_u_Opened_transaction_x, __pyx_k_Opened_transaction_x, sizeof(__pyx_k_Opened_transaction_x), 0, 1, 0, 0},
  11262. {&__pyx_kp_u_Opening_cursor_for_DB, __pyx_k_Opening_cursor_for_DB, sizeof(__pyx_k_Opening_cursor_for_DB), 0, 1, 0, 0},
  11263. {&__pyx_kp_u_Opening_environment_at, __pyx_k_Opening_environment_at, sizeof(__pyx_k_Opening_environment_at), 0, 1, 0, 0},
  11264. {&__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},
  11265. {&__pyx_n_u_RO, __pyx_k_RO, sizeof(__pyx_k_RO), 0, 1, 0, 1},
  11266. {&__pyx_n_u_RW, __pyx_k_RW, sizeof(__pyx_k_RW), 0, 1, 0, 1},
  11267. {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  11268. {&__pyx_kp_u_Store_is_not_open, __pyx_k_Store_is_not_open, sizeof(__pyx_k_Store_is_not_open), 0, 1, 0, 0},
  11269. {&__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},
  11270. {&__pyx_kp_u_Transaction_aborted, __pyx_k_Transaction_aborted, sizeof(__pyx_k_Transaction_aborted), 0, 1, 0, 0},
  11271. {&__pyx_kp_u_Transaction_committed, __pyx_k_Transaction_committed, sizeof(__pyx_k_Transaction_committed), 0, 1, 0, 0},
  11272. {&__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},
  11273. {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  11274. {&__pyx_kp_u__20, __pyx_k__20, sizeof(__pyx_k__20), 0, 1, 0, 0},
  11275. {&__pyx_kp_u__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 1, 0, 0},
  11276. {&__pyx_kp_u__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 1, 0, 0},
  11277. {&__pyx_n_s_abort, __pyx_k_abort, sizeof(__pyx_k_abort), 0, 0, 1, 1},
  11278. {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  11279. {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  11280. {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  11281. {&__pyx_n_s_close_env, __pyx_k_close_env, sizeof(__pyx_k_close_env), 0, 0, 1, 1},
  11282. {&__pyx_n_s_commit_pending_transaction, __pyx_k_commit_pending_transaction, sizeof(__pyx_k_commit_pending_transaction), 0, 0, 1, 1},
  11283. {&__pyx_n_s_contextlib, __pyx_k_contextlib, sizeof(__pyx_k_contextlib), 0, 0, 1, 1},
  11284. {&__pyx_n_s_contextmanager, __pyx_k_contextmanager, sizeof(__pyx_k_contextmanager), 0, 0, 1, 1},
  11285. {&__pyx_n_s_create, __pyx_k_create, sizeof(__pyx_k_create), 0, 0, 1, 1},
  11286. {&__pyx_n_s_currentThread, __pyx_k_currentThread, sizeof(__pyx_k_currentThread), 0, 0, 1, 1},
  11287. {&__pyx_n_s_current_process, __pyx_k_current_process, sizeof(__pyx_k_current_process), 0, 0, 1, 1},
  11288. {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  11289. {&__pyx_n_s_data_v, __pyx_k_data_v, sizeof(__pyx_k_data_v), 0, 0, 1, 1},
  11290. {&__pyx_n_u_db_stats, __pyx_k_db_stats, sizeof(__pyx_k_db_stats), 0, 1, 0, 1},
  11291. {&__pyx_n_s_dbi, __pyx_k_dbi, sizeof(__pyx_k_dbi), 0, 0, 1, 1},
  11292. {&__pyx_n_s_dbi_flags, __pyx_k_dbi_flags, sizeof(__pyx_k_dbi_flags), 0, 0, 1, 1},
  11293. {&__pyx_n_s_dbi_labels, __pyx_k_dbi_labels, sizeof(__pyx_k_dbi_labels), 0, 0, 1, 1},
  11294. {&__pyx_n_s_dblabel, __pyx_k_dblabel, sizeof(__pyx_k_dblabel), 0, 0, 1, 1},
  11295. {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  11296. {&__pyx_n_s_destroy, __pyx_k_destroy, sizeof(__pyx_k_destroy), 0, 0, 1, 1},
  11297. {&__pyx_n_s_dirname, __pyx_k_dirname, sizeof(__pyx_k_dirname), 0, 0, 1, 1},
  11298. {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  11299. {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  11300. {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
  11301. {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  11302. {&__pyx_n_s_env, __pyx_k_env, sizeof(__pyx_k_env), 0, 0, 1, 1},
  11303. {&__pyx_n_s_env_flags, __pyx_k_env_flags, sizeof(__pyx_k_env_flags), 0, 0, 1, 1},
  11304. {&__pyx_n_s_env_path, __pyx_k_env_path, sizeof(__pyx_k_env_path), 0, 0, 1, 1},
  11305. {&__pyx_n_s_env_perms, __pyx_k_env_perms, sizeof(__pyx_k_env_perms), 0, 0, 1, 1},
  11306. {&__pyx_n_u_env_size, __pyx_k_env_size, sizeof(__pyx_k_env_size), 0, 1, 0, 1},
  11307. {&__pyx_n_u_env_stats, __pyx_k_env_stats, sizeof(__pyx_k_env_stats), 0, 1, 0, 1},
  11308. {&__pyx_n_s_exist_ok, __pyx_k_exist_ok, sizeof(__pyx_k_exist_ok), 0, 0, 1, 1},
  11309. {&__pyx_n_s_exists, __pyx_k_exists, sizeof(__pyx_k_exists), 0, 0, 1, 1},
  11310. {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  11311. {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
  11312. {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  11313. {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  11314. {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1},
  11315. {&__pyx_n_s_getName, __pyx_k_getName, sizeof(__pyx_k_getName), 0, 0, 1, 1},
  11316. {&__pyx_n_s_get_data, __pyx_k_get_data, sizeof(__pyx_k_get_data), 0, 0, 1, 1},
  11317. {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  11318. {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  11319. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  11320. {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  11321. {&__pyx_n_s_info, __pyx_k_info, sizeof(__pyx_k_info), 0, 0, 1, 1},
  11322. {&__pyx_n_s_is_open, __pyx_k_is_open, sizeof(__pyx_k_is_open), 0, 0, 1, 1},
  11323. {&__pyx_n_s_is_txn_rw, __pyx_k_is_txn_rw, sizeof(__pyx_k_is_txn_rw), 0, 0, 1, 1},
  11324. {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  11325. {&__pyx_n_s_key_v, __pyx_k_key_v, sizeof(__pyx_k_key_v), 0, 0, 1, 1},
  11326. {&__pyx_n_s_lakesuperior, __pyx_k_lakesuperior, sizeof(__pyx_k_lakesuperior), 0, 0, 1, 1},
  11327. {&__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},
  11328. {&__pyx_kp_u_lock, __pyx_k_lock, sizeof(__pyx_k_lock), 0, 1, 0, 0},
  11329. {&__pyx_n_s_logger, __pyx_k_logger, sizeof(__pyx_k_logger), 0, 0, 1, 1},
  11330. {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
  11331. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  11332. {&__pyx_n_s_makedirs, __pyx_k_makedirs, sizeof(__pyx_k_makedirs), 0, 0, 1, 1},
  11333. {&__pyx_n_u_map_size, __pyx_k_map_size, sizeof(__pyx_k_map_size), 0, 1, 0, 1},
  11334. {&__pyx_n_u_max_dbs, __pyx_k_max_dbs, sizeof(__pyx_k_max_dbs), 0, 1, 0, 1},
  11335. {&__pyx_n_u_max_spare_txns, __pyx_k_max_spare_txns, sizeof(__pyx_k_max_spare_txns), 0, 1, 0, 1},
  11336. {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  11337. {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  11338. {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  11339. {&__pyx_n_s_ms_branch_pages, __pyx_k_ms_branch_pages, sizeof(__pyx_k_ms_branch_pages), 0, 0, 1, 1},
  11340. {&__pyx_n_s_ms_depth, __pyx_k_ms_depth, sizeof(__pyx_k_ms_depth), 0, 0, 1, 1},
  11341. {&__pyx_n_s_ms_entries, __pyx_k_ms_entries, sizeof(__pyx_k_ms_entries), 0, 0, 1, 1},
  11342. {&__pyx_n_s_ms_leaf_pages, __pyx_k_ms_leaf_pages, sizeof(__pyx_k_ms_leaf_pages), 0, 0, 1, 1},
  11343. {&__pyx_n_s_ms_overflow_pages, __pyx_k_ms_overflow_pages, sizeof(__pyx_k_ms_overflow_pages), 0, 0, 1, 1},
  11344. {&__pyx_n_s_ms_psize, __pyx_k_ms_psize, sizeof(__pyx_k_ms_psize), 0, 0, 1, 1},
  11345. {&__pyx_n_s_multiprocessing, __pyx_k_multiprocessing, sizeof(__pyx_k_multiprocessing), 0, 0, 1, 1},
  11346. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  11347. {&__pyx_n_s_new_txn, __pyx_k_new_txn, sizeof(__pyx_k_new_txn), 0, 0, 1, 1},
  11348. {&__pyx_n_s_open_env, __pyx_k_open_env, sizeof(__pyx_k_open_env), 0, 0, 1, 1},
  11349. {&__pyx_kp_u_opened_x, __pyx_k_opened_x, sizeof(__pyx_k_opened_x), 0, 1, 0, 0},
  11350. {&__pyx_n_s_options, __pyx_k_options, sizeof(__pyx_k_options), 0, 0, 1, 1},
  11351. {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
  11352. {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
  11353. {&__pyx_n_s_path_2, __pyx_k_path_2, sizeof(__pyx_k_path_2), 0, 0, 1, 1},
  11354. {&__pyx_n_s_pid, __pyx_k_pid, sizeof(__pyx_k_pid), 0, 0, 1, 1},
  11355. {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  11356. {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
  11357. {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  11358. {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  11359. {&__pyx_n_s_rc, __pyx_k_rc, sizeof(__pyx_k_rc), 0, 0, 1, 1},
  11360. {&__pyx_n_s_readers_mult, __pyx_k_readers_mult, sizeof(__pyx_k_readers_mult), 0, 0, 1, 1},
  11361. {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  11362. {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  11363. {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  11364. {&__pyx_n_s_rmtree, __pyx_k_rmtree, sizeof(__pyx_k_rmtree), 0, 0, 1, 1},
  11365. {&__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},
  11366. {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  11367. {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  11368. {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  11369. {&__pyx_n_s_shutil, __pyx_k_shutil, sizeof(__pyx_k_shutil), 0, 0, 1, 1},
  11370. {&__pyx_n_s_st_size, __pyx_k_st_size, sizeof(__pyx_k_st_size), 0, 0, 1, 1},
  11371. {&__pyx_n_s_stat, __pyx_k_stat, sizeof(__pyx_k_stat), 0, 0, 1, 1},
  11372. {&__pyx_n_s_stats, __pyx_k_stats, sizeof(__pyx_k_stats), 0, 0, 1, 1},
  11373. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  11374. {&__pyx_n_s_threading, __pyx_k_threading, sizeof(__pyx_k_threading), 0, 0, 1, 1},
  11375. {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  11376. {&__pyx_n_s_txn_ctx, __pyx_k_txn_ctx, sizeof(__pyx_k_txn_ctx), 0, 0, 1, 1},
  11377. {&__pyx_n_s_txn_id, __pyx_k_txn_id, sizeof(__pyx_k_txn_id), 0, 0, 1, 1},
  11378. {&__pyx_kp_u_txn_is_open, __pyx_k_txn_is_open, sizeof(__pyx_k_txn_is_open), 0, 1, 0, 0},
  11379. {&__pyx_n_s_unlink, __pyx_k_unlink, sizeof(__pyx_k_unlink), 0, 0, 1, 1},
  11380. {&__pyx_n_s_warning, __pyx_k_warning, sizeof(__pyx_k_warning), 0, 0, 1, 1},
  11381. {&__pyx_n_s_workers, __pyx_k_workers, sizeof(__pyx_k_workers), 0, 0, 1, 1},
  11382. {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
  11383. {&__pyx_n_s_wsgi, __pyx_k_wsgi, sizeof(__pyx_k_wsgi), 0, 0, 1, 1},
  11384. {&__pyx_kp_u_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 1, 0, 0},
  11385. {0, 0, 0, 0, 0, 0, 0}
  11386. };
  11387. static int __Pyx_InitCachedBuiltins(void) {
  11388. __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 252, __pyx_L1_error)
  11389. __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 267, __pyx_L1_error)
  11390. __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 375, __pyx_L1_error)
  11391. __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
  11392. return 0;
  11393. __pyx_L1_error:;
  11394. return -1;
  11395. }
  11396. static int __Pyx_InitCachedConstants(void) {
  11397. __Pyx_RefNannyDeclarations
  11398. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  11399. /* "lakesuperior/store/base_lmdb_store.pyx":166
  11400. * """
  11401. * if self.is_open:
  11402. * logger.warning('Environment already open.') # <<<<<<<<<<<<<<
  11403. * return
  11404. *
  11405. */
  11406. __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Environment_already_open); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 166, __pyx_L1_error)
  11407. __Pyx_GOTREF(__pyx_tuple__2);
  11408. __Pyx_GIVEREF(__pyx_tuple__2);
  11409. /* "lakesuperior/store/base_lmdb_store.pyx":195
  11410. * # Set map size.
  11411. * _check(
  11412. * lmdb.mdb_env_set_mapsize(self.dbenv, self.options.get( # <<<<<<<<<<<<<<
  11413. * 'map_size', 1024 ** 3)),
  11414. * 'Error setting map size: {}')
  11415. */
  11416. __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)
  11417. __Pyx_GOTREF(__pyx_tuple__3);
  11418. __Pyx_GIVEREF(__pyx_tuple__3);
  11419. /* "lakesuperior/store/base_lmdb_store.pyx":264
  11420. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  11421. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  11422. * logger.info(f'Creating DBs.') # <<<<<<<<<<<<<<
  11423. * try:
  11424. * if len(self.dbi_labels):
  11425. */
  11426. __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Creating_DBs); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 264, __pyx_L1_error)
  11427. __Pyx_GOTREF(__pyx_tuple__5);
  11428. __Pyx_GIVEREF(__pyx_tuple__5);
  11429. /* "lakesuperior/store/base_lmdb_store.pyx":289
  11430. *
  11431. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  11432. * logger.debug('Cleaning up store env.') # <<<<<<<<<<<<<<
  11433. * if self.is_open:
  11434. * logger.debug('Closing store env.')
  11435. */
  11436. __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)
  11437. __Pyx_GOTREF(__pyx_tuple__7);
  11438. __Pyx_GIVEREF(__pyx_tuple__7);
  11439. /* "lakesuperior/store/base_lmdb_store.pyx":291
  11440. * logger.debug('Cleaning up store env.')
  11441. * if self.is_open:
  11442. * logger.debug('Closing store env.') # <<<<<<<<<<<<<<
  11443. * if self.is_txn_open is True:
  11444. * if commit_pending_transaction:
  11445. */
  11446. __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Closing_store_env); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 291, __pyx_L1_error)
  11447. __Pyx_GOTREF(__pyx_tuple__8);
  11448. __Pyx_GIVEREF(__pyx_tuple__8);
  11449. /* "lakesuperior/store/base_lmdb_store.pyx":343
  11450. * """
  11451. * if not self.is_open:
  11452. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  11453. *
  11454. * if self.is_txn_open:
  11455. */
  11456. __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)
  11457. __Pyx_GOTREF(__pyx_tuple__9);
  11458. __Pyx_GIVEREF(__pyx_tuple__9);
  11459. /* "lakesuperior/store/base_lmdb_store.pyx":346
  11460. *
  11461. * if self.is_txn_open:
  11462. * logger.debug( # <<<<<<<<<<<<<<
  11463. * 'Transaction is already active. Not opening another one.')
  11464. * #logger.debug('before yield')
  11465. */
  11466. __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)
  11467. __Pyx_GOTREF(__pyx_tuple__10);
  11468. __Pyx_GIVEREF(__pyx_tuple__10);
  11469. /* "lakesuperior/store/base_lmdb_store.pyx":375
  11470. * """
  11471. * if not self.is_open:
  11472. * raise RuntimeError('Store must be opened first.') # <<<<<<<<<<<<<<
  11473. * #logger.debug('Beginning a {} transaction.'.format(
  11474. * # 'read/write' if write else 'read-only'))
  11475. */
  11476. __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)
  11477. __Pyx_GOTREF(__pyx_tuple__11);
  11478. __Pyx_GIVEREF(__pyx_tuple__11);
  11479. /* "lakesuperior/store/base_lmdb_store.pyx":407
  11480. * """
  11481. * if new_txn is True:
  11482. * with self.txn_ctx(): # <<<<<<<<<<<<<<
  11483. * return self._key_exists(
  11484. * key, len(key), dblabel=dblabel.encode())
  11485. */
  11486. __pyx_tuple__12 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 407, __pyx_L1_error)
  11487. __Pyx_GOTREF(__pyx_tuple__12);
  11488. __Pyx_GIVEREF(__pyx_tuple__12);
  11489. __pyx_tuple__13 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 407, __pyx_L1_error)
  11490. __Pyx_GOTREF(__pyx_tuple__13);
  11491. __Pyx_GIVEREF(__pyx_tuple__13);
  11492. /* "lakesuperior/store/base_lmdb_store.pyx":608
  11493. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  11494. * if not self.is_open:
  11495. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  11496. *
  11497. * cdef:
  11498. */
  11499. __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)
  11500. __Pyx_GOTREF(__pyx_tuple__18);
  11501. __Pyx_GIVEREF(__pyx_tuple__18);
  11502. /* "lakesuperior/store/base_lmdb_store.pyx":668
  11503. *
  11504. * if dblabel is NULL:
  11505. * logger.debug('Getting DBI without label.') # <<<<<<<<<<<<<<
  11506. * dbidx = (
  11507. * 0 if dblabel is NULL
  11508. */
  11509. __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)
  11510. __Pyx_GOTREF(__pyx_tuple__19);
  11511. __Pyx_GIVEREF(__pyx_tuple__19);
  11512. /* "(tree fragment)":2
  11513. * def __reduce_cython__(self):
  11514. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  11515. * def __setstate_cython__(self, __pyx_state):
  11516. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  11517. */
  11518. __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)
  11519. __Pyx_GOTREF(__pyx_tuple__21);
  11520. __Pyx_GIVEREF(__pyx_tuple__21);
  11521. /* "(tree fragment)":4
  11522. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  11523. * def __setstate_cython__(self, __pyx_state):
  11524. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  11525. */
  11526. __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)
  11527. __Pyx_GOTREF(__pyx_tuple__22);
  11528. __Pyx_GIVEREF(__pyx_tuple__22);
  11529. __Pyx_RefNannyFinishContext();
  11530. return 0;
  11531. __pyx_L1_error:;
  11532. __Pyx_RefNannyFinishContext();
  11533. return -1;
  11534. }
  11535. static int __Pyx_InitGlobals(void) {
  11536. /* InitThreads.init */
  11537. #ifdef WITH_THREAD
  11538. PyEval_InitThreads();
  11539. #endif
  11540. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  11541. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  11542. __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  11543. __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  11544. __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  11545. __pyx_int_416 = PyInt_FromLong(416); if (unlikely(!__pyx_int_416)) __PYX_ERR(0, 1, __pyx_L1_error)
  11546. __pyx_int_488 = PyInt_FromLong(488); if (unlikely(!__pyx_int_488)) __PYX_ERR(0, 1, __pyx_L1_error)
  11547. __pyx_int_1073741824 = PyInt_FromLong(1073741824L); if (unlikely(!__pyx_int_1073741824)) __PYX_ERR(0, 1, __pyx_L1_error)
  11548. return 0;
  11549. __pyx_L1_error:;
  11550. return -1;
  11551. }
  11552. static int __Pyx_modinit_global_init_code(void); /*proto*/
  11553. static int __Pyx_modinit_variable_export_code(void); /*proto*/
  11554. static int __Pyx_modinit_function_export_code(void); /*proto*/
  11555. static int __Pyx_modinit_type_init_code(void); /*proto*/
  11556. static int __Pyx_modinit_type_import_code(void); /*proto*/
  11557. static int __Pyx_modinit_variable_import_code(void); /*proto*/
  11558. static int __Pyx_modinit_function_import_code(void); /*proto*/
  11559. static int __Pyx_modinit_global_init_code(void) {
  11560. __Pyx_RefNannyDeclarations
  11561. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  11562. /*--- Global init code ---*/
  11563. __Pyx_RefNannyFinishContext();
  11564. return 0;
  11565. }
  11566. static int __Pyx_modinit_variable_export_code(void) {
  11567. __Pyx_RefNannyDeclarations
  11568. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  11569. /*--- Variable export code ---*/
  11570. 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)
  11571. 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)
  11572. 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)
  11573. 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)
  11574. 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)
  11575. __Pyx_RefNannyFinishContext();
  11576. return 0;
  11577. __pyx_L1_error:;
  11578. __Pyx_RefNannyFinishContext();
  11579. return -1;
  11580. }
  11581. static int __Pyx_modinit_function_export_code(void) {
  11582. __Pyx_RefNannyDeclarations
  11583. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  11584. /*--- Function export code ---*/
  11585. 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)
  11586. __Pyx_RefNannyFinishContext();
  11587. return 0;
  11588. __pyx_L1_error:;
  11589. __Pyx_RefNannyFinishContext();
  11590. return -1;
  11591. }
  11592. static int __Pyx_modinit_type_init_code(void) {
  11593. __Pyx_RefNannyDeclarations
  11594. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  11595. /*--- Type init code ---*/
  11596. __pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = &__pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  11597. __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;
  11598. __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;
  11599. __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;
  11600. __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;
  11601. __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;
  11602. __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;
  11603. __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;
  11604. __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;
  11605. __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;
  11606. __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;
  11607. __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;
  11608. __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;
  11609. __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;
  11610. __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;
  11611. __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;
  11612. __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;
  11613. __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;
  11614. __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;
  11615. __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;
  11616. if (PyType_Ready(&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  11617. __pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.tp_print = 0;
  11618. 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)) {
  11619. __pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  11620. }
  11621. #if CYTHON_COMPILING_IN_CPYTHON
  11622. {
  11623. PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 49, __pyx_L1_error)
  11624. if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
  11625. __pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
  11626. __pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__.doc = __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__;
  11627. ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__;
  11628. }
  11629. }
  11630. #endif
  11631. 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)
  11632. if (PyObject_SetAttrString(__pyx_m, "BaseLmdbStore", (PyObject *)&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  11633. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  11634. __pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = &__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  11635. if (PyType_Ready(&__pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx) < 0) __PYX_ERR(0, 334, __pyx_L1_error)
  11636. __pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx.tp_print = 0;
  11637. 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)) {
  11638. __pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  11639. }
  11640. __pyx_ptype_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = &__pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx;
  11641. __Pyx_RefNannyFinishContext();
  11642. return 0;
  11643. __pyx_L1_error:;
  11644. __Pyx_RefNannyFinishContext();
  11645. return -1;
  11646. }
  11647. static int __Pyx_modinit_type_import_code(void) {
  11648. __Pyx_RefNannyDeclarations
  11649. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  11650. /*--- Type import code ---*/
  11651. __Pyx_RefNannyFinishContext();
  11652. return 0;
  11653. }
  11654. static int __Pyx_modinit_variable_import_code(void) {
  11655. __Pyx_RefNannyDeclarations
  11656. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  11657. /*--- Variable import code ---*/
  11658. __Pyx_RefNannyFinishContext();
  11659. return 0;
  11660. }
  11661. static int __Pyx_modinit_function_import_code(void) {
  11662. __Pyx_RefNannyDeclarations
  11663. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  11664. /*--- Function import code ---*/
  11665. __Pyx_RefNannyFinishContext();
  11666. return 0;
  11667. }
  11668. #if PY_MAJOR_VERSION < 3
  11669. #ifdef CYTHON_NO_PYINIT_EXPORT
  11670. #define __Pyx_PyMODINIT_FUNC void
  11671. #else
  11672. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  11673. #endif
  11674. #else
  11675. #ifdef CYTHON_NO_PYINIT_EXPORT
  11676. #define __Pyx_PyMODINIT_FUNC PyObject *
  11677. #else
  11678. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  11679. #endif
  11680. #endif
  11681. #ifndef CYTHON_SMALL_CODE
  11682. #if defined(__clang__)
  11683. #define CYTHON_SMALL_CODE
  11684. #elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
  11685. #define CYTHON_SMALL_CODE __attribute__((optimize("Os")))
  11686. #else
  11687. #define CYTHON_SMALL_CODE
  11688. #endif
  11689. #endif
  11690. #if PY_MAJOR_VERSION < 3
  11691. __Pyx_PyMODINIT_FUNC initbase_lmdb_store(void) CYTHON_SMALL_CODE; /*proto*/
  11692. __Pyx_PyMODINIT_FUNC initbase_lmdb_store(void)
  11693. #else
  11694. __Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void) CYTHON_SMALL_CODE; /*proto*/
  11695. __Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void)
  11696. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11697. {
  11698. return PyModuleDef_Init(&__pyx_moduledef);
  11699. }
  11700. static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
  11701. PyObject *value = PyObject_GetAttrString(spec, from_name);
  11702. int result = 0;
  11703. if (likely(value)) {
  11704. result = PyDict_SetItemString(moddict, to_name, value);
  11705. Py_DECREF(value);
  11706. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  11707. PyErr_Clear();
  11708. } else {
  11709. result = -1;
  11710. }
  11711. return result;
  11712. }
  11713. static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
  11714. PyObject *module = NULL, *moddict, *modname;
  11715. if (__pyx_m)
  11716. return __Pyx_NewRef(__pyx_m);
  11717. modname = PyObject_GetAttrString(spec, "name");
  11718. if (unlikely(!modname)) goto bad;
  11719. module = PyModule_NewObject(modname);
  11720. Py_DECREF(modname);
  11721. if (unlikely(!module)) goto bad;
  11722. moddict = PyModule_GetDict(module);
  11723. if (unlikely(!moddict)) goto bad;
  11724. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
  11725. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
  11726. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
  11727. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
  11728. return module;
  11729. bad:
  11730. Py_XDECREF(module);
  11731. return NULL;
  11732. }
  11733. static int __pyx_pymod_exec_base_lmdb_store(PyObject *__pyx_pyinit_module)
  11734. #endif
  11735. #endif
  11736. {
  11737. __Pyx_TraceDeclarations
  11738. PyObject *__pyx_t_1 = NULL;
  11739. PyObject *__pyx_t_2 = NULL;
  11740. PyObject *__pyx_t_3 = NULL;
  11741. PyObject *__pyx_t_4 = NULL;
  11742. PyObject *__pyx_t_5 = NULL;
  11743. __Pyx_RefNannyDeclarations
  11744. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11745. if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
  11746. #elif PY_MAJOR_VERSION >= 3
  11747. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  11748. #endif
  11749. #if CYTHON_REFNANNY
  11750. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  11751. if (!__Pyx_RefNanny) {
  11752. PyErr_Clear();
  11753. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  11754. if (!__Pyx_RefNanny)
  11755. Py_FatalError("failed to import 'refnanny' module");
  11756. }
  11757. #endif
  11758. __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void)", 0);
  11759. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11760. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  11761. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  11762. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  11763. #ifdef __Pyx_CyFunction_USED
  11764. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11765. #endif
  11766. #ifdef __Pyx_FusedFunction_USED
  11767. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11768. #endif
  11769. #ifdef __Pyx_Coroutine_USED
  11770. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11771. #endif
  11772. #ifdef __Pyx_Generator_USED
  11773. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11774. #endif
  11775. #ifdef __Pyx_AsyncGen_USED
  11776. if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11777. #endif
  11778. #ifdef __Pyx_StopAsyncIteration_USED
  11779. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11780. #endif
  11781. /*--- Library function declarations ---*/
  11782. /*--- Threads initialization code ---*/
  11783. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  11784. #ifdef WITH_THREAD /* Python build with threading support? */
  11785. PyEval_InitThreads();
  11786. #endif
  11787. #endif
  11788. /*--- Module creation code ---*/
  11789. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11790. __pyx_m = __pyx_pyinit_module;
  11791. Py_INCREF(__pyx_m);
  11792. #else
  11793. #if PY_MAJOR_VERSION < 3
  11794. __pyx_m = Py_InitModule4("base_lmdb_store", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  11795. #else
  11796. __pyx_m = PyModule_Create(&__pyx_moduledef);
  11797. #endif
  11798. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  11799. #endif
  11800. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  11801. Py_INCREF(__pyx_d);
  11802. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  11803. __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  11804. #if CYTHON_COMPILING_IN_PYPY
  11805. Py_INCREF(__pyx_b);
  11806. #endif
  11807. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  11808. /*--- Initialize various global constants etc. ---*/
  11809. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11810. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  11811. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11812. #endif
  11813. if (__pyx_module_is_main_lakesuperior__store__base_lmdb_store) {
  11814. if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11815. }
  11816. #if PY_MAJOR_VERSION >= 3
  11817. {
  11818. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  11819. if (!PyDict_GetItemString(modules, "lakesuperior.store.base_lmdb_store")) {
  11820. if (unlikely(PyDict_SetItemString(modules, "lakesuperior.store.base_lmdb_store", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  11821. }
  11822. }
  11823. #endif
  11824. /*--- Builtin init code ---*/
  11825. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11826. /*--- Constants init code ---*/
  11827. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11828. /*--- Global type/function init code ---*/
  11829. (void)__Pyx_modinit_global_init_code();
  11830. if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
  11831. if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
  11832. if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  11833. (void)__Pyx_modinit_type_import_code();
  11834. (void)__Pyx_modinit_variable_import_code();
  11835. (void)__Pyx_modinit_function_import_code();
  11836. /*--- Execution code ---*/
  11837. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  11838. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11839. #endif
  11840. __Pyx_TraceCall("__Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void)", __pyx_f[0], 1, 0, __PYX_ERR(0, 1, __pyx_L1_error));
  11841. /* "lakesuperior/store/base_lmdb_store.pyx":1
  11842. * import logging # <<<<<<<<<<<<<<
  11843. * import os
  11844. * import threading
  11845. */
  11846. __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  11847. __Pyx_GOTREF(__pyx_t_1);
  11848. if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11849. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11850. /* "lakesuperior/store/base_lmdb_store.pyx":2
  11851. * import logging
  11852. * import os # <<<<<<<<<<<<<<
  11853. * import threading
  11854. * import multiprocessing
  11855. */
  11856. __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)
  11857. __Pyx_GOTREF(__pyx_t_1);
  11858. if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
  11859. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11860. /* "lakesuperior/store/base_lmdb_store.pyx":3
  11861. * import logging
  11862. * import os
  11863. * import threading # <<<<<<<<<<<<<<
  11864. * import multiprocessing
  11865. *
  11866. */
  11867. __pyx_t_1 = __Pyx_Import(__pyx_n_s_threading, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
  11868. __Pyx_GOTREF(__pyx_t_1);
  11869. if (PyDict_SetItem(__pyx_d, __pyx_n_s_threading, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
  11870. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11871. /* "lakesuperior/store/base_lmdb_store.pyx":4
  11872. * import os
  11873. * import threading
  11874. * import multiprocessing # <<<<<<<<<<<<<<
  11875. *
  11876. * from contextlib import contextmanager
  11877. */
  11878. __pyx_t_1 = __Pyx_Import(__pyx_n_s_multiprocessing, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
  11879. __Pyx_GOTREF(__pyx_t_1);
  11880. if (PyDict_SetItem(__pyx_d, __pyx_n_s_multiprocessing, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
  11881. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11882. /* "lakesuperior/store/base_lmdb_store.pyx":6
  11883. * import multiprocessing
  11884. *
  11885. * from contextlib import contextmanager # <<<<<<<<<<<<<<
  11886. * from os import makedirs, path
  11887. * from shutil import rmtree
  11888. */
  11889. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
  11890. __Pyx_GOTREF(__pyx_t_1);
  11891. __Pyx_INCREF(__pyx_n_s_contextmanager);
  11892. __Pyx_GIVEREF(__pyx_n_s_contextmanager);
  11893. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_contextmanager);
  11894. __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)
  11895. __Pyx_GOTREF(__pyx_t_2);
  11896. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11897. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_contextmanager); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
  11898. __Pyx_GOTREF(__pyx_t_1);
  11899. if (PyDict_SetItem(__pyx_d, __pyx_n_s_contextmanager, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  11900. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11901. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11902. /* "lakesuperior/store/base_lmdb_store.pyx":7
  11903. *
  11904. * from contextlib import contextmanager
  11905. * from os import makedirs, path # <<<<<<<<<<<<<<
  11906. * from shutil import rmtree
  11907. *
  11908. */
  11909. __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  11910. __Pyx_GOTREF(__pyx_t_2);
  11911. __Pyx_INCREF(__pyx_n_s_makedirs);
  11912. __Pyx_GIVEREF(__pyx_n_s_makedirs);
  11913. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_makedirs);
  11914. __Pyx_INCREF(__pyx_n_s_path);
  11915. __Pyx_GIVEREF(__pyx_n_s_path);
  11916. PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_path);
  11917. __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)
  11918. __Pyx_GOTREF(__pyx_t_1);
  11919. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11920. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_makedirs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  11921. __Pyx_GOTREF(__pyx_t_2);
  11922. if (PyDict_SetItem(__pyx_d, __pyx_n_s_makedirs, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  11923. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11924. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  11925. __Pyx_GOTREF(__pyx_t_2);
  11926. if (PyDict_SetItem(__pyx_d, __pyx_n_s_path, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  11927. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11928. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11929. /* "lakesuperior/store/base_lmdb_store.pyx":8
  11930. * from contextlib import contextmanager
  11931. * from os import makedirs, path
  11932. * from shutil import rmtree # <<<<<<<<<<<<<<
  11933. *
  11934. * from lakesuperior import env, wsgi
  11935. */
  11936. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  11937. __Pyx_GOTREF(__pyx_t_1);
  11938. __Pyx_INCREF(__pyx_n_s_rmtree);
  11939. __Pyx_GIVEREF(__pyx_n_s_rmtree);
  11940. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_rmtree);
  11941. __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)
  11942. __Pyx_GOTREF(__pyx_t_2);
  11943. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11944. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_rmtree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  11945. __Pyx_GOTREF(__pyx_t_1);
  11946. if (PyDict_SetItem(__pyx_d, __pyx_n_s_rmtree, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  11947. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11948. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11949. /* "lakesuperior/store/base_lmdb_store.pyx":10
  11950. * from shutil import rmtree
  11951. *
  11952. * from lakesuperior import env, wsgi # <<<<<<<<<<<<<<
  11953. *
  11954. * from lakesuperior.cy_include cimport cylmdb as lmdb
  11955. */
  11956. __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  11957. __Pyx_GOTREF(__pyx_t_2);
  11958. __Pyx_INCREF(__pyx_n_s_env);
  11959. __Pyx_GIVEREF(__pyx_n_s_env);
  11960. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_env);
  11961. __Pyx_INCREF(__pyx_n_s_wsgi);
  11962. __Pyx_GIVEREF(__pyx_n_s_wsgi);
  11963. PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_wsgi);
  11964. __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)
  11965. __Pyx_GOTREF(__pyx_t_1);
  11966. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11967. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_env); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  11968. __Pyx_GOTREF(__pyx_t_2);
  11969. if (PyDict_SetItem(__pyx_d, __pyx_n_s_env, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  11970. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11971. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_wsgi); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  11972. __Pyx_GOTREF(__pyx_t_2);
  11973. if (PyDict_SetItem(__pyx_d, __pyx_n_s_wsgi, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  11974. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11975. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11976. /* "lakesuperior/store/base_lmdb_store.pyx":19
  11977. *
  11978. *
  11979. * logger = logging.getLogger(__name__) # <<<<<<<<<<<<<<
  11980. *
  11981. *
  11982. */
  11983. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  11984. __Pyx_GOTREF(__pyx_t_1);
  11985. __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)
  11986. __Pyx_GOTREF(__pyx_t_2);
  11987. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11988. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  11989. __Pyx_GOTREF(__pyx_t_1);
  11990. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error)
  11991. __Pyx_GOTREF(__pyx_t_3);
  11992. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11993. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11994. if (PyDict_SetItem(__pyx_d, __pyx_n_s_logger, __pyx_t_3) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
  11995. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  11996. /* "lakesuperior/store/base_lmdb_store.pyx":38
  11997. *
  11998. *
  11999. * class LmdbError(Exception): # <<<<<<<<<<<<<<
  12000. * pass
  12001. *
  12002. */
  12003. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error)
  12004. __Pyx_GOTREF(__pyx_t_3);
  12005. __Pyx_INCREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  12006. __Pyx_GIVEREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  12007. PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  12008. __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  12009. __Pyx_GOTREF(__pyx_t_1);
  12010. __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)
  12011. __Pyx_GOTREF(__pyx_t_2);
  12012. __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)
  12013. __Pyx_GOTREF(__pyx_t_4);
  12014. if (PyDict_SetItem(__pyx_d, __pyx_n_s_LmdbError, __pyx_t_4) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
  12015. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  12016. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12017. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12018. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12019. /* "lakesuperior/store/base_lmdb_store.pyx":41
  12020. * pass
  12021. *
  12022. * class KeyNotFoundError(LmdbError): # <<<<<<<<<<<<<<
  12023. * pass
  12024. *
  12025. */
  12026. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error)
  12027. __Pyx_GOTREF(__pyx_t_3);
  12028. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
  12029. __Pyx_GOTREF(__pyx_t_1);
  12030. __Pyx_GIVEREF(__pyx_t_3);
  12031. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  12032. __pyx_t_3 = 0;
  12033. __pyx_t_3 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error)
  12034. __Pyx_GOTREF(__pyx_t_3);
  12035. __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)
  12036. __Pyx_GOTREF(__pyx_t_2);
  12037. __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)
  12038. __Pyx_GOTREF(__pyx_t_4);
  12039. if (PyDict_SetItem(__pyx_d, __pyx_n_s_KeyNotFoundError, __pyx_t_4) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
  12040. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  12041. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12042. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12043. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12044. /* "lakesuperior/store/base_lmdb_store.pyx":44
  12045. * pass
  12046. *
  12047. * class KeyExistsError(LmdbError): # <<<<<<<<<<<<<<
  12048. * pass
  12049. *
  12050. */
  12051. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
  12052. __Pyx_GOTREF(__pyx_t_1);
  12053. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error)
  12054. __Pyx_GOTREF(__pyx_t_3);
  12055. __Pyx_GIVEREF(__pyx_t_1);
  12056. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  12057. __pyx_t_1 = 0;
  12058. __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
  12059. __Pyx_GOTREF(__pyx_t_1);
  12060. __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)
  12061. __Pyx_GOTREF(__pyx_t_2);
  12062. __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)
  12063. __Pyx_GOTREF(__pyx_t_4);
  12064. if (PyDict_SetItem(__pyx_d, __pyx_n_s_KeyExistsError, __pyx_t_4) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
  12065. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  12066. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12067. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12068. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12069. /* "lakesuperior/store/base_lmdb_store.pyx":71
  12070. * """
  12071. *
  12072. * dbi_labels = [] # <<<<<<<<<<<<<<
  12073. * dbi_flags = {}
  12074. * """
  12075. */
  12076. __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
  12077. __Pyx_GOTREF(__pyx_t_3);
  12078. 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)
  12079. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12080. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12081. /* "lakesuperior/store/base_lmdb_store.pyx":72
  12082. *
  12083. * dbi_labels = []
  12084. * dbi_flags = {} # <<<<<<<<<<<<<<
  12085. * """
  12086. * Configuration of databases in the environment.
  12087. */
  12088. __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
  12089. __Pyx_GOTREF(__pyx_t_3);
  12090. 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)
  12091. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12092. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12093. /* "lakesuperior/store/base_lmdb_store.pyx":87
  12094. * """
  12095. *
  12096. * env_flags = 0 # <<<<<<<<<<<<<<
  12097. * """
  12098. * LMDB environment flags.
  12099. */
  12100. 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)
  12101. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12102. /* "lakesuperior/store/base_lmdb_store.pyx":95
  12103. * """
  12104. *
  12105. * env_perms = 0o640 # <<<<<<<<<<<<<<
  12106. * """
  12107. * The UNIX permissions to set on created environment files and semaphores.
  12108. */
  12109. 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)
  12110. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12111. /* "lakesuperior/store/base_lmdb_store.pyx":103
  12112. * """
  12113. *
  12114. * options = {} # <<<<<<<<<<<<<<
  12115. * """
  12116. * LMDB environment option overrides. Setting this is not required.
  12117. */
  12118. __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 103, __pyx_L1_error)
  12119. __Pyx_GOTREF(__pyx_t_3);
  12120. 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)
  12121. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12122. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12123. /* "lakesuperior/store/base_lmdb_store.pyx":122
  12124. * """
  12125. *
  12126. * readers_mult = 4 # <<<<<<<<<<<<<<
  12127. * """
  12128. * Number to multiply WSGI workers by to set the numer of LMDB reader slots.
  12129. */
  12130. 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)
  12131. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12132. /* "lakesuperior/store/base_lmdb_store.pyx":333
  12133. * ### PYTHON-ACCESSIBLE METHODS ###
  12134. *
  12135. * @contextmanager # <<<<<<<<<<<<<<
  12136. * def txn_ctx(self, write=False):
  12137. * """
  12138. */
  12139. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_contextmanager); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
  12140. __Pyx_GOTREF(__pyx_t_1);
  12141. /* "lakesuperior/store/base_lmdb_store.pyx":334
  12142. *
  12143. * @contextmanager
  12144. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  12145. * """
  12146. * Transaction context manager.
  12147. */
  12148. __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)
  12149. __Pyx_GOTREF(__pyx_t_2);
  12150. __pyx_t_4 = NULL;
  12151. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  12152. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
  12153. if (likely(__pyx_t_4)) {
  12154. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  12155. __Pyx_INCREF(__pyx_t_4);
  12156. __Pyx_INCREF(function);
  12157. __Pyx_DECREF_SET(__pyx_t_1, function);
  12158. }
  12159. }
  12160. if (!__pyx_t_4) {
  12161. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L1_error)
  12162. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12163. __Pyx_GOTREF(__pyx_t_3);
  12164. } else {
  12165. #if CYTHON_FAST_PYCALL
  12166. if (PyFunction_Check(__pyx_t_1)) {
  12167. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
  12168. __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)
  12169. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  12170. __Pyx_GOTREF(__pyx_t_3);
  12171. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12172. } else
  12173. #endif
  12174. #if CYTHON_FAST_PYCCALL
  12175. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  12176. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
  12177. __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)
  12178. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  12179. __Pyx_GOTREF(__pyx_t_3);
  12180. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12181. } else
  12182. #endif
  12183. {
  12184. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 333, __pyx_L1_error)
  12185. __Pyx_GOTREF(__pyx_t_5);
  12186. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  12187. __Pyx_GIVEREF(__pyx_t_2);
  12188. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
  12189. __pyx_t_2 = 0;
  12190. __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)
  12191. __Pyx_GOTREF(__pyx_t_3);
  12192. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  12193. }
  12194. }
  12195. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12196. 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)
  12197. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12198. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12199. /* "lakesuperior/store/base_lmdb_store.pyx":416
  12200. * cdef inline bint _key_exists(
  12201. * self, unsigned char *key, unsigned char klen,
  12202. * unsigned char *dblabel=b'') except -1: # <<<<<<<<<<<<<<
  12203. * """
  12204. * Return whether a key exists in a database.
  12205. */
  12206. __pyx_k__14 = ((unsigned char *)((char const *)""));
  12207. /* "lakesuperior/store/base_lmdb_store.pyx":449
  12208. * cdef void _put(
  12209. * self, unsigned char *key, size_t key_size, unsigned char *data,
  12210. * size_t data_size, unsigned char *dblabel='', # <<<<<<<<<<<<<<
  12211. * lmdb.MDB_txn *txn=NULL, unsigned int flags=0) except *:
  12212. * """
  12213. */
  12214. __pyx_k__15 = ((unsigned char *)((char const *)""));
  12215. /* "lakesuperior/store/base_lmdb_store.pyx":484
  12216. * cdef void _get_data(
  12217. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  12218. * unsigned char *dblabel='') except *: # <<<<<<<<<<<<<<
  12219. * """
  12220. * Get a single value (non-dup) for a key.
  12221. */
  12222. __pyx_k__16 = ((unsigned char *)((char const *)""));
  12223. /* "lakesuperior/store/base_lmdb_store.pyx":508
  12224. * cdef void _delete(
  12225. * self, unsigned char *key, size_t klen,
  12226. * unsigned char *dblabel=b'') except *: # <<<<<<<<<<<<<<
  12227. * """
  12228. * Delete one single value by key from a non-dup database.
  12229. */
  12230. __pyx_k__17 = ((unsigned char *)((char const *)""));
  12231. /* "lakesuperior/store/base_lmdb_store.pyx":1
  12232. * import logging # <<<<<<<<<<<<<<
  12233. * import os
  12234. * import threading
  12235. */
  12236. __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  12237. __Pyx_GOTREF(__pyx_t_3);
  12238. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  12239. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12240. __Pyx_TraceReturn(Py_None, 0);
  12241. /*--- Wrapped vars code ---*/
  12242. goto __pyx_L0;
  12243. __pyx_L1_error:;
  12244. __Pyx_XDECREF(__pyx_t_1);
  12245. __Pyx_XDECREF(__pyx_t_2);
  12246. __Pyx_XDECREF(__pyx_t_3);
  12247. __Pyx_XDECREF(__pyx_t_4);
  12248. __Pyx_XDECREF(__pyx_t_5);
  12249. if (__pyx_m) {
  12250. if (__pyx_d) {
  12251. __Pyx_AddTraceback("init lakesuperior.store.base_lmdb_store", 0, __pyx_lineno, __pyx_filename);
  12252. }
  12253. Py_DECREF(__pyx_m); __pyx_m = 0;
  12254. } else if (!PyErr_Occurred()) {
  12255. PyErr_SetString(PyExc_ImportError, "init lakesuperior.store.base_lmdb_store");
  12256. }
  12257. __pyx_L0:;
  12258. __Pyx_RefNannyFinishContext();
  12259. #if CYTHON_PEP489_MULTI_PHASE_INIT
  12260. return (__pyx_m != NULL) ? 0 : -1;
  12261. #elif PY_MAJOR_VERSION >= 3
  12262. return __pyx_m;
  12263. #else
  12264. return;
  12265. #endif
  12266. }
  12267. /* --- Runtime support code --- */
  12268. /* Refnanny */
  12269. #if CYTHON_REFNANNY
  12270. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  12271. PyObject *m = NULL, *p = NULL;
  12272. void *r = NULL;
  12273. m = PyImport_ImportModule((char *)modname);
  12274. if (!m) goto end;
  12275. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  12276. if (!p) goto end;
  12277. r = PyLong_AsVoidPtr(p);
  12278. end:
  12279. Py_XDECREF(p);
  12280. Py_XDECREF(m);
  12281. return (__Pyx_RefNannyAPIStruct *)r;
  12282. }
  12283. #endif
  12284. /* PyObjectGetAttrStr */
  12285. #if CYTHON_USE_TYPE_SLOTS
  12286. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  12287. PyTypeObject* tp = Py_TYPE(obj);
  12288. if (likely(tp->tp_getattro))
  12289. return tp->tp_getattro(obj, attr_name);
  12290. #if PY_MAJOR_VERSION < 3
  12291. if (likely(tp->tp_getattr))
  12292. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  12293. #endif
  12294. return PyObject_GetAttr(obj, attr_name);
  12295. }
  12296. #endif
  12297. /* GetBuiltinName */
  12298. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  12299. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  12300. if (unlikely(!result)) {
  12301. PyErr_Format(PyExc_NameError,
  12302. #if PY_MAJOR_VERSION >= 3
  12303. "name '%U' is not defined", name);
  12304. #else
  12305. "name '%.200s' is not defined", PyString_AS_STRING(name));
  12306. #endif
  12307. }
  12308. return result;
  12309. }
  12310. /* PyErrFetchRestore */
  12311. #if CYTHON_FAST_THREAD_STATE
  12312. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  12313. PyObject *tmp_type, *tmp_value, *tmp_tb;
  12314. tmp_type = tstate->curexc_type;
  12315. tmp_value = tstate->curexc_value;
  12316. tmp_tb = tstate->curexc_traceback;
  12317. tstate->curexc_type = type;
  12318. tstate->curexc_value = value;
  12319. tstate->curexc_traceback = tb;
  12320. Py_XDECREF(tmp_type);
  12321. Py_XDECREF(tmp_value);
  12322. Py_XDECREF(tmp_tb);
  12323. }
  12324. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  12325. *type = tstate->curexc_type;
  12326. *value = tstate->curexc_value;
  12327. *tb = tstate->curexc_traceback;
  12328. tstate->curexc_type = 0;
  12329. tstate->curexc_value = 0;
  12330. tstate->curexc_traceback = 0;
  12331. }
  12332. #endif
  12333. /* Profile */
  12334. #if CYTHON_PROFILE
  12335. static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
  12336. PyFrameObject** frame,
  12337. PyThreadState* tstate,
  12338. const char *funcname,
  12339. const char *srcfile,
  12340. int firstlineno) {
  12341. PyObject *type, *value, *traceback;
  12342. int retval;
  12343. if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
  12344. if (*code == NULL) {
  12345. *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
  12346. if (*code == NULL) return 0;
  12347. }
  12348. *frame = PyFrame_New(
  12349. tstate, /*PyThreadState *tstate*/
  12350. *code, /*PyCodeObject *code*/
  12351. __pyx_d, /*PyObject *globals*/
  12352. 0 /*PyObject *locals*/
  12353. );
  12354. if (*frame == NULL) return 0;
  12355. if (CYTHON_TRACE && (*frame)->f_trace == NULL) {
  12356. Py_INCREF(Py_None);
  12357. (*frame)->f_trace = Py_None;
  12358. }
  12359. #if PY_VERSION_HEX < 0x030400B1
  12360. } else {
  12361. (*frame)->f_tstate = tstate;
  12362. #endif
  12363. }
  12364. __Pyx_PyFrame_SetLineNumber(*frame, firstlineno);
  12365. retval = 1;
  12366. tstate->tracing++;
  12367. tstate->use_tracing = 0;
  12368. __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
  12369. #if CYTHON_TRACE
  12370. if (tstate->c_tracefunc)
  12371. retval = tstate->c_tracefunc(tstate->c_traceobj, *frame, PyTrace_CALL, NULL) == 0;
  12372. if (retval && tstate->c_profilefunc)
  12373. #endif
  12374. retval = tstate->c_profilefunc(tstate->c_profileobj, *frame, PyTrace_CALL, NULL) == 0;
  12375. tstate->use_tracing = (tstate->c_profilefunc ||
  12376. (CYTHON_TRACE && tstate->c_tracefunc));
  12377. tstate->tracing--;
  12378. if (retval) {
  12379. __Pyx_ErrRestoreInState(tstate, type, value, traceback);
  12380. return tstate->use_tracing && retval;
  12381. } else {
  12382. Py_XDECREF(type);
  12383. Py_XDECREF(value);
  12384. Py_XDECREF(traceback);
  12385. return -1;
  12386. }
  12387. }
  12388. static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) {
  12389. PyObject *py_srcfile = 0;
  12390. PyObject *py_funcname = 0;
  12391. PyCodeObject *py_code = 0;
  12392. #if PY_MAJOR_VERSION < 3
  12393. py_funcname = PyString_FromString(funcname);
  12394. py_srcfile = PyString_FromString(srcfile);
  12395. #else
  12396. py_funcname = PyUnicode_FromString(funcname);
  12397. py_srcfile = PyUnicode_FromString(srcfile);
  12398. #endif
  12399. if (!py_funcname | !py_srcfile) goto bad;
  12400. py_code = PyCode_New(
  12401. 0,
  12402. #if PY_MAJOR_VERSION >= 3
  12403. 0,
  12404. #endif
  12405. 0,
  12406. 0,
  12407. CO_OPTIMIZED | CO_NEWLOCALS,
  12408. __pyx_empty_bytes, /*PyObject *code,*/
  12409. __pyx_empty_tuple, /*PyObject *consts,*/
  12410. __pyx_empty_tuple, /*PyObject *names,*/
  12411. __pyx_empty_tuple, /*PyObject *varnames,*/
  12412. __pyx_empty_tuple, /*PyObject *freevars,*/
  12413. __pyx_empty_tuple, /*PyObject *cellvars,*/
  12414. py_srcfile, /*PyObject *filename,*/
  12415. py_funcname, /*PyObject *name,*/
  12416. firstlineno,
  12417. __pyx_empty_bytes /*PyObject *lnotab*/
  12418. );
  12419. bad:
  12420. Py_XDECREF(py_srcfile);
  12421. Py_XDECREF(py_funcname);
  12422. return py_code;
  12423. }
  12424. #endif
  12425. /* GetModuleGlobalName */
  12426. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  12427. PyObject *result;
  12428. #if !CYTHON_AVOID_BORROWED_REFS
  12429. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
  12430. result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
  12431. if (likely(result)) {
  12432. Py_INCREF(result);
  12433. } else if (unlikely(PyErr_Occurred())) {
  12434. result = NULL;
  12435. } else {
  12436. #else
  12437. result = PyDict_GetItem(__pyx_d, name);
  12438. if (likely(result)) {
  12439. Py_INCREF(result);
  12440. } else {
  12441. #endif
  12442. #else
  12443. result = PyObject_GetItem(__pyx_d, name);
  12444. if (!result) {
  12445. PyErr_Clear();
  12446. #endif
  12447. result = __Pyx_GetBuiltinName(name);
  12448. }
  12449. return result;
  12450. }
  12451. /* PyCFunctionFastCall */
  12452. #if CYTHON_FAST_PYCCALL
  12453. static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
  12454. PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
  12455. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  12456. PyObject *self = PyCFunction_GET_SELF(func);
  12457. int flags = PyCFunction_GET_FLAGS(func);
  12458. assert(PyCFunction_Check(func));
  12459. assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
  12460. assert(nargs >= 0);
  12461. assert(nargs == 0 || args != NULL);
  12462. /* _PyCFunction_FastCallDict() must not be called with an exception set,
  12463. because it may clear it (directly or indirectly) and so the
  12464. caller loses its exception */
  12465. assert(!PyErr_Occurred());
  12466. if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
  12467. return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
  12468. } else {
  12469. return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
  12470. }
  12471. }
  12472. #endif
  12473. /* PyFunctionFastCall */
  12474. #if CYTHON_FAST_PYCALL
  12475. #include "frameobject.h"
  12476. static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
  12477. PyObject *globals) {
  12478. PyFrameObject *f;
  12479. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  12480. PyObject **fastlocals;
  12481. Py_ssize_t i;
  12482. PyObject *result;
  12483. assert(globals != NULL);
  12484. /* XXX Perhaps we should create a specialized
  12485. PyFrame_New() that doesn't take locals, but does
  12486. take builtins without sanity checking them.
  12487. */
  12488. assert(tstate != NULL);
  12489. f = PyFrame_New(tstate, co, globals, NULL);
  12490. if (f == NULL) {
  12491. return NULL;
  12492. }
  12493. fastlocals = f->f_localsplus;
  12494. for (i = 0; i < na; i++) {
  12495. Py_INCREF(*args);
  12496. fastlocals[i] = *args++;
  12497. }
  12498. result = PyEval_EvalFrameEx(f,0);
  12499. ++tstate->recursion_depth;
  12500. Py_DECREF(f);
  12501. --tstate->recursion_depth;
  12502. return result;
  12503. }
  12504. #if 1 || PY_VERSION_HEX < 0x030600B1
  12505. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
  12506. PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
  12507. PyObject *globals = PyFunction_GET_GLOBALS(func);
  12508. PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
  12509. PyObject *closure;
  12510. #if PY_MAJOR_VERSION >= 3
  12511. PyObject *kwdefs;
  12512. #endif
  12513. PyObject *kwtuple, **k;
  12514. PyObject **d;
  12515. Py_ssize_t nd;
  12516. Py_ssize_t nk;
  12517. PyObject *result;
  12518. assert(kwargs == NULL || PyDict_Check(kwargs));
  12519. nk = kwargs ? PyDict_Size(kwargs) : 0;
  12520. if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
  12521. return NULL;
  12522. }
  12523. if (
  12524. #if PY_MAJOR_VERSION >= 3
  12525. co->co_kwonlyargcount == 0 &&
  12526. #endif
  12527. likely(kwargs == NULL || nk == 0) &&
  12528. co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
  12529. if (argdefs == NULL && co->co_argcount == nargs) {
  12530. result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
  12531. goto done;
  12532. }
  12533. else if (nargs == 0 && argdefs != NULL
  12534. && co->co_argcount == Py_SIZE(argdefs)) {
  12535. /* function called with no arguments, but all parameters have
  12536. a default value: use default values as arguments .*/
  12537. args = &PyTuple_GET_ITEM(argdefs, 0);
  12538. result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
  12539. goto done;
  12540. }
  12541. }
  12542. if (kwargs != NULL) {
  12543. Py_ssize_t pos, i;
  12544. kwtuple = PyTuple_New(2 * nk);
  12545. if (kwtuple == NULL) {
  12546. result = NULL;
  12547. goto done;
  12548. }
  12549. k = &PyTuple_GET_ITEM(kwtuple, 0);
  12550. pos = i = 0;
  12551. while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
  12552. Py_INCREF(k[i]);
  12553. Py_INCREF(k[i+1]);
  12554. i += 2;
  12555. }
  12556. nk = i / 2;
  12557. }
  12558. else {
  12559. kwtuple = NULL;
  12560. k = NULL;
  12561. }
  12562. closure = PyFunction_GET_CLOSURE(func);
  12563. #if PY_MAJOR_VERSION >= 3
  12564. kwdefs = PyFunction_GET_KW_DEFAULTS(func);
  12565. #endif
  12566. if (argdefs != NULL) {
  12567. d = &PyTuple_GET_ITEM(argdefs, 0);
  12568. nd = Py_SIZE(argdefs);
  12569. }
  12570. else {
  12571. d = NULL;
  12572. nd = 0;
  12573. }
  12574. #if PY_MAJOR_VERSION >= 3
  12575. result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
  12576. args, nargs,
  12577. k, (int)nk,
  12578. d, (int)nd, kwdefs, closure);
  12579. #else
  12580. result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
  12581. args, nargs,
  12582. k, (int)nk,
  12583. d, (int)nd, closure);
  12584. #endif
  12585. Py_XDECREF(kwtuple);
  12586. done:
  12587. Py_LeaveRecursiveCall();
  12588. return result;
  12589. }
  12590. #endif
  12591. #endif
  12592. /* PyObjectCall */
  12593. #if CYTHON_COMPILING_IN_CPYTHON
  12594. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  12595. PyObject *result;
  12596. ternaryfunc call = func->ob_type->tp_call;
  12597. if (unlikely(!call))
  12598. return PyObject_Call(func, arg, kw);
  12599. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  12600. return NULL;
  12601. result = (*call)(func, arg, kw);
  12602. Py_LeaveRecursiveCall();
  12603. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  12604. PyErr_SetString(
  12605. PyExc_SystemError,
  12606. "NULL result without error in PyObject_Call");
  12607. }
  12608. return result;
  12609. }
  12610. #endif
  12611. /* PyObjectCallMethO */
  12612. #if CYTHON_COMPILING_IN_CPYTHON
  12613. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  12614. PyObject *self, *result;
  12615. PyCFunction cfunc;
  12616. cfunc = PyCFunction_GET_FUNCTION(func);
  12617. self = PyCFunction_GET_SELF(func);
  12618. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  12619. return NULL;
  12620. result = cfunc(self, arg);
  12621. Py_LeaveRecursiveCall();
  12622. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  12623. PyErr_SetString(
  12624. PyExc_SystemError,
  12625. "NULL result without error in PyObject_Call");
  12626. }
  12627. return result;
  12628. }
  12629. #endif
  12630. /* PyObjectCallOneArg */
  12631. #if CYTHON_COMPILING_IN_CPYTHON
  12632. static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  12633. PyObject *result;
  12634. PyObject *args = PyTuple_New(1);
  12635. if (unlikely(!args)) return NULL;
  12636. Py_INCREF(arg);
  12637. PyTuple_SET_ITEM(args, 0, arg);
  12638. result = __Pyx_PyObject_Call(func, args, NULL);
  12639. Py_DECREF(args);
  12640. return result;
  12641. }
  12642. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  12643. #if CYTHON_FAST_PYCALL
  12644. if (PyFunction_Check(func)) {
  12645. return __Pyx_PyFunction_FastCall(func, &arg, 1);
  12646. }
  12647. #endif
  12648. if (likely(PyCFunction_Check(func))) {
  12649. if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
  12650. return __Pyx_PyObject_CallMethO(func, arg);
  12651. #if CYTHON_FAST_PYCCALL
  12652. } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
  12653. return __Pyx_PyCFunction_FastCall(func, &arg, 1);
  12654. #endif
  12655. }
  12656. }
  12657. return __Pyx__PyObject_CallOneArg(func, arg);
  12658. }
  12659. #else
  12660. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  12661. PyObject *result;
  12662. PyObject *args = PyTuple_Pack(1, arg);
  12663. if (unlikely(!args)) return NULL;
  12664. result = __Pyx_PyObject_Call(func, args, NULL);
  12665. Py_DECREF(args);
  12666. return result;
  12667. }
  12668. #endif
  12669. /* PyObjectCallNoArg */
  12670. #if CYTHON_COMPILING_IN_CPYTHON
  12671. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  12672. #if CYTHON_FAST_PYCALL
  12673. if (PyFunction_Check(func)) {
  12674. return __Pyx_PyFunction_FastCall(func, NULL, 0);
  12675. }
  12676. #endif
  12677. #ifdef __Pyx_CyFunction_USED
  12678. if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
  12679. #else
  12680. if (likely(PyCFunction_Check(func))) {
  12681. #endif
  12682. if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
  12683. return __Pyx_PyObject_CallMethO(func, NULL);
  12684. }
  12685. }
  12686. return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
  12687. }
  12688. #endif
  12689. /* RaiseException */
  12690. #if PY_MAJOR_VERSION < 3
  12691. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  12692. CYTHON_UNUSED PyObject *cause) {
  12693. __Pyx_PyThreadState_declare
  12694. Py_XINCREF(type);
  12695. if (!value || value == Py_None)
  12696. value = NULL;
  12697. else
  12698. Py_INCREF(value);
  12699. if (!tb || tb == Py_None)
  12700. tb = NULL;
  12701. else {
  12702. Py_INCREF(tb);
  12703. if (!PyTraceBack_Check(tb)) {
  12704. PyErr_SetString(PyExc_TypeError,
  12705. "raise: arg 3 must be a traceback or None");
  12706. goto raise_error;
  12707. }
  12708. }
  12709. if (PyType_Check(type)) {
  12710. #if CYTHON_COMPILING_IN_PYPY
  12711. if (!value) {
  12712. Py_INCREF(Py_None);
  12713. value = Py_None;
  12714. }
  12715. #endif
  12716. PyErr_NormalizeException(&type, &value, &tb);
  12717. } else {
  12718. if (value) {
  12719. PyErr_SetString(PyExc_TypeError,
  12720. "instance exception may not have a separate value");
  12721. goto raise_error;
  12722. }
  12723. value = type;
  12724. type = (PyObject*) Py_TYPE(type);
  12725. Py_INCREF(type);
  12726. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  12727. PyErr_SetString(PyExc_TypeError,
  12728. "raise: exception class must be a subclass of BaseException");
  12729. goto raise_error;
  12730. }
  12731. }
  12732. __Pyx_PyThreadState_assign
  12733. __Pyx_ErrRestore(type, value, tb);
  12734. return;
  12735. raise_error:
  12736. Py_XDECREF(value);
  12737. Py_XDECREF(type);
  12738. Py_XDECREF(tb);
  12739. return;
  12740. }
  12741. #else
  12742. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  12743. PyObject* owned_instance = NULL;
  12744. if (tb == Py_None) {
  12745. tb = 0;
  12746. } else if (tb && !PyTraceBack_Check(tb)) {
  12747. PyErr_SetString(PyExc_TypeError,
  12748. "raise: arg 3 must be a traceback or None");
  12749. goto bad;
  12750. }
  12751. if (value == Py_None)
  12752. value = 0;
  12753. if (PyExceptionInstance_Check(type)) {
  12754. if (value) {
  12755. PyErr_SetString(PyExc_TypeError,
  12756. "instance exception may not have a separate value");
  12757. goto bad;
  12758. }
  12759. value = type;
  12760. type = (PyObject*) Py_TYPE(value);
  12761. } else if (PyExceptionClass_Check(type)) {
  12762. PyObject *instance_class = NULL;
  12763. if (value && PyExceptionInstance_Check(value)) {
  12764. instance_class = (PyObject*) Py_TYPE(value);
  12765. if (instance_class != type) {
  12766. int is_subclass = PyObject_IsSubclass(instance_class, type);
  12767. if (!is_subclass) {
  12768. instance_class = NULL;
  12769. } else if (unlikely(is_subclass == -1)) {
  12770. goto bad;
  12771. } else {
  12772. type = instance_class;
  12773. }
  12774. }
  12775. }
  12776. if (!instance_class) {
  12777. PyObject *args;
  12778. if (!value)
  12779. args = PyTuple_New(0);
  12780. else if (PyTuple_Check(value)) {
  12781. Py_INCREF(value);
  12782. args = value;
  12783. } else
  12784. args = PyTuple_Pack(1, value);
  12785. if (!args)
  12786. goto bad;
  12787. owned_instance = PyObject_Call(type, args, NULL);
  12788. Py_DECREF(args);
  12789. if (!owned_instance)
  12790. goto bad;
  12791. value = owned_instance;
  12792. if (!PyExceptionInstance_Check(value)) {
  12793. PyErr_Format(PyExc_TypeError,
  12794. "calling %R should have returned an instance of "
  12795. "BaseException, not %R",
  12796. type, Py_TYPE(value));
  12797. goto bad;
  12798. }
  12799. }
  12800. } else {
  12801. PyErr_SetString(PyExc_TypeError,
  12802. "raise: exception class must be a subclass of BaseException");
  12803. goto bad;
  12804. }
  12805. if (cause) {
  12806. PyObject *fixed_cause;
  12807. if (cause == Py_None) {
  12808. fixed_cause = NULL;
  12809. } else if (PyExceptionClass_Check(cause)) {
  12810. fixed_cause = PyObject_CallObject(cause, NULL);
  12811. if (fixed_cause == NULL)
  12812. goto bad;
  12813. } else if (PyExceptionInstance_Check(cause)) {
  12814. fixed_cause = cause;
  12815. Py_INCREF(fixed_cause);
  12816. } else {
  12817. PyErr_SetString(PyExc_TypeError,
  12818. "exception causes must derive from "
  12819. "BaseException");
  12820. goto bad;
  12821. }
  12822. PyException_SetCause(value, fixed_cause);
  12823. }
  12824. PyErr_SetObject(type, value);
  12825. if (tb) {
  12826. #if CYTHON_COMPILING_IN_PYPY
  12827. PyObject *tmp_type, *tmp_value, *tmp_tb;
  12828. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  12829. Py_INCREF(tb);
  12830. PyErr_Restore(tmp_type, tmp_value, tb);
  12831. Py_XDECREF(tmp_tb);
  12832. #else
  12833. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  12834. PyObject* tmp_tb = tstate->curexc_traceback;
  12835. if (tb != tmp_tb) {
  12836. Py_INCREF(tb);
  12837. tstate->curexc_traceback = tb;
  12838. Py_XDECREF(tmp_tb);
  12839. }
  12840. #endif
  12841. }
  12842. bad:
  12843. Py_XDECREF(owned_instance);
  12844. return;
  12845. }
  12846. #endif
  12847. /* decode_c_string */
  12848. static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
  12849. const char* cstring, Py_ssize_t start, Py_ssize_t stop,
  12850. const char* encoding, const char* errors,
  12851. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
  12852. Py_ssize_t length;
  12853. if (unlikely((start < 0) | (stop < 0))) {
  12854. size_t slen = strlen(cstring);
  12855. if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
  12856. PyErr_SetString(PyExc_OverflowError,
  12857. "c-string too long to convert to Python");
  12858. return NULL;
  12859. }
  12860. length = (Py_ssize_t) slen;
  12861. if (start < 0) {
  12862. start += length;
  12863. if (start < 0)
  12864. start = 0;
  12865. }
  12866. if (stop < 0)
  12867. stop += length;
  12868. }
  12869. length = stop - start;
  12870. if (unlikely(length <= 0))
  12871. return PyUnicode_FromUnicode(NULL, 0);
  12872. cstring += start;
  12873. if (decode_func) {
  12874. return decode_func(cstring, length, errors);
  12875. } else {
  12876. return PyUnicode_Decode(cstring, length, encoding, errors);
  12877. }
  12878. }
  12879. /* RaiseDoubleKeywords */
  12880. static void __Pyx_RaiseDoubleKeywordsError(
  12881. const char* func_name,
  12882. PyObject* kw_name)
  12883. {
  12884. PyErr_Format(PyExc_TypeError,
  12885. #if PY_MAJOR_VERSION >= 3
  12886. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  12887. #else
  12888. "%s() got multiple values for keyword argument '%s'", func_name,
  12889. PyString_AsString(kw_name));
  12890. #endif
  12891. }
  12892. /* ParseKeywords */
  12893. static int __Pyx_ParseOptionalKeywords(
  12894. PyObject *kwds,
  12895. PyObject **argnames[],
  12896. PyObject *kwds2,
  12897. PyObject *values[],
  12898. Py_ssize_t num_pos_args,
  12899. const char* function_name)
  12900. {
  12901. PyObject *key = 0, *value = 0;
  12902. Py_ssize_t pos = 0;
  12903. PyObject*** name;
  12904. PyObject*** first_kw_arg = argnames + num_pos_args;
  12905. while (PyDict_Next(kwds, &pos, &key, &value)) {
  12906. name = first_kw_arg;
  12907. while (*name && (**name != key)) name++;
  12908. if (*name) {
  12909. values[name-argnames] = value;
  12910. continue;
  12911. }
  12912. name = first_kw_arg;
  12913. #if PY_MAJOR_VERSION < 3
  12914. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  12915. while (*name) {
  12916. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  12917. && _PyString_Eq(**name, key)) {
  12918. values[name-argnames] = value;
  12919. break;
  12920. }
  12921. name++;
  12922. }
  12923. if (*name) continue;
  12924. else {
  12925. PyObject*** argname = argnames;
  12926. while (argname != first_kw_arg) {
  12927. if ((**argname == key) || (
  12928. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  12929. && _PyString_Eq(**argname, key))) {
  12930. goto arg_passed_twice;
  12931. }
  12932. argname++;
  12933. }
  12934. }
  12935. } else
  12936. #endif
  12937. if (likely(PyUnicode_Check(key))) {
  12938. while (*name) {
  12939. int cmp = (**name == key) ? 0 :
  12940. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  12941. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  12942. #endif
  12943. PyUnicode_Compare(**name, key);
  12944. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  12945. if (cmp == 0) {
  12946. values[name-argnames] = value;
  12947. break;
  12948. }
  12949. name++;
  12950. }
  12951. if (*name) continue;
  12952. else {
  12953. PyObject*** argname = argnames;
  12954. while (argname != first_kw_arg) {
  12955. int cmp = (**argname == key) ? 0 :
  12956. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  12957. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  12958. #endif
  12959. PyUnicode_Compare(**argname, key);
  12960. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  12961. if (cmp == 0) goto arg_passed_twice;
  12962. argname++;
  12963. }
  12964. }
  12965. } else
  12966. goto invalid_keyword_type;
  12967. if (kwds2) {
  12968. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  12969. } else {
  12970. goto invalid_keyword;
  12971. }
  12972. }
  12973. return 0;
  12974. arg_passed_twice:
  12975. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  12976. goto bad;
  12977. invalid_keyword_type:
  12978. PyErr_Format(PyExc_TypeError,
  12979. "%.200s() keywords must be strings", function_name);
  12980. goto bad;
  12981. invalid_keyword:
  12982. PyErr_Format(PyExc_TypeError,
  12983. #if PY_MAJOR_VERSION < 3
  12984. "%.200s() got an unexpected keyword argument '%.200s'",
  12985. function_name, PyString_AsString(key));
  12986. #else
  12987. "%s() got an unexpected keyword argument '%U'",
  12988. function_name, key);
  12989. #endif
  12990. bad:
  12991. return -1;
  12992. }
  12993. /* RaiseArgTupleInvalid */
  12994. static void __Pyx_RaiseArgtupleInvalid(
  12995. const char* func_name,
  12996. int exact,
  12997. Py_ssize_t num_min,
  12998. Py_ssize_t num_max,
  12999. Py_ssize_t num_found)
  13000. {
  13001. Py_ssize_t num_expected;
  13002. const char *more_or_less;
  13003. if (num_found < num_min) {
  13004. num_expected = num_min;
  13005. more_or_less = "at least";
  13006. } else {
  13007. num_expected = num_max;
  13008. more_or_less = "at most";
  13009. }
  13010. if (exact) {
  13011. more_or_less = "exactly";
  13012. }
  13013. PyErr_Format(PyExc_TypeError,
  13014. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  13015. func_name, more_or_less, num_expected,
  13016. (num_expected == 1) ? "" : "s", num_found);
  13017. }
  13018. /* WriteUnraisableException */
  13019. static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
  13020. CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
  13021. int full_traceback, CYTHON_UNUSED int nogil) {
  13022. PyObject *old_exc, *old_val, *old_tb;
  13023. PyObject *ctx;
  13024. __Pyx_PyThreadState_declare
  13025. #ifdef WITH_THREAD
  13026. PyGILState_STATE state;
  13027. if (nogil)
  13028. state = PyGILState_Ensure();
  13029. #ifdef _MSC_VER
  13030. else state = (PyGILState_STATE)-1;
  13031. #endif
  13032. #endif
  13033. __Pyx_PyThreadState_assign
  13034. __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
  13035. if (full_traceback) {
  13036. Py_XINCREF(old_exc);
  13037. Py_XINCREF(old_val);
  13038. Py_XINCREF(old_tb);
  13039. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  13040. PyErr_PrintEx(1);
  13041. }
  13042. #if PY_MAJOR_VERSION < 3
  13043. ctx = PyString_FromString(name);
  13044. #else
  13045. ctx = PyUnicode_FromString(name);
  13046. #endif
  13047. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  13048. if (!ctx) {
  13049. PyErr_WriteUnraisable(Py_None);
  13050. } else {
  13051. PyErr_WriteUnraisable(ctx);
  13052. Py_DECREF(ctx);
  13053. }
  13054. #ifdef WITH_THREAD
  13055. if (nogil)
  13056. PyGILState_Release(state);
  13057. #endif
  13058. }
  13059. /* SaveResetException */
  13060. #if CYTHON_FAST_THREAD_STATE
  13061. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13062. #if PY_VERSION_HEX >= 0x030700A3
  13063. *type = tstate->exc_state.exc_type;
  13064. *value = tstate->exc_state.exc_value;
  13065. *tb = tstate->exc_state.exc_traceback;
  13066. #else
  13067. *type = tstate->exc_type;
  13068. *value = tstate->exc_value;
  13069. *tb = tstate->exc_traceback;
  13070. #endif
  13071. Py_XINCREF(*type);
  13072. Py_XINCREF(*value);
  13073. Py_XINCREF(*tb);
  13074. }
  13075. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  13076. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13077. #if PY_VERSION_HEX >= 0x030700A3
  13078. tmp_type = tstate->exc_state.exc_type;
  13079. tmp_value = tstate->exc_state.exc_value;
  13080. tmp_tb = tstate->exc_state.exc_traceback;
  13081. tstate->exc_state.exc_type = type;
  13082. tstate->exc_state.exc_value = value;
  13083. tstate->exc_state.exc_traceback = tb;
  13084. #else
  13085. tmp_type = tstate->exc_type;
  13086. tmp_value = tstate->exc_value;
  13087. tmp_tb = tstate->exc_traceback;
  13088. tstate->exc_type = type;
  13089. tstate->exc_value = value;
  13090. tstate->exc_traceback = tb;
  13091. #endif
  13092. Py_XDECREF(tmp_type);
  13093. Py_XDECREF(tmp_value);
  13094. Py_XDECREF(tmp_tb);
  13095. }
  13096. #endif
  13097. /* PyErrExceptionMatches */
  13098. #if CYTHON_FAST_THREAD_STATE
  13099. static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  13100. Py_ssize_t i, n;
  13101. n = PyTuple_GET_SIZE(tuple);
  13102. #if PY_MAJOR_VERSION >= 3
  13103. for (i=0; i<n; i++) {
  13104. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  13105. }
  13106. #endif
  13107. for (i=0; i<n; i++) {
  13108. if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
  13109. }
  13110. return 0;
  13111. }
  13112. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  13113. PyObject *exc_type = tstate->curexc_type;
  13114. if (exc_type == err) return 1;
  13115. if (unlikely(!exc_type)) return 0;
  13116. if (unlikely(PyTuple_Check(err)))
  13117. return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
  13118. return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
  13119. }
  13120. #endif
  13121. /* GetException */
  13122. #if CYTHON_FAST_THREAD_STATE
  13123. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13124. #else
  13125. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
  13126. #endif
  13127. PyObject *local_type, *local_value, *local_tb;
  13128. #if CYTHON_FAST_THREAD_STATE
  13129. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13130. local_type = tstate->curexc_type;
  13131. local_value = tstate->curexc_value;
  13132. local_tb = tstate->curexc_traceback;
  13133. tstate->curexc_type = 0;
  13134. tstate->curexc_value = 0;
  13135. tstate->curexc_traceback = 0;
  13136. #else
  13137. PyErr_Fetch(&local_type, &local_value, &local_tb);
  13138. #endif
  13139. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  13140. #if CYTHON_FAST_THREAD_STATE
  13141. if (unlikely(tstate->curexc_type))
  13142. #else
  13143. if (unlikely(PyErr_Occurred()))
  13144. #endif
  13145. goto bad;
  13146. #if PY_MAJOR_VERSION >= 3
  13147. if (local_tb) {
  13148. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  13149. goto bad;
  13150. }
  13151. #endif
  13152. Py_XINCREF(local_tb);
  13153. Py_XINCREF(local_type);
  13154. Py_XINCREF(local_value);
  13155. *type = local_type;
  13156. *value = local_value;
  13157. *tb = local_tb;
  13158. #if CYTHON_FAST_THREAD_STATE
  13159. #if PY_VERSION_HEX >= 0x030700A3
  13160. tmp_type = tstate->exc_state.exc_type;
  13161. tmp_value = tstate->exc_state.exc_value;
  13162. tmp_tb = tstate->exc_state.exc_traceback;
  13163. tstate->exc_state.exc_type = local_type;
  13164. tstate->exc_state.exc_value = local_value;
  13165. tstate->exc_state.exc_traceback = local_tb;
  13166. #else
  13167. tmp_type = tstate->exc_type;
  13168. tmp_value = tstate->exc_value;
  13169. tmp_tb = tstate->exc_traceback;
  13170. tstate->exc_type = local_type;
  13171. tstate->exc_value = local_value;
  13172. tstate->exc_traceback = local_tb;
  13173. #endif
  13174. Py_XDECREF(tmp_type);
  13175. Py_XDECREF(tmp_value);
  13176. Py_XDECREF(tmp_tb);
  13177. #else
  13178. PyErr_SetExcInfo(local_type, local_value, local_tb);
  13179. #endif
  13180. return 0;
  13181. bad:
  13182. *type = 0;
  13183. *value = 0;
  13184. *tb = 0;
  13185. Py_XDECREF(local_type);
  13186. Py_XDECREF(local_value);
  13187. Py_XDECREF(local_tb);
  13188. return -1;
  13189. }
  13190. /* SwapException */
  13191. #if CYTHON_FAST_THREAD_STATE
  13192. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13193. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13194. #if PY_VERSION_HEX >= 0x030700A3
  13195. tmp_type = tstate->exc_state.exc_type;
  13196. tmp_value = tstate->exc_state.exc_value;
  13197. tmp_tb = tstate->exc_state.exc_traceback;
  13198. tstate->exc_state.exc_type = *type;
  13199. tstate->exc_state.exc_value = *value;
  13200. tstate->exc_state.exc_traceback = *tb;
  13201. #else
  13202. tmp_type = tstate->exc_type;
  13203. tmp_value = tstate->exc_value;
  13204. tmp_tb = tstate->exc_traceback;
  13205. tstate->exc_type = *type;
  13206. tstate->exc_value = *value;
  13207. tstate->exc_traceback = *tb;
  13208. #endif
  13209. *type = tmp_type;
  13210. *value = tmp_value;
  13211. *tb = tmp_tb;
  13212. }
  13213. #else
  13214. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  13215. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13216. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  13217. PyErr_SetExcInfo(*type, *value, *tb);
  13218. *type = tmp_type;
  13219. *value = tmp_value;
  13220. *tb = tmp_tb;
  13221. }
  13222. #endif
  13223. /* PyUnicode_Unicode */
  13224. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj) {
  13225. if (unlikely(obj == Py_None))
  13226. obj = __pyx_kp_u_None;
  13227. return __Pyx_NewRef(obj);
  13228. }
  13229. /* JoinPyUnicode */
  13230. static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
  13231. CYTHON_UNUSED Py_UCS4 max_char) {
  13232. #if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  13233. PyObject *result_uval;
  13234. int result_ukind;
  13235. Py_ssize_t i, char_pos;
  13236. void *result_udata;
  13237. #if CYTHON_PEP393_ENABLED
  13238. result_uval = PyUnicode_New(result_ulength, max_char);
  13239. if (unlikely(!result_uval)) return NULL;
  13240. result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
  13241. result_udata = PyUnicode_DATA(result_uval);
  13242. #else
  13243. result_uval = PyUnicode_FromUnicode(NULL, result_ulength);
  13244. if (unlikely(!result_uval)) return NULL;
  13245. result_ukind = sizeof(Py_UNICODE);
  13246. result_udata = PyUnicode_AS_UNICODE(result_uval);
  13247. #endif
  13248. char_pos = 0;
  13249. for (i=0; i < value_count; i++) {
  13250. int ukind;
  13251. Py_ssize_t ulength;
  13252. void *udata;
  13253. PyObject *uval = PyTuple_GET_ITEM(value_tuple, i);
  13254. if (unlikely(__Pyx_PyUnicode_READY(uval)))
  13255. goto bad;
  13256. ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
  13257. if (unlikely(!ulength))
  13258. continue;
  13259. if (unlikely(char_pos + ulength < 0))
  13260. goto overflow;
  13261. ukind = __Pyx_PyUnicode_KIND(uval);
  13262. udata = __Pyx_PyUnicode_DATA(uval);
  13263. if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
  13264. memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
  13265. } else {
  13266. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
  13267. _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
  13268. #else
  13269. Py_ssize_t j;
  13270. for (j=0; j < ulength; j++) {
  13271. Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
  13272. __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
  13273. }
  13274. #endif
  13275. }
  13276. char_pos += ulength;
  13277. }
  13278. return result_uval;
  13279. overflow:
  13280. PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
  13281. bad:
  13282. Py_DECREF(result_uval);
  13283. return NULL;
  13284. #else
  13285. result_ulength++;
  13286. value_count++;
  13287. return PyUnicode_Join(__pyx_empty_unicode, value_tuple);
  13288. #endif
  13289. }
  13290. /* FastTypeChecks */
  13291. #if CYTHON_COMPILING_IN_CPYTHON
  13292. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  13293. while (a) {
  13294. a = a->tp_base;
  13295. if (a == b)
  13296. return 1;
  13297. }
  13298. return b == &PyBaseObject_Type;
  13299. }
  13300. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  13301. PyObject *mro;
  13302. if (a == b) return 1;
  13303. mro = a->tp_mro;
  13304. if (likely(mro)) {
  13305. Py_ssize_t i, n;
  13306. n = PyTuple_GET_SIZE(mro);
  13307. for (i = 0; i < n; i++) {
  13308. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  13309. return 1;
  13310. }
  13311. return 0;
  13312. }
  13313. return __Pyx_InBases(a, b);
  13314. }
  13315. #if PY_MAJOR_VERSION == 2
  13316. static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
  13317. PyObject *exception, *value, *tb;
  13318. int res;
  13319. __Pyx_PyThreadState_declare
  13320. __Pyx_PyThreadState_assign
  13321. __Pyx_ErrFetch(&exception, &value, &tb);
  13322. res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
  13323. if (unlikely(res == -1)) {
  13324. PyErr_WriteUnraisable(err);
  13325. res = 0;
  13326. }
  13327. if (!res) {
  13328. res = PyObject_IsSubclass(err, exc_type2);
  13329. if (unlikely(res == -1)) {
  13330. PyErr_WriteUnraisable(err);
  13331. res = 0;
  13332. }
  13333. }
  13334. __Pyx_ErrRestore(exception, value, tb);
  13335. return res;
  13336. }
  13337. #else
  13338. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  13339. int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
  13340. if (!res) {
  13341. res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  13342. }
  13343. return res;
  13344. }
  13345. #endif
  13346. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  13347. Py_ssize_t i, n;
  13348. assert(PyExceptionClass_Check(exc_type));
  13349. n = PyTuple_GET_SIZE(tuple);
  13350. #if PY_MAJOR_VERSION >= 3
  13351. for (i=0; i<n; i++) {
  13352. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  13353. }
  13354. #endif
  13355. for (i=0; i<n; i++) {
  13356. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  13357. #if PY_MAJOR_VERSION < 3
  13358. if (likely(exc_type == t)) return 1;
  13359. #endif
  13360. if (likely(PyExceptionClass_Check(t))) {
  13361. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  13362. } else {
  13363. }
  13364. }
  13365. return 0;
  13366. }
  13367. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  13368. if (likely(err == exc_type)) return 1;
  13369. if (likely(PyExceptionClass_Check(err))) {
  13370. if (likely(PyExceptionClass_Check(exc_type))) {
  13371. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  13372. } else if (likely(PyTuple_Check(exc_type))) {
  13373. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  13374. } else {
  13375. }
  13376. }
  13377. return PyErr_GivenExceptionMatches(err, exc_type);
  13378. }
  13379. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  13380. assert(PyExceptionClass_Check(exc_type1));
  13381. assert(PyExceptionClass_Check(exc_type2));
  13382. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  13383. if (likely(PyExceptionClass_Check(err))) {
  13384. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  13385. }
  13386. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  13387. }
  13388. #endif
  13389. /* PyObjectSetAttrStr */
  13390. #if CYTHON_USE_TYPE_SLOTS
  13391. static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
  13392. PyTypeObject* tp = Py_TYPE(obj);
  13393. if (likely(tp->tp_setattro))
  13394. return tp->tp_setattro(obj, attr_name, value);
  13395. #if PY_MAJOR_VERSION < 3
  13396. if (likely(tp->tp_setattr))
  13397. return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
  13398. #endif
  13399. return PyObject_SetAttr(obj, attr_name, value);
  13400. }
  13401. #endif
  13402. /* PyIntBinop */
  13403. #if !CYTHON_COMPILING_IN_PYPY
  13404. static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
  13405. #if PY_MAJOR_VERSION < 3
  13406. if (likely(PyInt_CheckExact(op1))) {
  13407. const long b = intval;
  13408. long x;
  13409. long a = PyInt_AS_LONG(op1);
  13410. x = (long)((unsigned long)a + b);
  13411. if (likely((x^a) >= 0 || (x^b) >= 0))
  13412. return PyInt_FromLong(x);
  13413. return PyLong_Type.tp_as_number->nb_add(op1, op2);
  13414. }
  13415. #endif
  13416. #if CYTHON_USE_PYLONG_INTERNALS
  13417. if (likely(PyLong_CheckExact(op1))) {
  13418. const long b = intval;
  13419. long a, x;
  13420. #ifdef HAVE_LONG_LONG
  13421. const PY_LONG_LONG llb = intval;
  13422. PY_LONG_LONG lla, llx;
  13423. #endif
  13424. const digit* digits = ((PyLongObject*)op1)->ob_digit;
  13425. const Py_ssize_t size = Py_SIZE(op1);
  13426. if (likely(__Pyx_sst_abs(size) <= 1)) {
  13427. a = likely(size) ? digits[0] : 0;
  13428. if (size == -1) a = -a;
  13429. } else {
  13430. switch (size) {
  13431. case -2:
  13432. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  13433. a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13434. break;
  13435. #ifdef HAVE_LONG_LONG
  13436. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  13437. lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  13438. goto long_long;
  13439. #endif
  13440. }
  13441. CYTHON_FALLTHROUGH;
  13442. case 2:
  13443. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  13444. a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13445. break;
  13446. #ifdef HAVE_LONG_LONG
  13447. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  13448. lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  13449. goto long_long;
  13450. #endif
  13451. }
  13452. CYTHON_FALLTHROUGH;
  13453. case -3:
  13454. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  13455. a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13456. break;
  13457. #ifdef HAVE_LONG_LONG
  13458. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  13459. 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]));
  13460. goto long_long;
  13461. #endif
  13462. }
  13463. CYTHON_FALLTHROUGH;
  13464. case 3:
  13465. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  13466. a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13467. break;
  13468. #ifdef HAVE_LONG_LONG
  13469. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  13470. 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]));
  13471. goto long_long;
  13472. #endif
  13473. }
  13474. CYTHON_FALLTHROUGH;
  13475. case -4:
  13476. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  13477. a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13478. break;
  13479. #ifdef HAVE_LONG_LONG
  13480. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  13481. 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]));
  13482. goto long_long;
  13483. #endif
  13484. }
  13485. CYTHON_FALLTHROUGH;
  13486. case 4:
  13487. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  13488. a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13489. break;
  13490. #ifdef HAVE_LONG_LONG
  13491. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  13492. 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]));
  13493. goto long_long;
  13494. #endif
  13495. }
  13496. CYTHON_FALLTHROUGH;
  13497. default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
  13498. }
  13499. }
  13500. x = a + b;
  13501. return PyLong_FromLong(x);
  13502. #ifdef HAVE_LONG_LONG
  13503. long_long:
  13504. llx = lla + llb;
  13505. return PyLong_FromLongLong(llx);
  13506. #endif
  13507. }
  13508. #endif
  13509. if (PyFloat_CheckExact(op1)) {
  13510. const long b = intval;
  13511. double a = PyFloat_AS_DOUBLE(op1);
  13512. double result;
  13513. PyFPE_START_PROTECT("add", return NULL)
  13514. result = ((double)a) + (double)b;
  13515. PyFPE_END_PROTECT(result)
  13516. return PyFloat_FromDouble(result);
  13517. }
  13518. return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
  13519. }
  13520. #endif
  13521. /* DictGetItem */
  13522. #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
  13523. static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
  13524. PyObject *value;
  13525. value = PyDict_GetItemWithError(d, key);
  13526. if (unlikely(!value)) {
  13527. if (!PyErr_Occurred()) {
  13528. PyObject* args = PyTuple_Pack(1, key);
  13529. if (likely(args))
  13530. PyErr_SetObject(PyExc_KeyError, args);
  13531. Py_XDECREF(args);
  13532. }
  13533. return NULL;
  13534. }
  13535. Py_INCREF(value);
  13536. return value;
  13537. }
  13538. #endif
  13539. /* PyObject_GenericGetAttrNoDict */
  13540. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  13541. static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
  13542. PyErr_Format(PyExc_AttributeError,
  13543. #if PY_MAJOR_VERSION >= 3
  13544. "'%.50s' object has no attribute '%U'",
  13545. tp->tp_name, attr_name);
  13546. #else
  13547. "'%.50s' object has no attribute '%.400s'",
  13548. tp->tp_name, PyString_AS_STRING(attr_name));
  13549. #endif
  13550. return NULL;
  13551. }
  13552. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
  13553. PyObject *descr;
  13554. PyTypeObject *tp = Py_TYPE(obj);
  13555. if (unlikely(!PyString_Check(attr_name))) {
  13556. return PyObject_GenericGetAttr(obj, attr_name);
  13557. }
  13558. assert(!tp->tp_dictoffset);
  13559. descr = _PyType_Lookup(tp, attr_name);
  13560. if (unlikely(!descr)) {
  13561. return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
  13562. }
  13563. Py_INCREF(descr);
  13564. #if PY_MAJOR_VERSION < 3
  13565. if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
  13566. #endif
  13567. {
  13568. descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
  13569. if (unlikely(f)) {
  13570. PyObject *res = f(descr, obj, (PyObject *)tp);
  13571. Py_DECREF(descr);
  13572. return res;
  13573. }
  13574. }
  13575. return descr;
  13576. }
  13577. #endif
  13578. /* PyObject_GenericGetAttr */
  13579. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  13580. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
  13581. if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
  13582. return PyObject_GenericGetAttr(obj, attr_name);
  13583. }
  13584. return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
  13585. }
  13586. #endif
  13587. /* SetVTable */
  13588. static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
  13589. #if PY_VERSION_HEX >= 0x02070000
  13590. PyObject *ob = PyCapsule_New(vtable, 0, 0);
  13591. #else
  13592. PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
  13593. #endif
  13594. if (!ob)
  13595. goto bad;
  13596. if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
  13597. goto bad;
  13598. Py_DECREF(ob);
  13599. return 0;
  13600. bad:
  13601. Py_XDECREF(ob);
  13602. return -1;
  13603. }
  13604. /* SetupReduce */
  13605. static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  13606. int ret;
  13607. PyObject *name_attr;
  13608. name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  13609. if (likely(name_attr)) {
  13610. ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  13611. } else {
  13612. ret = -1;
  13613. }
  13614. if (unlikely(ret < 0)) {
  13615. PyErr_Clear();
  13616. ret = 0;
  13617. }
  13618. Py_XDECREF(name_attr);
  13619. return ret;
  13620. }
  13621. static int __Pyx_setup_reduce(PyObject* type_obj) {
  13622. int ret = 0;
  13623. PyObject *object_reduce = NULL;
  13624. PyObject *object_reduce_ex = NULL;
  13625. PyObject *reduce = NULL;
  13626. PyObject *reduce_ex = NULL;
  13627. PyObject *reduce_cython = NULL;
  13628. PyObject *setstate = NULL;
  13629. PyObject *setstate_cython = NULL;
  13630. #if CYTHON_USE_PYTYPE_LOOKUP
  13631. if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
  13632. #else
  13633. if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
  13634. #endif
  13635. #if CYTHON_USE_PYTYPE_LOOKUP
  13636. object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  13637. #else
  13638. object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  13639. #endif
  13640. reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
  13641. if (reduce_ex == object_reduce_ex) {
  13642. #if CYTHON_USE_PYTYPE_LOOKUP
  13643. object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  13644. #else
  13645. object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  13646. #endif
  13647. reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
  13648. if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
  13649. reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
  13650. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
  13651. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
  13652. setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
  13653. if (!setstate) PyErr_Clear();
  13654. if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
  13655. setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
  13656. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
  13657. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
  13658. }
  13659. PyType_Modified((PyTypeObject*)type_obj);
  13660. }
  13661. }
  13662. goto GOOD;
  13663. BAD:
  13664. if (!PyErr_Occurred())
  13665. PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
  13666. ret = -1;
  13667. GOOD:
  13668. #if !CYTHON_USE_PYTYPE_LOOKUP
  13669. Py_XDECREF(object_reduce);
  13670. Py_XDECREF(object_reduce_ex);
  13671. #endif
  13672. Py_XDECREF(reduce);
  13673. Py_XDECREF(reduce_ex);
  13674. Py_XDECREF(reduce_cython);
  13675. Py_XDECREF(setstate);
  13676. Py_XDECREF(setstate_cython);
  13677. return ret;
  13678. }
  13679. /* Import */
  13680. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  13681. PyObject *empty_list = 0;
  13682. PyObject *module = 0;
  13683. PyObject *global_dict = 0;
  13684. PyObject *empty_dict = 0;
  13685. PyObject *list;
  13686. #if PY_MAJOR_VERSION < 3
  13687. PyObject *py_import;
  13688. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  13689. if (!py_import)
  13690. goto bad;
  13691. #endif
  13692. if (from_list)
  13693. list = from_list;
  13694. else {
  13695. empty_list = PyList_New(0);
  13696. if (!empty_list)
  13697. goto bad;
  13698. list = empty_list;
  13699. }
  13700. global_dict = PyModule_GetDict(__pyx_m);
  13701. if (!global_dict)
  13702. goto bad;
  13703. empty_dict = PyDict_New();
  13704. if (!empty_dict)
  13705. goto bad;
  13706. {
  13707. #if PY_MAJOR_VERSION >= 3
  13708. if (level == -1) {
  13709. if (strchr(__Pyx_MODULE_NAME, '.')) {
  13710. module = PyImport_ImportModuleLevelObject(
  13711. name, global_dict, empty_dict, list, 1);
  13712. if (!module) {
  13713. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  13714. goto bad;
  13715. PyErr_Clear();
  13716. }
  13717. }
  13718. level = 0;
  13719. }
  13720. #endif
  13721. if (!module) {
  13722. #if PY_MAJOR_VERSION < 3
  13723. PyObject *py_level = PyInt_FromLong(level);
  13724. if (!py_level)
  13725. goto bad;
  13726. module = PyObject_CallFunctionObjArgs(py_import,
  13727. name, global_dict, empty_dict, list, py_level, NULL);
  13728. Py_DECREF(py_level);
  13729. #else
  13730. module = PyImport_ImportModuleLevelObject(
  13731. name, global_dict, empty_dict, list, level);
  13732. #endif
  13733. }
  13734. }
  13735. bad:
  13736. #if PY_MAJOR_VERSION < 3
  13737. Py_XDECREF(py_import);
  13738. #endif
  13739. Py_XDECREF(empty_list);
  13740. Py_XDECREF(empty_dict);
  13741. return module;
  13742. }
  13743. /* ImportFrom */
  13744. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  13745. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  13746. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  13747. PyErr_Format(PyExc_ImportError,
  13748. #if PY_MAJOR_VERSION < 3
  13749. "cannot import name %.230s", PyString_AS_STRING(name));
  13750. #else
  13751. "cannot import name %S", name);
  13752. #endif
  13753. }
  13754. return value;
  13755. }
  13756. /* CalculateMetaclass */
  13757. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
  13758. Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
  13759. for (i=0; i < nbases; i++) {
  13760. PyTypeObject *tmptype;
  13761. PyObject *tmp = PyTuple_GET_ITEM(bases, i);
  13762. tmptype = Py_TYPE(tmp);
  13763. #if PY_MAJOR_VERSION < 3
  13764. if (tmptype == &PyClass_Type)
  13765. continue;
  13766. #endif
  13767. if (!metaclass) {
  13768. metaclass = tmptype;
  13769. continue;
  13770. }
  13771. if (PyType_IsSubtype(metaclass, tmptype))
  13772. continue;
  13773. if (PyType_IsSubtype(tmptype, metaclass)) {
  13774. metaclass = tmptype;
  13775. continue;
  13776. }
  13777. PyErr_SetString(PyExc_TypeError,
  13778. "metaclass conflict: "
  13779. "the metaclass of a derived class "
  13780. "must be a (non-strict) subclass "
  13781. "of the metaclasses of all its bases");
  13782. return NULL;
  13783. }
  13784. if (!metaclass) {
  13785. #if PY_MAJOR_VERSION < 3
  13786. metaclass = &PyClass_Type;
  13787. #else
  13788. metaclass = &PyType_Type;
  13789. #endif
  13790. }
  13791. Py_INCREF((PyObject*) metaclass);
  13792. return (PyObject*) metaclass;
  13793. }
  13794. /* Py3ClassCreate */
  13795. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
  13796. PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
  13797. PyObject *ns;
  13798. if (metaclass) {
  13799. PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
  13800. if (prep) {
  13801. PyObject *pargs = PyTuple_Pack(2, name, bases);
  13802. if (unlikely(!pargs)) {
  13803. Py_DECREF(prep);
  13804. return NULL;
  13805. }
  13806. ns = PyObject_Call(prep, pargs, mkw);
  13807. Py_DECREF(prep);
  13808. Py_DECREF(pargs);
  13809. } else {
  13810. if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
  13811. return NULL;
  13812. PyErr_Clear();
  13813. ns = PyDict_New();
  13814. }
  13815. } else {
  13816. ns = PyDict_New();
  13817. }
  13818. if (unlikely(!ns))
  13819. return NULL;
  13820. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
  13821. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
  13822. if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
  13823. return ns;
  13824. bad:
  13825. Py_DECREF(ns);
  13826. return NULL;
  13827. }
  13828. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
  13829. PyObject *dict, PyObject *mkw,
  13830. int calculate_metaclass, int allow_py2_metaclass) {
  13831. PyObject *result, *margs;
  13832. PyObject *owned_metaclass = NULL;
  13833. if (allow_py2_metaclass) {
  13834. owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
  13835. if (owned_metaclass) {
  13836. metaclass = owned_metaclass;
  13837. } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
  13838. PyErr_Clear();
  13839. } else {
  13840. return NULL;
  13841. }
  13842. }
  13843. if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
  13844. metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
  13845. Py_XDECREF(owned_metaclass);
  13846. if (unlikely(!metaclass))
  13847. return NULL;
  13848. owned_metaclass = metaclass;
  13849. }
  13850. margs = PyTuple_Pack(3, name, bases, dict);
  13851. if (unlikely(!margs)) {
  13852. result = NULL;
  13853. } else {
  13854. result = PyObject_Call(metaclass, margs, mkw);
  13855. Py_DECREF(margs);
  13856. }
  13857. Py_XDECREF(owned_metaclass);
  13858. return result;
  13859. }
  13860. /* GetNameInClass */
  13861. static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
  13862. __Pyx_PyThreadState_declare
  13863. __Pyx_PyThreadState_assign
  13864. if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
  13865. return NULL;
  13866. __Pyx_PyErr_Clear();
  13867. return __Pyx_GetModuleGlobalName(name);
  13868. }
  13869. static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
  13870. PyObject *result;
  13871. result = __Pyx_PyObject_GetAttrStr(nmspace, name);
  13872. if (!result) {
  13873. result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
  13874. }
  13875. return result;
  13876. }
  13877. /* CLineInTraceback */
  13878. #ifndef CYTHON_CLINE_IN_TRACEBACK
  13879. static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
  13880. PyObject *use_cline;
  13881. PyObject *ptype, *pvalue, *ptraceback;
  13882. #if CYTHON_COMPILING_IN_CPYTHON
  13883. PyObject **cython_runtime_dict;
  13884. #endif
  13885. if (unlikely(!__pyx_cython_runtime)) {
  13886. return c_line;
  13887. }
  13888. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  13889. #if CYTHON_COMPILING_IN_CPYTHON
  13890. cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
  13891. if (likely(cython_runtime_dict)) {
  13892. use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
  13893. } else
  13894. #endif
  13895. {
  13896. PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
  13897. if (use_cline_obj) {
  13898. use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
  13899. Py_DECREF(use_cline_obj);
  13900. } else {
  13901. PyErr_Clear();
  13902. use_cline = NULL;
  13903. }
  13904. }
  13905. if (!use_cline) {
  13906. c_line = 0;
  13907. PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
  13908. }
  13909. else if (PyObject_Not(use_cline) != 0) {
  13910. c_line = 0;
  13911. }
  13912. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  13913. return c_line;
  13914. }
  13915. #endif
  13916. /* CodeObjectCache */
  13917. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  13918. int start = 0, mid = 0, end = count - 1;
  13919. if (end >= 0 && code_line > entries[end].code_line) {
  13920. return count;
  13921. }
  13922. while (start < end) {
  13923. mid = start + (end - start) / 2;
  13924. if (code_line < entries[mid].code_line) {
  13925. end = mid;
  13926. } else if (code_line > entries[mid].code_line) {
  13927. start = mid + 1;
  13928. } else {
  13929. return mid;
  13930. }
  13931. }
  13932. if (code_line <= entries[mid].code_line) {
  13933. return mid;
  13934. } else {
  13935. return mid + 1;
  13936. }
  13937. }
  13938. static PyCodeObject *__pyx_find_code_object(int code_line) {
  13939. PyCodeObject* code_object;
  13940. int pos;
  13941. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  13942. return NULL;
  13943. }
  13944. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  13945. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  13946. return NULL;
  13947. }
  13948. code_object = __pyx_code_cache.entries[pos].code_object;
  13949. Py_INCREF(code_object);
  13950. return code_object;
  13951. }
  13952. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  13953. int pos, i;
  13954. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  13955. if (unlikely(!code_line)) {
  13956. return;
  13957. }
  13958. if (unlikely(!entries)) {
  13959. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  13960. if (likely(entries)) {
  13961. __pyx_code_cache.entries = entries;
  13962. __pyx_code_cache.max_count = 64;
  13963. __pyx_code_cache.count = 1;
  13964. entries[0].code_line = code_line;
  13965. entries[0].code_object = code_object;
  13966. Py_INCREF(code_object);
  13967. }
  13968. return;
  13969. }
  13970. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  13971. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  13972. PyCodeObject* tmp = entries[pos].code_object;
  13973. entries[pos].code_object = code_object;
  13974. Py_DECREF(tmp);
  13975. return;
  13976. }
  13977. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  13978. int new_max = __pyx_code_cache.max_count + 64;
  13979. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  13980. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  13981. if (unlikely(!entries)) {
  13982. return;
  13983. }
  13984. __pyx_code_cache.entries = entries;
  13985. __pyx_code_cache.max_count = new_max;
  13986. }
  13987. for (i=__pyx_code_cache.count; i>pos; i--) {
  13988. entries[i] = entries[i-1];
  13989. }
  13990. entries[pos].code_line = code_line;
  13991. entries[pos].code_object = code_object;
  13992. __pyx_code_cache.count++;
  13993. Py_INCREF(code_object);
  13994. }
  13995. /* AddTraceback */
  13996. #include "compile.h"
  13997. #include "frameobject.h"
  13998. #include "traceback.h"
  13999. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  14000. const char *funcname, int c_line,
  14001. int py_line, const char *filename) {
  14002. PyCodeObject *py_code = 0;
  14003. PyObject *py_srcfile = 0;
  14004. PyObject *py_funcname = 0;
  14005. #if PY_MAJOR_VERSION < 3
  14006. py_srcfile = PyString_FromString(filename);
  14007. #else
  14008. py_srcfile = PyUnicode_FromString(filename);
  14009. #endif
  14010. if (!py_srcfile) goto bad;
  14011. if (c_line) {
  14012. #if PY_MAJOR_VERSION < 3
  14013. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  14014. #else
  14015. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  14016. #endif
  14017. }
  14018. else {
  14019. #if PY_MAJOR_VERSION < 3
  14020. py_funcname = PyString_FromString(funcname);
  14021. #else
  14022. py_funcname = PyUnicode_FromString(funcname);
  14023. #endif
  14024. }
  14025. if (!py_funcname) goto bad;
  14026. py_code = __Pyx_PyCode_New(
  14027. 0,
  14028. 0,
  14029. 0,
  14030. 0,
  14031. 0,
  14032. __pyx_empty_bytes, /*PyObject *code,*/
  14033. __pyx_empty_tuple, /*PyObject *consts,*/
  14034. __pyx_empty_tuple, /*PyObject *names,*/
  14035. __pyx_empty_tuple, /*PyObject *varnames,*/
  14036. __pyx_empty_tuple, /*PyObject *freevars,*/
  14037. __pyx_empty_tuple, /*PyObject *cellvars,*/
  14038. py_srcfile, /*PyObject *filename,*/
  14039. py_funcname, /*PyObject *name,*/
  14040. py_line,
  14041. __pyx_empty_bytes /*PyObject *lnotab*/
  14042. );
  14043. Py_DECREF(py_srcfile);
  14044. Py_DECREF(py_funcname);
  14045. return py_code;
  14046. bad:
  14047. Py_XDECREF(py_srcfile);
  14048. Py_XDECREF(py_funcname);
  14049. return NULL;
  14050. }
  14051. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  14052. int py_line, const char *filename) {
  14053. PyCodeObject *py_code = 0;
  14054. PyFrameObject *py_frame = 0;
  14055. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  14056. if (c_line) {
  14057. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  14058. }
  14059. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  14060. if (!py_code) {
  14061. py_code = __Pyx_CreateCodeObjectForTraceback(
  14062. funcname, c_line, py_line, filename);
  14063. if (!py_code) goto bad;
  14064. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  14065. }
  14066. py_frame = PyFrame_New(
  14067. tstate, /*PyThreadState *tstate,*/
  14068. py_code, /*PyCodeObject *code,*/
  14069. __pyx_d, /*PyObject *globals,*/
  14070. 0 /*PyObject *locals*/
  14071. );
  14072. if (!py_frame) goto bad;
  14073. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  14074. PyTraceBack_Here(py_frame);
  14075. bad:
  14076. Py_XDECREF(py_code);
  14077. Py_XDECREF(py_frame);
  14078. }
  14079. /* CIntToPy */
  14080. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
  14081. const int neg_one = (int) -1, const_zero = (int) 0;
  14082. const int is_unsigned = neg_one > const_zero;
  14083. if (is_unsigned) {
  14084. if (sizeof(int) < sizeof(long)) {
  14085. return PyInt_FromLong((long) value);
  14086. } else if (sizeof(int) <= sizeof(unsigned long)) {
  14087. return PyLong_FromUnsignedLong((unsigned long) value);
  14088. #ifdef HAVE_LONG_LONG
  14089. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  14090. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14091. #endif
  14092. }
  14093. } else {
  14094. if (sizeof(int) <= sizeof(long)) {
  14095. return PyInt_FromLong((long) value);
  14096. #ifdef HAVE_LONG_LONG
  14097. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  14098. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14099. #endif
  14100. }
  14101. }
  14102. {
  14103. int one = 1; int little = (int)*(unsigned char *)&one;
  14104. unsigned char *bytes = (unsigned char *)&value;
  14105. return _PyLong_FromByteArray(bytes, sizeof(int),
  14106. little, !is_unsigned);
  14107. }
  14108. }
  14109. /* CIntToPy */
  14110. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
  14111. const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
  14112. const int is_unsigned = neg_one > const_zero;
  14113. if (is_unsigned) {
  14114. if (sizeof(unsigned int) < sizeof(long)) {
  14115. return PyInt_FromLong((long) value);
  14116. } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
  14117. return PyLong_FromUnsignedLong((unsigned long) value);
  14118. #ifdef HAVE_LONG_LONG
  14119. } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
  14120. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14121. #endif
  14122. }
  14123. } else {
  14124. if (sizeof(unsigned int) <= sizeof(long)) {
  14125. return PyInt_FromLong((long) value);
  14126. #ifdef HAVE_LONG_LONG
  14127. } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
  14128. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14129. #endif
  14130. }
  14131. }
  14132. {
  14133. int one = 1; int little = (int)*(unsigned char *)&one;
  14134. unsigned char *bytes = (unsigned char *)&value;
  14135. return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
  14136. little, !is_unsigned);
  14137. }
  14138. }
  14139. /* CIntToPy */
  14140. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) {
  14141. const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0;
  14142. const int is_unsigned = neg_one > const_zero;
  14143. if (is_unsigned) {
  14144. if (sizeof(unsigned long) < sizeof(long)) {
  14145. return PyInt_FromLong((long) value);
  14146. } else if (sizeof(unsigned long) <= sizeof(unsigned long)) {
  14147. return PyLong_FromUnsignedLong((unsigned long) value);
  14148. #ifdef HAVE_LONG_LONG
  14149. } else if (sizeof(unsigned long) <= sizeof(unsigned PY_LONG_LONG)) {
  14150. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14151. #endif
  14152. }
  14153. } else {
  14154. if (sizeof(unsigned long) <= sizeof(long)) {
  14155. return PyInt_FromLong((long) value);
  14156. #ifdef HAVE_LONG_LONG
  14157. } else if (sizeof(unsigned long) <= sizeof(PY_LONG_LONG)) {
  14158. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14159. #endif
  14160. }
  14161. }
  14162. {
  14163. int one = 1; int little = (int)*(unsigned char *)&one;
  14164. unsigned char *bytes = (unsigned char *)&value;
  14165. return _PyLong_FromByteArray(bytes, sizeof(unsigned long),
  14166. little, !is_unsigned);
  14167. }
  14168. }
  14169. /* CIntFromPyVerify */
  14170. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  14171. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  14172. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  14173. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  14174. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  14175. {\
  14176. func_type value = func_value;\
  14177. if (sizeof(target_type) < sizeof(func_type)) {\
  14178. if (unlikely(value != (func_type) (target_type) value)) {\
  14179. func_type zero = 0;\
  14180. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  14181. return (target_type) -1;\
  14182. if (is_unsigned && unlikely(value < zero))\
  14183. goto raise_neg_overflow;\
  14184. else\
  14185. goto raise_overflow;\
  14186. }\
  14187. }\
  14188. return (target_type) value;\
  14189. }
  14190. /* CIntToPy */
  14191. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  14192. const long neg_one = (long) -1, const_zero = (long) 0;
  14193. const int is_unsigned = neg_one > const_zero;
  14194. if (is_unsigned) {
  14195. if (sizeof(long) < sizeof(long)) {
  14196. return PyInt_FromLong((long) value);
  14197. } else if (sizeof(long) <= sizeof(unsigned long)) {
  14198. return PyLong_FromUnsignedLong((unsigned long) value);
  14199. #ifdef HAVE_LONG_LONG
  14200. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  14201. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14202. #endif
  14203. }
  14204. } else {
  14205. if (sizeof(long) <= sizeof(long)) {
  14206. return PyInt_FromLong((long) value);
  14207. #ifdef HAVE_LONG_LONG
  14208. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  14209. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14210. #endif
  14211. }
  14212. }
  14213. {
  14214. int one = 1; int little = (int)*(unsigned char *)&one;
  14215. unsigned char *bytes = (unsigned char *)&value;
  14216. return _PyLong_FromByteArray(bytes, sizeof(long),
  14217. little, !is_unsigned);
  14218. }
  14219. }
  14220. /* CIntToPy */
  14221. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_MDB_dbi(MDB_dbi value) {
  14222. const MDB_dbi neg_one = (MDB_dbi) -1, const_zero = (MDB_dbi) 0;
  14223. const int is_unsigned = neg_one > const_zero;
  14224. if (is_unsigned) {
  14225. if (sizeof(MDB_dbi) < sizeof(long)) {
  14226. return PyInt_FromLong((long) value);
  14227. } else if (sizeof(MDB_dbi) <= sizeof(unsigned long)) {
  14228. return PyLong_FromUnsignedLong((unsigned long) value);
  14229. #ifdef HAVE_LONG_LONG
  14230. } else if (sizeof(MDB_dbi) <= sizeof(unsigned PY_LONG_LONG)) {
  14231. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14232. #endif
  14233. }
  14234. } else {
  14235. if (sizeof(MDB_dbi) <= sizeof(long)) {
  14236. return PyInt_FromLong((long) value);
  14237. #ifdef HAVE_LONG_LONG
  14238. } else if (sizeof(MDB_dbi) <= sizeof(PY_LONG_LONG)) {
  14239. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14240. #endif
  14241. }
  14242. }
  14243. {
  14244. int one = 1; int little = (int)*(unsigned char *)&one;
  14245. unsigned char *bytes = (unsigned char *)&value;
  14246. return _PyLong_FromByteArray(bytes, sizeof(MDB_dbi),
  14247. little, !is_unsigned);
  14248. }
  14249. }
  14250. static PyObject* __pyx_convert__to_py_struct__MDB_stat(struct MDB_stat s) {
  14251. PyObject* res;
  14252. PyObject* member;
  14253. res = __Pyx_PyDict_NewPresized(6); if (unlikely(!res)) return NULL;
  14254. member = __Pyx_PyInt_From_unsigned_int(s.ms_psize); if (unlikely(!member)) goto bad;
  14255. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_psize, member) < 0)) goto bad;
  14256. Py_DECREF(member);
  14257. member = __Pyx_PyInt_From_unsigned_int(s.ms_depth); if (unlikely(!member)) goto bad;
  14258. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_depth, member) < 0)) goto bad;
  14259. Py_DECREF(member);
  14260. member = __Pyx_PyInt_FromSize_t(s.ms_branch_pages); if (unlikely(!member)) goto bad;
  14261. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_branch_pages, member) < 0)) goto bad;
  14262. Py_DECREF(member);
  14263. member = __Pyx_PyInt_FromSize_t(s.ms_leaf_pages); if (unlikely(!member)) goto bad;
  14264. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_leaf_pages, member) < 0)) goto bad;
  14265. Py_DECREF(member);
  14266. member = __Pyx_PyInt_FromSize_t(s.ms_overflow_pages); if (unlikely(!member)) goto bad;
  14267. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_overflow_pages, member) < 0)) goto bad;
  14268. Py_DECREF(member);
  14269. member = __Pyx_PyInt_FromSize_t(s.ms_entries); if (unlikely(!member)) goto bad;
  14270. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_entries, member) < 0)) goto bad;
  14271. Py_DECREF(member);
  14272. return res;
  14273. bad:
  14274. Py_XDECREF(member);
  14275. Py_DECREF(res);
  14276. return NULL;
  14277. }
  14278. /* CIntFromPy */
  14279. static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
  14280. const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
  14281. const int is_unsigned = neg_one > const_zero;
  14282. #if PY_MAJOR_VERSION < 3
  14283. if (likely(PyInt_Check(x))) {
  14284. if (sizeof(size_t) < sizeof(long)) {
  14285. __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
  14286. } else {
  14287. long val = PyInt_AS_LONG(x);
  14288. if (is_unsigned && unlikely(val < 0)) {
  14289. goto raise_neg_overflow;
  14290. }
  14291. return (size_t) val;
  14292. }
  14293. } else
  14294. #endif
  14295. if (likely(PyLong_Check(x))) {
  14296. if (is_unsigned) {
  14297. #if CYTHON_USE_PYLONG_INTERNALS
  14298. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14299. switch (Py_SIZE(x)) {
  14300. case 0: return (size_t) 0;
  14301. case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
  14302. case 2:
  14303. if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
  14304. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14305. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14306. } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
  14307. return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14308. }
  14309. }
  14310. break;
  14311. case 3:
  14312. if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
  14313. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14314. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14315. } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
  14316. return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14317. }
  14318. }
  14319. break;
  14320. case 4:
  14321. if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
  14322. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14323. __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])))
  14324. } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
  14325. 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]));
  14326. }
  14327. }
  14328. break;
  14329. }
  14330. #endif
  14331. #if CYTHON_COMPILING_IN_CPYTHON
  14332. if (unlikely(Py_SIZE(x) < 0)) {
  14333. goto raise_neg_overflow;
  14334. }
  14335. #else
  14336. {
  14337. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14338. if (unlikely(result < 0))
  14339. return (size_t) -1;
  14340. if (unlikely(result == 1))
  14341. goto raise_neg_overflow;
  14342. }
  14343. #endif
  14344. if (sizeof(size_t) <= sizeof(unsigned long)) {
  14345. __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
  14346. #ifdef HAVE_LONG_LONG
  14347. } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
  14348. __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14349. #endif
  14350. }
  14351. } else {
  14352. #if CYTHON_USE_PYLONG_INTERNALS
  14353. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14354. switch (Py_SIZE(x)) {
  14355. case 0: return (size_t) 0;
  14356. case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
  14357. case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0])
  14358. case -2:
  14359. if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
  14360. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14361. __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14362. } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14363. return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14364. }
  14365. }
  14366. break;
  14367. case 2:
  14368. if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
  14369. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14370. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14371. } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14372. return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14373. }
  14374. }
  14375. break;
  14376. case -3:
  14377. if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14378. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14379. __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14380. } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14381. return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14382. }
  14383. }
  14384. break;
  14385. case 3:
  14386. if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
  14387. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14388. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14389. } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14390. return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14391. }
  14392. }
  14393. break;
  14394. case -4:
  14395. if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14396. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14397. __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])))
  14398. } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
  14399. 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])));
  14400. }
  14401. }
  14402. break;
  14403. case 4:
  14404. if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
  14405. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14406. __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])))
  14407. } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
  14408. 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])));
  14409. }
  14410. }
  14411. break;
  14412. }
  14413. #endif
  14414. if (sizeof(size_t) <= sizeof(long)) {
  14415. __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
  14416. #ifdef HAVE_LONG_LONG
  14417. } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
  14418. __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
  14419. #endif
  14420. }
  14421. }
  14422. {
  14423. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14424. PyErr_SetString(PyExc_RuntimeError,
  14425. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14426. #else
  14427. size_t val;
  14428. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14429. #if PY_MAJOR_VERSION < 3
  14430. if (likely(v) && !PyLong_Check(v)) {
  14431. PyObject *tmp = v;
  14432. v = PyNumber_Long(tmp);
  14433. Py_DECREF(tmp);
  14434. }
  14435. #endif
  14436. if (likely(v)) {
  14437. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14438. unsigned char *bytes = (unsigned char *)&val;
  14439. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14440. bytes, sizeof(val),
  14441. is_little, !is_unsigned);
  14442. Py_DECREF(v);
  14443. if (likely(!ret))
  14444. return val;
  14445. }
  14446. #endif
  14447. return (size_t) -1;
  14448. }
  14449. } else {
  14450. size_t val;
  14451. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14452. if (!tmp) return (size_t) -1;
  14453. val = __Pyx_PyInt_As_size_t(tmp);
  14454. Py_DECREF(tmp);
  14455. return val;
  14456. }
  14457. raise_overflow:
  14458. PyErr_SetString(PyExc_OverflowError,
  14459. "value too large to convert to size_t");
  14460. return (size_t) -1;
  14461. raise_neg_overflow:
  14462. PyErr_SetString(PyExc_OverflowError,
  14463. "can't convert negative value to size_t");
  14464. return (size_t) -1;
  14465. }
  14466. /* CIntFromPy */
  14467. static CYTHON_INLINE MDB_dbi __Pyx_PyInt_As_MDB_dbi(PyObject *x) {
  14468. const MDB_dbi neg_one = (MDB_dbi) -1, const_zero = (MDB_dbi) 0;
  14469. const int is_unsigned = neg_one > const_zero;
  14470. #if PY_MAJOR_VERSION < 3
  14471. if (likely(PyInt_Check(x))) {
  14472. if (sizeof(MDB_dbi) < sizeof(long)) {
  14473. __PYX_VERIFY_RETURN_INT(MDB_dbi, long, PyInt_AS_LONG(x))
  14474. } else {
  14475. long val = PyInt_AS_LONG(x);
  14476. if (is_unsigned && unlikely(val < 0)) {
  14477. goto raise_neg_overflow;
  14478. }
  14479. return (MDB_dbi) val;
  14480. }
  14481. } else
  14482. #endif
  14483. if (likely(PyLong_Check(x))) {
  14484. if (is_unsigned) {
  14485. #if CYTHON_USE_PYLONG_INTERNALS
  14486. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14487. switch (Py_SIZE(x)) {
  14488. case 0: return (MDB_dbi) 0;
  14489. case 1: __PYX_VERIFY_RETURN_INT(MDB_dbi, digit, digits[0])
  14490. case 2:
  14491. if (8 * sizeof(MDB_dbi) > 1 * PyLong_SHIFT) {
  14492. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14493. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14494. } else if (8 * sizeof(MDB_dbi) >= 2 * PyLong_SHIFT) {
  14495. return (MDB_dbi) (((((MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0]));
  14496. }
  14497. }
  14498. break;
  14499. case 3:
  14500. if (8 * sizeof(MDB_dbi) > 2 * PyLong_SHIFT) {
  14501. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14502. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14503. } else if (8 * sizeof(MDB_dbi) >= 3 * PyLong_SHIFT) {
  14504. return (MDB_dbi) (((((((MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0]));
  14505. }
  14506. }
  14507. break;
  14508. case 4:
  14509. if (8 * sizeof(MDB_dbi) > 3 * PyLong_SHIFT) {
  14510. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14511. __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])))
  14512. } else if (8 * sizeof(MDB_dbi) >= 4 * PyLong_SHIFT) {
  14513. 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]));
  14514. }
  14515. }
  14516. break;
  14517. }
  14518. #endif
  14519. #if CYTHON_COMPILING_IN_CPYTHON
  14520. if (unlikely(Py_SIZE(x) < 0)) {
  14521. goto raise_neg_overflow;
  14522. }
  14523. #else
  14524. {
  14525. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14526. if (unlikely(result < 0))
  14527. return (MDB_dbi) -1;
  14528. if (unlikely(result == 1))
  14529. goto raise_neg_overflow;
  14530. }
  14531. #endif
  14532. if (sizeof(MDB_dbi) <= sizeof(unsigned long)) {
  14533. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, unsigned long, PyLong_AsUnsignedLong(x))
  14534. #ifdef HAVE_LONG_LONG
  14535. } else if (sizeof(MDB_dbi) <= sizeof(unsigned PY_LONG_LONG)) {
  14536. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14537. #endif
  14538. }
  14539. } else {
  14540. #if CYTHON_USE_PYLONG_INTERNALS
  14541. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14542. switch (Py_SIZE(x)) {
  14543. case 0: return (MDB_dbi) 0;
  14544. case -1: __PYX_VERIFY_RETURN_INT(MDB_dbi, sdigit, (sdigit) (-(sdigit)digits[0]))
  14545. case 1: __PYX_VERIFY_RETURN_INT(MDB_dbi, digit, +digits[0])
  14546. case -2:
  14547. if (8 * sizeof(MDB_dbi) - 1 > 1 * PyLong_SHIFT) {
  14548. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14549. __PYX_VERIFY_RETURN_INT(MDB_dbi, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14550. } else if (8 * sizeof(MDB_dbi) - 1 > 2 * PyLong_SHIFT) {
  14551. return (MDB_dbi) (((MDB_dbi)-1)*(((((MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14552. }
  14553. }
  14554. break;
  14555. case 2:
  14556. if (8 * sizeof(MDB_dbi) > 1 * PyLong_SHIFT) {
  14557. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14558. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14559. } else if (8 * sizeof(MDB_dbi) - 1 > 2 * PyLong_SHIFT) {
  14560. return (MDB_dbi) ((((((MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14561. }
  14562. }
  14563. break;
  14564. case -3:
  14565. if (8 * sizeof(MDB_dbi) - 1 > 2 * PyLong_SHIFT) {
  14566. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14567. __PYX_VERIFY_RETURN_INT(MDB_dbi, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14568. } else if (8 * sizeof(MDB_dbi) - 1 > 3 * PyLong_SHIFT) {
  14569. return (MDB_dbi) (((MDB_dbi)-1)*(((((((MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14570. }
  14571. }
  14572. break;
  14573. case 3:
  14574. if (8 * sizeof(MDB_dbi) > 2 * PyLong_SHIFT) {
  14575. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14576. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14577. } else if (8 * sizeof(MDB_dbi) - 1 > 3 * PyLong_SHIFT) {
  14578. return (MDB_dbi) ((((((((MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14579. }
  14580. }
  14581. break;
  14582. case -4:
  14583. if (8 * sizeof(MDB_dbi) - 1 > 3 * PyLong_SHIFT) {
  14584. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14585. __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])))
  14586. } else if (8 * sizeof(MDB_dbi) - 1 > 4 * PyLong_SHIFT) {
  14587. 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])));
  14588. }
  14589. }
  14590. break;
  14591. case 4:
  14592. if (8 * sizeof(MDB_dbi) > 3 * PyLong_SHIFT) {
  14593. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14594. __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])))
  14595. } else if (8 * sizeof(MDB_dbi) - 1 > 4 * PyLong_SHIFT) {
  14596. 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])));
  14597. }
  14598. }
  14599. break;
  14600. }
  14601. #endif
  14602. if (sizeof(MDB_dbi) <= sizeof(long)) {
  14603. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, long, PyLong_AsLong(x))
  14604. #ifdef HAVE_LONG_LONG
  14605. } else if (sizeof(MDB_dbi) <= sizeof(PY_LONG_LONG)) {
  14606. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, PY_LONG_LONG, PyLong_AsLongLong(x))
  14607. #endif
  14608. }
  14609. }
  14610. {
  14611. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14612. PyErr_SetString(PyExc_RuntimeError,
  14613. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14614. #else
  14615. MDB_dbi val;
  14616. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14617. #if PY_MAJOR_VERSION < 3
  14618. if (likely(v) && !PyLong_Check(v)) {
  14619. PyObject *tmp = v;
  14620. v = PyNumber_Long(tmp);
  14621. Py_DECREF(tmp);
  14622. }
  14623. #endif
  14624. if (likely(v)) {
  14625. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14626. unsigned char *bytes = (unsigned char *)&val;
  14627. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14628. bytes, sizeof(val),
  14629. is_little, !is_unsigned);
  14630. Py_DECREF(v);
  14631. if (likely(!ret))
  14632. return val;
  14633. }
  14634. #endif
  14635. return (MDB_dbi) -1;
  14636. }
  14637. } else {
  14638. MDB_dbi val;
  14639. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14640. if (!tmp) return (MDB_dbi) -1;
  14641. val = __Pyx_PyInt_As_MDB_dbi(tmp);
  14642. Py_DECREF(tmp);
  14643. return val;
  14644. }
  14645. raise_overflow:
  14646. PyErr_SetString(PyExc_OverflowError,
  14647. "value too large to convert to MDB_dbi");
  14648. return (MDB_dbi) -1;
  14649. raise_neg_overflow:
  14650. PyErr_SetString(PyExc_OverflowError,
  14651. "can't convert negative value to MDB_dbi");
  14652. return (MDB_dbi) -1;
  14653. }
  14654. /* CIntFromPy */
  14655. static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) {
  14656. const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
  14657. const int is_unsigned = neg_one > const_zero;
  14658. #if PY_MAJOR_VERSION < 3
  14659. if (likely(PyInt_Check(x))) {
  14660. if (sizeof(unsigned int) < sizeof(long)) {
  14661. __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x))
  14662. } else {
  14663. long val = PyInt_AS_LONG(x);
  14664. if (is_unsigned && unlikely(val < 0)) {
  14665. goto raise_neg_overflow;
  14666. }
  14667. return (unsigned int) val;
  14668. }
  14669. } else
  14670. #endif
  14671. if (likely(PyLong_Check(x))) {
  14672. if (is_unsigned) {
  14673. #if CYTHON_USE_PYLONG_INTERNALS
  14674. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14675. switch (Py_SIZE(x)) {
  14676. case 0: return (unsigned int) 0;
  14677. case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0])
  14678. case 2:
  14679. if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
  14680. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14681. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14682. } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) {
  14683. return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
  14684. }
  14685. }
  14686. break;
  14687. case 3:
  14688. if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
  14689. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14690. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14691. } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) {
  14692. return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
  14693. }
  14694. }
  14695. break;
  14696. case 4:
  14697. if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
  14698. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14699. __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])))
  14700. } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) {
  14701. 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]));
  14702. }
  14703. }
  14704. break;
  14705. }
  14706. #endif
  14707. #if CYTHON_COMPILING_IN_CPYTHON
  14708. if (unlikely(Py_SIZE(x) < 0)) {
  14709. goto raise_neg_overflow;
  14710. }
  14711. #else
  14712. {
  14713. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14714. if (unlikely(result < 0))
  14715. return (unsigned int) -1;
  14716. if (unlikely(result == 1))
  14717. goto raise_neg_overflow;
  14718. }
  14719. #endif
  14720. if (sizeof(unsigned int) <= sizeof(unsigned long)) {
  14721. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x))
  14722. #ifdef HAVE_LONG_LONG
  14723. } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
  14724. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14725. #endif
  14726. }
  14727. } else {
  14728. #if CYTHON_USE_PYLONG_INTERNALS
  14729. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14730. switch (Py_SIZE(x)) {
  14731. case 0: return (unsigned int) 0;
  14732. case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0]))
  14733. case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0])
  14734. case -2:
  14735. if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) {
  14736. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14737. __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14738. } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
  14739. return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14740. }
  14741. }
  14742. break;
  14743. case 2:
  14744. if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
  14745. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14746. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14747. } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
  14748. return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14749. }
  14750. }
  14751. break;
  14752. case -3:
  14753. if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
  14754. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14755. __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14756. } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
  14757. return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14758. }
  14759. }
  14760. break;
  14761. case 3:
  14762. if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
  14763. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14764. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14765. } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
  14766. return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14767. }
  14768. }
  14769. break;
  14770. case -4:
  14771. if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
  14772. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14773. __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])))
  14774. } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
  14775. 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])));
  14776. }
  14777. }
  14778. break;
  14779. case 4:
  14780. if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
  14781. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14782. __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])))
  14783. } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
  14784. 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])));
  14785. }
  14786. }
  14787. break;
  14788. }
  14789. #endif
  14790. if (sizeof(unsigned int) <= sizeof(long)) {
  14791. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x))
  14792. #ifdef HAVE_LONG_LONG
  14793. } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
  14794. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x))
  14795. #endif
  14796. }
  14797. }
  14798. {
  14799. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14800. PyErr_SetString(PyExc_RuntimeError,
  14801. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14802. #else
  14803. unsigned int val;
  14804. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14805. #if PY_MAJOR_VERSION < 3
  14806. if (likely(v) && !PyLong_Check(v)) {
  14807. PyObject *tmp = v;
  14808. v = PyNumber_Long(tmp);
  14809. Py_DECREF(tmp);
  14810. }
  14811. #endif
  14812. if (likely(v)) {
  14813. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14814. unsigned char *bytes = (unsigned char *)&val;
  14815. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14816. bytes, sizeof(val),
  14817. is_little, !is_unsigned);
  14818. Py_DECREF(v);
  14819. if (likely(!ret))
  14820. return val;
  14821. }
  14822. #endif
  14823. return (unsigned int) -1;
  14824. }
  14825. } else {
  14826. unsigned int val;
  14827. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14828. if (!tmp) return (unsigned int) -1;
  14829. val = __Pyx_PyInt_As_unsigned_int(tmp);
  14830. Py_DECREF(tmp);
  14831. return val;
  14832. }
  14833. raise_overflow:
  14834. PyErr_SetString(PyExc_OverflowError,
  14835. "value too large to convert to unsigned int");
  14836. return (unsigned int) -1;
  14837. raise_neg_overflow:
  14838. PyErr_SetString(PyExc_OverflowError,
  14839. "can't convert negative value to unsigned int");
  14840. return (unsigned int) -1;
  14841. }
  14842. /* CIntFromPy */
  14843. static CYTHON_INLINE mode_t __Pyx_PyInt_As_mode_t(PyObject *x) {
  14844. const mode_t neg_one = (mode_t) -1, const_zero = (mode_t) 0;
  14845. const int is_unsigned = neg_one > const_zero;
  14846. #if PY_MAJOR_VERSION < 3
  14847. if (likely(PyInt_Check(x))) {
  14848. if (sizeof(mode_t) < sizeof(long)) {
  14849. __PYX_VERIFY_RETURN_INT(mode_t, long, PyInt_AS_LONG(x))
  14850. } else {
  14851. long val = PyInt_AS_LONG(x);
  14852. if (is_unsigned && unlikely(val < 0)) {
  14853. goto raise_neg_overflow;
  14854. }
  14855. return (mode_t) val;
  14856. }
  14857. } else
  14858. #endif
  14859. if (likely(PyLong_Check(x))) {
  14860. if (is_unsigned) {
  14861. #if CYTHON_USE_PYLONG_INTERNALS
  14862. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14863. switch (Py_SIZE(x)) {
  14864. case 0: return (mode_t) 0;
  14865. case 1: __PYX_VERIFY_RETURN_INT(mode_t, digit, digits[0])
  14866. case 2:
  14867. if (8 * sizeof(mode_t) > 1 * PyLong_SHIFT) {
  14868. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14869. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14870. } else if (8 * sizeof(mode_t) >= 2 * PyLong_SHIFT) {
  14871. return (mode_t) (((((mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0]));
  14872. }
  14873. }
  14874. break;
  14875. case 3:
  14876. if (8 * sizeof(mode_t) > 2 * PyLong_SHIFT) {
  14877. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14878. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14879. } else if (8 * sizeof(mode_t) >= 3 * PyLong_SHIFT) {
  14880. return (mode_t) (((((((mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0]));
  14881. }
  14882. }
  14883. break;
  14884. case 4:
  14885. if (8 * sizeof(mode_t) > 3 * PyLong_SHIFT) {
  14886. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14887. __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])))
  14888. } else if (8 * sizeof(mode_t) >= 4 * PyLong_SHIFT) {
  14889. 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]));
  14890. }
  14891. }
  14892. break;
  14893. }
  14894. #endif
  14895. #if CYTHON_COMPILING_IN_CPYTHON
  14896. if (unlikely(Py_SIZE(x) < 0)) {
  14897. goto raise_neg_overflow;
  14898. }
  14899. #else
  14900. {
  14901. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14902. if (unlikely(result < 0))
  14903. return (mode_t) -1;
  14904. if (unlikely(result == 1))
  14905. goto raise_neg_overflow;
  14906. }
  14907. #endif
  14908. if (sizeof(mode_t) <= sizeof(unsigned long)) {
  14909. __PYX_VERIFY_RETURN_INT_EXC(mode_t, unsigned long, PyLong_AsUnsignedLong(x))
  14910. #ifdef HAVE_LONG_LONG
  14911. } else if (sizeof(mode_t) <= sizeof(unsigned PY_LONG_LONG)) {
  14912. __PYX_VERIFY_RETURN_INT_EXC(mode_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14913. #endif
  14914. }
  14915. } else {
  14916. #if CYTHON_USE_PYLONG_INTERNALS
  14917. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14918. switch (Py_SIZE(x)) {
  14919. case 0: return (mode_t) 0;
  14920. case -1: __PYX_VERIFY_RETURN_INT(mode_t, sdigit, (sdigit) (-(sdigit)digits[0]))
  14921. case 1: __PYX_VERIFY_RETURN_INT(mode_t, digit, +digits[0])
  14922. case -2:
  14923. if (8 * sizeof(mode_t) - 1 > 1 * PyLong_SHIFT) {
  14924. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14925. __PYX_VERIFY_RETURN_INT(mode_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14926. } else if (8 * sizeof(mode_t) - 1 > 2 * PyLong_SHIFT) {
  14927. return (mode_t) (((mode_t)-1)*(((((mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  14928. }
  14929. }
  14930. break;
  14931. case 2:
  14932. if (8 * sizeof(mode_t) > 1 * PyLong_SHIFT) {
  14933. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14934. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14935. } else if (8 * sizeof(mode_t) - 1 > 2 * PyLong_SHIFT) {
  14936. return (mode_t) ((((((mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  14937. }
  14938. }
  14939. break;
  14940. case -3:
  14941. if (8 * sizeof(mode_t) - 1 > 2 * PyLong_SHIFT) {
  14942. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14943. __PYX_VERIFY_RETURN_INT(mode_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14944. } else if (8 * sizeof(mode_t) - 1 > 3 * PyLong_SHIFT) {
  14945. return (mode_t) (((mode_t)-1)*(((((((mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  14946. }
  14947. }
  14948. break;
  14949. case 3:
  14950. if (8 * sizeof(mode_t) > 2 * PyLong_SHIFT) {
  14951. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14952. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14953. } else if (8 * sizeof(mode_t) - 1 > 3 * PyLong_SHIFT) {
  14954. return (mode_t) ((((((((mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  14955. }
  14956. }
  14957. break;
  14958. case -4:
  14959. if (8 * sizeof(mode_t) - 1 > 3 * PyLong_SHIFT) {
  14960. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14961. __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])))
  14962. } else if (8 * sizeof(mode_t) - 1 > 4 * PyLong_SHIFT) {
  14963. 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])));
  14964. }
  14965. }
  14966. break;
  14967. case 4:
  14968. if (8 * sizeof(mode_t) > 3 * PyLong_SHIFT) {
  14969. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14970. __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])))
  14971. } else if (8 * sizeof(mode_t) - 1 > 4 * PyLong_SHIFT) {
  14972. 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])));
  14973. }
  14974. }
  14975. break;
  14976. }
  14977. #endif
  14978. if (sizeof(mode_t) <= sizeof(long)) {
  14979. __PYX_VERIFY_RETURN_INT_EXC(mode_t, long, PyLong_AsLong(x))
  14980. #ifdef HAVE_LONG_LONG
  14981. } else if (sizeof(mode_t) <= sizeof(PY_LONG_LONG)) {
  14982. __PYX_VERIFY_RETURN_INT_EXC(mode_t, PY_LONG_LONG, PyLong_AsLongLong(x))
  14983. #endif
  14984. }
  14985. }
  14986. {
  14987. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14988. PyErr_SetString(PyExc_RuntimeError,
  14989. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14990. #else
  14991. mode_t val;
  14992. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14993. #if PY_MAJOR_VERSION < 3
  14994. if (likely(v) && !PyLong_Check(v)) {
  14995. PyObject *tmp = v;
  14996. v = PyNumber_Long(tmp);
  14997. Py_DECREF(tmp);
  14998. }
  14999. #endif
  15000. if (likely(v)) {
  15001. int one = 1; int is_little = (int)*(unsigned char *)&one;
  15002. unsigned char *bytes = (unsigned char *)&val;
  15003. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  15004. bytes, sizeof(val),
  15005. is_little, !is_unsigned);
  15006. Py_DECREF(v);
  15007. if (likely(!ret))
  15008. return val;
  15009. }
  15010. #endif
  15011. return (mode_t) -1;
  15012. }
  15013. } else {
  15014. mode_t val;
  15015. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  15016. if (!tmp) return (mode_t) -1;
  15017. val = __Pyx_PyInt_As_mode_t(tmp);
  15018. Py_DECREF(tmp);
  15019. return val;
  15020. }
  15021. raise_overflow:
  15022. PyErr_SetString(PyExc_OverflowError,
  15023. "value too large to convert to mode_t");
  15024. return (mode_t) -1;
  15025. raise_neg_overflow:
  15026. PyErr_SetString(PyExc_OverflowError,
  15027. "can't convert negative value to mode_t");
  15028. return (mode_t) -1;
  15029. }
  15030. /* CIntFromPy */
  15031. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  15032. const int neg_one = (int) -1, const_zero = (int) 0;
  15033. const int is_unsigned = neg_one > const_zero;
  15034. #if PY_MAJOR_VERSION < 3
  15035. if (likely(PyInt_Check(x))) {
  15036. if (sizeof(int) < sizeof(long)) {
  15037. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  15038. } else {
  15039. long val = PyInt_AS_LONG(x);
  15040. if (is_unsigned && unlikely(val < 0)) {
  15041. goto raise_neg_overflow;
  15042. }
  15043. return (int) val;
  15044. }
  15045. } else
  15046. #endif
  15047. if (likely(PyLong_Check(x))) {
  15048. if (is_unsigned) {
  15049. #if CYTHON_USE_PYLONG_INTERNALS
  15050. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15051. switch (Py_SIZE(x)) {
  15052. case 0: return (int) 0;
  15053. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  15054. case 2:
  15055. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  15056. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15057. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15058. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  15059. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  15060. }
  15061. }
  15062. break;
  15063. case 3:
  15064. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  15065. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15066. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15067. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  15068. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  15069. }
  15070. }
  15071. break;
  15072. case 4:
  15073. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  15074. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15075. __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])))
  15076. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  15077. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  15078. }
  15079. }
  15080. break;
  15081. }
  15082. #endif
  15083. #if CYTHON_COMPILING_IN_CPYTHON
  15084. if (unlikely(Py_SIZE(x) < 0)) {
  15085. goto raise_neg_overflow;
  15086. }
  15087. #else
  15088. {
  15089. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  15090. if (unlikely(result < 0))
  15091. return (int) -1;
  15092. if (unlikely(result == 1))
  15093. goto raise_neg_overflow;
  15094. }
  15095. #endif
  15096. if (sizeof(int) <= sizeof(unsigned long)) {
  15097. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  15098. #ifdef HAVE_LONG_LONG
  15099. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  15100. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  15101. #endif
  15102. }
  15103. } else {
  15104. #if CYTHON_USE_PYLONG_INTERNALS
  15105. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15106. switch (Py_SIZE(x)) {
  15107. case 0: return (int) 0;
  15108. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  15109. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  15110. case -2:
  15111. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  15112. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15113. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15114. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  15115. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15116. }
  15117. }
  15118. break;
  15119. case 2:
  15120. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  15121. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15122. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15123. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  15124. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15125. }
  15126. }
  15127. break;
  15128. case -3:
  15129. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  15130. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15131. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15132. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  15133. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15134. }
  15135. }
  15136. break;
  15137. case 3:
  15138. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  15139. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15140. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15141. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  15142. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15143. }
  15144. }
  15145. break;
  15146. case -4:
  15147. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  15148. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15149. __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])))
  15150. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  15151. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15152. }
  15153. }
  15154. break;
  15155. case 4:
  15156. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  15157. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15158. __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])))
  15159. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  15160. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15161. }
  15162. }
  15163. break;
  15164. }
  15165. #endif
  15166. if (sizeof(int) <= sizeof(long)) {
  15167. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  15168. #ifdef HAVE_LONG_LONG
  15169. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  15170. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  15171. #endif
  15172. }
  15173. }
  15174. {
  15175. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  15176. PyErr_SetString(PyExc_RuntimeError,
  15177. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  15178. #else
  15179. int val;
  15180. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  15181. #if PY_MAJOR_VERSION < 3
  15182. if (likely(v) && !PyLong_Check(v)) {
  15183. PyObject *tmp = v;
  15184. v = PyNumber_Long(tmp);
  15185. Py_DECREF(tmp);
  15186. }
  15187. #endif
  15188. if (likely(v)) {
  15189. int one = 1; int is_little = (int)*(unsigned char *)&one;
  15190. unsigned char *bytes = (unsigned char *)&val;
  15191. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  15192. bytes, sizeof(val),
  15193. is_little, !is_unsigned);
  15194. Py_DECREF(v);
  15195. if (likely(!ret))
  15196. return val;
  15197. }
  15198. #endif
  15199. return (int) -1;
  15200. }
  15201. } else {
  15202. int val;
  15203. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  15204. if (!tmp) return (int) -1;
  15205. val = __Pyx_PyInt_As_int(tmp);
  15206. Py_DECREF(tmp);
  15207. return val;
  15208. }
  15209. raise_overflow:
  15210. PyErr_SetString(PyExc_OverflowError,
  15211. "value too large to convert to int");
  15212. return (int) -1;
  15213. raise_neg_overflow:
  15214. PyErr_SetString(PyExc_OverflowError,
  15215. "can't convert negative value to int");
  15216. return (int) -1;
  15217. }
  15218. /* CIntFromPy */
  15219. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  15220. const long neg_one = (long) -1, const_zero = (long) 0;
  15221. const int is_unsigned = neg_one > const_zero;
  15222. #if PY_MAJOR_VERSION < 3
  15223. if (likely(PyInt_Check(x))) {
  15224. if (sizeof(long) < sizeof(long)) {
  15225. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  15226. } else {
  15227. long val = PyInt_AS_LONG(x);
  15228. if (is_unsigned && unlikely(val < 0)) {
  15229. goto raise_neg_overflow;
  15230. }
  15231. return (long) val;
  15232. }
  15233. } else
  15234. #endif
  15235. if (likely(PyLong_Check(x))) {
  15236. if (is_unsigned) {
  15237. #if CYTHON_USE_PYLONG_INTERNALS
  15238. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15239. switch (Py_SIZE(x)) {
  15240. case 0: return (long) 0;
  15241. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  15242. case 2:
  15243. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  15244. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15245. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15246. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  15247. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  15248. }
  15249. }
  15250. break;
  15251. case 3:
  15252. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  15253. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15254. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15255. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  15256. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  15257. }
  15258. }
  15259. break;
  15260. case 4:
  15261. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  15262. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15263. __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])))
  15264. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  15265. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  15266. }
  15267. }
  15268. break;
  15269. }
  15270. #endif
  15271. #if CYTHON_COMPILING_IN_CPYTHON
  15272. if (unlikely(Py_SIZE(x) < 0)) {
  15273. goto raise_neg_overflow;
  15274. }
  15275. #else
  15276. {
  15277. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  15278. if (unlikely(result < 0))
  15279. return (long) -1;
  15280. if (unlikely(result == 1))
  15281. goto raise_neg_overflow;
  15282. }
  15283. #endif
  15284. if (sizeof(long) <= sizeof(unsigned long)) {
  15285. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  15286. #ifdef HAVE_LONG_LONG
  15287. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  15288. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  15289. #endif
  15290. }
  15291. } else {
  15292. #if CYTHON_USE_PYLONG_INTERNALS
  15293. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15294. switch (Py_SIZE(x)) {
  15295. case 0: return (long) 0;
  15296. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  15297. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  15298. case -2:
  15299. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  15300. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15301. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15302. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  15303. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15304. }
  15305. }
  15306. break;
  15307. case 2:
  15308. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  15309. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15310. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15311. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  15312. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15313. }
  15314. }
  15315. break;
  15316. case -3:
  15317. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  15318. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15319. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15320. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  15321. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15322. }
  15323. }
  15324. break;
  15325. case 3:
  15326. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  15327. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15328. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15329. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  15330. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15331. }
  15332. }
  15333. break;
  15334. case -4:
  15335. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  15336. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15337. __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])))
  15338. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  15339. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15340. }
  15341. }
  15342. break;
  15343. case 4:
  15344. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  15345. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15346. __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])))
  15347. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  15348. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15349. }
  15350. }
  15351. break;
  15352. }
  15353. #endif
  15354. if (sizeof(long) <= sizeof(long)) {
  15355. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  15356. #ifdef HAVE_LONG_LONG
  15357. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  15358. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  15359. #endif
  15360. }
  15361. }
  15362. {
  15363. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  15364. PyErr_SetString(PyExc_RuntimeError,
  15365. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  15366. #else
  15367. long val;
  15368. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  15369. #if PY_MAJOR_VERSION < 3
  15370. if (likely(v) && !PyLong_Check(v)) {
  15371. PyObject *tmp = v;
  15372. v = PyNumber_Long(tmp);
  15373. Py_DECREF(tmp);
  15374. }
  15375. #endif
  15376. if (likely(v)) {
  15377. int one = 1; int is_little = (int)*(unsigned char *)&one;
  15378. unsigned char *bytes = (unsigned char *)&val;
  15379. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  15380. bytes, sizeof(val),
  15381. is_little, !is_unsigned);
  15382. Py_DECREF(v);
  15383. if (likely(!ret))
  15384. return val;
  15385. }
  15386. #endif
  15387. return (long) -1;
  15388. }
  15389. } else {
  15390. long val;
  15391. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  15392. if (!tmp) return (long) -1;
  15393. val = __Pyx_PyInt_As_long(tmp);
  15394. Py_DECREF(tmp);
  15395. return val;
  15396. }
  15397. raise_overflow:
  15398. PyErr_SetString(PyExc_OverflowError,
  15399. "value too large to convert to long");
  15400. return (long) -1;
  15401. raise_neg_overflow:
  15402. PyErr_SetString(PyExc_OverflowError,
  15403. "can't convert negative value to long");
  15404. return (long) -1;
  15405. }
  15406. /* FetchCommonType */
  15407. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
  15408. PyObject* fake_module;
  15409. PyTypeObject* cached_type = NULL;
  15410. fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
  15411. if (!fake_module) return NULL;
  15412. Py_INCREF(fake_module);
  15413. cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
  15414. if (cached_type) {
  15415. if (!PyType_Check((PyObject*)cached_type)) {
  15416. PyErr_Format(PyExc_TypeError,
  15417. "Shared Cython type %.200s is not a type object",
  15418. type->tp_name);
  15419. goto bad;
  15420. }
  15421. if (cached_type->tp_basicsize != type->tp_basicsize) {
  15422. PyErr_Format(PyExc_TypeError,
  15423. "Shared Cython type %.200s has the wrong size, try recompiling",
  15424. type->tp_name);
  15425. goto bad;
  15426. }
  15427. } else {
  15428. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
  15429. PyErr_Clear();
  15430. if (PyType_Ready(type) < 0) goto bad;
  15431. if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
  15432. goto bad;
  15433. Py_INCREF(type);
  15434. cached_type = type;
  15435. }
  15436. done:
  15437. Py_DECREF(fake_module);
  15438. return cached_type;
  15439. bad:
  15440. Py_XDECREF(cached_type);
  15441. cached_type = NULL;
  15442. goto done;
  15443. }
  15444. /* PyObjectCallMethod1 */
  15445. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
  15446. PyObject *result = NULL;
  15447. #if CYTHON_UNPACK_METHODS
  15448. if (likely(PyMethod_Check(method))) {
  15449. PyObject *self = PyMethod_GET_SELF(method);
  15450. if (likely(self)) {
  15451. PyObject *args;
  15452. PyObject *function = PyMethod_GET_FUNCTION(method);
  15453. #if CYTHON_FAST_PYCALL
  15454. if (PyFunction_Check(function)) {
  15455. PyObject *args[2] = {self, arg};
  15456. result = __Pyx_PyFunction_FastCall(function, args, 2);
  15457. goto done;
  15458. }
  15459. #endif
  15460. #if CYTHON_FAST_PYCCALL
  15461. if (__Pyx_PyFastCFunction_Check(function)) {
  15462. PyObject *args[2] = {self, arg};
  15463. result = __Pyx_PyCFunction_FastCall(function, args, 2);
  15464. goto done;
  15465. }
  15466. #endif
  15467. args = PyTuple_New(2);
  15468. if (unlikely(!args)) goto done;
  15469. Py_INCREF(self);
  15470. PyTuple_SET_ITEM(args, 0, self);
  15471. Py_INCREF(arg);
  15472. PyTuple_SET_ITEM(args, 1, arg);
  15473. Py_INCREF(function);
  15474. result = __Pyx_PyObject_Call(function, args, NULL);
  15475. Py_DECREF(args);
  15476. Py_DECREF(function);
  15477. return result;
  15478. }
  15479. }
  15480. #endif
  15481. result = __Pyx_PyObject_CallOneArg(method, arg);
  15482. goto done;
  15483. done:
  15484. return result;
  15485. }
  15486. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
  15487. PyObject *method, *result;
  15488. method = __Pyx_PyObject_GetAttrStr(obj, method_name);
  15489. if (unlikely(!method)) return NULL;
  15490. result = __Pyx__PyObject_CallMethod1(method, arg);
  15491. Py_DECREF(method);
  15492. return result;
  15493. }
  15494. /* CoroutineBase */
  15495. #include <structmember.h>
  15496. #include <frameobject.h>
  15497. #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
  15498. static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
  15499. PyObject *et, *ev, *tb;
  15500. PyObject *value = NULL;
  15501. __Pyx_ErrFetch(&et, &ev, &tb);
  15502. if (!et) {
  15503. Py_XDECREF(tb);
  15504. Py_XDECREF(ev);
  15505. Py_INCREF(Py_None);
  15506. *pvalue = Py_None;
  15507. return 0;
  15508. }
  15509. if (likely(et == PyExc_StopIteration)) {
  15510. if (!ev) {
  15511. Py_INCREF(Py_None);
  15512. value = Py_None;
  15513. }
  15514. #if PY_VERSION_HEX >= 0x030300A0
  15515. else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
  15516. value = ((PyStopIterationObject *)ev)->value;
  15517. Py_INCREF(value);
  15518. Py_DECREF(ev);
  15519. }
  15520. #endif
  15521. else if (unlikely(PyTuple_Check(ev))) {
  15522. if (PyTuple_GET_SIZE(ev) >= 1) {
  15523. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  15524. value = PyTuple_GET_ITEM(ev, 0);
  15525. Py_INCREF(value);
  15526. #else
  15527. value = PySequence_ITEM(ev, 0);
  15528. #endif
  15529. } else {
  15530. Py_INCREF(Py_None);
  15531. value = Py_None;
  15532. }
  15533. Py_DECREF(ev);
  15534. }
  15535. else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
  15536. value = ev;
  15537. }
  15538. if (likely(value)) {
  15539. Py_XDECREF(tb);
  15540. Py_DECREF(et);
  15541. *pvalue = value;
  15542. return 0;
  15543. }
  15544. } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
  15545. __Pyx_ErrRestore(et, ev, tb);
  15546. return -1;
  15547. }
  15548. PyErr_NormalizeException(&et, &ev, &tb);
  15549. if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
  15550. __Pyx_ErrRestore(et, ev, tb);
  15551. return -1;
  15552. }
  15553. Py_XDECREF(tb);
  15554. Py_DECREF(et);
  15555. #if PY_VERSION_HEX >= 0x030300A0
  15556. value = ((PyStopIterationObject *)ev)->value;
  15557. Py_INCREF(value);
  15558. Py_DECREF(ev);
  15559. #else
  15560. {
  15561. PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
  15562. Py_DECREF(ev);
  15563. if (likely(args)) {
  15564. value = PySequence_GetItem(args, 0);
  15565. Py_DECREF(args);
  15566. }
  15567. if (unlikely(!value)) {
  15568. __Pyx_ErrRestore(NULL, NULL, NULL);
  15569. Py_INCREF(Py_None);
  15570. value = Py_None;
  15571. }
  15572. }
  15573. #endif
  15574. *pvalue = value;
  15575. return 0;
  15576. }
  15577. static CYTHON_INLINE
  15578. void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
  15579. PyObject *exc_type = self->exc_type;
  15580. PyObject *exc_value = self->exc_value;
  15581. PyObject *exc_traceback = self->exc_traceback;
  15582. self->exc_type = NULL;
  15583. self->exc_value = NULL;
  15584. self->exc_traceback = NULL;
  15585. Py_XDECREF(exc_type);
  15586. Py_XDECREF(exc_value);
  15587. Py_XDECREF(exc_traceback);
  15588. }
  15589. #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
  15590. static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
  15591. const char *msg;
  15592. if (0) {
  15593. #ifdef __Pyx_Coroutine_USED
  15594. } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
  15595. msg = "coroutine already executing";
  15596. #endif
  15597. #ifdef __Pyx_AsyncGen_USED
  15598. } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
  15599. msg = "async generator already executing";
  15600. #endif
  15601. } else {
  15602. msg = "generator already executing";
  15603. }
  15604. PyErr_SetString(PyExc_ValueError, msg);
  15605. }
  15606. #define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
  15607. static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
  15608. const char *msg;
  15609. if (0) {
  15610. #ifdef __Pyx_Coroutine_USED
  15611. } else if (__Pyx_Coroutine_Check(gen)) {
  15612. msg = "can't send non-None value to a just-started coroutine";
  15613. #endif
  15614. #ifdef __Pyx_AsyncGen_USED
  15615. } else if (__Pyx_AsyncGen_CheckExact(gen)) {
  15616. msg = "can't send non-None value to a just-started async generator";
  15617. #endif
  15618. } else {
  15619. msg = "can't send non-None value to a just-started generator";
  15620. }
  15621. PyErr_SetString(PyExc_TypeError, msg);
  15622. }
  15623. #define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
  15624. static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
  15625. #ifdef __Pyx_Coroutine_USED
  15626. if (!closing && __Pyx_Coroutine_Check(gen)) {
  15627. PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
  15628. } else
  15629. #endif
  15630. if (value) {
  15631. #ifdef __Pyx_AsyncGen_USED
  15632. if (__Pyx_AsyncGen_CheckExact(gen))
  15633. PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
  15634. else
  15635. #endif
  15636. PyErr_SetNone(PyExc_StopIteration);
  15637. }
  15638. }
  15639. static
  15640. PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
  15641. __Pyx_PyThreadState_declare
  15642. PyThreadState *tstate;
  15643. PyObject *retval;
  15644. assert(!self->is_running);
  15645. if (unlikely(self->resume_label == 0)) {
  15646. if (unlikely(value && value != Py_None)) {
  15647. return __Pyx_Coroutine_NotStartedError((PyObject*)self);
  15648. }
  15649. }
  15650. if (unlikely(self->resume_label == -1)) {
  15651. return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
  15652. }
  15653. #if CYTHON_FAST_THREAD_STATE
  15654. __Pyx_PyThreadState_assign
  15655. tstate = __pyx_tstate;
  15656. #else
  15657. tstate = __Pyx_PyThreadState_Current;
  15658. #endif
  15659. if (self->exc_type) {
  15660. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  15661. #else
  15662. if (self->exc_traceback) {
  15663. PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
  15664. PyFrameObject *f = tb->tb_frame;
  15665. Py_XINCREF(tstate->frame);
  15666. assert(f->f_back == NULL);
  15667. f->f_back = tstate->frame;
  15668. }
  15669. #endif
  15670. __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
  15671. &self->exc_traceback);
  15672. } else {
  15673. __Pyx_Coroutine_ExceptionClear(self);
  15674. __Pyx_ExceptionSave(&self->exc_type, &self->exc_value, &self->exc_traceback);
  15675. }
  15676. self->is_running = 1;
  15677. retval = self->body((PyObject *) self, tstate, value);
  15678. self->is_running = 0;
  15679. return retval;
  15680. }
  15681. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self) {
  15682. if (likely(self->exc_traceback)) {
  15683. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  15684. #else
  15685. PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
  15686. PyFrameObject *f = tb->tb_frame;
  15687. Py_CLEAR(f->f_back);
  15688. #endif
  15689. }
  15690. }
  15691. static CYTHON_INLINE
  15692. PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
  15693. if (unlikely(!retval)) {
  15694. __Pyx_PyThreadState_declare
  15695. __Pyx_PyThreadState_assign
  15696. if (!__Pyx_PyErr_Occurred()) {
  15697. PyObject *exc = PyExc_StopIteration;
  15698. #ifdef __Pyx_AsyncGen_USED
  15699. if (__Pyx_AsyncGen_CheckExact(gen))
  15700. exc = __Pyx_PyExc_StopAsyncIteration;
  15701. #endif
  15702. __Pyx_PyErr_SetNone(exc);
  15703. }
  15704. }
  15705. return retval;
  15706. }
  15707. static CYTHON_INLINE
  15708. PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
  15709. PyObject *ret;
  15710. PyObject *val = NULL;
  15711. __Pyx_Coroutine_Undelegate(gen);
  15712. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
  15713. ret = __Pyx_Coroutine_SendEx(gen, val, 0);
  15714. Py_XDECREF(val);
  15715. return ret;
  15716. }
  15717. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
  15718. PyObject *retval;
  15719. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  15720. PyObject *yf = gen->yieldfrom;
  15721. if (unlikely(gen->is_running))
  15722. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15723. if (yf) {
  15724. PyObject *ret;
  15725. gen->is_running = 1;
  15726. #ifdef __Pyx_Generator_USED
  15727. if (__Pyx_Generator_CheckExact(yf)) {
  15728. ret = __Pyx_Coroutine_Send(yf, value);
  15729. } else
  15730. #endif
  15731. #ifdef __Pyx_Coroutine_USED
  15732. if (__Pyx_Coroutine_Check(yf)) {
  15733. ret = __Pyx_Coroutine_Send(yf, value);
  15734. } else
  15735. #endif
  15736. #ifdef __Pyx_AsyncGen_USED
  15737. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  15738. ret = __Pyx_async_gen_asend_send(yf, value);
  15739. } else
  15740. #endif
  15741. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
  15742. if (PyGen_CheckExact(yf)) {
  15743. ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  15744. } else
  15745. #endif
  15746. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
  15747. if (PyCoro_CheckExact(yf)) {
  15748. ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  15749. } else
  15750. #endif
  15751. {
  15752. if (value == Py_None)
  15753. ret = Py_TYPE(yf)->tp_iternext(yf);
  15754. else
  15755. ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
  15756. }
  15757. gen->is_running = 0;
  15758. if (likely(ret)) {
  15759. return ret;
  15760. }
  15761. retval = __Pyx_Coroutine_FinishDelegation(gen);
  15762. } else {
  15763. retval = __Pyx_Coroutine_SendEx(gen, value, 0);
  15764. }
  15765. return __Pyx_Coroutine_MethodReturn(self, retval);
  15766. }
  15767. static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
  15768. PyObject *retval = NULL;
  15769. int err = 0;
  15770. #ifdef __Pyx_Generator_USED
  15771. if (__Pyx_Generator_CheckExact(yf)) {
  15772. retval = __Pyx_Coroutine_Close(yf);
  15773. if (!retval)
  15774. return -1;
  15775. } else
  15776. #endif
  15777. #ifdef __Pyx_Coroutine_USED
  15778. if (__Pyx_Coroutine_Check(yf)) {
  15779. retval = __Pyx_Coroutine_Close(yf);
  15780. if (!retval)
  15781. return -1;
  15782. } else
  15783. if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  15784. retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
  15785. if (!retval)
  15786. return -1;
  15787. } else
  15788. #endif
  15789. #ifdef __Pyx_AsyncGen_USED
  15790. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  15791. retval = __Pyx_async_gen_asend_close(yf, NULL);
  15792. } else
  15793. if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
  15794. retval = __Pyx_async_gen_athrow_close(yf, NULL);
  15795. } else
  15796. #endif
  15797. {
  15798. PyObject *meth;
  15799. gen->is_running = 1;
  15800. meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
  15801. if (unlikely(!meth)) {
  15802. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
  15803. PyErr_WriteUnraisable(yf);
  15804. }
  15805. PyErr_Clear();
  15806. } else {
  15807. retval = PyObject_CallFunction(meth, NULL);
  15808. Py_DECREF(meth);
  15809. if (!retval)
  15810. err = -1;
  15811. }
  15812. gen->is_running = 0;
  15813. }
  15814. Py_XDECREF(retval);
  15815. return err;
  15816. }
  15817. static PyObject *__Pyx_Generator_Next(PyObject *self) {
  15818. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  15819. PyObject *yf = gen->yieldfrom;
  15820. if (unlikely(gen->is_running))
  15821. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15822. if (yf) {
  15823. PyObject *ret;
  15824. gen->is_running = 1;
  15825. #ifdef __Pyx_Generator_USED
  15826. if (__Pyx_Generator_CheckExact(yf)) {
  15827. ret = __Pyx_Generator_Next(yf);
  15828. } else
  15829. #endif
  15830. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
  15831. if (PyGen_CheckExact(yf)) {
  15832. ret = _PyGen_Send((PyGenObject*)yf, NULL);
  15833. } else
  15834. #endif
  15835. #ifdef __Pyx_Coroutine_USED
  15836. if (__Pyx_Coroutine_Check(yf)) {
  15837. ret = __Pyx_Coroutine_Send(yf, Py_None);
  15838. } else
  15839. #endif
  15840. ret = Py_TYPE(yf)->tp_iternext(yf);
  15841. gen->is_running = 0;
  15842. if (likely(ret)) {
  15843. return ret;
  15844. }
  15845. return __Pyx_Coroutine_FinishDelegation(gen);
  15846. }
  15847. return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
  15848. }
  15849. static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
  15850. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15851. PyObject *retval, *raised_exception;
  15852. PyObject *yf = gen->yieldfrom;
  15853. int err = 0;
  15854. if (unlikely(gen->is_running))
  15855. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15856. if (yf) {
  15857. Py_INCREF(yf);
  15858. err = __Pyx_Coroutine_CloseIter(gen, yf);
  15859. __Pyx_Coroutine_Undelegate(gen);
  15860. Py_DECREF(yf);
  15861. }
  15862. if (err == 0)
  15863. PyErr_SetNone(PyExc_GeneratorExit);
  15864. retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
  15865. if (unlikely(retval)) {
  15866. const char *msg;
  15867. Py_DECREF(retval);
  15868. if ((0)) {
  15869. #ifdef __Pyx_Coroutine_USED
  15870. } else if (__Pyx_Coroutine_Check(self)) {
  15871. msg = "coroutine ignored GeneratorExit";
  15872. #endif
  15873. #ifdef __Pyx_AsyncGen_USED
  15874. } else if (__Pyx_AsyncGen_CheckExact(self)) {
  15875. #if PY_VERSION_HEX < 0x03060000
  15876. msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
  15877. #else
  15878. msg = "async generator ignored GeneratorExit";
  15879. #endif
  15880. #endif
  15881. } else {
  15882. msg = "generator ignored GeneratorExit";
  15883. }
  15884. PyErr_SetString(PyExc_RuntimeError, msg);
  15885. return NULL;
  15886. }
  15887. raised_exception = PyErr_Occurred();
  15888. if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
  15889. if (raised_exception) PyErr_Clear();
  15890. Py_INCREF(Py_None);
  15891. return Py_None;
  15892. }
  15893. return NULL;
  15894. }
  15895. static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
  15896. PyObject *args, int close_on_genexit) {
  15897. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15898. PyObject *yf = gen->yieldfrom;
  15899. if (unlikely(gen->is_running))
  15900. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15901. if (yf) {
  15902. PyObject *ret;
  15903. Py_INCREF(yf);
  15904. if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
  15905. int err = __Pyx_Coroutine_CloseIter(gen, yf);
  15906. Py_DECREF(yf);
  15907. __Pyx_Coroutine_Undelegate(gen);
  15908. if (err < 0)
  15909. return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
  15910. goto throw_here;
  15911. }
  15912. gen->is_running = 1;
  15913. if (0
  15914. #ifdef __Pyx_Generator_USED
  15915. || __Pyx_Generator_CheckExact(yf)
  15916. #endif
  15917. #ifdef __Pyx_Coroutine_USED
  15918. || __Pyx_Coroutine_Check(yf)
  15919. #endif
  15920. ) {
  15921. ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
  15922. #ifdef __Pyx_Coroutine_USED
  15923. } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  15924. ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
  15925. #endif
  15926. } else {
  15927. PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
  15928. if (unlikely(!meth)) {
  15929. Py_DECREF(yf);
  15930. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
  15931. gen->is_running = 0;
  15932. return NULL;
  15933. }
  15934. PyErr_Clear();
  15935. __Pyx_Coroutine_Undelegate(gen);
  15936. gen->is_running = 0;
  15937. goto throw_here;
  15938. }
  15939. if (likely(args)) {
  15940. ret = PyObject_CallObject(meth, args);
  15941. } else {
  15942. ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
  15943. }
  15944. Py_DECREF(meth);
  15945. }
  15946. gen->is_running = 0;
  15947. Py_DECREF(yf);
  15948. if (!ret) {
  15949. ret = __Pyx_Coroutine_FinishDelegation(gen);
  15950. }
  15951. return __Pyx_Coroutine_MethodReturn(self, ret);
  15952. }
  15953. throw_here:
  15954. __Pyx_Raise(typ, val, tb, NULL);
  15955. return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
  15956. }
  15957. static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
  15958. PyObject *typ;
  15959. PyObject *val = NULL;
  15960. PyObject *tb = NULL;
  15961. if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
  15962. return NULL;
  15963. return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
  15964. }
  15965. static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
  15966. Py_VISIT(gen->closure);
  15967. Py_VISIT(gen->classobj);
  15968. Py_VISIT(gen->yieldfrom);
  15969. Py_VISIT(gen->exc_type);
  15970. Py_VISIT(gen->exc_value);
  15971. Py_VISIT(gen->exc_traceback);
  15972. return 0;
  15973. }
  15974. static int __Pyx_Coroutine_clear(PyObject *self) {
  15975. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15976. Py_CLEAR(gen->closure);
  15977. Py_CLEAR(gen->classobj);
  15978. Py_CLEAR(gen->yieldfrom);
  15979. Py_CLEAR(gen->exc_type);
  15980. Py_CLEAR(gen->exc_value);
  15981. Py_CLEAR(gen->exc_traceback);
  15982. #ifdef __Pyx_AsyncGen_USED
  15983. if (__Pyx_AsyncGen_CheckExact(self)) {
  15984. Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
  15985. }
  15986. #endif
  15987. Py_CLEAR(gen->gi_code);
  15988. Py_CLEAR(gen->gi_name);
  15989. Py_CLEAR(gen->gi_qualname);
  15990. Py_CLEAR(gen->gi_modulename);
  15991. return 0;
  15992. }
  15993. static void __Pyx_Coroutine_dealloc(PyObject *self) {
  15994. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15995. PyObject_GC_UnTrack(gen);
  15996. if (gen->gi_weakreflist != NULL)
  15997. PyObject_ClearWeakRefs(self);
  15998. if (gen->resume_label >= 0) {
  15999. PyObject_GC_Track(self);
  16000. #if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
  16001. if (PyObject_CallFinalizerFromDealloc(self))
  16002. #else
  16003. Py_TYPE(gen)->tp_del(self);
  16004. if (self->ob_refcnt > 0)
  16005. #endif
  16006. {
  16007. return;
  16008. }
  16009. PyObject_GC_UnTrack(self);
  16010. }
  16011. #ifdef __Pyx_AsyncGen_USED
  16012. if (__Pyx_AsyncGen_CheckExact(self)) {
  16013. /* We have to handle this case for asynchronous generators
  16014. right here, because this code has to be between UNTRACK
  16015. and GC_Del. */
  16016. Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
  16017. }
  16018. #endif
  16019. __Pyx_Coroutine_clear(self);
  16020. PyObject_GC_Del(gen);
  16021. }
  16022. static void __Pyx_Coroutine_del(PyObject *self) {
  16023. PyObject *error_type, *error_value, *error_traceback;
  16024. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  16025. __Pyx_PyThreadState_declare
  16026. if (gen->resume_label < 0) {
  16027. return;
  16028. }
  16029. #if !CYTHON_USE_TP_FINALIZE
  16030. assert(self->ob_refcnt == 0);
  16031. self->ob_refcnt = 1;
  16032. #endif
  16033. __Pyx_PyThreadState_assign
  16034. __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
  16035. #ifdef __Pyx_AsyncGen_USED
  16036. if (__Pyx_AsyncGen_CheckExact(self)) {
  16037. __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
  16038. PyObject *finalizer = agen->ag_finalizer;
  16039. if (finalizer && !agen->ag_closed) {
  16040. PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
  16041. if (unlikely(!res)) {
  16042. PyErr_WriteUnraisable(self);
  16043. } else {
  16044. Py_DECREF(res);
  16045. }
  16046. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  16047. return;
  16048. }
  16049. }
  16050. #endif
  16051. if (unlikely(gen->resume_label == 0 && !error_value)) {
  16052. #ifdef __Pyx_Coroutine_USED
  16053. #ifdef __Pyx_Generator_USED
  16054. if (!__Pyx_Generator_CheckExact(self))
  16055. #endif
  16056. {
  16057. PyObject_GC_UnTrack(self);
  16058. #if PY_MAJOR_VERSION >= 3 || defined(PyErr_WarnFormat)
  16059. if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
  16060. PyErr_WriteUnraisable(self);
  16061. #else
  16062. {PyObject *msg;
  16063. char *cmsg;
  16064. #if CYTHON_COMPILING_IN_PYPY
  16065. msg = NULL;
  16066. cmsg = (char*) "coroutine was never awaited";
  16067. #else
  16068. char *cname;
  16069. PyObject *qualname;
  16070. qualname = gen->gi_qualname;
  16071. cname = PyString_AS_STRING(qualname);
  16072. msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
  16073. if (unlikely(!msg)) {
  16074. PyErr_Clear();
  16075. cmsg = (char*) "coroutine was never awaited";
  16076. } else {
  16077. cmsg = PyString_AS_STRING(msg);
  16078. }
  16079. #endif
  16080. if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
  16081. PyErr_WriteUnraisable(self);
  16082. Py_XDECREF(msg);}
  16083. #endif
  16084. PyObject_GC_Track(self);
  16085. }
  16086. #endif
  16087. } else {
  16088. PyObject *res = __Pyx_Coroutine_Close(self);
  16089. if (unlikely(!res)) {
  16090. if (PyErr_Occurred())
  16091. PyErr_WriteUnraisable(self);
  16092. } else {
  16093. Py_DECREF(res);
  16094. }
  16095. }
  16096. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  16097. #if !CYTHON_USE_TP_FINALIZE
  16098. assert(self->ob_refcnt > 0);
  16099. if (--self->ob_refcnt == 0) {
  16100. return;
  16101. }
  16102. {
  16103. Py_ssize_t refcnt = self->ob_refcnt;
  16104. _Py_NewReference(self);
  16105. self->ob_refcnt = refcnt;
  16106. }
  16107. #if CYTHON_COMPILING_IN_CPYTHON
  16108. assert(PyType_IS_GC(self->ob_type) &&
  16109. _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
  16110. _Py_DEC_REFTOTAL;
  16111. #endif
  16112. #ifdef COUNT_ALLOCS
  16113. --Py_TYPE(self)->tp_frees;
  16114. --Py_TYPE(self)->tp_allocs;
  16115. #endif
  16116. #endif
  16117. }
  16118. static PyObject *
  16119. __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
  16120. {
  16121. PyObject *name = self->gi_name;
  16122. if (unlikely(!name)) name = Py_None;
  16123. Py_INCREF(name);
  16124. return name;
  16125. }
  16126. static int
  16127. __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value)
  16128. {
  16129. PyObject *tmp;
  16130. #if PY_MAJOR_VERSION >= 3
  16131. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  16132. #else
  16133. if (unlikely(value == NULL || !PyString_Check(value))) {
  16134. #endif
  16135. PyErr_SetString(PyExc_TypeError,
  16136. "__name__ must be set to a string object");
  16137. return -1;
  16138. }
  16139. tmp = self->gi_name;
  16140. Py_INCREF(value);
  16141. self->gi_name = value;
  16142. Py_XDECREF(tmp);
  16143. return 0;
  16144. }
  16145. static PyObject *
  16146. __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
  16147. {
  16148. PyObject *name = self->gi_qualname;
  16149. if (unlikely(!name)) name = Py_None;
  16150. Py_INCREF(name);
  16151. return name;
  16152. }
  16153. static int
  16154. __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value)
  16155. {
  16156. PyObject *tmp;
  16157. #if PY_MAJOR_VERSION >= 3
  16158. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  16159. #else
  16160. if (unlikely(value == NULL || !PyString_Check(value))) {
  16161. #endif
  16162. PyErr_SetString(PyExc_TypeError,
  16163. "__qualname__ must be set to a string object");
  16164. return -1;
  16165. }
  16166. tmp = self->gi_qualname;
  16167. Py_INCREF(value);
  16168. self->gi_qualname = value;
  16169. Py_XDECREF(tmp);
  16170. return 0;
  16171. }
  16172. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  16173. PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  16174. PyObject *name, PyObject *qualname, PyObject *module_name) {
  16175. __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
  16176. if (unlikely(!gen))
  16177. return NULL;
  16178. return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
  16179. }
  16180. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  16181. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  16182. PyObject *name, PyObject *qualname, PyObject *module_name) {
  16183. gen->body = body;
  16184. gen->closure = closure;
  16185. Py_XINCREF(closure);
  16186. gen->is_running = 0;
  16187. gen->resume_label = 0;
  16188. gen->classobj = NULL;
  16189. gen->yieldfrom = NULL;
  16190. gen->exc_type = NULL;
  16191. gen->exc_value = NULL;
  16192. gen->exc_traceback = NULL;
  16193. gen->gi_weakreflist = NULL;
  16194. Py_XINCREF(qualname);
  16195. gen->gi_qualname = qualname;
  16196. Py_XINCREF(name);
  16197. gen->gi_name = name;
  16198. Py_XINCREF(module_name);
  16199. gen->gi_modulename = module_name;
  16200. Py_XINCREF(code);
  16201. gen->gi_code = code;
  16202. PyObject_GC_Track(gen);
  16203. return gen;
  16204. }
  16205. /* PatchModuleWithCoroutine */
  16206. static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
  16207. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  16208. int result;
  16209. PyObject *globals, *result_obj;
  16210. globals = PyDict_New(); if (unlikely(!globals)) goto ignore;
  16211. result = PyDict_SetItemString(globals, "_cython_coroutine_type",
  16212. #ifdef __Pyx_Coroutine_USED
  16213. (PyObject*)__pyx_CoroutineType);
  16214. #else
  16215. Py_None);
  16216. #endif
  16217. if (unlikely(result < 0)) goto ignore;
  16218. result = PyDict_SetItemString(globals, "_cython_generator_type",
  16219. #ifdef __Pyx_Generator_USED
  16220. (PyObject*)__pyx_GeneratorType);
  16221. #else
  16222. Py_None);
  16223. #endif
  16224. if (unlikely(result < 0)) goto ignore;
  16225. if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
  16226. if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
  16227. result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
  16228. if (unlikely(!result_obj)) goto ignore;
  16229. Py_DECREF(result_obj);
  16230. Py_DECREF(globals);
  16231. return module;
  16232. ignore:
  16233. Py_XDECREF(globals);
  16234. PyErr_WriteUnraisable(module);
  16235. if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
  16236. Py_DECREF(module);
  16237. module = NULL;
  16238. }
  16239. #else
  16240. py_code++;
  16241. #endif
  16242. return module;
  16243. }
  16244. /* PatchGeneratorABC */
  16245. #ifndef CYTHON_REGISTER_ABCS
  16246. #define CYTHON_REGISTER_ABCS 1
  16247. #endif
  16248. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  16249. static PyObject* __Pyx_patch_abc_module(PyObject *module);
  16250. static PyObject* __Pyx_patch_abc_module(PyObject *module) {
  16251. module = __Pyx_Coroutine_patch_module(
  16252. module, ""
  16253. "if _cython_generator_type is not None:\n"
  16254. " try: Generator = _module.Generator\n"
  16255. " except AttributeError: pass\n"
  16256. " else: Generator.register(_cython_generator_type)\n"
  16257. "if _cython_coroutine_type is not None:\n"
  16258. " try: Coroutine = _module.Coroutine\n"
  16259. " except AttributeError: pass\n"
  16260. " else: Coroutine.register(_cython_coroutine_type)\n"
  16261. );
  16262. return module;
  16263. }
  16264. #endif
  16265. static int __Pyx_patch_abc(void) {
  16266. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  16267. static int abc_patched = 0;
  16268. if (CYTHON_REGISTER_ABCS && !abc_patched) {
  16269. PyObject *module;
  16270. module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
  16271. if (!module) {
  16272. PyErr_WriteUnraisable(NULL);
  16273. if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
  16274. ((PY_MAJOR_VERSION >= 3) ?
  16275. "Cython module failed to register with collections.abc module" :
  16276. "Cython module failed to register with collections module"), 1) < 0)) {
  16277. return -1;
  16278. }
  16279. } else {
  16280. module = __Pyx_patch_abc_module(module);
  16281. abc_patched = 1;
  16282. if (unlikely(!module))
  16283. return -1;
  16284. Py_DECREF(module);
  16285. }
  16286. module = PyImport_ImportModule("backports_abc");
  16287. if (module) {
  16288. module = __Pyx_patch_abc_module(module);
  16289. Py_XDECREF(module);
  16290. }
  16291. if (!module) {
  16292. PyErr_Clear();
  16293. }
  16294. }
  16295. #else
  16296. if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
  16297. #endif
  16298. return 0;
  16299. }
  16300. /* Generator */
  16301. static PyMethodDef __pyx_Generator_methods[] = {
  16302. {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
  16303. (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
  16304. {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
  16305. (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
  16306. {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS,
  16307. (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
  16308. {0, 0, 0, 0}
  16309. };
  16310. static PyMemberDef __pyx_Generator_memberlist[] = {
  16311. {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
  16312. {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
  16313. (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
  16314. {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
  16315. {0, 0, 0, 0, 0}
  16316. };
  16317. static PyGetSetDef __pyx_Generator_getsets[] = {
  16318. {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
  16319. (char*) PyDoc_STR("name of the generator"), 0},
  16320. {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
  16321. (char*) PyDoc_STR("qualified name of the generator"), 0},
  16322. {0, 0, 0, 0, 0}
  16323. };
  16324. static PyTypeObject __pyx_GeneratorType_type = {
  16325. PyVarObject_HEAD_INIT(0, 0)
  16326. "generator",
  16327. sizeof(__pyx_CoroutineObject),
  16328. 0,
  16329. (destructor) __Pyx_Coroutine_dealloc,
  16330. 0,
  16331. 0,
  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. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
  16345. 0,
  16346. (traverseproc) __Pyx_Coroutine_traverse,
  16347. 0,
  16348. 0,
  16349. offsetof(__pyx_CoroutineObject, gi_weakreflist),
  16350. 0,
  16351. (iternextfunc) __Pyx_Generator_Next,
  16352. __pyx_Generator_methods,
  16353. __pyx_Generator_memberlist,
  16354. __pyx_Generator_getsets,
  16355. 0,
  16356. 0,
  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. #if CYTHON_USE_TP_FINALIZE
  16371. 0,
  16372. #else
  16373. __Pyx_Coroutine_del,
  16374. #endif
  16375. 0,
  16376. #if CYTHON_USE_TP_FINALIZE
  16377. __Pyx_Coroutine_del,
  16378. #elif PY_VERSION_HEX >= 0x030400a1
  16379. 0,
  16380. #endif
  16381. };
  16382. static int __pyx_Generator_init(void) {
  16383. __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  16384. __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
  16385. __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
  16386. if (unlikely(!__pyx_GeneratorType)) {
  16387. return -1;
  16388. }
  16389. return 0;
  16390. }
  16391. /* CheckBinaryVersion */
  16392. static int __Pyx_check_binary_version(void) {
  16393. char ctversion[4], rtversion[4];
  16394. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  16395. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  16396. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  16397. char message[200];
  16398. PyOS_snprintf(message, sizeof(message),
  16399. "compiletime version %s of module '%.100s' "
  16400. "does not match runtime version %s",
  16401. ctversion, __Pyx_MODULE_NAME, rtversion);
  16402. return PyErr_WarnEx(NULL, message, 1);
  16403. }
  16404. return 0;
  16405. }
  16406. /* VoidPtrExport */
  16407. static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
  16408. PyObject *d;
  16409. PyObject *cobj = 0;
  16410. d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
  16411. Py_XINCREF(d);
  16412. if (!d) {
  16413. d = PyDict_New();
  16414. if (!d)
  16415. goto bad;
  16416. if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
  16417. goto bad;
  16418. }
  16419. #if PY_VERSION_HEX >= 0x02070000
  16420. cobj = PyCapsule_New(p, sig, 0);
  16421. #else
  16422. cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
  16423. #endif
  16424. if (!cobj)
  16425. goto bad;
  16426. if (PyDict_SetItem(d, name, cobj) < 0)
  16427. goto bad;
  16428. Py_DECREF(cobj);
  16429. Py_DECREF(d);
  16430. return 0;
  16431. bad:
  16432. Py_XDECREF(cobj);
  16433. Py_XDECREF(d);
  16434. return -1;
  16435. }
  16436. /* FunctionExport */
  16437. static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
  16438. PyObject *d = 0;
  16439. PyObject *cobj = 0;
  16440. union {
  16441. void (*fp)(void);
  16442. void *p;
  16443. } tmp;
  16444. d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
  16445. if (!d) {
  16446. PyErr_Clear();
  16447. d = PyDict_New();
  16448. if (!d)
  16449. goto bad;
  16450. Py_INCREF(d);
  16451. if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
  16452. goto bad;
  16453. }
  16454. tmp.fp = f;
  16455. #if PY_VERSION_HEX >= 0x02070000
  16456. cobj = PyCapsule_New(tmp.p, sig, 0);
  16457. #else
  16458. cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
  16459. #endif
  16460. if (!cobj)
  16461. goto bad;
  16462. if (PyDict_SetItemString(d, name, cobj) < 0)
  16463. goto bad;
  16464. Py_DECREF(cobj);
  16465. Py_DECREF(d);
  16466. return 0;
  16467. bad:
  16468. Py_XDECREF(cobj);
  16469. Py_XDECREF(d);
  16470. return -1;
  16471. }
  16472. /* InitStrings */
  16473. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  16474. while (t->p) {
  16475. #if PY_MAJOR_VERSION < 3
  16476. if (t->is_unicode) {
  16477. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  16478. } else if (t->intern) {
  16479. *t->p = PyString_InternFromString(t->s);
  16480. } else {
  16481. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  16482. }
  16483. #else
  16484. if (t->is_unicode | t->is_str) {
  16485. if (t->intern) {
  16486. *t->p = PyUnicode_InternFromString(t->s);
  16487. } else if (t->encoding) {
  16488. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  16489. } else {
  16490. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  16491. }
  16492. } else {
  16493. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  16494. }
  16495. #endif
  16496. if (!*t->p)
  16497. return -1;
  16498. if (PyObject_Hash(*t->p) == -1)
  16499. return -1;
  16500. ++t;
  16501. }
  16502. return 0;
  16503. }
  16504. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  16505. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  16506. }
  16507. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  16508. Py_ssize_t ignore;
  16509. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  16510. }
  16511. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  16512. #if !CYTHON_PEP393_ENABLED
  16513. static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  16514. char* defenc_c;
  16515. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  16516. if (!defenc) return NULL;
  16517. defenc_c = PyBytes_AS_STRING(defenc);
  16518. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16519. {
  16520. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  16521. char* c;
  16522. for (c = defenc_c; c < end; c++) {
  16523. if ((unsigned char) (*c) >= 128) {
  16524. PyUnicode_AsASCIIString(o);
  16525. return NULL;
  16526. }
  16527. }
  16528. }
  16529. #endif
  16530. *length = PyBytes_GET_SIZE(defenc);
  16531. return defenc_c;
  16532. }
  16533. #else
  16534. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  16535. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  16536. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16537. if (likely(PyUnicode_IS_ASCII(o))) {
  16538. *length = PyUnicode_GET_LENGTH(o);
  16539. return PyUnicode_AsUTF8(o);
  16540. } else {
  16541. PyUnicode_AsASCIIString(o);
  16542. return NULL;
  16543. }
  16544. #else
  16545. return PyUnicode_AsUTF8AndSize(o, length);
  16546. #endif
  16547. }
  16548. #endif
  16549. #endif
  16550. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  16551. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  16552. if (
  16553. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16554. __Pyx_sys_getdefaultencoding_not_ascii &&
  16555. #endif
  16556. PyUnicode_Check(o)) {
  16557. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  16558. } else
  16559. #endif
  16560. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  16561. if (PyByteArray_Check(o)) {
  16562. *length = PyByteArray_GET_SIZE(o);
  16563. return PyByteArray_AS_STRING(o);
  16564. } else
  16565. #endif
  16566. {
  16567. char* result;
  16568. int r = PyBytes_AsStringAndSize(o, &result, length);
  16569. if (unlikely(r < 0)) {
  16570. return NULL;
  16571. } else {
  16572. return result;
  16573. }
  16574. }
  16575. }
  16576. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  16577. int is_true = x == Py_True;
  16578. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  16579. else return PyObject_IsTrue(x);
  16580. }
  16581. static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
  16582. #if PY_MAJOR_VERSION >= 3
  16583. if (PyLong_Check(result)) {
  16584. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  16585. "__int__ returned non-int (type %.200s). "
  16586. "The ability to return an instance of a strict subclass of int "
  16587. "is deprecated, and may be removed in a future version of Python.",
  16588. Py_TYPE(result)->tp_name)) {
  16589. Py_DECREF(result);
  16590. return NULL;
  16591. }
  16592. return result;
  16593. }
  16594. #endif
  16595. PyErr_Format(PyExc_TypeError,
  16596. "__%.4s__ returned non-%.4s (type %.200s)",
  16597. type_name, type_name, Py_TYPE(result)->tp_name);
  16598. Py_DECREF(result);
  16599. return NULL;
  16600. }
  16601. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  16602. #if CYTHON_USE_TYPE_SLOTS
  16603. PyNumberMethods *m;
  16604. #endif
  16605. const char *name = NULL;
  16606. PyObject *res = NULL;
  16607. #if PY_MAJOR_VERSION < 3
  16608. if (likely(PyInt_Check(x) || PyLong_Check(x)))
  16609. #else
  16610. if (likely(PyLong_Check(x)))
  16611. #endif
  16612. return __Pyx_NewRef(x);
  16613. #if CYTHON_USE_TYPE_SLOTS
  16614. m = Py_TYPE(x)->tp_as_number;
  16615. #if PY_MAJOR_VERSION < 3
  16616. if (m && m->nb_int) {
  16617. name = "int";
  16618. res = m->nb_int(x);
  16619. }
  16620. else if (m && m->nb_long) {
  16621. name = "long";
  16622. res = m->nb_long(x);
  16623. }
  16624. #else
  16625. if (likely(m && m->nb_int)) {
  16626. name = "int";
  16627. res = m->nb_int(x);
  16628. }
  16629. #endif
  16630. #else
  16631. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  16632. res = PyNumber_Int(x);
  16633. }
  16634. #endif
  16635. if (likely(res)) {
  16636. #if PY_MAJOR_VERSION < 3
  16637. if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
  16638. #else
  16639. if (unlikely(!PyLong_CheckExact(res))) {
  16640. #endif
  16641. return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
  16642. }
  16643. }
  16644. else if (!PyErr_Occurred()) {
  16645. PyErr_SetString(PyExc_TypeError,
  16646. "an integer is required");
  16647. }
  16648. return res;
  16649. }
  16650. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  16651. Py_ssize_t ival;
  16652. PyObject *x;
  16653. #if PY_MAJOR_VERSION < 3
  16654. if (likely(PyInt_CheckExact(b))) {
  16655. if (sizeof(Py_ssize_t) >= sizeof(long))
  16656. return PyInt_AS_LONG(b);
  16657. else
  16658. return PyInt_AsSsize_t(x);
  16659. }
  16660. #endif
  16661. if (likely(PyLong_CheckExact(b))) {
  16662. #if CYTHON_USE_PYLONG_INTERNALS
  16663. const digit* digits = ((PyLongObject*)b)->ob_digit;
  16664. const Py_ssize_t size = Py_SIZE(b);
  16665. if (likely(__Pyx_sst_abs(size) <= 1)) {
  16666. ival = likely(size) ? digits[0] : 0;
  16667. if (size == -1) ival = -ival;
  16668. return ival;
  16669. } else {
  16670. switch (size) {
  16671. case 2:
  16672. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  16673. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16674. }
  16675. break;
  16676. case -2:
  16677. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  16678. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16679. }
  16680. break;
  16681. case 3:
  16682. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  16683. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16684. }
  16685. break;
  16686. case -3:
  16687. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  16688. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16689. }
  16690. break;
  16691. case 4:
  16692. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  16693. 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]));
  16694. }
  16695. break;
  16696. case -4:
  16697. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  16698. 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]));
  16699. }
  16700. break;
  16701. }
  16702. }
  16703. #endif
  16704. return PyLong_AsSsize_t(b);
  16705. }
  16706. x = PyNumber_Index(b);
  16707. if (!x) return -1;
  16708. ival = PyInt_AsSsize_t(x);
  16709. Py_DECREF(x);
  16710. return ival;
  16711. }
  16712. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  16713. return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
  16714. }
  16715. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  16716. return PyInt_FromSize_t(ival);
  16717. }
  16718. #endif /* Py_PYTHON_H */