base_lmdb_store.c 748 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559
  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. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats;
  794. /* "lakesuperior/store/base_lmdb_store.pxd":10
  795. * lmdb.MDB_dbi dbi
  796. *
  797. * void _check(int rc, str message=*) except * # <<<<<<<<<<<<<<
  798. *
  799. *
  800. */
  801. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check {
  802. int __pyx_n;
  803. PyObject *message;
  804. };
  805. /* "lakesuperior/store/base_lmdb_store.pxd":26
  806. * void _clear_stale_readers(self) except *
  807. * void _cur_close(self, lmdb.MDB_cursor *cur) except *
  808. * void _init_dbis(self, create=*) except * # <<<<<<<<<<<<<<
  809. * void _txn_begin(self, write=*, lmdb.MDB_txn *parent=*) except *
  810. * void _txn_commit(self) except *
  811. */
  812. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis {
  813. int __pyx_n;
  814. PyObject *create;
  815. };
  816. /* "lakesuperior/store/base_lmdb_store.pxd":27
  817. * void _cur_close(self, lmdb.MDB_cursor *cur) except *
  818. * void _init_dbis(self, create=*) except *
  819. * void _txn_begin(self, write=*, lmdb.MDB_txn *parent=*) except * # <<<<<<<<<<<<<<
  820. * void _txn_commit(self) except *
  821. * void _txn_abort(self) except *
  822. */
  823. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin {
  824. int __pyx_n;
  825. PyObject *write;
  826. MDB_txn *parent;
  827. };
  828. /* "lakesuperior/store/base_lmdb_store.pxd":30
  829. * void _txn_commit(self) except *
  830. * void _txn_abort(self) except *
  831. * inline bint _key_exists( # <<<<<<<<<<<<<<
  832. * self, unsigned char *key, unsigned char klen,
  833. * unsigned char *dblabel=*) except -1
  834. */
  835. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists {
  836. int __pyx_n;
  837. unsigned char *dblabel;
  838. };
  839. /* "lakesuperior/store/base_lmdb_store.pxd":35
  840. *
  841. * size_t _txn_id(self) except -1
  842. * lmdb.MDB_cursor *_cur_open( # <<<<<<<<<<<<<<
  843. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*) except *
  844. *
  845. */
  846. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__cur_open {
  847. int __pyx_n;
  848. unsigned char *dblabel;
  849. MDB_txn *txn;
  850. };
  851. /* "lakesuperior/store/base_lmdb_store.pxd":38
  852. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*) except *
  853. *
  854. * lmdb.MDB_dbi get_dbi( # <<<<<<<<<<<<<<
  855. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*)
  856. *
  857. */
  858. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi {
  859. int __pyx_n;
  860. unsigned char *dblabel;
  861. MDB_txn *txn;
  862. };
  863. /* "lakesuperior/store/base_lmdb_store.pxd":41
  864. * self, unsigned char *dblabel=*, lmdb.MDB_txn *txn=*)
  865. *
  866. * void _put( # <<<<<<<<<<<<<<
  867. * self, unsigned char *key, size_t key_size, unsigned char *data,
  868. * size_t data_size, unsigned char *dblabel=*,
  869. */
  870. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put {
  871. int __pyx_n;
  872. unsigned char *dblabel;
  873. MDB_txn *txn;
  874. unsigned int flags;
  875. };
  876. /* "lakesuperior/store/base_lmdb_store.pxd":46
  877. * lmdb.MDB_txn *txn=*, unsigned int flags=*) except *
  878. *
  879. * void _get_data( # <<<<<<<<<<<<<<
  880. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  881. * unsigned char *dblabel=*) except *
  882. */
  883. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data {
  884. int __pyx_n;
  885. unsigned char *dblabel;
  886. };
  887. /* "lakesuperior/store/base_lmdb_store.pxd":50
  888. * unsigned char *dblabel=*) except *
  889. *
  890. * void _delete( # <<<<<<<<<<<<<<
  891. * self, unsigned char *key, size_t klen,
  892. * unsigned char *dblabel=*) except *
  893. */
  894. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete {
  895. int __pyx_n;
  896. unsigned char *dblabel;
  897. };
  898. /* "lakesuperior/store/base_lmdb_store.pxd":57
  899. * #int _reader_list_callback(self, const unsigned char *msg, void *str_)
  900. *
  901. * cpdef void close_env(self, bint commit_pending_transaction=*) except * # <<<<<<<<<<<<<<
  902. * cpdef void destroy(self, _path=*) except *
  903. * #cpdef get_dup_data(self, unsigned char *key, db=*)
  904. */
  905. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env {
  906. int __pyx_n;
  907. int commit_pending_transaction;
  908. };
  909. /* "lakesuperior/store/base_lmdb_store.pxd":58
  910. *
  911. * cpdef void close_env(self, bint commit_pending_transaction=*) except *
  912. * cpdef void destroy(self, _path=*) except * # <<<<<<<<<<<<<<
  913. * #cpdef get_dup_data(self, unsigned char *key, db=*)
  914. * #cpdef get_all_pairs(self, db=*)
  915. */
  916. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy {
  917. int __pyx_n;
  918. PyObject *_path;
  919. };
  920. /* "lakesuperior/store/base_lmdb_store.pxd":61
  921. * #cpdef get_dup_data(self, unsigned char *key, db=*)
  922. * #cpdef get_all_pairs(self, db=*)
  923. * cpdef bytes get_data(self, key, dblabel=*) # <<<<<<<<<<<<<<
  924. * cpdef dict stats(self, new_txn=*)
  925. * cpdef int txn_id(self)
  926. */
  927. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data {
  928. int __pyx_n;
  929. PyObject *dblabel;
  930. };
  931. /* "lakesuperior/store/base_lmdb_store.pxd":62
  932. * #cpdef get_all_pairs(self, db=*)
  933. * cpdef bytes get_data(self, key, dblabel=*)
  934. * cpdef dict stats(self, new_txn=*) # <<<<<<<<<<<<<<
  935. * cpdef int txn_id(self)
  936. * #cpdef str reader_list(self)
  937. */
  938. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats {
  939. int __pyx_n;
  940. PyObject *new_txn;
  941. };
  942. /* "lakesuperior/store/base_lmdb_store.pxd":13
  943. *
  944. *
  945. * cdef class BaseLmdbStore: # <<<<<<<<<<<<<<
  946. * cdef:
  947. * readonly bint is_txn_open
  948. */
  949. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore {
  950. PyObject_HEAD
  951. struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_vtab;
  952. int is_txn_open;
  953. int _open;
  954. unsigned int _readers;
  955. PyObject *env_path;
  956. MDB_dbi *dbis;
  957. MDB_env *dbenv;
  958. MDB_txn *txn;
  959. MDB_cursor **curs;
  960. };
  961. /* "lakesuperior/store/base_lmdb_store.pyx":334
  962. *
  963. * @contextmanager
  964. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  965. * """
  966. * Transaction context manager.
  967. */
  968. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx {
  969. PyObject_HEAD
  970. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self;
  971. PyObject *__pyx_v_write;
  972. PyObject *__pyx_t_0;
  973. PyObject *__pyx_t_1;
  974. PyObject *__pyx_t_2;
  975. };
  976. /* "lakesuperior/store/base_lmdb_store.pyx":49
  977. *
  978. *
  979. * cdef class BaseLmdbStore: # <<<<<<<<<<<<<<
  980. * """
  981. * Generic LMDB store abstract class.
  982. */
  983. struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore {
  984. void (*_clear_stale_readers)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  985. void (*_cur_close)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, MDB_cursor *);
  986. 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);
  987. 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);
  988. void (*_txn_commit)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  989. void (*_txn_abort)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  990. 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);
  991. size_t (*_txn_id)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  992. 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);
  993. 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);
  994. 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);
  995. 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);
  996. 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);
  997. PyObject *(*_stats)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *);
  998. 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);
  999. 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);
  1000. 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);
  1001. PyObject *(*stats)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats *__pyx_optional_args);
  1002. int (*txn_id)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch);
  1003. };
  1004. static struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  1005. 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);
  1006. /* --- Runtime support code (head) --- */
  1007. /* Refnanny.proto */
  1008. #ifndef CYTHON_REFNANNY
  1009. #define CYTHON_REFNANNY 0
  1010. #endif
  1011. #if CYTHON_REFNANNY
  1012. typedef struct {
  1013. void (*INCREF)(void*, PyObject*, int);
  1014. void (*DECREF)(void*, PyObject*, int);
  1015. void (*GOTREF)(void*, PyObject*, int);
  1016. void (*GIVEREF)(void*, PyObject*, int);
  1017. void* (*SetupContext)(const char*, int, const char*);
  1018. void (*FinishContext)(void**);
  1019. } __Pyx_RefNannyAPIStruct;
  1020. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  1021. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  1022. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  1023. #ifdef WITH_THREAD
  1024. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1025. if (acquire_gil) {\
  1026. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1027. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  1028. PyGILState_Release(__pyx_gilstate_save);\
  1029. } else {\
  1030. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  1031. }
  1032. #else
  1033. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1034. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  1035. #endif
  1036. #define __Pyx_RefNannyFinishContext()\
  1037. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  1038. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1039. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1040. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1041. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1042. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  1043. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  1044. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  1045. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  1046. #else
  1047. #define __Pyx_RefNannyDeclarations
  1048. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  1049. #define __Pyx_RefNannyFinishContext()
  1050. #define __Pyx_INCREF(r) Py_INCREF(r)
  1051. #define __Pyx_DECREF(r) Py_DECREF(r)
  1052. #define __Pyx_GOTREF(r)
  1053. #define __Pyx_GIVEREF(r)
  1054. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  1055. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  1056. #define __Pyx_XGOTREF(r)
  1057. #define __Pyx_XGIVEREF(r)
  1058. #endif
  1059. #define __Pyx_XDECREF_SET(r, v) do {\
  1060. PyObject *tmp = (PyObject *) r;\
  1061. r = v; __Pyx_XDECREF(tmp);\
  1062. } while (0)
  1063. #define __Pyx_DECREF_SET(r, v) do {\
  1064. PyObject *tmp = (PyObject *) r;\
  1065. r = v; __Pyx_DECREF(tmp);\
  1066. } while (0)
  1067. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  1068. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  1069. /* PyObjectGetAttrStr.proto */
  1070. #if CYTHON_USE_TYPE_SLOTS
  1071. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  1072. #else
  1073. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  1074. #endif
  1075. /* GetBuiltinName.proto */
  1076. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  1077. /* PyThreadStateGet.proto */
  1078. #if CYTHON_FAST_THREAD_STATE
  1079. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1080. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  1081. #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
  1082. #else
  1083. #define __Pyx_PyThreadState_declare
  1084. #define __Pyx_PyThreadState_assign
  1085. #define __Pyx_PyErr_Occurred() PyErr_Occurred()
  1086. #endif
  1087. /* PyErrFetchRestore.proto */
  1088. #if CYTHON_FAST_THREAD_STATE
  1089. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  1090. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1091. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1092. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1093. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1094. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1095. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1096. #if CYTHON_COMPILING_IN_CPYTHON
  1097. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  1098. #else
  1099. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1100. #endif
  1101. #else
  1102. #define __Pyx_PyErr_Clear() PyErr_Clear()
  1103. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1104. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1105. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1106. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  1107. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  1108. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1109. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1110. #endif
  1111. /* Profile.proto */
  1112. #ifndef CYTHON_PROFILE
  1113. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  1114. #define CYTHON_PROFILE 0
  1115. #else
  1116. #define CYTHON_PROFILE 1
  1117. #endif
  1118. #endif
  1119. #ifndef CYTHON_TRACE_NOGIL
  1120. #define CYTHON_TRACE_NOGIL 0
  1121. #else
  1122. #if CYTHON_TRACE_NOGIL && !defined(CYTHON_TRACE)
  1123. #define CYTHON_TRACE 1
  1124. #endif
  1125. #endif
  1126. #ifndef CYTHON_TRACE
  1127. #define CYTHON_TRACE 0
  1128. #endif
  1129. #if CYTHON_TRACE
  1130. #undef CYTHON_PROFILE_REUSE_FRAME
  1131. #endif
  1132. #ifndef CYTHON_PROFILE_REUSE_FRAME
  1133. #define CYTHON_PROFILE_REUSE_FRAME 0
  1134. #endif
  1135. #if CYTHON_PROFILE || CYTHON_TRACE
  1136. #include "compile.h"
  1137. #include "frameobject.h"
  1138. #include "traceback.h"
  1139. #if CYTHON_PROFILE_REUSE_FRAME
  1140. #define CYTHON_FRAME_MODIFIER static
  1141. #define CYTHON_FRAME_DEL(frame)
  1142. #else
  1143. #define CYTHON_FRAME_MODIFIER
  1144. #define CYTHON_FRAME_DEL(frame) Py_CLEAR(frame)
  1145. #endif
  1146. #define __Pyx_TraceDeclarations\
  1147. static PyCodeObject *__pyx_frame_code = NULL;\
  1148. CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL;\
  1149. int __Pyx_use_tracing = 0;
  1150. #define __Pyx_TraceFrameInit(codeobj)\
  1151. if (codeobj) __pyx_frame_code = (PyCodeObject*) codeobj;
  1152. #ifdef WITH_THREAD
  1153. #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  1154. if (nogil) {\
  1155. if (CYTHON_TRACE_NOGIL) {\
  1156. PyThreadState *tstate;\
  1157. PyGILState_STATE state = PyGILState_Ensure();\
  1158. tstate = __Pyx_PyThreadState_Current;\
  1159. if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
  1160. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1161. __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
  1162. }\
  1163. PyGILState_Release(state);\
  1164. if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
  1165. }\
  1166. } else {\
  1167. PyThreadState* tstate = PyThreadState_GET();\
  1168. if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
  1169. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1170. __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
  1171. if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
  1172. }\
  1173. }
  1174. #else
  1175. #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  1176. { PyThreadState* tstate = PyThreadState_GET();\
  1177. if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
  1178. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1179. __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
  1180. if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
  1181. }\
  1182. }
  1183. #endif
  1184. #define __Pyx_TraceException()\
  1185. if (likely(!__Pyx_use_tracing)); else {\
  1186. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1187. if (tstate->use_tracing &&\
  1188. (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
  1189. tstate->tracing++;\
  1190. tstate->use_tracing = 0;\
  1191. PyObject *exc_info = __Pyx_GetExceptionTuple(tstate);\
  1192. if (exc_info) {\
  1193. if (CYTHON_TRACE && tstate->c_tracefunc)\
  1194. tstate->c_tracefunc(\
  1195. tstate->c_traceobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
  1196. tstate->c_profilefunc(\
  1197. tstate->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
  1198. Py_DECREF(exc_info);\
  1199. }\
  1200. tstate->use_tracing = 1;\
  1201. tstate->tracing--;\
  1202. }\
  1203. }
  1204. static void __Pyx_call_return_trace_func(PyThreadState *tstate, PyFrameObject *frame, PyObject *result) {
  1205. PyObject *type, *value, *traceback;
  1206. __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
  1207. tstate->tracing++;
  1208. tstate->use_tracing = 0;
  1209. if (CYTHON_TRACE && tstate->c_tracefunc)
  1210. tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_RETURN, result);
  1211. if (tstate->c_profilefunc)
  1212. tstate->c_profilefunc(tstate->c_profileobj, frame, PyTrace_RETURN, result);
  1213. CYTHON_FRAME_DEL(frame);
  1214. tstate->use_tracing = 1;
  1215. tstate->tracing--;
  1216. __Pyx_ErrRestoreInState(tstate, type, value, traceback);
  1217. }
  1218. #ifdef WITH_THREAD
  1219. #define __Pyx_TraceReturn(result, nogil)\
  1220. if (likely(!__Pyx_use_tracing)); else {\
  1221. if (nogil) {\
  1222. if (CYTHON_TRACE_NOGIL) {\
  1223. PyThreadState *tstate;\
  1224. PyGILState_STATE state = PyGILState_Ensure();\
  1225. tstate = __Pyx_PyThreadState_Current;\
  1226. if (tstate->use_tracing) {\
  1227. __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
  1228. }\
  1229. PyGILState_Release(state);\
  1230. }\
  1231. } else {\
  1232. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1233. if (tstate->use_tracing) {\
  1234. __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
  1235. }\
  1236. }\
  1237. }
  1238. #else
  1239. #define __Pyx_TraceReturn(result, nogil)\
  1240. if (likely(!__Pyx_use_tracing)); else {\
  1241. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1242. if (tstate->use_tracing) {\
  1243. __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
  1244. }\
  1245. }
  1246. #endif
  1247. static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno);
  1248. static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, PyThreadState* tstate, const char *funcname, const char *srcfile, int firstlineno);
  1249. #else
  1250. #define __Pyx_TraceDeclarations
  1251. #define __Pyx_TraceFrameInit(codeobj)
  1252. #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error) if ((1)); else goto_error;
  1253. #define __Pyx_TraceException()
  1254. #define __Pyx_TraceReturn(result, nogil)
  1255. #endif
  1256. #if CYTHON_TRACE
  1257. static int __Pyx_call_line_trace_func(PyThreadState *tstate, PyFrameObject *frame, int lineno) {
  1258. int ret;
  1259. PyObject *type, *value, *traceback;
  1260. __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
  1261. __Pyx_PyFrame_SetLineNumber(frame, lineno);
  1262. tstate->tracing++;
  1263. tstate->use_tracing = 0;
  1264. ret = tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_LINE, NULL);
  1265. tstate->use_tracing = 1;
  1266. tstate->tracing--;
  1267. if (likely(!ret)) {
  1268. __Pyx_ErrRestoreInState(tstate, type, value, traceback);
  1269. } else {
  1270. Py_XDECREF(type);
  1271. Py_XDECREF(value);
  1272. Py_XDECREF(traceback);
  1273. }
  1274. return ret;
  1275. }
  1276. #ifdef WITH_THREAD
  1277. #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  1278. if (likely(!__Pyx_use_tracing)); else {\
  1279. if (nogil) {\
  1280. if (CYTHON_TRACE_NOGIL) {\
  1281. int ret = 0;\
  1282. PyThreadState *tstate;\
  1283. PyGILState_STATE state = PyGILState_Ensure();\
  1284. tstate = __Pyx_PyThreadState_Current;\
  1285. if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
  1286. ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
  1287. }\
  1288. PyGILState_Release(state);\
  1289. if (unlikely(ret)) goto_error;\
  1290. }\
  1291. } else {\
  1292. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1293. if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
  1294. int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
  1295. if (unlikely(ret)) goto_error;\
  1296. }\
  1297. }\
  1298. }
  1299. #else
  1300. #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  1301. if (likely(!__Pyx_use_tracing)); else {\
  1302. PyThreadState* tstate = __Pyx_PyThreadState_Current;\
  1303. if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
  1304. int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
  1305. if (unlikely(ret)) goto_error;\
  1306. }\
  1307. }
  1308. #endif
  1309. #else
  1310. #define __Pyx_TraceLine(lineno, nogil, goto_error) if ((1)); else goto_error;
  1311. #endif
  1312. /* GetModuleGlobalName.proto */
  1313. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
  1314. /* PyCFunctionFastCall.proto */
  1315. #if CYTHON_FAST_PYCCALL
  1316. static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
  1317. #else
  1318. #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
  1319. #endif
  1320. /* PyFunctionFastCall.proto */
  1321. #if CYTHON_FAST_PYCALL
  1322. #define __Pyx_PyFunction_FastCall(func, args, nargs)\
  1323. __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
  1324. #if 1 || PY_VERSION_HEX < 0x030600B1
  1325. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
  1326. #else
  1327. #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
  1328. #endif
  1329. #endif
  1330. /* PyObjectCall.proto */
  1331. #if CYTHON_COMPILING_IN_CPYTHON
  1332. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  1333. #else
  1334. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  1335. #endif
  1336. /* PyObjectCallMethO.proto */
  1337. #if CYTHON_COMPILING_IN_CPYTHON
  1338. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  1339. #endif
  1340. /* PyObjectCallOneArg.proto */
  1341. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  1342. /* PyObjectCallNoArg.proto */
  1343. #if CYTHON_COMPILING_IN_CPYTHON
  1344. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  1345. #else
  1346. #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
  1347. #endif
  1348. /* RaiseException.proto */
  1349. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  1350. /* IncludeStringH.proto */
  1351. #include <string.h>
  1352. /* decode_c_string_utf16.proto */
  1353. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
  1354. int byteorder = 0;
  1355. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1356. }
  1357. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
  1358. int byteorder = -1;
  1359. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1360. }
  1361. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
  1362. int byteorder = 1;
  1363. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1364. }
  1365. /* decode_c_string.proto */
  1366. static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
  1367. const char* cstring, Py_ssize_t start, Py_ssize_t stop,
  1368. const char* encoding, const char* errors,
  1369. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
  1370. /* RaiseDoubleKeywords.proto */
  1371. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  1372. /* ParseKeywords.proto */
  1373. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
  1374. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
  1375. const char* function_name);
  1376. /* RaiseArgTupleInvalid.proto */
  1377. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  1378. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  1379. /* WriteUnraisableException.proto */
  1380. static void __Pyx_WriteUnraisable(const char *name, int clineno,
  1381. int lineno, const char *filename,
  1382. int full_traceback, int nogil);
  1383. /* SaveResetException.proto */
  1384. #if CYTHON_FAST_THREAD_STATE
  1385. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  1386. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1387. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  1388. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1389. #else
  1390. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  1391. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  1392. #endif
  1393. /* PyErrExceptionMatches.proto */
  1394. #if CYTHON_FAST_THREAD_STATE
  1395. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  1396. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  1397. #else
  1398. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  1399. #endif
  1400. /* GetException.proto */
  1401. #if CYTHON_FAST_THREAD_STATE
  1402. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  1403. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1404. #else
  1405. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  1406. #endif
  1407. /* SwapException.proto */
  1408. #if CYTHON_FAST_THREAD_STATE
  1409. #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
  1410. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1411. #else
  1412. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
  1413. #endif
  1414. /* PyUnicode_Unicode.proto */
  1415. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj);
  1416. /* JoinPyUnicode.proto */
  1417. static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
  1418. Py_UCS4 max_char);
  1419. /* PyObjectFormatSimple.proto */
  1420. #if CYTHON_COMPILING_IN_PYPY
  1421. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1422. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1423. PyObject_Format(s, f))
  1424. #elif PY_MAJOR_VERSION < 3
  1425. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1426. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1427. likely(PyString_CheckExact(s)) ? PyUnicode_FromEncodedObject(s, NULL, "strict") :\
  1428. PyObject_Format(s, f))
  1429. #elif CYTHON_USE_TYPE_SLOTS
  1430. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1431. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1432. likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_str(s) :\
  1433. likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_str(s) :\
  1434. PyObject_Format(s, f))
  1435. #else
  1436. #define __Pyx_PyObject_FormatSimple(s, f) (\
  1437. likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
  1438. PyObject_Format(s, f))
  1439. #endif
  1440. /* FastTypeChecks.proto */
  1441. #if CYTHON_COMPILING_IN_CPYTHON
  1442. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  1443. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  1444. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  1445. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  1446. #else
  1447. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  1448. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  1449. #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
  1450. #endif
  1451. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  1452. /* PyObjectSetAttrStr.proto */
  1453. #if CYTHON_USE_TYPE_SLOTS
  1454. #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
  1455. static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
  1456. #else
  1457. #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
  1458. #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
  1459. #endif
  1460. /* PyObjectLookupSpecial.proto */
  1461. #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
  1462. static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
  1463. PyObject *res;
  1464. PyTypeObject *tp = Py_TYPE(obj);
  1465. #if PY_MAJOR_VERSION < 3
  1466. if (unlikely(PyInstance_Check(obj)))
  1467. return __Pyx_PyObject_GetAttrStr(obj, attr_name);
  1468. #endif
  1469. res = _PyType_Lookup(tp, attr_name);
  1470. if (likely(res)) {
  1471. descrgetfunc f = Py_TYPE(res)->tp_descr_get;
  1472. if (!f) {
  1473. Py_INCREF(res);
  1474. } else {
  1475. res = f(res, obj, (PyObject *)tp);
  1476. }
  1477. } else {
  1478. PyErr_SetObject(PyExc_AttributeError, attr_name);
  1479. }
  1480. return res;
  1481. }
  1482. #else
  1483. #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
  1484. #endif
  1485. /* PyIntBinop.proto */
  1486. #if !CYTHON_COMPILING_IN_PYPY
  1487. static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
  1488. #else
  1489. #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
  1490. (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
  1491. #endif
  1492. /* DictGetItem.proto */
  1493. #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
  1494. static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
  1495. #define __Pyx_PyObject_Dict_GetItem(obj, name)\
  1496. (likely(PyDict_CheckExact(obj)) ?\
  1497. __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
  1498. #else
  1499. #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
  1500. #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
  1501. #endif
  1502. /* PyObject_GenericGetAttrNoDict.proto */
  1503. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1504. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
  1505. #else
  1506. #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
  1507. #endif
  1508. /* PyObject_GenericGetAttr.proto */
  1509. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1510. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
  1511. #else
  1512. #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
  1513. #endif
  1514. /* SetVTable.proto */
  1515. static int __Pyx_SetVtable(PyObject *dict, void *vtable);
  1516. /* SetupReduce.proto */
  1517. static int __Pyx_setup_reduce(PyObject* type_obj);
  1518. /* Import.proto */
  1519. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
  1520. /* ImportFrom.proto */
  1521. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  1522. /* CalculateMetaclass.proto */
  1523. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
  1524. /* Py3ClassCreate.proto */
  1525. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
  1526. PyObject *mkw, PyObject *modname, PyObject *doc);
  1527. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
  1528. PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
  1529. /* GetNameInClass.proto */
  1530. static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);
  1531. /* CLineInTraceback.proto */
  1532. #ifdef CYTHON_CLINE_IN_TRACEBACK
  1533. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  1534. #else
  1535. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  1536. #endif
  1537. /* CodeObjectCache.proto */
  1538. typedef struct {
  1539. PyCodeObject* code_object;
  1540. int code_line;
  1541. } __Pyx_CodeObjectCacheEntry;
  1542. struct __Pyx_CodeObjectCache {
  1543. int count;
  1544. int max_count;
  1545. __Pyx_CodeObjectCacheEntry* entries;
  1546. };
  1547. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  1548. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  1549. static PyCodeObject *__pyx_find_code_object(int code_line);
  1550. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  1551. /* AddTraceback.proto */
  1552. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1553. int py_line, const char *filename);
  1554. /* CIntToPy.proto */
  1555. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
  1556. /* CIntToPy.proto */
  1557. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
  1558. /* CIntToPy.proto */
  1559. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value);
  1560. /* CIntToPy.proto */
  1561. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  1562. /* CIntToPy.proto */
  1563. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_MDB_dbi(MDB_dbi value);
  1564. static PyObject* __pyx_convert__to_py_struct__MDB_stat(struct MDB_stat s);
  1565. /* CIntFromPy.proto */
  1566. static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
  1567. /* CIntFromPy.proto */
  1568. static CYTHON_INLINE MDB_dbi __Pyx_PyInt_As_MDB_dbi(PyObject *);
  1569. /* CIntFromPy.proto */
  1570. static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *);
  1571. /* CIntFromPy.proto */
  1572. static CYTHON_INLINE mode_t __Pyx_PyInt_As_mode_t(PyObject *);
  1573. /* CIntFromPy.proto */
  1574. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  1575. /* CIntFromPy.proto */
  1576. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  1577. /* FetchCommonType.proto */
  1578. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
  1579. /* PyObjectCallMethod1.proto */
  1580. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
  1581. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg);
  1582. /* CoroutineBase.proto */
  1583. typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
  1584. typedef struct {
  1585. PyObject_HEAD
  1586. __pyx_coroutine_body_t body;
  1587. PyObject *closure;
  1588. PyObject *exc_type;
  1589. PyObject *exc_value;
  1590. PyObject *exc_traceback;
  1591. PyObject *gi_weakreflist;
  1592. PyObject *classobj;
  1593. PyObject *yieldfrom;
  1594. PyObject *gi_name;
  1595. PyObject *gi_qualname;
  1596. PyObject *gi_modulename;
  1597. PyObject *gi_code;
  1598. int resume_label;
  1599. char is_running;
  1600. } __pyx_CoroutineObject;
  1601. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  1602. PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  1603. PyObject *name, PyObject *qualname, PyObject *module_name);
  1604. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  1605. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  1606. PyObject *name, PyObject *qualname, PyObject *module_name);
  1607. static int __Pyx_Coroutine_clear(PyObject *self);
  1608. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
  1609. static PyObject *__Pyx_Coroutine_Close(PyObject *self);
  1610. static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
  1611. #define __Pyx_Coroutine_SwapException(self) {\
  1612. __Pyx_ExceptionSwap(&(self)->exc_type, &(self)->exc_value, &(self)->exc_traceback);\
  1613. __Pyx_Coroutine_ResetFrameBackpointer(self);\
  1614. }
  1615. #define __Pyx_Coroutine_ResetAndClearException(self) {\
  1616. __Pyx_ExceptionReset((self)->exc_type, (self)->exc_value, (self)->exc_traceback);\
  1617. (self)->exc_type = (self)->exc_value = (self)->exc_traceback = NULL;\
  1618. }
  1619. #if CYTHON_FAST_THREAD_STATE
  1620. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  1621. __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
  1622. #else
  1623. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  1624. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
  1625. #endif
  1626. static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
  1627. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self);
  1628. /* PatchModuleWithCoroutine.proto */
  1629. static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);
  1630. /* PatchGeneratorABC.proto */
  1631. static int __Pyx_patch_abc(void);
  1632. /* Generator.proto */
  1633. #define __Pyx_Generator_USED
  1634. static PyTypeObject *__pyx_GeneratorType = 0;
  1635. #define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
  1636. #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
  1637. __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
  1638. static PyObject *__Pyx_Generator_Next(PyObject *self);
  1639. static int __pyx_Generator_init(void);
  1640. /* CheckBinaryVersion.proto */
  1641. static int __Pyx_check_binary_version(void);
  1642. /* VoidPtrExport.proto */
  1643. static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
  1644. /* FunctionExport.proto */
  1645. static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
  1646. /* InitStrings.proto */
  1647. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  1648. 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*/
  1649. 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*/
  1650. 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*/
  1651. 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*/
  1652. 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*/
  1653. 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*/
  1654. 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*/
  1655. 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*/
  1656. 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*/
  1657. 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, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats *__pyx_optional_args); /* proto*/
  1658. static PyObject *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto*/
  1659. 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*/
  1660. 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*/
  1661. 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*/
  1662. 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*/
  1663. 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*/
  1664. 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*/
  1665. 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*/
  1666. 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*/
  1667. /* Module declarations from 'lakesuperior.cy_include' */
  1668. /* Module declarations from 'libc.stdint' */
  1669. /* Module declarations from 'posix.types' */
  1670. /* Module declarations from 'lakesuperior.cy_include.cylmdb' */
  1671. /* Module declarations from 'libc' */
  1672. /* Module declarations from 'libc.errno' */
  1673. /* Module declarations from 'cpython.mem' */
  1674. /* Module declarations from 'lakesuperior.store.base_lmdb_store' */
  1675. static PyTypeObject *__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = 0;
  1676. static PyTypeObject *__pyx_ptype_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = 0;
  1677. static int __pyx_v_12lakesuperior_5store_15base_lmdb_store_rc;
  1678. static size_t __pyx_v_12lakesuperior_5store_15base_lmdb_store_i;
  1679. static struct MDB_val __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v;
  1680. static struct MDB_val __pyx_v_12lakesuperior_5store_15base_lmdb_store_data_v;
  1681. static MDB_dbi __pyx_v_12lakesuperior_5store_15base_lmdb_store_dbi;
  1682. 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*/
  1683. #define __Pyx_MODULE_NAME "lakesuperior.store.base_lmdb_store"
  1684. extern int __pyx_module_is_main_lakesuperior__store__base_lmdb_store;
  1685. int __pyx_module_is_main_lakesuperior__store__base_lmdb_store = 0;
  1686. /* Implementation of 'lakesuperior.store.base_lmdb_store' */
  1687. static PyObject *__pyx_builtin_MemoryError;
  1688. static PyObject *__pyx_builtin_enumerate;
  1689. static PyObject *__pyx_builtin_RuntimeError;
  1690. static PyObject *__pyx_builtin_TypeError;
  1691. static const char __pyx_k_[] = "";
  1692. static const char __pyx_k_i[] = "i";
  1693. static const char __pyx_k_x[] = "{:x}";
  1694. static const char __pyx_k_RO[] = "RO";
  1695. static const char __pyx_k_RW[] = "RW";
  1696. static const char __pyx_k__4[] = ".";
  1697. static const char __pyx_k__6[] = ": ";
  1698. static const char __pyx_k_os[] = "os";
  1699. static const char __pyx_k_rc[] = "rc";
  1700. static const char __pyx_k_DBI[] = " (DBI ";
  1701. static const char __pyx_k__20[] = ")...";
  1702. static const char __pyx_k_dbi[] = "dbi";
  1703. static const char __pyx_k_doc[] = "__doc__";
  1704. static const char __pyx_k_env[] = "env";
  1705. static const char __pyx_k_get[] = "get";
  1706. static const char __pyx_k_key[] = "key";
  1707. static const char __pyx_k_pid[] = "pid";
  1708. static const char __pyx_k_None[] = "None";
  1709. static const char __pyx_k_args[] = "args";
  1710. static const char __pyx_k_data[] = "data";
  1711. static const char __pyx_k_exit[] = "__exit__";
  1712. static const char __pyx_k_info[] = "info";
  1713. static const char __pyx_k_lock[] = "-lock";
  1714. static const char __pyx_k_main[] = "__main__";
  1715. static const char __pyx_k_mode[] = "mode";
  1716. static const char __pyx_k_name[] = "__name__";
  1717. static const char __pyx_k_path[] = "path";
  1718. static const char __pyx_k_send[] = "send";
  1719. static const char __pyx_k_stat[] = "stat";
  1720. static const char __pyx_k_test[] = "__test__";
  1721. static const char __pyx_k_wsgi[] = "wsgi";
  1722. static const char __pyx_k_abort[] = "abort";
  1723. static const char __pyx_k_close[] = "close";
  1724. static const char __pyx_k_debug[] = "debug";
  1725. static const char __pyx_k_enter[] = "__enter__";
  1726. static const char __pyx_k_flags[] = "flags";
  1727. static const char __pyx_k_index[] = "index";
  1728. static const char __pyx_k_key_v[] = "key_v";
  1729. static const char __pyx_k_stats[] = "stats";
  1730. static const char __pyx_k_throw[] = "throw";
  1731. static const char __pyx_k_write[] = "write";
  1732. static const char __pyx_k_create[] = "create";
  1733. static const char __pyx_k_data_v[] = "data_v";
  1734. static const char __pyx_k_encode[] = "encode";
  1735. static const char __pyx_k_exists[] = "exists";
  1736. static const char __pyx_k_format[] = "format";
  1737. static const char __pyx_k_import[] = "__import__";
  1738. static const char __pyx_k_logger[] = "logger";
  1739. static const char __pyx_k_module[] = "__module__";
  1740. static const char __pyx_k_path_2[] = "_path";
  1741. static const char __pyx_k_reduce[] = "__reduce__";
  1742. static const char __pyx_k_rmtree[] = "rmtree";
  1743. static const char __pyx_k_shutil[] = "shutil";
  1744. static const char __pyx_k_txn_id[] = "txn_id";
  1745. static const char __pyx_k_unlink[] = "unlink";
  1746. static const char __pyx_k_dblabel[] = "dblabel";
  1747. static const char __pyx_k_destroy[] = "destroy";
  1748. static const char __pyx_k_dirname[] = "dirname";
  1749. static const char __pyx_k_getName[] = "getName";
  1750. static const char __pyx_k_is_open[] = "is_open";
  1751. static const char __pyx_k_logging[] = "logging";
  1752. static const char __pyx_k_max_dbs[] = "max_dbs";
  1753. static const char __pyx_k_new_txn[] = "new_txn";
  1754. static const char __pyx_k_options[] = "options";
  1755. static const char __pyx_k_prepare[] = "__prepare__";
  1756. static const char __pyx_k_st_size[] = "st_size";
  1757. static const char __pyx_k_txn_ctx[] = "txn_ctx";
  1758. static const char __pyx_k_warning[] = "warning";
  1759. static const char __pyx_k_workers[] = "workers";
  1760. static const char __pyx_k_db_stats[] = "db_stats";
  1761. static const char __pyx_k_env_path[] = "env_path";
  1762. static const char __pyx_k_env_size[] = "env_size";
  1763. static const char __pyx_k_exist_ok[] = "exist_ok";
  1764. static const char __pyx_k_get_data[] = "get_data";
  1765. static const char __pyx_k_getstate[] = "__getstate__";
  1766. static const char __pyx_k_makedirs[] = "makedirs";
  1767. static const char __pyx_k_map_size[] = "map_size";
  1768. static const char __pyx_k_ms_depth[] = "ms_depth";
  1769. static const char __pyx_k_ms_psize[] = "ms_psize";
  1770. static const char __pyx_k_open_env[] = "open_env";
  1771. static const char __pyx_k_opened_x[] = "...opened @ {:x}.";
  1772. static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
  1773. static const char __pyx_k_qualname[] = "__qualname__";
  1774. static const char __pyx_k_setstate[] = "__setstate__";
  1775. static const char __pyx_k_LmdbError[] = "LmdbError";
  1776. static const char __pyx_k_TypeError[] = "TypeError";
  1777. static const char __pyx_k_close_env[] = "close_env";
  1778. static const char __pyx_k_dbi_flags[] = "dbi_flags";
  1779. static const char __pyx_k_enumerate[] = "enumerate";
  1780. static const char __pyx_k_env_flags[] = "env_flags";
  1781. static const char __pyx_k_env_perms[] = "env_perms";
  1782. static const char __pyx_k_env_stats[] = "env_stats";
  1783. static const char __pyx_k_getLogger[] = "getLogger";
  1784. static const char __pyx_k_is_txn_rw[] = "is_txn_rw";
  1785. static const char __pyx_k_metaclass[] = "__metaclass__";
  1786. static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
  1787. static const char __pyx_k_threading[] = "threading";
  1788. static const char __pyx_k_Created_DB[] = "Created DB ";
  1789. static const char __pyx_k_LMDB_Error[] = "LMDB Error ({}): ";
  1790. static const char __pyx_k_contextlib[] = "contextlib";
  1791. static const char __pyx_k_dbi_labels[] = "dbi_labels";
  1792. static const char __pyx_k_ms_entries[] = "ms_entries";
  1793. static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
  1794. static const char __pyx_k_Max_readers[] = "Max. readers: {}";
  1795. static const char __pyx_k_MemoryError[] = "MemoryError";
  1796. static const char __pyx_k_txn_is_open[] = "txn is open: {}";
  1797. static const char __pyx_k_Creating_DBs[] = "Creating DBs.";
  1798. static const char __pyx_k_RuntimeError[] = "RuntimeError";
  1799. static const char __pyx_k_lakesuperior[] = "lakesuperior";
  1800. static const char __pyx_k_readers_mult[] = "readers_mult";
  1801. static const char __pyx_k_currentThread[] = "currentThread";
  1802. static const char __pyx_k_ms_leaf_pages[] = "ms_leaf_pages";
  1803. static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
  1804. static const char __pyx_k_Internal_error[] = "\nInternal error ({}): ";
  1805. static const char __pyx_k_KeyExistsError[] = "KeyExistsError";
  1806. static const char __pyx_k_contextmanager[] = "contextmanager";
  1807. static const char __pyx_k_max_spare_txns[] = "max_spare_txns";
  1808. static const char __pyx_k_Created_DBenv_x[] = "Created DBenv @ {:x}";
  1809. static const char __pyx_k_DBenv_address_x[] = "DBenv address: {:x}";
  1810. static const char __pyx_k_current_process[] = "current_process";
  1811. static const char __pyx_k_ms_branch_pages[] = "ms_branch_pages";
  1812. static const char __pyx_k_multiprocessing[] = "multiprocessing";
  1813. static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
  1814. static const char __pyx_k_KeyNotFoundError[] = "KeyNotFoundError";
  1815. static const char __pyx_k_Closing_store_env[] = "Closing store env.";
  1816. static const char __pyx_k_FileNotFoundError[] = "FileNotFoundError";
  1817. static const char __pyx_k_Store_is_not_open[] = "Store is not open.";
  1818. static const char __pyx_k_ms_overflow_pages[] = "ms_overflow_pages";
  1819. static const char __pyx_k_Error_putting_data[] = "Error putting data: {}, {}";
  1820. static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
  1821. static const char __pyx_k_Transaction_aborted[] = "Transaction @ {} aborted.";
  1822. static const char __pyx_k_Error_opening_cursor[] = "Error opening cursor: ";
  1823. static const char __pyx_k_Opened_transaction_x[] = "Opened transaction @ {:x}";
  1824. static const char __pyx_k_BaseLmdbStore_txn_ctx[] = "BaseLmdbStore.txn_ctx";
  1825. static const char __pyx_k_Cleaning_up_store_env[] = "Cleaning up store env.";
  1826. static const char __pyx_k_Cleared_stale_readers[] = "Cleared {} stale readers.";
  1827. static const char __pyx_k_Opening_cursor_for_DB[] = "Opening cursor for DB ";
  1828. static const char __pyx_k_Transaction_committed[] = "Transaction @ {} committed.";
  1829. static const char __pyx_k_Error_setting_map_size[] = "Error setting map size: {}";
  1830. static const char __pyx_k_Opening_environment_at[] = "Opening environment at {}.";
  1831. static const char __pyx_k_Environment_already_open[] = "Environment already open.";
  1832. static const char __pyx_k_Error_opening_transaction[] = "Error opening transaction.";
  1833. static const char __pyx_k_Error_setting_max_readers[] = "Error setting max. readers: {}";
  1834. static const char __pyx_k_Getting_DBI_without_label[] = "Getting DBI without label.";
  1835. static const char __pyx_k_Error_getting_data_for_key[] = "Error getting data for key '{}'.";
  1836. static const char __pyx_k_Store_must_be_opened_first[] = "Store must be opened first.";
  1837. static const char __pyx_k_commit_pending_transaction[] = "commit_pending_transaction";
  1838. static const char __pyx_k_Error_getting_datbase_stats[] = "Error getting datbase stats: {}";
  1839. static const char __pyx_k_Error_setting_max_databases[] = "Error setting max. databases: {}";
  1840. static const char __pyx_k_Could_not_create_store_at_Error[] = "Could not create store at {}. Error: {}";
  1841. static const char __pyx_k_Error_creating_DB_environment_ha[] = "Error creating DB environment handle: {}";
  1842. static const char __pyx_k_Error_opening_the_database_envir[] = "Error opening the database environment: ";
  1843. static const char __pyx_k_Opening_transaction_in_PID_threa[] = "Opening {} transaction in PID {}, thread {}";
  1844. static const char __pyx_k_Transaction_is_already_active_No[] = "Transaction is already active. Not opening another one.";
  1845. static const char __pyx_k_lakesuperior_store_base_lmdb_sto[] = "lakesuperior.store.base_lmdb_store";
  1846. 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";
  1847. static PyObject *__pyx_kp_u_;
  1848. static PyObject *__pyx_n_s_BaseLmdbStore_txn_ctx;
  1849. static PyObject *__pyx_kp_u_Cleaning_up_store_env;
  1850. static PyObject *__pyx_kp_u_Cleared_stale_readers;
  1851. static PyObject *__pyx_kp_u_Closing_store_env;
  1852. static PyObject *__pyx_kp_u_Could_not_create_store_at_Error;
  1853. static PyObject *__pyx_kp_u_Created_DB;
  1854. static PyObject *__pyx_kp_u_Created_DBenv_x;
  1855. static PyObject *__pyx_kp_u_Creating_DBs;
  1856. static PyObject *__pyx_kp_u_DBI;
  1857. static PyObject *__pyx_kp_u_DBenv_address_x;
  1858. static PyObject *__pyx_kp_u_Environment_already_open;
  1859. static PyObject *__pyx_kp_u_Error_creating_DB_environment_ha;
  1860. static PyObject *__pyx_kp_u_Error_getting_data_for_key;
  1861. static PyObject *__pyx_kp_u_Error_getting_datbase_stats;
  1862. static PyObject *__pyx_kp_u_Error_opening_cursor;
  1863. static PyObject *__pyx_kp_u_Error_opening_the_database_envir;
  1864. static PyObject *__pyx_kp_u_Error_opening_transaction;
  1865. static PyObject *__pyx_kp_u_Error_putting_data;
  1866. static PyObject *__pyx_kp_u_Error_setting_map_size;
  1867. static PyObject *__pyx_kp_u_Error_setting_max_databases;
  1868. static PyObject *__pyx_kp_u_Error_setting_max_readers;
  1869. static PyObject *__pyx_n_s_FileNotFoundError;
  1870. static PyObject *__pyx_kp_u_Getting_DBI_without_label;
  1871. static PyObject *__pyx_kp_u_Internal_error;
  1872. static PyObject *__pyx_n_s_KeyExistsError;
  1873. static PyObject *__pyx_n_s_KeyNotFoundError;
  1874. static PyObject *__pyx_kp_u_LMDB_Error;
  1875. static PyObject *__pyx_n_s_LmdbError;
  1876. static PyObject *__pyx_kp_u_Max_readers;
  1877. static PyObject *__pyx_n_s_MemoryError;
  1878. static PyObject *__pyx_kp_u_None;
  1879. static PyObject *__pyx_kp_u_Opened_transaction_x;
  1880. static PyObject *__pyx_kp_u_Opening_cursor_for_DB;
  1881. static PyObject *__pyx_kp_u_Opening_environment_at;
  1882. static PyObject *__pyx_kp_u_Opening_transaction_in_PID_threa;
  1883. static PyObject *__pyx_n_u_RO;
  1884. static PyObject *__pyx_n_u_RW;
  1885. static PyObject *__pyx_n_s_RuntimeError;
  1886. static PyObject *__pyx_kp_u_Store_is_not_open;
  1887. static PyObject *__pyx_kp_u_Store_must_be_opened_first;
  1888. static PyObject *__pyx_kp_u_Transaction_aborted;
  1889. static PyObject *__pyx_kp_u_Transaction_committed;
  1890. static PyObject *__pyx_kp_u_Transaction_is_already_active_No;
  1891. static PyObject *__pyx_n_s_TypeError;
  1892. static PyObject *__pyx_kp_u__20;
  1893. static PyObject *__pyx_kp_u__4;
  1894. static PyObject *__pyx_kp_u__6;
  1895. static PyObject *__pyx_n_s_abort;
  1896. static PyObject *__pyx_n_s_args;
  1897. static PyObject *__pyx_n_s_cline_in_traceback;
  1898. static PyObject *__pyx_n_s_close;
  1899. static PyObject *__pyx_n_s_close_env;
  1900. static PyObject *__pyx_n_s_commit_pending_transaction;
  1901. static PyObject *__pyx_n_s_contextlib;
  1902. static PyObject *__pyx_n_s_contextmanager;
  1903. static PyObject *__pyx_n_s_create;
  1904. static PyObject *__pyx_n_s_currentThread;
  1905. static PyObject *__pyx_n_s_current_process;
  1906. static PyObject *__pyx_n_s_data;
  1907. static PyObject *__pyx_n_s_data_v;
  1908. static PyObject *__pyx_n_u_db_stats;
  1909. static PyObject *__pyx_n_s_dbi;
  1910. static PyObject *__pyx_n_s_dbi_flags;
  1911. static PyObject *__pyx_n_s_dbi_labels;
  1912. static PyObject *__pyx_n_s_dblabel;
  1913. static PyObject *__pyx_n_s_debug;
  1914. static PyObject *__pyx_n_s_destroy;
  1915. static PyObject *__pyx_n_s_dirname;
  1916. static PyObject *__pyx_n_s_doc;
  1917. static PyObject *__pyx_n_s_encode;
  1918. static PyObject *__pyx_n_s_enter;
  1919. static PyObject *__pyx_n_s_enumerate;
  1920. static PyObject *__pyx_n_s_env;
  1921. static PyObject *__pyx_n_s_env_flags;
  1922. static PyObject *__pyx_n_s_env_path;
  1923. static PyObject *__pyx_n_s_env_perms;
  1924. static PyObject *__pyx_n_u_env_size;
  1925. static PyObject *__pyx_n_u_env_stats;
  1926. static PyObject *__pyx_n_s_exist_ok;
  1927. static PyObject *__pyx_n_s_exists;
  1928. static PyObject *__pyx_n_s_exit;
  1929. static PyObject *__pyx_n_s_flags;
  1930. static PyObject *__pyx_n_s_format;
  1931. static PyObject *__pyx_n_s_get;
  1932. static PyObject *__pyx_n_s_getLogger;
  1933. static PyObject *__pyx_n_s_getName;
  1934. static PyObject *__pyx_n_s_get_data;
  1935. static PyObject *__pyx_n_s_getstate;
  1936. static PyObject *__pyx_n_s_i;
  1937. static PyObject *__pyx_n_s_import;
  1938. static PyObject *__pyx_n_s_index;
  1939. static PyObject *__pyx_n_s_info;
  1940. static PyObject *__pyx_n_s_is_open;
  1941. static PyObject *__pyx_n_s_is_txn_rw;
  1942. static PyObject *__pyx_n_s_key;
  1943. static PyObject *__pyx_n_s_key_v;
  1944. static PyObject *__pyx_n_s_lakesuperior;
  1945. static PyObject *__pyx_n_s_lakesuperior_store_base_lmdb_sto;
  1946. static PyObject *__pyx_kp_u_lock;
  1947. static PyObject *__pyx_n_s_logger;
  1948. static PyObject *__pyx_n_s_logging;
  1949. static PyObject *__pyx_n_s_main;
  1950. static PyObject *__pyx_n_s_makedirs;
  1951. static PyObject *__pyx_n_u_map_size;
  1952. static PyObject *__pyx_n_u_max_dbs;
  1953. static PyObject *__pyx_n_u_max_spare_txns;
  1954. static PyObject *__pyx_n_s_metaclass;
  1955. static PyObject *__pyx_n_s_mode;
  1956. static PyObject *__pyx_n_s_module;
  1957. static PyObject *__pyx_n_s_ms_branch_pages;
  1958. static PyObject *__pyx_n_s_ms_depth;
  1959. static PyObject *__pyx_n_s_ms_entries;
  1960. static PyObject *__pyx_n_s_ms_leaf_pages;
  1961. static PyObject *__pyx_n_s_ms_overflow_pages;
  1962. static PyObject *__pyx_n_s_ms_psize;
  1963. static PyObject *__pyx_n_s_multiprocessing;
  1964. static PyObject *__pyx_n_s_name;
  1965. static PyObject *__pyx_n_s_new_txn;
  1966. static PyObject *__pyx_n_s_open_env;
  1967. static PyObject *__pyx_kp_u_opened_x;
  1968. static PyObject *__pyx_n_s_options;
  1969. static PyObject *__pyx_n_s_os;
  1970. static PyObject *__pyx_n_s_path;
  1971. static PyObject *__pyx_n_s_path_2;
  1972. static PyObject *__pyx_n_s_pid;
  1973. static PyObject *__pyx_n_s_prepare;
  1974. static PyObject *__pyx_n_s_pyx_capi;
  1975. static PyObject *__pyx_n_s_pyx_vtable;
  1976. static PyObject *__pyx_n_s_qualname;
  1977. static PyObject *__pyx_n_s_rc;
  1978. static PyObject *__pyx_n_s_readers_mult;
  1979. static PyObject *__pyx_n_s_reduce;
  1980. static PyObject *__pyx_n_s_reduce_cython;
  1981. static PyObject *__pyx_n_s_reduce_ex;
  1982. static PyObject *__pyx_n_s_rmtree;
  1983. static PyObject *__pyx_kp_s_self_curs_self_dbenv_self_dbis_s;
  1984. static PyObject *__pyx_n_s_send;
  1985. static PyObject *__pyx_n_s_setstate;
  1986. static PyObject *__pyx_n_s_setstate_cython;
  1987. static PyObject *__pyx_n_s_shutil;
  1988. static PyObject *__pyx_n_s_st_size;
  1989. static PyObject *__pyx_n_s_stat;
  1990. static PyObject *__pyx_n_s_stats;
  1991. static PyObject *__pyx_n_s_test;
  1992. static PyObject *__pyx_n_s_threading;
  1993. static PyObject *__pyx_n_s_throw;
  1994. static PyObject *__pyx_n_s_txn_ctx;
  1995. static PyObject *__pyx_n_s_txn_id;
  1996. static PyObject *__pyx_kp_u_txn_is_open;
  1997. static PyObject *__pyx_n_s_unlink;
  1998. static PyObject *__pyx_n_s_warning;
  1999. static PyObject *__pyx_n_s_workers;
  2000. static PyObject *__pyx_n_s_write;
  2001. static PyObject *__pyx_n_s_wsgi;
  2002. static PyObject *__pyx_kp_u_x;
  2003. 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 */
  2004. 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 */
  2005. 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 */
  2006. 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 */
  2007. 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 */
  2008. 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 */
  2009. 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 */
  2010. 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 */
  2011. 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 */
  2012. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2013. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2014. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self); /* proto */
  2015. 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 */
  2016. 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 */
  2017. 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 */
  2018. 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 */
  2019. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_new_txn); /* proto */
  2020. 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 */
  2021. 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 */
  2022. 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 */
  2023. 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 */
  2024. 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 */
  2025. 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 */
  2026. 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 */
  2027. static PyObject *__pyx_tp_new_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2028. static PyObject *__pyx_tp_new_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2029. static PyObject *__pyx_int_0;
  2030. static PyObject *__pyx_int_1;
  2031. static PyObject *__pyx_int_4;
  2032. static PyObject *__pyx_int_416;
  2033. static PyObject *__pyx_int_488;
  2034. static PyObject *__pyx_int_1073741824;
  2035. static unsigned char *__pyx_k__14;
  2036. static unsigned char *__pyx_k__15;
  2037. static unsigned char *__pyx_k__16;
  2038. static unsigned char *__pyx_k__17;
  2039. static PyObject *__pyx_tuple__2;
  2040. static PyObject *__pyx_tuple__3;
  2041. static PyObject *__pyx_tuple__5;
  2042. static PyObject *__pyx_tuple__7;
  2043. static PyObject *__pyx_tuple__8;
  2044. static PyObject *__pyx_tuple__9;
  2045. static PyObject *__pyx_tuple__10;
  2046. static PyObject *__pyx_tuple__11;
  2047. static PyObject *__pyx_tuple__12;
  2048. static PyObject *__pyx_tuple__13;
  2049. static PyObject *__pyx_tuple__18;
  2050. static PyObject *__pyx_tuple__19;
  2051. static PyObject *__pyx_tuple__21;
  2052. static PyObject *__pyx_tuple__22;
  2053. /* Late includes */
  2054. /* "lakesuperior/store/base_lmdb_store.pyx":22
  2055. *
  2056. *
  2057. * cdef void _check(int rc, str message='') except *: # <<<<<<<<<<<<<<
  2058. * """
  2059. * Check return code.
  2060. */
  2061. 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) {
  2062. PyObject *__pyx_v_message = ((PyObject*)__pyx_kp_u_);
  2063. PyObject *__pyx_v_out_msg = NULL;
  2064. __Pyx_TraceDeclarations
  2065. __Pyx_RefNannyDeclarations
  2066. int __pyx_t_1;
  2067. PyObject *__pyx_t_2 = NULL;
  2068. PyObject *__pyx_t_3 = NULL;
  2069. PyObject *__pyx_t_4 = NULL;
  2070. Py_ssize_t __pyx_t_5;
  2071. PyObject *__pyx_t_6 = NULL;
  2072. PyObject *__pyx_t_7 = NULL;
  2073. PyObject *__pyx_t_8 = NULL;
  2074. char *__pyx_t_9;
  2075. __Pyx_RefNannySetupContext("_check", 0);
  2076. __Pyx_TraceCall("_check", __pyx_f[0], 22, 0, __PYX_ERR(0, 22, __pyx_L1_error));
  2077. if (__pyx_optional_args) {
  2078. if (__pyx_optional_args->__pyx_n > 0) {
  2079. __pyx_v_message = __pyx_optional_args->message;
  2080. }
  2081. }
  2082. /* "lakesuperior/store/base_lmdb_store.pyx":26
  2083. * Check return code.
  2084. * """
  2085. * if rc == lmdb.MDB_NOTFOUND: # <<<<<<<<<<<<<<
  2086. * raise KeyNotFoundError()
  2087. * if rc == lmdb.MDB_KEYEXIST:
  2088. */
  2089. __pyx_t_1 = ((__pyx_v_rc == MDB_NOTFOUND) != 0);
  2090. if (unlikely(__pyx_t_1)) {
  2091. /* "lakesuperior/store/base_lmdb_store.pyx":27
  2092. * """
  2093. * if rc == lmdb.MDB_NOTFOUND:
  2094. * raise KeyNotFoundError() # <<<<<<<<<<<<<<
  2095. * if rc == lmdb.MDB_KEYEXIST:
  2096. * raise KeyExistsError()
  2097. */
  2098. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error)
  2099. __Pyx_GOTREF(__pyx_t_3);
  2100. __pyx_t_4 = NULL;
  2101. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  2102. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  2103. if (likely(__pyx_t_4)) {
  2104. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2105. __Pyx_INCREF(__pyx_t_4);
  2106. __Pyx_INCREF(function);
  2107. __Pyx_DECREF_SET(__pyx_t_3, function);
  2108. }
  2109. }
  2110. if (__pyx_t_4) {
  2111. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
  2112. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2113. } else {
  2114. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
  2115. }
  2116. __Pyx_GOTREF(__pyx_t_2);
  2117. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2118. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  2119. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2120. __PYX_ERR(0, 27, __pyx_L1_error)
  2121. /* "lakesuperior/store/base_lmdb_store.pyx":26
  2122. * Check return code.
  2123. * """
  2124. * if rc == lmdb.MDB_NOTFOUND: # <<<<<<<<<<<<<<
  2125. * raise KeyNotFoundError()
  2126. * if rc == lmdb.MDB_KEYEXIST:
  2127. */
  2128. }
  2129. /* "lakesuperior/store/base_lmdb_store.pyx":28
  2130. * if rc == lmdb.MDB_NOTFOUND:
  2131. * raise KeyNotFoundError()
  2132. * if rc == lmdb.MDB_KEYEXIST: # <<<<<<<<<<<<<<
  2133. * raise KeyExistsError()
  2134. * if rc != lmdb.MDB_SUCCESS:
  2135. */
  2136. __pyx_t_1 = ((__pyx_v_rc == MDB_KEYEXIST) != 0);
  2137. if (unlikely(__pyx_t_1)) {
  2138. /* "lakesuperior/store/base_lmdb_store.pyx":29
  2139. * raise KeyNotFoundError()
  2140. * if rc == lmdb.MDB_KEYEXIST:
  2141. * raise KeyExistsError() # <<<<<<<<<<<<<<
  2142. * if rc != lmdb.MDB_SUCCESS:
  2143. * out_msg = (
  2144. */
  2145. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyExistsError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error)
  2146. __Pyx_GOTREF(__pyx_t_3);
  2147. __pyx_t_4 = NULL;
  2148. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  2149. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  2150. if (likely(__pyx_t_4)) {
  2151. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2152. __Pyx_INCREF(__pyx_t_4);
  2153. __Pyx_INCREF(function);
  2154. __Pyx_DECREF_SET(__pyx_t_3, function);
  2155. }
  2156. }
  2157. if (__pyx_t_4) {
  2158. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  2159. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2160. } else {
  2161. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  2162. }
  2163. __Pyx_GOTREF(__pyx_t_2);
  2164. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2165. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  2166. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2167. __PYX_ERR(0, 29, __pyx_L1_error)
  2168. /* "lakesuperior/store/base_lmdb_store.pyx":28
  2169. * if rc == lmdb.MDB_NOTFOUND:
  2170. * raise KeyNotFoundError()
  2171. * if rc == lmdb.MDB_KEYEXIST: # <<<<<<<<<<<<<<
  2172. * raise KeyExistsError()
  2173. * if rc != lmdb.MDB_SUCCESS:
  2174. */
  2175. }
  2176. /* "lakesuperior/store/base_lmdb_store.pyx":30
  2177. * if rc == lmdb.MDB_KEYEXIST:
  2178. * raise KeyExistsError()
  2179. * if rc != lmdb.MDB_SUCCESS: # <<<<<<<<<<<<<<
  2180. * out_msg = (
  2181. * message + '\nInternal error ({}): '.format(rc)
  2182. */
  2183. __pyx_t_1 = ((__pyx_v_rc != MDB_SUCCESS) != 0);
  2184. if (unlikely(__pyx_t_1)) {
  2185. /* "lakesuperior/store/base_lmdb_store.pyx":33
  2186. * out_msg = (
  2187. * message + '\nInternal error ({}): '.format(rc)
  2188. * if len(message) else 'LMDB Error ({}): '.format(rc)) # <<<<<<<<<<<<<<
  2189. * out_msg += lmdb.mdb_strerror(rc).decode()
  2190. * raise LmdbError(out_msg)
  2191. */
  2192. if (unlikely(__pyx_v_message == Py_None)) {
  2193. PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
  2194. __PYX_ERR(0, 33, __pyx_L1_error)
  2195. }
  2196. __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)
  2197. if ((__pyx_t_5 != 0)) {
  2198. /* "lakesuperior/store/base_lmdb_store.pyx":32
  2199. * if rc != lmdb.MDB_SUCCESS:
  2200. * out_msg = (
  2201. * message + '\nInternal error ({}): '.format(rc) # <<<<<<<<<<<<<<
  2202. * if len(message) else 'LMDB Error ({}): '.format(rc))
  2203. * out_msg += lmdb.mdb_strerror(rc).decode()
  2204. */
  2205. __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)
  2206. __Pyx_GOTREF(__pyx_t_4);
  2207. __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 32, __pyx_L1_error)
  2208. __Pyx_GOTREF(__pyx_t_6);
  2209. __pyx_t_7 = NULL;
  2210. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  2211. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
  2212. if (likely(__pyx_t_7)) {
  2213. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2214. __Pyx_INCREF(__pyx_t_7);
  2215. __Pyx_INCREF(function);
  2216. __Pyx_DECREF_SET(__pyx_t_4, function);
  2217. }
  2218. }
  2219. if (!__pyx_t_7) {
  2220. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error)
  2221. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2222. __Pyx_GOTREF(__pyx_t_3);
  2223. } else {
  2224. #if CYTHON_FAST_PYCALL
  2225. if (PyFunction_Check(__pyx_t_4)) {
  2226. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  2227. __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)
  2228. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  2229. __Pyx_GOTREF(__pyx_t_3);
  2230. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2231. } else
  2232. #endif
  2233. #if CYTHON_FAST_PYCCALL
  2234. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  2235. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  2236. __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)
  2237. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  2238. __Pyx_GOTREF(__pyx_t_3);
  2239. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2240. } else
  2241. #endif
  2242. {
  2243. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 32, __pyx_L1_error)
  2244. __Pyx_GOTREF(__pyx_t_8);
  2245. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  2246. __Pyx_GIVEREF(__pyx_t_6);
  2247. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
  2248. __pyx_t_6 = 0;
  2249. __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)
  2250. __Pyx_GOTREF(__pyx_t_3);
  2251. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2252. }
  2253. }
  2254. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2255. __pyx_t_4 = PyNumber_Add(__pyx_v_message, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 32, __pyx_L1_error)
  2256. __Pyx_GOTREF(__pyx_t_4);
  2257. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2258. __pyx_t_2 = __pyx_t_4;
  2259. __pyx_t_4 = 0;
  2260. } else {
  2261. /* "lakesuperior/store/base_lmdb_store.pyx":33
  2262. * out_msg = (
  2263. * message + '\nInternal error ({}): '.format(rc)
  2264. * if len(message) else 'LMDB Error ({}): '.format(rc)) # <<<<<<<<<<<<<<
  2265. * out_msg += lmdb.mdb_strerror(rc).decode()
  2266. * raise LmdbError(out_msg)
  2267. */
  2268. __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)
  2269. __Pyx_GOTREF(__pyx_t_3);
  2270. __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 33, __pyx_L1_error)
  2271. __Pyx_GOTREF(__pyx_t_8);
  2272. __pyx_t_6 = NULL;
  2273. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  2274. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
  2275. if (likely(__pyx_t_6)) {
  2276. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2277. __Pyx_INCREF(__pyx_t_6);
  2278. __Pyx_INCREF(function);
  2279. __Pyx_DECREF_SET(__pyx_t_3, function);
  2280. }
  2281. }
  2282. if (!__pyx_t_6) {
  2283. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error)
  2284. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2285. __Pyx_GOTREF(__pyx_t_4);
  2286. } else {
  2287. #if CYTHON_FAST_PYCALL
  2288. if (PyFunction_Check(__pyx_t_3)) {
  2289. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_8};
  2290. __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)
  2291. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2292. __Pyx_GOTREF(__pyx_t_4);
  2293. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2294. } else
  2295. #endif
  2296. #if CYTHON_FAST_PYCCALL
  2297. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  2298. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_8};
  2299. __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)
  2300. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2301. __Pyx_GOTREF(__pyx_t_4);
  2302. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2303. } else
  2304. #endif
  2305. {
  2306. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 33, __pyx_L1_error)
  2307. __Pyx_GOTREF(__pyx_t_7);
  2308. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
  2309. __Pyx_GIVEREF(__pyx_t_8);
  2310. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_8);
  2311. __pyx_t_8 = 0;
  2312. __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)
  2313. __Pyx_GOTREF(__pyx_t_4);
  2314. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2315. }
  2316. }
  2317. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2318. __pyx_t_2 = __pyx_t_4;
  2319. __pyx_t_4 = 0;
  2320. }
  2321. __pyx_v_out_msg = __pyx_t_2;
  2322. __pyx_t_2 = 0;
  2323. /* "lakesuperior/store/base_lmdb_store.pyx":34
  2324. * message + '\nInternal error ({}): '.format(rc)
  2325. * if len(message) else 'LMDB Error ({}): '.format(rc))
  2326. * out_msg += lmdb.mdb_strerror(rc).decode() # <<<<<<<<<<<<<<
  2327. * raise LmdbError(out_msg)
  2328. *
  2329. */
  2330. __pyx_t_9 = mdb_strerror(__pyx_v_rc);
  2331. __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)
  2332. __Pyx_GOTREF(__pyx_t_2);
  2333. __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_out_msg, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error)
  2334. __Pyx_GOTREF(__pyx_t_4);
  2335. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2336. __Pyx_DECREF_SET(__pyx_v_out_msg, __pyx_t_4);
  2337. __pyx_t_4 = 0;
  2338. /* "lakesuperior/store/base_lmdb_store.pyx":35
  2339. * if len(message) else 'LMDB Error ({}): '.format(rc))
  2340. * out_msg += lmdb.mdb_strerror(rc).decode()
  2341. * raise LmdbError(out_msg) # <<<<<<<<<<<<<<
  2342. *
  2343. *
  2344. */
  2345. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
  2346. __Pyx_GOTREF(__pyx_t_2);
  2347. __pyx_t_3 = NULL;
  2348. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  2349. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  2350. if (likely(__pyx_t_3)) {
  2351. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  2352. __Pyx_INCREF(__pyx_t_3);
  2353. __Pyx_INCREF(function);
  2354. __Pyx_DECREF_SET(__pyx_t_2, function);
  2355. }
  2356. }
  2357. if (!__pyx_t_3) {
  2358. __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)
  2359. __Pyx_GOTREF(__pyx_t_4);
  2360. } else {
  2361. #if CYTHON_FAST_PYCALL
  2362. if (PyFunction_Check(__pyx_t_2)) {
  2363. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_out_msg};
  2364. __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)
  2365. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2366. __Pyx_GOTREF(__pyx_t_4);
  2367. } else
  2368. #endif
  2369. #if CYTHON_FAST_PYCCALL
  2370. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  2371. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_out_msg};
  2372. __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)
  2373. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2374. __Pyx_GOTREF(__pyx_t_4);
  2375. } else
  2376. #endif
  2377. {
  2378. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 35, __pyx_L1_error)
  2379. __Pyx_GOTREF(__pyx_t_7);
  2380. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
  2381. __Pyx_INCREF(__pyx_v_out_msg);
  2382. __Pyx_GIVEREF(__pyx_v_out_msg);
  2383. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_out_msg);
  2384. __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)
  2385. __Pyx_GOTREF(__pyx_t_4);
  2386. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2387. }
  2388. }
  2389. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2390. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  2391. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2392. __PYX_ERR(0, 35, __pyx_L1_error)
  2393. /* "lakesuperior/store/base_lmdb_store.pyx":30
  2394. * if rc == lmdb.MDB_KEYEXIST:
  2395. * raise KeyExistsError()
  2396. * if rc != lmdb.MDB_SUCCESS: # <<<<<<<<<<<<<<
  2397. * out_msg = (
  2398. * message + '\nInternal error ({}): '.format(rc)
  2399. */
  2400. }
  2401. /* "lakesuperior/store/base_lmdb_store.pyx":22
  2402. *
  2403. *
  2404. * cdef void _check(int rc, str message='') except *: # <<<<<<<<<<<<<<
  2405. * """
  2406. * Check return code.
  2407. */
  2408. /* function exit code */
  2409. goto __pyx_L0;
  2410. __pyx_L1_error:;
  2411. __Pyx_XDECREF(__pyx_t_2);
  2412. __Pyx_XDECREF(__pyx_t_3);
  2413. __Pyx_XDECREF(__pyx_t_4);
  2414. __Pyx_XDECREF(__pyx_t_6);
  2415. __Pyx_XDECREF(__pyx_t_7);
  2416. __Pyx_XDECREF(__pyx_t_8);
  2417. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store._check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2418. __pyx_L0:;
  2419. __Pyx_XDECREF(__pyx_v_out_msg);
  2420. __Pyx_TraceReturn(Py_None, 0);
  2421. __Pyx_RefNannyFinishContext();
  2422. }
  2423. /* "lakesuperior/store/base_lmdb_store.pyx":129
  2424. * ### INIT & TEARDOWN ###
  2425. *
  2426. * def __init__(self, env_path, open_env=True, create=True): # <<<<<<<<<<<<<<
  2427. * """
  2428. * Initialize DB environment and databases.
  2429. */
  2430. /* Python wrapper */
  2431. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2432. 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 ";
  2433. #if CYTHON_COMPILING_IN_CPYTHON
  2434. struct wrapperbase __pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__;
  2435. #endif
  2436. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2437. PyObject *__pyx_v_env_path = 0;
  2438. PyObject *__pyx_v_open_env = 0;
  2439. PyObject *__pyx_v_create = 0;
  2440. int __pyx_r;
  2441. __Pyx_RefNannyDeclarations
  2442. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  2443. {
  2444. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_env_path,&__pyx_n_s_open_env,&__pyx_n_s_create,0};
  2445. PyObject* values[3] = {0,0,0};
  2446. values[1] = ((PyObject *)Py_True);
  2447. values[2] = ((PyObject *)Py_True);
  2448. if (unlikely(__pyx_kwds)) {
  2449. Py_ssize_t kw_args;
  2450. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2451. switch (pos_args) {
  2452. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2453. CYTHON_FALLTHROUGH;
  2454. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2455. CYTHON_FALLTHROUGH;
  2456. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2457. CYTHON_FALLTHROUGH;
  2458. case 0: break;
  2459. default: goto __pyx_L5_argtuple_error;
  2460. }
  2461. kw_args = PyDict_Size(__pyx_kwds);
  2462. switch (pos_args) {
  2463. case 0:
  2464. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_env_path)) != 0)) kw_args--;
  2465. else goto __pyx_L5_argtuple_error;
  2466. CYTHON_FALLTHROUGH;
  2467. case 1:
  2468. if (kw_args > 0) {
  2469. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_open_env);
  2470. if (value) { values[1] = value; kw_args--; }
  2471. }
  2472. CYTHON_FALLTHROUGH;
  2473. case 2:
  2474. if (kw_args > 0) {
  2475. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_create);
  2476. if (value) { values[2] = value; kw_args--; }
  2477. }
  2478. }
  2479. if (unlikely(kw_args > 0)) {
  2480. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 129, __pyx_L3_error)
  2481. }
  2482. } else {
  2483. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2484. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2485. CYTHON_FALLTHROUGH;
  2486. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2487. CYTHON_FALLTHROUGH;
  2488. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2489. break;
  2490. default: goto __pyx_L5_argtuple_error;
  2491. }
  2492. }
  2493. __pyx_v_env_path = values[0];
  2494. __pyx_v_open_env = values[1];
  2495. __pyx_v_create = values[2];
  2496. }
  2497. goto __pyx_L4_argument_unpacking_done;
  2498. __pyx_L5_argtuple_error:;
  2499. __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 129, __pyx_L3_error)
  2500. __pyx_L3_error:;
  2501. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2502. __Pyx_RefNannyFinishContext();
  2503. return -1;
  2504. __pyx_L4_argument_unpacking_done:;
  2505. __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);
  2506. /* function exit code */
  2507. __Pyx_RefNannyFinishContext();
  2508. return __pyx_r;
  2509. }
  2510. 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) {
  2511. int __pyx_r;
  2512. __Pyx_TraceDeclarations
  2513. __Pyx_RefNannyDeclarations
  2514. PyObject *__pyx_t_1 = NULL;
  2515. int __pyx_t_2;
  2516. PyObject *__pyx_t_3 = NULL;
  2517. PyObject *__pyx_t_4 = NULL;
  2518. PyObject *__pyx_t_5 = NULL;
  2519. __Pyx_RefNannySetupContext("__init__", 0);
  2520. __Pyx_TraceCall("__init__", __pyx_f[0], 129, 0, __PYX_ERR(0, 129, __pyx_L1_error));
  2521. /* "lakesuperior/store/base_lmdb_store.pyx":139
  2522. * be created if the store is opened immediately.
  2523. * """
  2524. * self._open = False # <<<<<<<<<<<<<<
  2525. * self.is_txn_open = False
  2526. * self.env_path = env_path
  2527. */
  2528. __pyx_v_self->_open = 0;
  2529. /* "lakesuperior/store/base_lmdb_store.pyx":140
  2530. * """
  2531. * self._open = False
  2532. * self.is_txn_open = False # <<<<<<<<<<<<<<
  2533. * self.env_path = env_path
  2534. * if open_env:
  2535. */
  2536. __pyx_v_self->is_txn_open = 0;
  2537. /* "lakesuperior/store/base_lmdb_store.pyx":141
  2538. * self._open = False
  2539. * self.is_txn_open = False
  2540. * self.env_path = env_path # <<<<<<<<<<<<<<
  2541. * if open_env:
  2542. * self.open_env(create)
  2543. */
  2544. 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)
  2545. __pyx_t_1 = __pyx_v_env_path;
  2546. __Pyx_INCREF(__pyx_t_1);
  2547. __Pyx_GIVEREF(__pyx_t_1);
  2548. __Pyx_GOTREF(__pyx_v_self->env_path);
  2549. __Pyx_DECREF(__pyx_v_self->env_path);
  2550. __pyx_v_self->env_path = ((PyObject*)__pyx_t_1);
  2551. __pyx_t_1 = 0;
  2552. /* "lakesuperior/store/base_lmdb_store.pyx":142
  2553. * self.is_txn_open = False
  2554. * self.env_path = env_path
  2555. * if open_env: # <<<<<<<<<<<<<<
  2556. * self.open_env(create)
  2557. * #logger.info('Init DB with path: {}'.format(self.env_path))
  2558. */
  2559. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_open_env); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 142, __pyx_L1_error)
  2560. if (__pyx_t_2) {
  2561. /* "lakesuperior/store/base_lmdb_store.pyx":143
  2562. * self.env_path = env_path
  2563. * if open_env:
  2564. * self.open_env(create) # <<<<<<<<<<<<<<
  2565. * #logger.info('Init DB with path: {}'.format(self.env_path))
  2566. *
  2567. */
  2568. __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)
  2569. __Pyx_GOTREF(__pyx_t_3);
  2570. __pyx_t_4 = NULL;
  2571. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  2572. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  2573. if (likely(__pyx_t_4)) {
  2574. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2575. __Pyx_INCREF(__pyx_t_4);
  2576. __Pyx_INCREF(function);
  2577. __Pyx_DECREF_SET(__pyx_t_3, function);
  2578. }
  2579. }
  2580. if (!__pyx_t_4) {
  2581. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_create); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
  2582. __Pyx_GOTREF(__pyx_t_1);
  2583. } else {
  2584. #if CYTHON_FAST_PYCALL
  2585. if (PyFunction_Check(__pyx_t_3)) {
  2586. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_create};
  2587. __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)
  2588. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2589. __Pyx_GOTREF(__pyx_t_1);
  2590. } else
  2591. #endif
  2592. #if CYTHON_FAST_PYCCALL
  2593. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  2594. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_create};
  2595. __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)
  2596. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2597. __Pyx_GOTREF(__pyx_t_1);
  2598. } else
  2599. #endif
  2600. {
  2601. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error)
  2602. __Pyx_GOTREF(__pyx_t_5);
  2603. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  2604. __Pyx_INCREF(__pyx_v_create);
  2605. __Pyx_GIVEREF(__pyx_v_create);
  2606. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_create);
  2607. __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)
  2608. __Pyx_GOTREF(__pyx_t_1);
  2609. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2610. }
  2611. }
  2612. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2613. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2614. /* "lakesuperior/store/base_lmdb_store.pyx":142
  2615. * self.is_txn_open = False
  2616. * self.env_path = env_path
  2617. * if open_env: # <<<<<<<<<<<<<<
  2618. * self.open_env(create)
  2619. * #logger.info('Init DB with path: {}'.format(self.env_path))
  2620. */
  2621. }
  2622. /* "lakesuperior/store/base_lmdb_store.pyx":129
  2623. * ### INIT & TEARDOWN ###
  2624. *
  2625. * def __init__(self, env_path, open_env=True, create=True): # <<<<<<<<<<<<<<
  2626. * """
  2627. * Initialize DB environment and databases.
  2628. */
  2629. /* function exit code */
  2630. __pyx_r = 0;
  2631. goto __pyx_L0;
  2632. __pyx_L1_error:;
  2633. __Pyx_XDECREF(__pyx_t_1);
  2634. __Pyx_XDECREF(__pyx_t_3);
  2635. __Pyx_XDECREF(__pyx_t_4);
  2636. __Pyx_XDECREF(__pyx_t_5);
  2637. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2638. __pyx_r = -1;
  2639. __pyx_L0:;
  2640. __Pyx_TraceReturn(Py_None, 0);
  2641. __Pyx_RefNannyFinishContext();
  2642. return __pyx_r;
  2643. }
  2644. /* "lakesuperior/store/base_lmdb_store.pyx":147
  2645. *
  2646. *
  2647. * def __dealloc__(self): # <<<<<<<<<<<<<<
  2648. * self.close_env()
  2649. *
  2650. */
  2651. /* Python wrapper */
  2652. static void __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
  2653. static void __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_3__dealloc__(PyObject *__pyx_v_self) {
  2654. __Pyx_RefNannyDeclarations
  2655. __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  2656. __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_2__dealloc__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  2657. /* function exit code */
  2658. __Pyx_RefNannyFinishContext();
  2659. }
  2660. static void __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_2__dealloc__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  2661. __Pyx_TraceDeclarations
  2662. __Pyx_RefNannyDeclarations
  2663. __Pyx_RefNannySetupContext("__dealloc__", 0);
  2664. __Pyx_TraceCall("__dealloc__", __pyx_f[0], 147, 0, __PYX_ERR(0, 147, __pyx_L1_error));
  2665. /* "lakesuperior/store/base_lmdb_store.pyx":148
  2666. *
  2667. * def __dealloc__(self):
  2668. * self.close_env() # <<<<<<<<<<<<<<
  2669. *
  2670. *
  2671. */
  2672. ((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)
  2673. /* "lakesuperior/store/base_lmdb_store.pyx":147
  2674. *
  2675. *
  2676. * def __dealloc__(self): # <<<<<<<<<<<<<<
  2677. * self.close_env()
  2678. *
  2679. */
  2680. /* function exit code */
  2681. goto __pyx_L0;
  2682. __pyx_L1_error:;
  2683. __Pyx_WriteUnraisable("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  2684. __pyx_L0:;
  2685. __Pyx_TraceReturn(Py_None, 0);
  2686. __Pyx_RefNannyFinishContext();
  2687. }
  2688. /* "lakesuperior/store/base_lmdb_store.pyx":152
  2689. *
  2690. * @property
  2691. * def is_open(self): # <<<<<<<<<<<<<<
  2692. * return self._open
  2693. *
  2694. */
  2695. /* Python wrapper */
  2696. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open_1__get__(PyObject *__pyx_v_self); /*proto*/
  2697. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open_1__get__(PyObject *__pyx_v_self) {
  2698. PyObject *__pyx_r = 0;
  2699. __Pyx_RefNannyDeclarations
  2700. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  2701. __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));
  2702. /* function exit code */
  2703. __Pyx_RefNannyFinishContext();
  2704. return __pyx_r;
  2705. }
  2706. 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) {
  2707. PyObject *__pyx_r = NULL;
  2708. __Pyx_TraceDeclarations
  2709. __Pyx_RefNannyDeclarations
  2710. PyObject *__pyx_t_1 = NULL;
  2711. __Pyx_RefNannySetupContext("__get__", 0);
  2712. __Pyx_TraceCall("__get__", __pyx_f[0], 152, 0, __PYX_ERR(0, 152, __pyx_L1_error));
  2713. /* "lakesuperior/store/base_lmdb_store.pyx":153
  2714. * @property
  2715. * def is_open(self):
  2716. * return self._open # <<<<<<<<<<<<<<
  2717. *
  2718. *
  2719. */
  2720. __Pyx_XDECREF(__pyx_r);
  2721. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
  2722. __Pyx_GOTREF(__pyx_t_1);
  2723. __pyx_r = __pyx_t_1;
  2724. __pyx_t_1 = 0;
  2725. goto __pyx_L0;
  2726. /* "lakesuperior/store/base_lmdb_store.pyx":152
  2727. *
  2728. * @property
  2729. * def is_open(self): # <<<<<<<<<<<<<<
  2730. * return self._open
  2731. *
  2732. */
  2733. /* function exit code */
  2734. __pyx_L1_error:;
  2735. __Pyx_XDECREF(__pyx_t_1);
  2736. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.is_open.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2737. __pyx_r = NULL;
  2738. __pyx_L0:;
  2739. __Pyx_XGIVEREF(__pyx_r);
  2740. __Pyx_TraceReturn(__pyx_r, 0);
  2741. __Pyx_RefNannyFinishContext();
  2742. return __pyx_r;
  2743. }
  2744. /* "lakesuperior/store/base_lmdb_store.pyx":157
  2745. *
  2746. * @property
  2747. * def readers(self): # <<<<<<<<<<<<<<
  2748. * return self._readers
  2749. *
  2750. */
  2751. /* Python wrapper */
  2752. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers_1__get__(PyObject *__pyx_v_self); /*proto*/
  2753. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers_1__get__(PyObject *__pyx_v_self) {
  2754. PyObject *__pyx_r = 0;
  2755. __Pyx_RefNannyDeclarations
  2756. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  2757. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers___get__(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  2758. /* function exit code */
  2759. __Pyx_RefNannyFinishContext();
  2760. return __pyx_r;
  2761. }
  2762. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers___get__(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  2763. PyObject *__pyx_r = NULL;
  2764. __Pyx_TraceDeclarations
  2765. __Pyx_RefNannyDeclarations
  2766. PyObject *__pyx_t_1 = NULL;
  2767. __Pyx_RefNannySetupContext("__get__", 0);
  2768. __Pyx_TraceCall("__get__", __pyx_f[0], 157, 0, __PYX_ERR(0, 157, __pyx_L1_error));
  2769. /* "lakesuperior/store/base_lmdb_store.pyx":158
  2770. * @property
  2771. * def readers(self):
  2772. * return self._readers # <<<<<<<<<<<<<<
  2773. *
  2774. *
  2775. */
  2776. __Pyx_XDECREF(__pyx_r);
  2777. __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->_readers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error)
  2778. __Pyx_GOTREF(__pyx_t_1);
  2779. __pyx_r = __pyx_t_1;
  2780. __pyx_t_1 = 0;
  2781. goto __pyx_L0;
  2782. /* "lakesuperior/store/base_lmdb_store.pyx":157
  2783. *
  2784. * @property
  2785. * def readers(self): # <<<<<<<<<<<<<<
  2786. * return self._readers
  2787. *
  2788. */
  2789. /* function exit code */
  2790. __pyx_L1_error:;
  2791. __Pyx_XDECREF(__pyx_t_1);
  2792. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.readers.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2793. __pyx_r = NULL;
  2794. __pyx_L0:;
  2795. __Pyx_XGIVEREF(__pyx_r);
  2796. __Pyx_TraceReturn(__pyx_r, 0);
  2797. __Pyx_RefNannyFinishContext();
  2798. return __pyx_r;
  2799. }
  2800. /* "lakesuperior/store/base_lmdb_store.pyx":161
  2801. *
  2802. *
  2803. * def open_env(self, create): # <<<<<<<<<<<<<<
  2804. * """
  2805. * Open, and optionally create, store environment.
  2806. */
  2807. /* Python wrapper */
  2808. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5open_env(PyObject *__pyx_v_self, PyObject *__pyx_v_create); /*proto*/
  2809. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_4open_env[] = "\n Open, and optionally create, store environment.\n ";
  2810. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5open_env(PyObject *__pyx_v_self, PyObject *__pyx_v_create) {
  2811. PyObject *__pyx_r = 0;
  2812. __Pyx_RefNannyDeclarations
  2813. __Pyx_RefNannySetupContext("open_env (wrapper)", 0);
  2814. __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));
  2815. /* function exit code */
  2816. __Pyx_RefNannyFinishContext();
  2817. return __pyx_r;
  2818. }
  2819. 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) {
  2820. PyObject *__pyx_v_parent_path = NULL;
  2821. PyObject *__pyx_v_e = NULL;
  2822. PyObject *__pyx_v_max_dbs = NULL;
  2823. PyObject *__pyx_r = NULL;
  2824. __Pyx_TraceDeclarations
  2825. __Pyx_RefNannyDeclarations
  2826. PyObject *__pyx_t_1 = NULL;
  2827. int __pyx_t_2;
  2828. PyObject *__pyx_t_3 = NULL;
  2829. PyObject *__pyx_t_4 = NULL;
  2830. PyObject *__pyx_t_5 = NULL;
  2831. PyObject *__pyx_t_6 = NULL;
  2832. PyObject *__pyx_t_7 = NULL;
  2833. int __pyx_t_8;
  2834. PyObject *__pyx_t_9 = NULL;
  2835. PyObject *__pyx_t_10 = NULL;
  2836. PyObject *__pyx_t_11 = NULL;
  2837. int __pyx_t_12;
  2838. PyObject *__pyx_t_13 = NULL;
  2839. PyObject *__pyx_t_14 = NULL;
  2840. PyObject *__pyx_t_15 = NULL;
  2841. int __pyx_t_16;
  2842. char const *__pyx_t_17;
  2843. PyObject *__pyx_t_18 = NULL;
  2844. PyObject *__pyx_t_19 = NULL;
  2845. PyObject *__pyx_t_20 = NULL;
  2846. PyObject *__pyx_t_21 = NULL;
  2847. PyObject *__pyx_t_22 = NULL;
  2848. PyObject *__pyx_t_23 = NULL;
  2849. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_24;
  2850. size_t __pyx_t_25;
  2851. Py_ssize_t __pyx_t_26;
  2852. MDB_dbi __pyx_t_27;
  2853. unsigned int __pyx_t_28;
  2854. char const *__pyx_t_29;
  2855. mdb_mode_t __pyx_t_30;
  2856. Py_UCS4 __pyx_t_31;
  2857. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__init_dbis __pyx_t_32;
  2858. __Pyx_RefNannySetupContext("open_env", 0);
  2859. __Pyx_TraceCall("open_env", __pyx_f[0], 161, 0, __PYX_ERR(0, 161, __pyx_L1_error));
  2860. /* "lakesuperior/store/base_lmdb_store.pyx":165
  2861. * Open, and optionally create, store environment.
  2862. * """
  2863. * if self.is_open: # <<<<<<<<<<<<<<
  2864. * logger.warning('Environment already open.')
  2865. * return
  2866. */
  2867. __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)
  2868. __Pyx_GOTREF(__pyx_t_1);
  2869. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 165, __pyx_L1_error)
  2870. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2871. if (__pyx_t_2) {
  2872. /* "lakesuperior/store/base_lmdb_store.pyx":166
  2873. * """
  2874. * if self.is_open:
  2875. * logger.warning('Environment already open.') # <<<<<<<<<<<<<<
  2876. * return
  2877. *
  2878. */
  2879. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
  2880. __Pyx_GOTREF(__pyx_t_1);
  2881. __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)
  2882. __Pyx_GOTREF(__pyx_t_3);
  2883. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2884. __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)
  2885. __Pyx_GOTREF(__pyx_t_1);
  2886. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2887. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2888. /* "lakesuperior/store/base_lmdb_store.pyx":167
  2889. * if self.is_open:
  2890. * logger.warning('Environment already open.')
  2891. * return # <<<<<<<<<<<<<<
  2892. *
  2893. * logger.debug('Opening environment at {}.'.format(self.env_path))
  2894. */
  2895. __Pyx_XDECREF(__pyx_r);
  2896. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2897. goto __pyx_L0;
  2898. /* "lakesuperior/store/base_lmdb_store.pyx":165
  2899. * Open, and optionally create, store environment.
  2900. * """
  2901. * if self.is_open: # <<<<<<<<<<<<<<
  2902. * logger.warning('Environment already open.')
  2903. * return
  2904. */
  2905. }
  2906. /* "lakesuperior/store/base_lmdb_store.pyx":169
  2907. * return
  2908. *
  2909. * logger.debug('Opening environment at {}.'.format(self.env_path)) # <<<<<<<<<<<<<<
  2910. * if create:
  2911. * #logger.info('Creating db env at {}'.format(self.env_path))
  2912. */
  2913. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
  2914. __Pyx_GOTREF(__pyx_t_3);
  2915. __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)
  2916. __Pyx_GOTREF(__pyx_t_4);
  2917. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2918. __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)
  2919. __Pyx_GOTREF(__pyx_t_5);
  2920. __pyx_t_6 = NULL;
  2921. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  2922. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
  2923. if (likely(__pyx_t_6)) {
  2924. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  2925. __Pyx_INCREF(__pyx_t_6);
  2926. __Pyx_INCREF(function);
  2927. __Pyx_DECREF_SET(__pyx_t_5, function);
  2928. }
  2929. }
  2930. if (!__pyx_t_6) {
  2931. __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)
  2932. __Pyx_GOTREF(__pyx_t_3);
  2933. } else {
  2934. #if CYTHON_FAST_PYCALL
  2935. if (PyFunction_Check(__pyx_t_5)) {
  2936. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->env_path};
  2937. __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)
  2938. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2939. __Pyx_GOTREF(__pyx_t_3);
  2940. } else
  2941. #endif
  2942. #if CYTHON_FAST_PYCCALL
  2943. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  2944. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->env_path};
  2945. __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)
  2946. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2947. __Pyx_GOTREF(__pyx_t_3);
  2948. } else
  2949. #endif
  2950. {
  2951. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 169, __pyx_L1_error)
  2952. __Pyx_GOTREF(__pyx_t_7);
  2953. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
  2954. __Pyx_INCREF(__pyx_v_self->env_path);
  2955. __Pyx_GIVEREF(__pyx_v_self->env_path);
  2956. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_self->env_path);
  2957. __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)
  2958. __Pyx_GOTREF(__pyx_t_3);
  2959. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2960. }
  2961. }
  2962. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2963. __pyx_t_5 = NULL;
  2964. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  2965. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  2966. if (likely(__pyx_t_5)) {
  2967. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2968. __Pyx_INCREF(__pyx_t_5);
  2969. __Pyx_INCREF(function);
  2970. __Pyx_DECREF_SET(__pyx_t_4, function);
  2971. }
  2972. }
  2973. if (!__pyx_t_5) {
  2974. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
  2975. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2976. __Pyx_GOTREF(__pyx_t_1);
  2977. } else {
  2978. #if CYTHON_FAST_PYCALL
  2979. if (PyFunction_Check(__pyx_t_4)) {
  2980. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  2981. __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)
  2982. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2983. __Pyx_GOTREF(__pyx_t_1);
  2984. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2985. } else
  2986. #endif
  2987. #if CYTHON_FAST_PYCCALL
  2988. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  2989. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  2990. __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)
  2991. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2992. __Pyx_GOTREF(__pyx_t_1);
  2993. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2994. } else
  2995. #endif
  2996. {
  2997. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 169, __pyx_L1_error)
  2998. __Pyx_GOTREF(__pyx_t_7);
  2999. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  3000. __Pyx_GIVEREF(__pyx_t_3);
  3001. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3);
  3002. __pyx_t_3 = 0;
  3003. __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)
  3004. __Pyx_GOTREF(__pyx_t_1);
  3005. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3006. }
  3007. }
  3008. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3009. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3010. /* "lakesuperior/store/base_lmdb_store.pyx":170
  3011. *
  3012. * logger.debug('Opening environment at {}.'.format(self.env_path))
  3013. * if create: # <<<<<<<<<<<<<<
  3014. * #logger.info('Creating db env at {}'.format(self.env_path))
  3015. * parent_path = (
  3016. */
  3017. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_create); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 170, __pyx_L1_error)
  3018. if (__pyx_t_2) {
  3019. /* "lakesuperior/store/base_lmdb_store.pyx":174
  3020. * parent_path = (
  3021. * path.dirname(self.env_path)
  3022. * if lmdb.MDB_NOSUBDIR & self.flags # <<<<<<<<<<<<<<
  3023. * else self.env_path)
  3024. *
  3025. */
  3026. __pyx_t_4 = __Pyx_PyInt_From_int(MDB_NOSUBDIR); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
  3027. __Pyx_GOTREF(__pyx_t_4);
  3028. __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)
  3029. __Pyx_GOTREF(__pyx_t_7);
  3030. __pyx_t_3 = PyNumber_And(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
  3031. __Pyx_GOTREF(__pyx_t_3);
  3032. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3033. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3034. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 174, __pyx_L1_error)
  3035. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3036. if (__pyx_t_2) {
  3037. /* "lakesuperior/store/base_lmdb_store.pyx":173
  3038. * #logger.info('Creating db env at {}'.format(self.env_path))
  3039. * parent_path = (
  3040. * path.dirname(self.env_path) # <<<<<<<<<<<<<<
  3041. * if lmdb.MDB_NOSUBDIR & self.flags
  3042. * else self.env_path)
  3043. */
  3044. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 173, __pyx_L1_error)
  3045. __Pyx_GOTREF(__pyx_t_7);
  3046. __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)
  3047. __Pyx_GOTREF(__pyx_t_4);
  3048. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3049. __pyx_t_7 = NULL;
  3050. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  3051. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
  3052. if (likely(__pyx_t_7)) {
  3053. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  3054. __Pyx_INCREF(__pyx_t_7);
  3055. __Pyx_INCREF(function);
  3056. __Pyx_DECREF_SET(__pyx_t_4, function);
  3057. }
  3058. }
  3059. if (!__pyx_t_7) {
  3060. __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)
  3061. __Pyx_GOTREF(__pyx_t_3);
  3062. } else {
  3063. #if CYTHON_FAST_PYCALL
  3064. if (PyFunction_Check(__pyx_t_4)) {
  3065. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_self->env_path};
  3066. __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)
  3067. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3068. __Pyx_GOTREF(__pyx_t_3);
  3069. } else
  3070. #endif
  3071. #if CYTHON_FAST_PYCCALL
  3072. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  3073. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_self->env_path};
  3074. __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)
  3075. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3076. __Pyx_GOTREF(__pyx_t_3);
  3077. } else
  3078. #endif
  3079. {
  3080. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 173, __pyx_L1_error)
  3081. __Pyx_GOTREF(__pyx_t_5);
  3082. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
  3083. __Pyx_INCREF(__pyx_v_self->env_path);
  3084. __Pyx_GIVEREF(__pyx_v_self->env_path);
  3085. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_self->env_path);
  3086. __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)
  3087. __Pyx_GOTREF(__pyx_t_3);
  3088. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3089. }
  3090. }
  3091. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3092. __pyx_t_1 = __pyx_t_3;
  3093. __pyx_t_3 = 0;
  3094. } else {
  3095. /* "lakesuperior/store/base_lmdb_store.pyx":175
  3096. * path.dirname(self.env_path)
  3097. * if lmdb.MDB_NOSUBDIR & self.flags
  3098. * else self.env_path) # <<<<<<<<<<<<<<
  3099. *
  3100. * if not path.exists(parent_path):
  3101. */
  3102. __Pyx_INCREF(__pyx_v_self->env_path);
  3103. __pyx_t_1 = __pyx_v_self->env_path;
  3104. }
  3105. __pyx_v_parent_path = __pyx_t_1;
  3106. __pyx_t_1 = 0;
  3107. /* "lakesuperior/store/base_lmdb_store.pyx":177
  3108. * else self.env_path)
  3109. *
  3110. * if not path.exists(parent_path): # <<<<<<<<<<<<<<
  3111. * #logger.info(
  3112. * # 'Creating store directory at {}'.format(parent_path))
  3113. */
  3114. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
  3115. __Pyx_GOTREF(__pyx_t_3);
  3116. __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)
  3117. __Pyx_GOTREF(__pyx_t_4);
  3118. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3119. __pyx_t_3 = NULL;
  3120. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  3121. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
  3122. if (likely(__pyx_t_3)) {
  3123. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  3124. __Pyx_INCREF(__pyx_t_3);
  3125. __Pyx_INCREF(function);
  3126. __Pyx_DECREF_SET(__pyx_t_4, function);
  3127. }
  3128. }
  3129. if (!__pyx_t_3) {
  3130. __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)
  3131. __Pyx_GOTREF(__pyx_t_1);
  3132. } else {
  3133. #if CYTHON_FAST_PYCALL
  3134. if (PyFunction_Check(__pyx_t_4)) {
  3135. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_parent_path};
  3136. __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)
  3137. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3138. __Pyx_GOTREF(__pyx_t_1);
  3139. } else
  3140. #endif
  3141. #if CYTHON_FAST_PYCCALL
  3142. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  3143. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_parent_path};
  3144. __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)
  3145. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3146. __Pyx_GOTREF(__pyx_t_1);
  3147. } else
  3148. #endif
  3149. {
  3150. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 177, __pyx_L1_error)
  3151. __Pyx_GOTREF(__pyx_t_5);
  3152. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  3153. __Pyx_INCREF(__pyx_v_parent_path);
  3154. __Pyx_GIVEREF(__pyx_v_parent_path);
  3155. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_parent_path);
  3156. __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)
  3157. __Pyx_GOTREF(__pyx_t_1);
  3158. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3159. }
  3160. }
  3161. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3162. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 177, __pyx_L1_error)
  3163. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3164. __pyx_t_8 = ((!__pyx_t_2) != 0);
  3165. if (__pyx_t_8) {
  3166. /* "lakesuperior/store/base_lmdb_store.pyx":180
  3167. * #logger.info(
  3168. * # 'Creating store directory at {}'.format(parent_path))
  3169. * try: # <<<<<<<<<<<<<<
  3170. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3171. * except Exception as e:
  3172. */
  3173. {
  3174. __Pyx_PyThreadState_declare
  3175. __Pyx_PyThreadState_assign
  3176. __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
  3177. __Pyx_XGOTREF(__pyx_t_9);
  3178. __Pyx_XGOTREF(__pyx_t_10);
  3179. __Pyx_XGOTREF(__pyx_t_11);
  3180. /*try:*/ {
  3181. /* "lakesuperior/store/base_lmdb_store.pyx":181
  3182. * # 'Creating store directory at {}'.format(parent_path))
  3183. * try:
  3184. * makedirs(parent_path, mode=0o750, exist_ok=True) # <<<<<<<<<<<<<<
  3185. * except Exception as e:
  3186. * raise LmdbError(
  3187. */
  3188. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_makedirs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L6_error)
  3189. __Pyx_GOTREF(__pyx_t_1);
  3190. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L6_error)
  3191. __Pyx_GOTREF(__pyx_t_4);
  3192. __Pyx_INCREF(__pyx_v_parent_path);
  3193. __Pyx_GIVEREF(__pyx_v_parent_path);
  3194. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_parent_path);
  3195. __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L6_error)
  3196. __Pyx_GOTREF(__pyx_t_5);
  3197. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_mode, __pyx_int_488) < 0) __PYX_ERR(0, 181, __pyx_L6_error)
  3198. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_exist_ok, Py_True) < 0) __PYX_ERR(0, 181, __pyx_L6_error)
  3199. __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)
  3200. __Pyx_GOTREF(__pyx_t_3);
  3201. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3202. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3203. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3204. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3205. /* "lakesuperior/store/base_lmdb_store.pyx":180
  3206. * #logger.info(
  3207. * # 'Creating store directory at {}'.format(parent_path))
  3208. * try: # <<<<<<<<<<<<<<
  3209. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3210. * except Exception as e:
  3211. */
  3212. }
  3213. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3214. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3215. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  3216. goto __pyx_L11_try_end;
  3217. __pyx_L6_error:;
  3218. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3219. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3220. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3221. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  3222. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3223. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3224. /* "lakesuperior/store/base_lmdb_store.pyx":182
  3225. * try:
  3226. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3227. * except Exception as e: # <<<<<<<<<<<<<<
  3228. * raise LmdbError(
  3229. * 'Could not create store at {}. Error: {}'.format(
  3230. */
  3231. __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  3232. if (__pyx_t_12) {
  3233. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.open_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3234. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(0, 182, __pyx_L8_except_error)
  3235. __Pyx_GOTREF(__pyx_t_3);
  3236. __Pyx_GOTREF(__pyx_t_5);
  3237. __Pyx_GOTREF(__pyx_t_4);
  3238. __Pyx_INCREF(__pyx_t_5);
  3239. __pyx_v_e = __pyx_t_5;
  3240. /*try:*/ {
  3241. /* "lakesuperior/store/base_lmdb_store.pyx":183
  3242. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3243. * except Exception as e:
  3244. * raise LmdbError( # <<<<<<<<<<<<<<
  3245. * 'Could not create store at {}. Error: {}'.format(
  3246. * self.env_path, e))
  3247. */
  3248. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 183, __pyx_L17_error)
  3249. __Pyx_GOTREF(__pyx_t_7);
  3250. /* "lakesuperior/store/base_lmdb_store.pyx":184
  3251. * except Exception as e:
  3252. * raise LmdbError(
  3253. * 'Could not create store at {}. Error: {}'.format( # <<<<<<<<<<<<<<
  3254. * self.env_path, e))
  3255. *
  3256. */
  3257. __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)
  3258. __Pyx_GOTREF(__pyx_t_13);
  3259. /* "lakesuperior/store/base_lmdb_store.pyx":185
  3260. * raise LmdbError(
  3261. * 'Could not create store at {}. Error: {}'.format(
  3262. * self.env_path, e)) # <<<<<<<<<<<<<<
  3263. *
  3264. * # Create environment handle.
  3265. */
  3266. __pyx_t_14 = NULL;
  3267. __pyx_t_12 = 0;
  3268. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  3269. __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
  3270. if (likely(__pyx_t_14)) {
  3271. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  3272. __Pyx_INCREF(__pyx_t_14);
  3273. __Pyx_INCREF(function);
  3274. __Pyx_DECREF_SET(__pyx_t_13, function);
  3275. __pyx_t_12 = 1;
  3276. }
  3277. }
  3278. #if CYTHON_FAST_PYCALL
  3279. if (PyFunction_Check(__pyx_t_13)) {
  3280. PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_self->env_path, __pyx_v_e};
  3281. __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)
  3282. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  3283. __Pyx_GOTREF(__pyx_t_6);
  3284. } else
  3285. #endif
  3286. #if CYTHON_FAST_PYCCALL
  3287. if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
  3288. PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_self->env_path, __pyx_v_e};
  3289. __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)
  3290. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  3291. __Pyx_GOTREF(__pyx_t_6);
  3292. } else
  3293. #endif
  3294. {
  3295. __pyx_t_15 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 184, __pyx_L17_error)
  3296. __Pyx_GOTREF(__pyx_t_15);
  3297. if (__pyx_t_14) {
  3298. __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
  3299. }
  3300. __Pyx_INCREF(__pyx_v_self->env_path);
  3301. __Pyx_GIVEREF(__pyx_v_self->env_path);
  3302. PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_12, __pyx_v_self->env_path);
  3303. __Pyx_INCREF(__pyx_v_e);
  3304. __Pyx_GIVEREF(__pyx_v_e);
  3305. PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_12, __pyx_v_e);
  3306. __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)
  3307. __Pyx_GOTREF(__pyx_t_6);
  3308. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3309. }
  3310. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3311. __pyx_t_13 = NULL;
  3312. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
  3313. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
  3314. if (likely(__pyx_t_13)) {
  3315. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  3316. __Pyx_INCREF(__pyx_t_13);
  3317. __Pyx_INCREF(function);
  3318. __Pyx_DECREF_SET(__pyx_t_7, function);
  3319. }
  3320. }
  3321. if (!__pyx_t_13) {
  3322. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L17_error)
  3323. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3324. __Pyx_GOTREF(__pyx_t_1);
  3325. } else {
  3326. #if CYTHON_FAST_PYCALL
  3327. if (PyFunction_Check(__pyx_t_7)) {
  3328. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  3329. __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)
  3330. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3331. __Pyx_GOTREF(__pyx_t_1);
  3332. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3333. } else
  3334. #endif
  3335. #if CYTHON_FAST_PYCCALL
  3336. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  3337. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  3338. __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)
  3339. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3340. __Pyx_GOTREF(__pyx_t_1);
  3341. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3342. } else
  3343. #endif
  3344. {
  3345. __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 183, __pyx_L17_error)
  3346. __Pyx_GOTREF(__pyx_t_15);
  3347. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
  3348. __Pyx_GIVEREF(__pyx_t_6);
  3349. PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_6);
  3350. __pyx_t_6 = 0;
  3351. __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)
  3352. __Pyx_GOTREF(__pyx_t_1);
  3353. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3354. }
  3355. }
  3356. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3357. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  3358. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3359. __PYX_ERR(0, 183, __pyx_L17_error)
  3360. }
  3361. /* "lakesuperior/store/base_lmdb_store.pyx":182
  3362. * try:
  3363. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3364. * except Exception as e: # <<<<<<<<<<<<<<
  3365. * raise LmdbError(
  3366. * 'Could not create store at {}. Error: {}'.format(
  3367. */
  3368. /*finally:*/ {
  3369. __pyx_L17_error:;
  3370. /*exception exit:*/{
  3371. __Pyx_PyThreadState_declare
  3372. __Pyx_PyThreadState_assign
  3373. __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
  3374. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  3375. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3376. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3377. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  3378. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3379. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3380. if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
  3381. 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);
  3382. __Pyx_XGOTREF(__pyx_t_18);
  3383. __Pyx_XGOTREF(__pyx_t_19);
  3384. __Pyx_XGOTREF(__pyx_t_20);
  3385. __Pyx_XGOTREF(__pyx_t_21);
  3386. __Pyx_XGOTREF(__pyx_t_22);
  3387. __Pyx_XGOTREF(__pyx_t_23);
  3388. __pyx_t_12 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
  3389. {
  3390. __Pyx_DECREF(__pyx_v_e);
  3391. __pyx_v_e = NULL;
  3392. }
  3393. if (PY_MAJOR_VERSION >= 3) {
  3394. __Pyx_XGIVEREF(__pyx_t_21);
  3395. __Pyx_XGIVEREF(__pyx_t_22);
  3396. __Pyx_XGIVEREF(__pyx_t_23);
  3397. __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
  3398. }
  3399. __Pyx_XGIVEREF(__pyx_t_18);
  3400. __Pyx_XGIVEREF(__pyx_t_19);
  3401. __Pyx_XGIVEREF(__pyx_t_20);
  3402. __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
  3403. __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
  3404. __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
  3405. goto __pyx_L8_except_error;
  3406. }
  3407. }
  3408. }
  3409. goto __pyx_L8_except_error;
  3410. __pyx_L8_except_error:;
  3411. /* "lakesuperior/store/base_lmdb_store.pyx":180
  3412. * #logger.info(
  3413. * # 'Creating store directory at {}'.format(parent_path))
  3414. * try: # <<<<<<<<<<<<<<
  3415. * makedirs(parent_path, mode=0o750, exist_ok=True)
  3416. * except Exception as e:
  3417. */
  3418. __Pyx_XGIVEREF(__pyx_t_9);
  3419. __Pyx_XGIVEREF(__pyx_t_10);
  3420. __Pyx_XGIVEREF(__pyx_t_11);
  3421. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
  3422. goto __pyx_L1_error;
  3423. __pyx_L11_try_end:;
  3424. }
  3425. /* "lakesuperior/store/base_lmdb_store.pyx":177
  3426. * else self.env_path)
  3427. *
  3428. * if not path.exists(parent_path): # <<<<<<<<<<<<<<
  3429. * #logger.info(
  3430. * # 'Creating store directory at {}'.format(parent_path))
  3431. */
  3432. }
  3433. /* "lakesuperior/store/base_lmdb_store.pyx":170
  3434. *
  3435. * logger.debug('Opening environment at {}.'.format(self.env_path))
  3436. * if create: # <<<<<<<<<<<<<<
  3437. * #logger.info('Creating db env at {}'.format(self.env_path))
  3438. * parent_path = (
  3439. */
  3440. }
  3441. /* "lakesuperior/store/base_lmdb_store.pyx":188
  3442. *
  3443. * # Create environment handle.
  3444. * _check( # <<<<<<<<<<<<<<
  3445. * lmdb.mdb_env_create(&self.dbenv),
  3446. * 'Error creating DB environment handle: {}')
  3447. */
  3448. __pyx_t_24.__pyx_n = 1;
  3449. __pyx_t_24.message = __pyx_kp_u_Error_creating_DB_environment_ha;
  3450. __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)
  3451. /* "lakesuperior/store/base_lmdb_store.pyx":191
  3452. * lmdb.mdb_env_create(&self.dbenv),
  3453. * 'Error creating DB environment handle: {}')
  3454. * logger.debug('Created DBenv @ {:x}'.format(<unsigned long>self.dbenv)) # <<<<<<<<<<<<<<
  3455. *
  3456. * # Set map size.
  3457. */
  3458. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error)
  3459. __Pyx_GOTREF(__pyx_t_5);
  3460. __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)
  3461. __Pyx_GOTREF(__pyx_t_3);
  3462. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3463. __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)
  3464. __Pyx_GOTREF(__pyx_t_1);
  3465. __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)
  3466. __Pyx_GOTREF(__pyx_t_7);
  3467. __pyx_t_15 = NULL;
  3468. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  3469. __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
  3470. if (likely(__pyx_t_15)) {
  3471. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  3472. __Pyx_INCREF(__pyx_t_15);
  3473. __Pyx_INCREF(function);
  3474. __Pyx_DECREF_SET(__pyx_t_1, function);
  3475. }
  3476. }
  3477. if (!__pyx_t_15) {
  3478. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error)
  3479. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3480. __Pyx_GOTREF(__pyx_t_5);
  3481. } else {
  3482. #if CYTHON_FAST_PYCALL
  3483. if (PyFunction_Check(__pyx_t_1)) {
  3484. PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_7};
  3485. __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)
  3486. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  3487. __Pyx_GOTREF(__pyx_t_5);
  3488. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3489. } else
  3490. #endif
  3491. #if CYTHON_FAST_PYCCALL
  3492. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  3493. PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_7};
  3494. __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)
  3495. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  3496. __Pyx_GOTREF(__pyx_t_5);
  3497. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3498. } else
  3499. #endif
  3500. {
  3501. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 191, __pyx_L1_error)
  3502. __Pyx_GOTREF(__pyx_t_6);
  3503. __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_15); __pyx_t_15 = NULL;
  3504. __Pyx_GIVEREF(__pyx_t_7);
  3505. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_7);
  3506. __pyx_t_7 = 0;
  3507. __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)
  3508. __Pyx_GOTREF(__pyx_t_5);
  3509. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3510. }
  3511. }
  3512. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3513. __pyx_t_1 = NULL;
  3514. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  3515. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
  3516. if (likely(__pyx_t_1)) {
  3517. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  3518. __Pyx_INCREF(__pyx_t_1);
  3519. __Pyx_INCREF(function);
  3520. __Pyx_DECREF_SET(__pyx_t_3, function);
  3521. }
  3522. }
  3523. if (!__pyx_t_1) {
  3524. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 191, __pyx_L1_error)
  3525. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3526. __Pyx_GOTREF(__pyx_t_4);
  3527. } else {
  3528. #if CYTHON_FAST_PYCALL
  3529. if (PyFunction_Check(__pyx_t_3)) {
  3530. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
  3531. __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)
  3532. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3533. __Pyx_GOTREF(__pyx_t_4);
  3534. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3535. } else
  3536. #endif
  3537. #if CYTHON_FAST_PYCCALL
  3538. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  3539. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
  3540. __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)
  3541. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3542. __Pyx_GOTREF(__pyx_t_4);
  3543. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3544. } else
  3545. #endif
  3546. {
  3547. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 191, __pyx_L1_error)
  3548. __Pyx_GOTREF(__pyx_t_6);
  3549. __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
  3550. __Pyx_GIVEREF(__pyx_t_5);
  3551. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
  3552. __pyx_t_5 = 0;
  3553. __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)
  3554. __Pyx_GOTREF(__pyx_t_4);
  3555. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3556. }
  3557. }
  3558. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3559. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3560. /* "lakesuperior/store/base_lmdb_store.pyx":195
  3561. * # Set map size.
  3562. * _check(
  3563. * lmdb.mdb_env_set_mapsize(self.dbenv, self.options.get( # <<<<<<<<<<<<<<
  3564. * 'map_size', 1024 ** 3)),
  3565. * 'Error setting map size: {}')
  3566. */
  3567. __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)
  3568. __Pyx_GOTREF(__pyx_t_4);
  3569. __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)
  3570. __Pyx_GOTREF(__pyx_t_3);
  3571. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3572. __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)
  3573. __Pyx_GOTREF(__pyx_t_4);
  3574. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3575. __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)
  3576. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3577. /* "lakesuperior/store/base_lmdb_store.pyx":194
  3578. *
  3579. * # Set map size.
  3580. * _check( # <<<<<<<<<<<<<<
  3581. * lmdb.mdb_env_set_mapsize(self.dbenv, self.options.get(
  3582. * 'map_size', 1024 ** 3)),
  3583. */
  3584. __pyx_t_24.__pyx_n = 1;
  3585. __pyx_t_24.message = __pyx_kp_u_Error_setting_map_size;
  3586. __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)
  3587. /* "lakesuperior/store/base_lmdb_store.pyx":200
  3588. *
  3589. * # Set max databases.
  3590. * max_dbs = self.options.get('max_dbs', len(self.dbi_labels)) # <<<<<<<<<<<<<<
  3591. * _check(
  3592. * lmdb.mdb_env_set_maxdbs(self.dbenv, max_dbs),
  3593. */
  3594. __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)
  3595. __Pyx_GOTREF(__pyx_t_3);
  3596. __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)
  3597. __Pyx_GOTREF(__pyx_t_6);
  3598. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3599. __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)
  3600. __Pyx_GOTREF(__pyx_t_3);
  3601. __pyx_t_26 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_26 == ((Py_ssize_t)-1))) __PYX_ERR(0, 200, __pyx_L1_error)
  3602. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3603. __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_26); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
  3604. __Pyx_GOTREF(__pyx_t_3);
  3605. __pyx_t_5 = NULL;
  3606. __pyx_t_16 = 0;
  3607. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  3608. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
  3609. if (likely(__pyx_t_5)) {
  3610. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  3611. __Pyx_INCREF(__pyx_t_5);
  3612. __Pyx_INCREF(function);
  3613. __Pyx_DECREF_SET(__pyx_t_6, function);
  3614. __pyx_t_16 = 1;
  3615. }
  3616. }
  3617. #if CYTHON_FAST_PYCALL
  3618. if (PyFunction_Check(__pyx_t_6)) {
  3619. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_n_u_max_dbs, __pyx_t_3};
  3620. __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)
  3621. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3622. __Pyx_GOTREF(__pyx_t_4);
  3623. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3624. } else
  3625. #endif
  3626. #if CYTHON_FAST_PYCCALL
  3627. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  3628. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_n_u_max_dbs, __pyx_t_3};
  3629. __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)
  3630. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3631. __Pyx_GOTREF(__pyx_t_4);
  3632. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3633. } else
  3634. #endif
  3635. {
  3636. __pyx_t_1 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
  3637. __Pyx_GOTREF(__pyx_t_1);
  3638. if (__pyx_t_5) {
  3639. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL;
  3640. }
  3641. __Pyx_INCREF(__pyx_n_u_max_dbs);
  3642. __Pyx_GIVEREF(__pyx_n_u_max_dbs);
  3643. PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_16, __pyx_n_u_max_dbs);
  3644. __Pyx_GIVEREF(__pyx_t_3);
  3645. PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_16, __pyx_t_3);
  3646. __pyx_t_3 = 0;
  3647. __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)
  3648. __Pyx_GOTREF(__pyx_t_4);
  3649. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3650. }
  3651. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3652. __pyx_v_max_dbs = __pyx_t_4;
  3653. __pyx_t_4 = 0;
  3654. /* "lakesuperior/store/base_lmdb_store.pyx":202
  3655. * max_dbs = self.options.get('max_dbs', len(self.dbi_labels))
  3656. * _check(
  3657. * lmdb.mdb_env_set_maxdbs(self.dbenv, max_dbs), # <<<<<<<<<<<<<<
  3658. * 'Error setting max. databases: {}')
  3659. *
  3660. */
  3661. __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)
  3662. /* "lakesuperior/store/base_lmdb_store.pyx":201
  3663. * # Set max databases.
  3664. * max_dbs = self.options.get('max_dbs', len(self.dbi_labels))
  3665. * _check( # <<<<<<<<<<<<<<
  3666. * lmdb.mdb_env_set_maxdbs(self.dbenv, max_dbs),
  3667. * 'Error setting max. databases: {}')
  3668. */
  3669. __pyx_t_24.__pyx_n = 1;
  3670. __pyx_t_24.message = __pyx_kp_u_Error_setting_max_databases;
  3671. __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)
  3672. /* "lakesuperior/store/base_lmdb_store.pyx":206
  3673. *
  3674. * # Set max readers.
  3675. * self._readers = self.options.get( # <<<<<<<<<<<<<<
  3676. * 'max_spare_txns', wsgi.workers * self.readers_mult)
  3677. * _check(
  3678. */
  3679. __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)
  3680. __Pyx_GOTREF(__pyx_t_6);
  3681. __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)
  3682. __Pyx_GOTREF(__pyx_t_1);
  3683. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3684. /* "lakesuperior/store/base_lmdb_store.pyx":207
  3685. * # Set max readers.
  3686. * self._readers = self.options.get(
  3687. * 'max_spare_txns', wsgi.workers * self.readers_mult) # <<<<<<<<<<<<<<
  3688. * _check(
  3689. * lmdb.mdb_env_set_maxreaders(self.dbenv, self._readers),
  3690. */
  3691. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_wsgi); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 207, __pyx_L1_error)
  3692. __Pyx_GOTREF(__pyx_t_6);
  3693. __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)
  3694. __Pyx_GOTREF(__pyx_t_3);
  3695. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3696. __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)
  3697. __Pyx_GOTREF(__pyx_t_6);
  3698. __pyx_t_5 = PyNumber_Multiply(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error)
  3699. __Pyx_GOTREF(__pyx_t_5);
  3700. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3701. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3702. __pyx_t_6 = NULL;
  3703. __pyx_t_16 = 0;
  3704. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  3705. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
  3706. if (likely(__pyx_t_6)) {
  3707. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  3708. __Pyx_INCREF(__pyx_t_6);
  3709. __Pyx_INCREF(function);
  3710. __Pyx_DECREF_SET(__pyx_t_1, function);
  3711. __pyx_t_16 = 1;
  3712. }
  3713. }
  3714. #if CYTHON_FAST_PYCALL
  3715. if (PyFunction_Check(__pyx_t_1)) {
  3716. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_n_u_max_spare_txns, __pyx_t_5};
  3717. __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)
  3718. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3719. __Pyx_GOTREF(__pyx_t_4);
  3720. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3721. } else
  3722. #endif
  3723. #if CYTHON_FAST_PYCCALL
  3724. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  3725. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_n_u_max_spare_txns, __pyx_t_5};
  3726. __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)
  3727. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3728. __Pyx_GOTREF(__pyx_t_4);
  3729. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3730. } else
  3731. #endif
  3732. {
  3733. __pyx_t_3 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 206, __pyx_L1_error)
  3734. __Pyx_GOTREF(__pyx_t_3);
  3735. if (__pyx_t_6) {
  3736. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
  3737. }
  3738. __Pyx_INCREF(__pyx_n_u_max_spare_txns);
  3739. __Pyx_GIVEREF(__pyx_n_u_max_spare_txns);
  3740. PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_16, __pyx_n_u_max_spare_txns);
  3741. __Pyx_GIVEREF(__pyx_t_5);
  3742. PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_16, __pyx_t_5);
  3743. __pyx_t_5 = 0;
  3744. __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)
  3745. __Pyx_GOTREF(__pyx_t_4);
  3746. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3747. }
  3748. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3749. /* "lakesuperior/store/base_lmdb_store.pyx":206
  3750. *
  3751. * # Set max readers.
  3752. * self._readers = self.options.get( # <<<<<<<<<<<<<<
  3753. * 'max_spare_txns', wsgi.workers * self.readers_mult)
  3754. * _check(
  3755. */
  3756. __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)
  3757. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3758. __pyx_v_self->_readers = __pyx_t_28;
  3759. /* "lakesuperior/store/base_lmdb_store.pyx":208
  3760. * self._readers = self.options.get(
  3761. * 'max_spare_txns', wsgi.workers * self.readers_mult)
  3762. * _check( # <<<<<<<<<<<<<<
  3763. * lmdb.mdb_env_set_maxreaders(self.dbenv, self._readers),
  3764. * 'Error setting max. readers: {}')
  3765. */
  3766. __pyx_t_24.__pyx_n = 1;
  3767. __pyx_t_24.message = __pyx_kp_u_Error_setting_max_readers;
  3768. __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)
  3769. /* "lakesuperior/store/base_lmdb_store.pyx":211
  3770. * lmdb.mdb_env_set_maxreaders(self.dbenv, self._readers),
  3771. * 'Error setting max. readers: {}')
  3772. * logger.debug('Max. readers: {}'.format(self._readers)) # <<<<<<<<<<<<<<
  3773. *
  3774. * # Clear stale readers.
  3775. */
  3776. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
  3777. __Pyx_GOTREF(__pyx_t_1);
  3778. __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)
  3779. __Pyx_GOTREF(__pyx_t_3);
  3780. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3781. __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)
  3782. __Pyx_GOTREF(__pyx_t_5);
  3783. __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->_readers); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 211, __pyx_L1_error)
  3784. __Pyx_GOTREF(__pyx_t_6);
  3785. __pyx_t_7 = NULL;
  3786. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  3787. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  3788. if (likely(__pyx_t_7)) {
  3789. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  3790. __Pyx_INCREF(__pyx_t_7);
  3791. __Pyx_INCREF(function);
  3792. __Pyx_DECREF_SET(__pyx_t_5, function);
  3793. }
  3794. }
  3795. if (!__pyx_t_7) {
  3796. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
  3797. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3798. __Pyx_GOTREF(__pyx_t_1);
  3799. } else {
  3800. #if CYTHON_FAST_PYCALL
  3801. if (PyFunction_Check(__pyx_t_5)) {
  3802. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  3803. __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)
  3804. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3805. __Pyx_GOTREF(__pyx_t_1);
  3806. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3807. } else
  3808. #endif
  3809. #if CYTHON_FAST_PYCCALL
  3810. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  3811. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  3812. __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)
  3813. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3814. __Pyx_GOTREF(__pyx_t_1);
  3815. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3816. } else
  3817. #endif
  3818. {
  3819. __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 211, __pyx_L1_error)
  3820. __Pyx_GOTREF(__pyx_t_15);
  3821. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_7); __pyx_t_7 = NULL;
  3822. __Pyx_GIVEREF(__pyx_t_6);
  3823. PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_6);
  3824. __pyx_t_6 = 0;
  3825. __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)
  3826. __Pyx_GOTREF(__pyx_t_1);
  3827. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3828. }
  3829. }
  3830. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3831. __pyx_t_5 = NULL;
  3832. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  3833. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
  3834. if (likely(__pyx_t_5)) {
  3835. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  3836. __Pyx_INCREF(__pyx_t_5);
  3837. __Pyx_INCREF(function);
  3838. __Pyx_DECREF_SET(__pyx_t_3, function);
  3839. }
  3840. }
  3841. if (!__pyx_t_5) {
  3842. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 211, __pyx_L1_error)
  3843. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3844. __Pyx_GOTREF(__pyx_t_4);
  3845. } else {
  3846. #if CYTHON_FAST_PYCALL
  3847. if (PyFunction_Check(__pyx_t_3)) {
  3848. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1};
  3849. __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)
  3850. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3851. __Pyx_GOTREF(__pyx_t_4);
  3852. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3853. } else
  3854. #endif
  3855. #if CYTHON_FAST_PYCCALL
  3856. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  3857. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1};
  3858. __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)
  3859. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3860. __Pyx_GOTREF(__pyx_t_4);
  3861. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3862. } else
  3863. #endif
  3864. {
  3865. __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 211, __pyx_L1_error)
  3866. __Pyx_GOTREF(__pyx_t_15);
  3867. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_5); __pyx_t_5 = NULL;
  3868. __Pyx_GIVEREF(__pyx_t_1);
  3869. PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_1);
  3870. __pyx_t_1 = 0;
  3871. __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)
  3872. __Pyx_GOTREF(__pyx_t_4);
  3873. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3874. }
  3875. }
  3876. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3877. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3878. /* "lakesuperior/store/base_lmdb_store.pyx":214
  3879. *
  3880. * # Clear stale readers.
  3881. * self._clear_stale_readers() # <<<<<<<<<<<<<<
  3882. *
  3883. * # Open DB environment.
  3884. */
  3885. ((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)
  3886. /* "lakesuperior/store/base_lmdb_store.pyx":217
  3887. *
  3888. * # Open DB environment.
  3889. * logger.debug('DBenv address: {:x}'.format(<unsigned long>self.dbenv)) # <<<<<<<<<<<<<<
  3890. * _check(
  3891. * lmdb.mdb_env_open(
  3892. */
  3893. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  3894. __Pyx_GOTREF(__pyx_t_3);
  3895. __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)
  3896. __Pyx_GOTREF(__pyx_t_15);
  3897. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3898. __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)
  3899. __Pyx_GOTREF(__pyx_t_1);
  3900. __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)
  3901. __Pyx_GOTREF(__pyx_t_5);
  3902. __pyx_t_6 = NULL;
  3903. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  3904. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
  3905. if (likely(__pyx_t_6)) {
  3906. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  3907. __Pyx_INCREF(__pyx_t_6);
  3908. __Pyx_INCREF(function);
  3909. __Pyx_DECREF_SET(__pyx_t_1, function);
  3910. }
  3911. }
  3912. if (!__pyx_t_6) {
  3913. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  3914. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3915. __Pyx_GOTREF(__pyx_t_3);
  3916. } else {
  3917. #if CYTHON_FAST_PYCALL
  3918. if (PyFunction_Check(__pyx_t_1)) {
  3919. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
  3920. __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)
  3921. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3922. __Pyx_GOTREF(__pyx_t_3);
  3923. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3924. } else
  3925. #endif
  3926. #if CYTHON_FAST_PYCCALL
  3927. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  3928. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
  3929. __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)
  3930. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3931. __Pyx_GOTREF(__pyx_t_3);
  3932. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3933. } else
  3934. #endif
  3935. {
  3936. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 217, __pyx_L1_error)
  3937. __Pyx_GOTREF(__pyx_t_7);
  3938. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
  3939. __Pyx_GIVEREF(__pyx_t_5);
  3940. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
  3941. __pyx_t_5 = 0;
  3942. __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)
  3943. __Pyx_GOTREF(__pyx_t_3);
  3944. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3945. }
  3946. }
  3947. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3948. __pyx_t_1 = NULL;
  3949. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
  3950. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
  3951. if (likely(__pyx_t_1)) {
  3952. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
  3953. __Pyx_INCREF(__pyx_t_1);
  3954. __Pyx_INCREF(function);
  3955. __Pyx_DECREF_SET(__pyx_t_15, function);
  3956. }
  3957. }
  3958. if (!__pyx_t_1) {
  3959. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 217, __pyx_L1_error)
  3960. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3961. __Pyx_GOTREF(__pyx_t_4);
  3962. } else {
  3963. #if CYTHON_FAST_PYCALL
  3964. if (PyFunction_Check(__pyx_t_15)) {
  3965. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
  3966. __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)
  3967. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3968. __Pyx_GOTREF(__pyx_t_4);
  3969. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3970. } else
  3971. #endif
  3972. #if CYTHON_FAST_PYCCALL
  3973. if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
  3974. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
  3975. __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)
  3976. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3977. __Pyx_GOTREF(__pyx_t_4);
  3978. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3979. } else
  3980. #endif
  3981. {
  3982. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 217, __pyx_L1_error)
  3983. __Pyx_GOTREF(__pyx_t_7);
  3984. __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
  3985. __Pyx_GIVEREF(__pyx_t_3);
  3986. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3);
  3987. __pyx_t_3 = 0;
  3988. __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)
  3989. __Pyx_GOTREF(__pyx_t_4);
  3990. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3991. }
  3992. }
  3993. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3994. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3995. /* "lakesuperior/store/base_lmdb_store.pyx":220
  3996. * _check(
  3997. * lmdb.mdb_env_open(
  3998. * self.dbenv, self.env_path.encode(), # <<<<<<<<<<<<<<
  3999. * self.env_flags, self.env_perms),
  4000. * f'Error opening the database environment: {self.env_path}.')
  4001. */
  4002. if (unlikely(__pyx_v_self->env_path == Py_None)) {
  4003. PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
  4004. __PYX_ERR(0, 220, __pyx_L1_error)
  4005. }
  4006. __pyx_t_4 = PyUnicode_AsEncodedString(__pyx_v_self->env_path, NULL, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 220, __pyx_L1_error)
  4007. __Pyx_GOTREF(__pyx_t_4);
  4008. __pyx_t_29 = __Pyx_PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_29) && PyErr_Occurred())) __PYX_ERR(0, 220, __pyx_L1_error)
  4009. /* "lakesuperior/store/base_lmdb_store.pyx":221
  4010. * lmdb.mdb_env_open(
  4011. * self.dbenv, self.env_path.encode(),
  4012. * self.env_flags, self.env_perms), # <<<<<<<<<<<<<<
  4013. * f'Error opening the database environment: {self.env_path}.')
  4014. *
  4015. */
  4016. __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)
  4017. __Pyx_GOTREF(__pyx_t_15);
  4018. __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)
  4019. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4020. __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)
  4021. __Pyx_GOTREF(__pyx_t_15);
  4022. __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)
  4023. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4024. /* "lakesuperior/store/base_lmdb_store.pyx":222
  4025. * self.dbenv, self.env_path.encode(),
  4026. * self.env_flags, self.env_perms),
  4027. * f'Error opening the database environment: {self.env_path}.') # <<<<<<<<<<<<<<
  4028. *
  4029. * self._init_dbis(create)
  4030. */
  4031. __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 222, __pyx_L1_error)
  4032. __Pyx_GOTREF(__pyx_t_15);
  4033. __pyx_t_26 = 0;
  4034. __pyx_t_31 = 127;
  4035. __Pyx_INCREF(__pyx_kp_u_Error_opening_the_database_envir);
  4036. __pyx_t_26 += 40;
  4037. __Pyx_GIVEREF(__pyx_kp_u_Error_opening_the_database_envir);
  4038. PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_opening_the_database_envir);
  4039. __pyx_t_7 = __Pyx_PyUnicode_Unicode(__pyx_v_self->env_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 222, __pyx_L1_error)
  4040. __Pyx_GOTREF(__pyx_t_7);
  4041. __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;
  4042. __pyx_t_26 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
  4043. __Pyx_GIVEREF(__pyx_t_7);
  4044. PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_7);
  4045. __pyx_t_7 = 0;
  4046. __Pyx_INCREF(__pyx_kp_u__4);
  4047. __pyx_t_26 += 1;
  4048. __Pyx_GIVEREF(__pyx_kp_u__4);
  4049. PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_kp_u__4);
  4050. __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)
  4051. __Pyx_GOTREF(__pyx_t_7);
  4052. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4053. /* "lakesuperior/store/base_lmdb_store.pyx":218
  4054. * # Open DB environment.
  4055. * logger.debug('DBenv address: {:x}'.format(<unsigned long>self.dbenv))
  4056. * _check( # <<<<<<<<<<<<<<
  4057. * lmdb.mdb_env_open(
  4058. * self.dbenv, self.env_path.encode(),
  4059. */
  4060. __pyx_t_24.__pyx_n = 1;
  4061. __pyx_t_24.message = ((PyObject*)__pyx_t_7);
  4062. __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)
  4063. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4064. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4065. /* "lakesuperior/store/base_lmdb_store.pyx":224
  4066. * f'Error opening the database environment: {self.env_path}.')
  4067. *
  4068. * self._init_dbis(create) # <<<<<<<<<<<<<<
  4069. * self._open = True
  4070. *
  4071. */
  4072. __pyx_t_32.__pyx_n = 1;
  4073. __pyx_t_32.create = __pyx_v_create;
  4074. ((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)
  4075. /* "lakesuperior/store/base_lmdb_store.pyx":225
  4076. *
  4077. * self._init_dbis(create)
  4078. * self._open = True # <<<<<<<<<<<<<<
  4079. *
  4080. *
  4081. */
  4082. __pyx_v_self->_open = 1;
  4083. /* "lakesuperior/store/base_lmdb_store.pyx":161
  4084. *
  4085. *
  4086. * def open_env(self, create): # <<<<<<<<<<<<<<
  4087. * """
  4088. * Open, and optionally create, store environment.
  4089. */
  4090. /* function exit code */
  4091. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4092. goto __pyx_L0;
  4093. __pyx_L1_error:;
  4094. __Pyx_XDECREF(__pyx_t_1);
  4095. __Pyx_XDECREF(__pyx_t_3);
  4096. __Pyx_XDECREF(__pyx_t_4);
  4097. __Pyx_XDECREF(__pyx_t_5);
  4098. __Pyx_XDECREF(__pyx_t_6);
  4099. __Pyx_XDECREF(__pyx_t_7);
  4100. __Pyx_XDECREF(__pyx_t_13);
  4101. __Pyx_XDECREF(__pyx_t_14);
  4102. __Pyx_XDECREF(__pyx_t_15);
  4103. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.open_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4104. __pyx_r = NULL;
  4105. __pyx_L0:;
  4106. __Pyx_XDECREF(__pyx_v_parent_path);
  4107. __Pyx_XDECREF(__pyx_v_e);
  4108. __Pyx_XDECREF(__pyx_v_max_dbs);
  4109. __Pyx_XGIVEREF(__pyx_r);
  4110. __Pyx_TraceReturn(__pyx_r, 0);
  4111. __Pyx_RefNannyFinishContext();
  4112. return __pyx_r;
  4113. }
  4114. /* "lakesuperior/store/base_lmdb_store.pyx":228
  4115. *
  4116. *
  4117. * cdef void _clear_stale_readers(self) except *: # <<<<<<<<<<<<<<
  4118. * """
  4119. * Clear stale readers.
  4120. */
  4121. 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) {
  4122. int __pyx_v_stale_readers;
  4123. __Pyx_TraceDeclarations
  4124. __Pyx_RefNannyDeclarations
  4125. int __pyx_t_1;
  4126. PyObject *__pyx_t_2 = NULL;
  4127. PyObject *__pyx_t_3 = NULL;
  4128. PyObject *__pyx_t_4 = NULL;
  4129. PyObject *__pyx_t_5 = NULL;
  4130. PyObject *__pyx_t_6 = NULL;
  4131. PyObject *__pyx_t_7 = NULL;
  4132. PyObject *__pyx_t_8 = NULL;
  4133. __Pyx_RefNannySetupContext("_clear_stale_readers", 0);
  4134. __Pyx_TraceCall("_clear_stale_readers", __pyx_f[0], 228, 0, __PYX_ERR(0, 228, __pyx_L1_error));
  4135. /* "lakesuperior/store/base_lmdb_store.pyx":234
  4136. * cdef int stale_readers
  4137. *
  4138. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers)) # <<<<<<<<<<<<<<
  4139. * if stale_readers > 0:
  4140. * logger.debug('Cleared {} stale readers.'.format(stale_readers))
  4141. */
  4142. __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)
  4143. /* "lakesuperior/store/base_lmdb_store.pyx":235
  4144. *
  4145. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers))
  4146. * if stale_readers > 0: # <<<<<<<<<<<<<<
  4147. * logger.debug('Cleared {} stale readers.'.format(stale_readers))
  4148. *
  4149. */
  4150. __pyx_t_1 = ((__pyx_v_stale_readers > 0) != 0);
  4151. if (__pyx_t_1) {
  4152. /* "lakesuperior/store/base_lmdb_store.pyx":236
  4153. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers))
  4154. * if stale_readers > 0:
  4155. * logger.debug('Cleared {} stale readers.'.format(stale_readers)) # <<<<<<<<<<<<<<
  4156. *
  4157. *
  4158. */
  4159. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
  4160. __Pyx_GOTREF(__pyx_t_3);
  4161. __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)
  4162. __Pyx_GOTREF(__pyx_t_4);
  4163. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4164. __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)
  4165. __Pyx_GOTREF(__pyx_t_5);
  4166. __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_stale_readers); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 236, __pyx_L1_error)
  4167. __Pyx_GOTREF(__pyx_t_6);
  4168. __pyx_t_7 = NULL;
  4169. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  4170. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  4171. if (likely(__pyx_t_7)) {
  4172. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  4173. __Pyx_INCREF(__pyx_t_7);
  4174. __Pyx_INCREF(function);
  4175. __Pyx_DECREF_SET(__pyx_t_5, function);
  4176. }
  4177. }
  4178. if (!__pyx_t_7) {
  4179. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
  4180. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4181. __Pyx_GOTREF(__pyx_t_3);
  4182. } else {
  4183. #if CYTHON_FAST_PYCALL
  4184. if (PyFunction_Check(__pyx_t_5)) {
  4185. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  4186. __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)
  4187. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4188. __Pyx_GOTREF(__pyx_t_3);
  4189. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4190. } else
  4191. #endif
  4192. #if CYTHON_FAST_PYCCALL
  4193. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  4194. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  4195. __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)
  4196. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4197. __Pyx_GOTREF(__pyx_t_3);
  4198. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4199. } else
  4200. #endif
  4201. {
  4202. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 236, __pyx_L1_error)
  4203. __Pyx_GOTREF(__pyx_t_8);
  4204. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  4205. __Pyx_GIVEREF(__pyx_t_6);
  4206. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
  4207. __pyx_t_6 = 0;
  4208. __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)
  4209. __Pyx_GOTREF(__pyx_t_3);
  4210. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4211. }
  4212. }
  4213. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4214. __pyx_t_5 = NULL;
  4215. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  4216. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  4217. if (likely(__pyx_t_5)) {
  4218. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  4219. __Pyx_INCREF(__pyx_t_5);
  4220. __Pyx_INCREF(function);
  4221. __Pyx_DECREF_SET(__pyx_t_4, function);
  4222. }
  4223. }
  4224. if (!__pyx_t_5) {
  4225. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error)
  4226. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4227. __Pyx_GOTREF(__pyx_t_2);
  4228. } else {
  4229. #if CYTHON_FAST_PYCALL
  4230. if (PyFunction_Check(__pyx_t_4)) {
  4231. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4232. __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)
  4233. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4234. __Pyx_GOTREF(__pyx_t_2);
  4235. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4236. } else
  4237. #endif
  4238. #if CYTHON_FAST_PYCCALL
  4239. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  4240. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4241. __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)
  4242. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4243. __Pyx_GOTREF(__pyx_t_2);
  4244. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4245. } else
  4246. #endif
  4247. {
  4248. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 236, __pyx_L1_error)
  4249. __Pyx_GOTREF(__pyx_t_8);
  4250. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
  4251. __Pyx_GIVEREF(__pyx_t_3);
  4252. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_3);
  4253. __pyx_t_3 = 0;
  4254. __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)
  4255. __Pyx_GOTREF(__pyx_t_2);
  4256. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4257. }
  4258. }
  4259. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4260. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4261. /* "lakesuperior/store/base_lmdb_store.pyx":235
  4262. *
  4263. * _check(lmdb.mdb_reader_check(self.dbenv, &stale_readers))
  4264. * if stale_readers > 0: # <<<<<<<<<<<<<<
  4265. * logger.debug('Cleared {} stale readers.'.format(stale_readers))
  4266. *
  4267. */
  4268. }
  4269. /* "lakesuperior/store/base_lmdb_store.pyx":228
  4270. *
  4271. *
  4272. * cdef void _clear_stale_readers(self) except *: # <<<<<<<<<<<<<<
  4273. * """
  4274. * Clear stale readers.
  4275. */
  4276. /* function exit code */
  4277. goto __pyx_L0;
  4278. __pyx_L1_error:;
  4279. __Pyx_XDECREF(__pyx_t_2);
  4280. __Pyx_XDECREF(__pyx_t_3);
  4281. __Pyx_XDECREF(__pyx_t_4);
  4282. __Pyx_XDECREF(__pyx_t_5);
  4283. __Pyx_XDECREF(__pyx_t_6);
  4284. __Pyx_XDECREF(__pyx_t_7);
  4285. __Pyx_XDECREF(__pyx_t_8);
  4286. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._clear_stale_readers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4287. __pyx_L0:;
  4288. __Pyx_TraceReturn(Py_None, 0);
  4289. __Pyx_RefNannyFinishContext();
  4290. }
  4291. /* "lakesuperior/store/base_lmdb_store.pyx":239
  4292. *
  4293. *
  4294. * cdef void _init_dbis(self, create=True) except *: # <<<<<<<<<<<<<<
  4295. * """
  4296. * Initialize databases and cursors.
  4297. */
  4298. 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) {
  4299. PyObject *__pyx_v_create = ((PyObject *)Py_True);
  4300. size_t __pyx_v_i;
  4301. MDB_txn *__pyx_v_txn;
  4302. MDB_dbi __pyx_v_dbi;
  4303. long __pyx_v_create_flag;
  4304. long __pyx_v_txn_flags;
  4305. CYTHON_UNUSED int __pyx_v_rc;
  4306. PyObject *__pyx_v_dblabel = NULL;
  4307. PyObject *__pyx_v_flags = NULL;
  4308. __Pyx_TraceDeclarations
  4309. __Pyx_RefNannyDeclarations
  4310. long __pyx_t_1;
  4311. PyObject *__pyx_t_2 = NULL;
  4312. Py_ssize_t __pyx_t_3;
  4313. Py_ssize_t __pyx_t_4;
  4314. int __pyx_t_5;
  4315. PyObject *__pyx_t_6 = NULL;
  4316. PyObject *__pyx_t_7 = NULL;
  4317. PyObject *__pyx_t_8 = NULL;
  4318. PyObject *__pyx_t_9 = NULL;
  4319. size_t __pyx_t_10;
  4320. PyObject *(*__pyx_t_11)(PyObject *);
  4321. PyObject *__pyx_t_12 = NULL;
  4322. PyObject *__pyx_t_13 = NULL;
  4323. int __pyx_t_14;
  4324. PyObject *__pyx_t_15 = NULL;
  4325. char const *__pyx_t_16;
  4326. unsigned int __pyx_t_17;
  4327. Py_UCS4 __pyx_t_18;
  4328. PyObject *__pyx_t_19 = NULL;
  4329. __Pyx_RefNannySetupContext("_init_dbis", 0);
  4330. __Pyx_TraceCall("_init_dbis", __pyx_f[0], 239, 0, __PYX_ERR(0, 239, __pyx_L1_error));
  4331. if (__pyx_optional_args) {
  4332. if (__pyx_optional_args->__pyx_n > 0) {
  4333. __pyx_v_create = __pyx_optional_args->create;
  4334. }
  4335. }
  4336. /* "lakesuperior/store/base_lmdb_store.pyx":249
  4337. *
  4338. * # At least one slot (for environments without a database)
  4339. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc( # <<<<<<<<<<<<<<
  4340. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4341. * if not self.dbis:
  4342. */
  4343. __pyx_t_1 = 1;
  4344. /* "lakesuperior/store/base_lmdb_store.pyx":250
  4345. * # At least one slot (for environments without a database)
  4346. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc(
  4347. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi)) # <<<<<<<<<<<<<<
  4348. * if not self.dbis:
  4349. * raise MemoryError()
  4350. */
  4351. __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)
  4352. __Pyx_GOTREF(__pyx_t_2);
  4353. __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 250, __pyx_L1_error)
  4354. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4355. if (((__pyx_t_1 > __pyx_t_3) != 0)) {
  4356. __pyx_t_4 = __pyx_t_1;
  4357. } else {
  4358. __pyx_t_4 = __pyx_t_3;
  4359. }
  4360. /* "lakesuperior/store/base_lmdb_store.pyx":249
  4361. *
  4362. * # At least one slot (for environments without a database)
  4363. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc( # <<<<<<<<<<<<<<
  4364. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4365. * if not self.dbis:
  4366. */
  4367. __pyx_v_self->dbis = ((MDB_dbi *)PyMem_Malloc((__pyx_t_4 * (sizeof(MDB_dbi)))));
  4368. /* "lakesuperior/store/base_lmdb_store.pyx":251
  4369. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc(
  4370. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4371. * if not self.dbis: # <<<<<<<<<<<<<<
  4372. * raise MemoryError()
  4373. *
  4374. */
  4375. __pyx_t_5 = ((!(__pyx_v_self->dbis != 0)) != 0);
  4376. if (unlikely(__pyx_t_5)) {
  4377. /* "lakesuperior/store/base_lmdb_store.pyx":252
  4378. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4379. * if not self.dbis:
  4380. * raise MemoryError() # <<<<<<<<<<<<<<
  4381. *
  4382. * # DBIs seem to start from 2. We want to map cursor pointers in the
  4383. */
  4384. PyErr_NoMemory(); __PYX_ERR(0, 252, __pyx_L1_error)
  4385. /* "lakesuperior/store/base_lmdb_store.pyx":251
  4386. * self.dbis = <lmdb.MDB_dbi *>PyMem_Malloc(
  4387. * max(len(self.dbi_labels), 1) * sizeof(lmdb.MDB_dbi))
  4388. * if not self.dbis: # <<<<<<<<<<<<<<
  4389. * raise MemoryError()
  4390. *
  4391. */
  4392. }
  4393. /* "lakesuperior/store/base_lmdb_store.pyx":257
  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. * raise MemoryError()
  4399. */
  4400. __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)
  4401. __Pyx_GOTREF(__pyx_t_2);
  4402. __pyx_t_4 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 257, __pyx_L1_error)
  4403. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4404. /* "lakesuperior/store/base_lmdb_store.pyx":256
  4405. * # DBIs seem to start from 2. We want to map cursor pointers in the
  4406. * # array to DBIs, so we need an extra slot.
  4407. * self.curs = <lmdb.MDB_cursor **>PyMem_Malloc( # <<<<<<<<<<<<<<
  4408. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4409. * if not self.curs:
  4410. */
  4411. __pyx_v_self->curs = ((MDB_cursor **)PyMem_Malloc(((__pyx_t_4 + 2) * (sizeof(MDB_cursor *)))));
  4412. /* "lakesuperior/store/base_lmdb_store.pyx":258
  4413. * self.curs = <lmdb.MDB_cursor **>PyMem_Malloc(
  4414. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4415. * if not self.curs: # <<<<<<<<<<<<<<
  4416. * raise MemoryError()
  4417. *
  4418. */
  4419. __pyx_t_5 = ((!(__pyx_v_self->curs != 0)) != 0);
  4420. if (unlikely(__pyx_t_5)) {
  4421. /* "lakesuperior/store/base_lmdb_store.pyx":259
  4422. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4423. * if not self.curs:
  4424. * raise MemoryError() # <<<<<<<<<<<<<<
  4425. *
  4426. * create_flag = lmdb.MDB_CREATE if create is True else 0
  4427. */
  4428. PyErr_NoMemory(); __PYX_ERR(0, 259, __pyx_L1_error)
  4429. /* "lakesuperior/store/base_lmdb_store.pyx":258
  4430. * self.curs = <lmdb.MDB_cursor **>PyMem_Malloc(
  4431. * (len(self.dbi_labels) + 2) * sizeof(lmdb.MDB_cursor*))
  4432. * if not self.curs: # <<<<<<<<<<<<<<
  4433. * raise MemoryError()
  4434. *
  4435. */
  4436. }
  4437. /* "lakesuperior/store/base_lmdb_store.pyx":261
  4438. * raise MemoryError()
  4439. *
  4440. * create_flag = lmdb.MDB_CREATE if create is True else 0 # <<<<<<<<<<<<<<
  4441. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  4442. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4443. */
  4444. __pyx_t_5 = (__pyx_v_create == Py_True);
  4445. if ((__pyx_t_5 != 0)) {
  4446. __pyx_t_1 = MDB_CREATE;
  4447. } else {
  4448. __pyx_t_1 = 0;
  4449. }
  4450. __pyx_v_create_flag = __pyx_t_1;
  4451. /* "lakesuperior/store/base_lmdb_store.pyx":262
  4452. *
  4453. * create_flag = lmdb.MDB_CREATE if create is True else 0
  4454. * txn_flags = 0 if create else lmdb.MDB_RDONLY # <<<<<<<<<<<<<<
  4455. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4456. * logger.info(f'Creating DBs.')
  4457. */
  4458. __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_create); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 262, __pyx_L1_error)
  4459. if (__pyx_t_5) {
  4460. __pyx_t_1 = 0;
  4461. } else {
  4462. __pyx_t_1 = MDB_RDONLY;
  4463. }
  4464. __pyx_v_txn_flags = __pyx_t_1;
  4465. /* "lakesuperior/store/base_lmdb_store.pyx":263
  4466. * create_flag = lmdb.MDB_CREATE if create is True else 0
  4467. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  4468. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn) # <<<<<<<<<<<<<<
  4469. * logger.info(f'Creating DBs.')
  4470. * try:
  4471. */
  4472. __pyx_v_rc = mdb_txn_begin(__pyx_v_self->dbenv, NULL, __pyx_v_txn_flags, (&__pyx_v_txn));
  4473. /* "lakesuperior/store/base_lmdb_store.pyx":264
  4474. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  4475. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4476. * logger.info(f'Creating DBs.') # <<<<<<<<<<<<<<
  4477. * try:
  4478. * if len(self.dbi_labels):
  4479. */
  4480. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error)
  4481. __Pyx_GOTREF(__pyx_t_2);
  4482. __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)
  4483. __Pyx_GOTREF(__pyx_t_6);
  4484. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4485. __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)
  4486. __Pyx_GOTREF(__pyx_t_2);
  4487. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4488. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4489. /* "lakesuperior/store/base_lmdb_store.pyx":265
  4490. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4491. * logger.info(f'Creating DBs.')
  4492. * try: # <<<<<<<<<<<<<<
  4493. * if len(self.dbi_labels):
  4494. * for i, dblabel in enumerate(self.dbi_labels):
  4495. */
  4496. {
  4497. __Pyx_PyThreadState_declare
  4498. __Pyx_PyThreadState_assign
  4499. __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
  4500. __Pyx_XGOTREF(__pyx_t_7);
  4501. __Pyx_XGOTREF(__pyx_t_8);
  4502. __Pyx_XGOTREF(__pyx_t_9);
  4503. /*try:*/ {
  4504. /* "lakesuperior/store/base_lmdb_store.pyx":266
  4505. * logger.info(f'Creating DBs.')
  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. */
  4511. __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)
  4512. __Pyx_GOTREF(__pyx_t_2);
  4513. __pyx_t_4 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 266, __pyx_L5_error)
  4514. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4515. __pyx_t_5 = (__pyx_t_4 != 0);
  4516. if (__pyx_t_5) {
  4517. /* "lakesuperior/store/base_lmdb_store.pyx":267
  4518. * try:
  4519. * if len(self.dbi_labels):
  4520. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  4521. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4522. * _check(lmdb.mdb_dbi_open(
  4523. */
  4524. __pyx_t_10 = 0;
  4525. __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)
  4526. __Pyx_GOTREF(__pyx_t_2);
  4527. if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
  4528. __pyx_t_6 = __pyx_t_2; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = 0;
  4529. __pyx_t_11 = NULL;
  4530. } else {
  4531. __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 267, __pyx_L5_error)
  4532. __Pyx_GOTREF(__pyx_t_6);
  4533. __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 267, __pyx_L5_error)
  4534. }
  4535. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4536. for (;;) {
  4537. if (likely(!__pyx_t_11)) {
  4538. if (likely(PyList_CheckExact(__pyx_t_6))) {
  4539. if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_6)) break;
  4540. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4541. __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)
  4542. #else
  4543. __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)
  4544. __Pyx_GOTREF(__pyx_t_2);
  4545. #endif
  4546. } else {
  4547. if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
  4548. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4549. __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)
  4550. #else
  4551. __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)
  4552. __Pyx_GOTREF(__pyx_t_2);
  4553. #endif
  4554. }
  4555. } else {
  4556. __pyx_t_2 = __pyx_t_11(__pyx_t_6);
  4557. if (unlikely(!__pyx_t_2)) {
  4558. PyObject* exc_type = PyErr_Occurred();
  4559. if (exc_type) {
  4560. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  4561. else __PYX_ERR(0, 267, __pyx_L5_error)
  4562. }
  4563. break;
  4564. }
  4565. __Pyx_GOTREF(__pyx_t_2);
  4566. }
  4567. __Pyx_XDECREF_SET(__pyx_v_dblabel, __pyx_t_2);
  4568. __pyx_t_2 = 0;
  4569. __pyx_v_i = __pyx_t_10;
  4570. __pyx_t_10 = (__pyx_t_10 + 1);
  4571. /* "lakesuperior/store/base_lmdb_store.pyx":268
  4572. * if len(self.dbi_labels):
  4573. * for i, dblabel in enumerate(self.dbi_labels):
  4574. * flags = self.dbi_flags.get(dblabel, 0) | create_flag # <<<<<<<<<<<<<<
  4575. * _check(lmdb.mdb_dbi_open(
  4576. * txn, dblabel.encode(), flags, self.dbis + i))
  4577. */
  4578. __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)
  4579. __Pyx_GOTREF(__pyx_t_12);
  4580. __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)
  4581. __Pyx_GOTREF(__pyx_t_13);
  4582. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4583. __pyx_t_12 = NULL;
  4584. __pyx_t_14 = 0;
  4585. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  4586. __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
  4587. if (likely(__pyx_t_12)) {
  4588. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  4589. __Pyx_INCREF(__pyx_t_12);
  4590. __Pyx_INCREF(function);
  4591. __Pyx_DECREF_SET(__pyx_t_13, function);
  4592. __pyx_t_14 = 1;
  4593. }
  4594. }
  4595. #if CYTHON_FAST_PYCALL
  4596. if (PyFunction_Check(__pyx_t_13)) {
  4597. PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_dblabel, __pyx_int_0};
  4598. __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)
  4599. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4600. __Pyx_GOTREF(__pyx_t_2);
  4601. } else
  4602. #endif
  4603. #if CYTHON_FAST_PYCCALL
  4604. if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
  4605. PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_dblabel, __pyx_int_0};
  4606. __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)
  4607. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4608. __Pyx_GOTREF(__pyx_t_2);
  4609. } else
  4610. #endif
  4611. {
  4612. __pyx_t_15 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 268, __pyx_L5_error)
  4613. __Pyx_GOTREF(__pyx_t_15);
  4614. if (__pyx_t_12) {
  4615. __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_12); __pyx_t_12 = NULL;
  4616. }
  4617. __Pyx_INCREF(__pyx_v_dblabel);
  4618. __Pyx_GIVEREF(__pyx_v_dblabel);
  4619. PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_v_dblabel);
  4620. __Pyx_INCREF(__pyx_int_0);
  4621. __Pyx_GIVEREF(__pyx_int_0);
  4622. PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_int_0);
  4623. __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)
  4624. __Pyx_GOTREF(__pyx_t_2);
  4625. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4626. }
  4627. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4628. __pyx_t_13 = __Pyx_PyInt_From_long(__pyx_v_create_flag); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 268, __pyx_L5_error)
  4629. __Pyx_GOTREF(__pyx_t_13);
  4630. __pyx_t_15 = PyNumber_Or(__pyx_t_2, __pyx_t_13); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 268, __pyx_L5_error)
  4631. __Pyx_GOTREF(__pyx_t_15);
  4632. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4633. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4634. __Pyx_XDECREF_SET(__pyx_v_flags, __pyx_t_15);
  4635. __pyx_t_15 = 0;
  4636. /* "lakesuperior/store/base_lmdb_store.pyx":270
  4637. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4638. * _check(lmdb.mdb_dbi_open(
  4639. * txn, dblabel.encode(), flags, self.dbis + i)) # <<<<<<<<<<<<<<
  4640. * dbi = self.dbis[i]
  4641. * logger.info(f'Created DB {dblabel}: {dbi}')
  4642. */
  4643. __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)
  4644. __Pyx_GOTREF(__pyx_t_13);
  4645. __pyx_t_2 = NULL;
  4646. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  4647. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_13);
  4648. if (likely(__pyx_t_2)) {
  4649. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  4650. __Pyx_INCREF(__pyx_t_2);
  4651. __Pyx_INCREF(function);
  4652. __Pyx_DECREF_SET(__pyx_t_13, function);
  4653. }
  4654. }
  4655. if (__pyx_t_2) {
  4656. __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 270, __pyx_L5_error)
  4657. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4658. } else {
  4659. __pyx_t_15 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 270, __pyx_L5_error)
  4660. }
  4661. __Pyx_GOTREF(__pyx_t_15);
  4662. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4663. __pyx_t_16 = __Pyx_PyObject_AsString(__pyx_t_15); if (unlikely((!__pyx_t_16) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L5_error)
  4664. __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)
  4665. /* "lakesuperior/store/base_lmdb_store.pyx":269
  4666. * for i, dblabel in enumerate(self.dbi_labels):
  4667. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4668. * _check(lmdb.mdb_dbi_open( # <<<<<<<<<<<<<<
  4669. * txn, dblabel.encode(), flags, self.dbis + i))
  4670. * dbi = self.dbis[i]
  4671. */
  4672. __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)
  4673. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4674. /* "lakesuperior/store/base_lmdb_store.pyx":271
  4675. * _check(lmdb.mdb_dbi_open(
  4676. * txn, dblabel.encode(), flags, self.dbis + i))
  4677. * dbi = self.dbis[i] # <<<<<<<<<<<<<<
  4678. * logger.info(f'Created DB {dblabel}: {dbi}')
  4679. * # Open and close cursor to initialize the memory slot.
  4680. */
  4681. __pyx_v_dbi = (__pyx_v_self->dbis[__pyx_v_i]);
  4682. /* "lakesuperior/store/base_lmdb_store.pyx":272
  4683. * txn, dblabel.encode(), flags, self.dbis + i))
  4684. * dbi = self.dbis[i]
  4685. * logger.info(f'Created DB {dblabel}: {dbi}') # <<<<<<<<<<<<<<
  4686. * # Open and close cursor to initialize the memory slot.
  4687. * _check(lmdb.mdb_cursor_open(
  4688. */
  4689. __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 272, __pyx_L5_error)
  4690. __Pyx_GOTREF(__pyx_t_13);
  4691. __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)
  4692. __Pyx_GOTREF(__pyx_t_2);
  4693. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4694. __pyx_t_13 = PyTuple_New(4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 272, __pyx_L5_error)
  4695. __Pyx_GOTREF(__pyx_t_13);
  4696. __pyx_t_3 = 0;
  4697. __pyx_t_18 = 127;
  4698. __Pyx_INCREF(__pyx_kp_u_Created_DB);
  4699. __pyx_t_3 += 11;
  4700. __Pyx_GIVEREF(__pyx_kp_u_Created_DB);
  4701. PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_kp_u_Created_DB);
  4702. __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_v_dblabel, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L5_error)
  4703. __Pyx_GOTREF(__pyx_t_12);
  4704. __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;
  4705. __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12);
  4706. __Pyx_GIVEREF(__pyx_t_12);
  4707. PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12);
  4708. __pyx_t_12 = 0;
  4709. __Pyx_INCREF(__pyx_kp_u__6);
  4710. __pyx_t_3 += 2;
  4711. __Pyx_GIVEREF(__pyx_kp_u__6);
  4712. PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_kp_u__6);
  4713. __pyx_t_12 = __Pyx_PyInt_From_MDB_dbi(__pyx_v_dbi); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L5_error)
  4714. __Pyx_GOTREF(__pyx_t_12);
  4715. __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_t_12, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 272, __pyx_L5_error)
  4716. __Pyx_GOTREF(__pyx_t_19);
  4717. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4718. __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;
  4719. __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19);
  4720. __Pyx_GIVEREF(__pyx_t_19);
  4721. PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_19);
  4722. __pyx_t_19 = 0;
  4723. __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)
  4724. __Pyx_GOTREF(__pyx_t_19);
  4725. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4726. __pyx_t_13 = NULL;
  4727. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  4728. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
  4729. if (likely(__pyx_t_13)) {
  4730. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  4731. __Pyx_INCREF(__pyx_t_13);
  4732. __Pyx_INCREF(function);
  4733. __Pyx_DECREF_SET(__pyx_t_2, function);
  4734. }
  4735. }
  4736. if (!__pyx_t_13) {
  4737. __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_19); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 272, __pyx_L5_error)
  4738. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  4739. __Pyx_GOTREF(__pyx_t_15);
  4740. } else {
  4741. #if CYTHON_FAST_PYCALL
  4742. if (PyFunction_Check(__pyx_t_2)) {
  4743. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_19};
  4744. __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)
  4745. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4746. __Pyx_GOTREF(__pyx_t_15);
  4747. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  4748. } else
  4749. #endif
  4750. #if CYTHON_FAST_PYCCALL
  4751. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  4752. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_19};
  4753. __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)
  4754. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4755. __Pyx_GOTREF(__pyx_t_15);
  4756. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  4757. } else
  4758. #endif
  4759. {
  4760. __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L5_error)
  4761. __Pyx_GOTREF(__pyx_t_12);
  4762. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL;
  4763. __Pyx_GIVEREF(__pyx_t_19);
  4764. PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_19);
  4765. __pyx_t_19 = 0;
  4766. __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)
  4767. __Pyx_GOTREF(__pyx_t_15);
  4768. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4769. }
  4770. }
  4771. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4772. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4773. /* "lakesuperior/store/base_lmdb_store.pyx":274
  4774. * logger.info(f'Created DB {dblabel}: {dbi}')
  4775. * # Open and close cursor to initialize the memory slot.
  4776. * _check(lmdb.mdb_cursor_open( # <<<<<<<<<<<<<<
  4777. * txn, dbi, self.curs + dbi))
  4778. * #lmdb.mdb_cursor_close(self.curs[dbi])
  4779. */
  4780. __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)
  4781. /* "lakesuperior/store/base_lmdb_store.pyx":267
  4782. * try:
  4783. * if len(self.dbi_labels):
  4784. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  4785. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4786. * _check(lmdb.mdb_dbi_open(
  4787. */
  4788. }
  4789. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4790. /* "lakesuperior/store/base_lmdb_store.pyx":266
  4791. * logger.info(f'Creating DBs.')
  4792. * try:
  4793. * if len(self.dbi_labels): # <<<<<<<<<<<<<<
  4794. * for i, dblabel in enumerate(self.dbi_labels):
  4795. * flags = self.dbi_flags.get(dblabel, 0) | create_flag
  4796. */
  4797. goto __pyx_L11;
  4798. }
  4799. /* "lakesuperior/store/base_lmdb_store.pyx":278
  4800. * #lmdb.mdb_cursor_close(self.curs[dbi])
  4801. * else:
  4802. * _check(lmdb.mdb_dbi_open(txn, NULL, 0, self.dbis)) # <<<<<<<<<<<<<<
  4803. * _check(lmdb.mdb_cursor_open(txn, self.dbis[0], self.curs))
  4804. * #lmdb.mdb_cursor_close(self.curs[self.dbis[0]])
  4805. */
  4806. /*else*/ {
  4807. __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)
  4808. /* "lakesuperior/store/base_lmdb_store.pyx":279
  4809. * else:
  4810. * _check(lmdb.mdb_dbi_open(txn, NULL, 0, self.dbis))
  4811. * _check(lmdb.mdb_cursor_open(txn, self.dbis[0], self.curs)) # <<<<<<<<<<<<<<
  4812. * #lmdb.mdb_cursor_close(self.curs[self.dbis[0]])
  4813. *
  4814. */
  4815. __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)
  4816. }
  4817. __pyx_L11:;
  4818. /* "lakesuperior/store/base_lmdb_store.pyx":282
  4819. * #lmdb.mdb_cursor_close(self.curs[self.dbis[0]])
  4820. *
  4821. * _check(lmdb.mdb_txn_commit(txn)) # <<<<<<<<<<<<<<
  4822. * except:
  4823. * lmdb.mdb_txn_abort(txn)
  4824. */
  4825. __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)
  4826. /* "lakesuperior/store/base_lmdb_store.pyx":265
  4827. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4828. * logger.info(f'Creating DBs.')
  4829. * try: # <<<<<<<<<<<<<<
  4830. * if len(self.dbi_labels):
  4831. * for i, dblabel in enumerate(self.dbi_labels):
  4832. */
  4833. }
  4834. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4835. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  4836. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  4837. goto __pyx_L10_try_end;
  4838. __pyx_L5_error:;
  4839. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4840. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  4841. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4842. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  4843. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  4844. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4845. /* "lakesuperior/store/base_lmdb_store.pyx":283
  4846. *
  4847. * _check(lmdb.mdb_txn_commit(txn))
  4848. * except: # <<<<<<<<<<<<<<
  4849. * lmdb.mdb_txn_abort(txn)
  4850. * raise
  4851. */
  4852. /*except:*/ {
  4853. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._init_dbis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4854. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_15, &__pyx_t_2) < 0) __PYX_ERR(0, 283, __pyx_L7_except_error)
  4855. __Pyx_GOTREF(__pyx_t_6);
  4856. __Pyx_GOTREF(__pyx_t_15);
  4857. __Pyx_GOTREF(__pyx_t_2);
  4858. /* "lakesuperior/store/base_lmdb_store.pyx":284
  4859. * _check(lmdb.mdb_txn_commit(txn))
  4860. * except:
  4861. * lmdb.mdb_txn_abort(txn) # <<<<<<<<<<<<<<
  4862. * raise
  4863. *
  4864. */
  4865. mdb_txn_abort(__pyx_v_txn);
  4866. /* "lakesuperior/store/base_lmdb_store.pyx":285
  4867. * except:
  4868. * lmdb.mdb_txn_abort(txn)
  4869. * raise # <<<<<<<<<<<<<<
  4870. *
  4871. *
  4872. */
  4873. __Pyx_GIVEREF(__pyx_t_6);
  4874. __Pyx_GIVEREF(__pyx_t_15);
  4875. __Pyx_XGIVEREF(__pyx_t_2);
  4876. __Pyx_ErrRestoreWithState(__pyx_t_6, __pyx_t_15, __pyx_t_2);
  4877. __pyx_t_6 = 0; __pyx_t_15 = 0; __pyx_t_2 = 0;
  4878. __PYX_ERR(0, 285, __pyx_L7_except_error)
  4879. }
  4880. __pyx_L7_except_error:;
  4881. /* "lakesuperior/store/base_lmdb_store.pyx":265
  4882. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  4883. * logger.info(f'Creating DBs.')
  4884. * try: # <<<<<<<<<<<<<<
  4885. * if len(self.dbi_labels):
  4886. * for i, dblabel in enumerate(self.dbi_labels):
  4887. */
  4888. __Pyx_XGIVEREF(__pyx_t_7);
  4889. __Pyx_XGIVEREF(__pyx_t_8);
  4890. __Pyx_XGIVEREF(__pyx_t_9);
  4891. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  4892. goto __pyx_L1_error;
  4893. __pyx_L10_try_end:;
  4894. }
  4895. /* "lakesuperior/store/base_lmdb_store.pyx":239
  4896. *
  4897. *
  4898. * cdef void _init_dbis(self, create=True) except *: # <<<<<<<<<<<<<<
  4899. * """
  4900. * Initialize databases and cursors.
  4901. */
  4902. /* function exit code */
  4903. goto __pyx_L0;
  4904. __pyx_L1_error:;
  4905. __Pyx_XDECREF(__pyx_t_2);
  4906. __Pyx_XDECREF(__pyx_t_6);
  4907. __Pyx_XDECREF(__pyx_t_12);
  4908. __Pyx_XDECREF(__pyx_t_13);
  4909. __Pyx_XDECREF(__pyx_t_15);
  4910. __Pyx_XDECREF(__pyx_t_19);
  4911. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._init_dbis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4912. __pyx_L0:;
  4913. __Pyx_XDECREF(__pyx_v_dblabel);
  4914. __Pyx_XDECREF(__pyx_v_flags);
  4915. __Pyx_TraceReturn(Py_None, 0);
  4916. __Pyx_RefNannyFinishContext();
  4917. }
  4918. /* "lakesuperior/store/base_lmdb_store.pyx":288
  4919. *
  4920. *
  4921. * cpdef void close_env(self, bint commit_pending_transaction=False) except *: # <<<<<<<<<<<<<<
  4922. * logger.debug('Cleaning up store env.')
  4923. * if self.is_open:
  4924. */
  4925. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4926. 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) {
  4927. int __pyx_v_commit_pending_transaction = ((int)0);
  4928. __Pyx_TraceDeclarations
  4929. __Pyx_RefNannyDeclarations
  4930. PyObject *__pyx_t_1 = NULL;
  4931. PyObject *__pyx_t_2 = NULL;
  4932. PyObject *__pyx_t_3 = NULL;
  4933. PyObject *__pyx_t_4 = NULL;
  4934. PyObject *__pyx_t_5 = NULL;
  4935. PyObject *__pyx_t_6 = NULL;
  4936. int __pyx_t_7;
  4937. __Pyx_RefNannySetupContext("close_env", 0);
  4938. __Pyx_TraceCall("close_env", __pyx_f[0], 288, 0, __PYX_ERR(0, 288, __pyx_L1_error));
  4939. if (__pyx_optional_args) {
  4940. if (__pyx_optional_args->__pyx_n > 0) {
  4941. __pyx_v_commit_pending_transaction = __pyx_optional_args->commit_pending_transaction;
  4942. }
  4943. }
  4944. /* Check if called by wrapper */
  4945. if (unlikely(__pyx_skip_dispatch)) ;
  4946. /* Check if overridden in Python */
  4947. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  4948. __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)
  4949. __Pyx_GOTREF(__pyx_t_1);
  4950. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env)) {
  4951. __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_commit_pending_transaction); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error)
  4952. __Pyx_GOTREF(__pyx_t_3);
  4953. __Pyx_INCREF(__pyx_t_1);
  4954. __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
  4955. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  4956. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  4957. if (likely(__pyx_t_5)) {
  4958. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  4959. __Pyx_INCREF(__pyx_t_5);
  4960. __Pyx_INCREF(function);
  4961. __Pyx_DECREF_SET(__pyx_t_4, function);
  4962. }
  4963. }
  4964. if (!__pyx_t_5) {
  4965. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
  4966. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4967. __Pyx_GOTREF(__pyx_t_2);
  4968. } else {
  4969. #if CYTHON_FAST_PYCALL
  4970. if (PyFunction_Check(__pyx_t_4)) {
  4971. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4972. __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)
  4973. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4974. __Pyx_GOTREF(__pyx_t_2);
  4975. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4976. } else
  4977. #endif
  4978. #if CYTHON_FAST_PYCCALL
  4979. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  4980. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
  4981. __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)
  4982. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4983. __Pyx_GOTREF(__pyx_t_2);
  4984. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4985. } else
  4986. #endif
  4987. {
  4988. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error)
  4989. __Pyx_GOTREF(__pyx_t_6);
  4990. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
  4991. __Pyx_GIVEREF(__pyx_t_3);
  4992. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
  4993. __pyx_t_3 = 0;
  4994. __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)
  4995. __Pyx_GOTREF(__pyx_t_2);
  4996. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4997. }
  4998. }
  4999. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5000. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5001. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5002. goto __pyx_L0;
  5003. }
  5004. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5005. }
  5006. /* "lakesuperior/store/base_lmdb_store.pyx":289
  5007. *
  5008. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  5009. * logger.debug('Cleaning up store env.') # <<<<<<<<<<<<<<
  5010. * if self.is_open:
  5011. * logger.debug('Closing store env.')
  5012. */
  5013. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error)
  5014. __Pyx_GOTREF(__pyx_t_1);
  5015. __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)
  5016. __Pyx_GOTREF(__pyx_t_2);
  5017. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5018. __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)
  5019. __Pyx_GOTREF(__pyx_t_1);
  5020. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5021. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5022. /* "lakesuperior/store/base_lmdb_store.pyx":290
  5023. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  5024. * logger.debug('Cleaning up store env.')
  5025. * if self.is_open: # <<<<<<<<<<<<<<
  5026. * logger.debug('Closing store env.')
  5027. * if self.is_txn_open is True:
  5028. */
  5029. __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)
  5030. __Pyx_GOTREF(__pyx_t_1);
  5031. __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 290, __pyx_L1_error)
  5032. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5033. if (__pyx_t_7) {
  5034. /* "lakesuperior/store/base_lmdb_store.pyx":291
  5035. * logger.debug('Cleaning up store env.')
  5036. * if self.is_open:
  5037. * logger.debug('Closing store env.') # <<<<<<<<<<<<<<
  5038. * if self.is_txn_open is True:
  5039. * if commit_pending_transaction:
  5040. */
  5041. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error)
  5042. __Pyx_GOTREF(__pyx_t_1);
  5043. __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)
  5044. __Pyx_GOTREF(__pyx_t_2);
  5045. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5046. __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)
  5047. __Pyx_GOTREF(__pyx_t_1);
  5048. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5049. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5050. /* "lakesuperior/store/base_lmdb_store.pyx":292
  5051. * if self.is_open:
  5052. * logger.debug('Closing store env.')
  5053. * if self.is_txn_open is True: # <<<<<<<<<<<<<<
  5054. * if commit_pending_transaction:
  5055. * self._txn_commit()
  5056. */
  5057. __pyx_t_7 = ((__pyx_v_self->is_txn_open == 1) != 0);
  5058. if (__pyx_t_7) {
  5059. /* "lakesuperior/store/base_lmdb_store.pyx":293
  5060. * logger.debug('Closing store env.')
  5061. * if self.is_txn_open is True:
  5062. * if commit_pending_transaction: # <<<<<<<<<<<<<<
  5063. * self._txn_commit()
  5064. * else:
  5065. */
  5066. __pyx_t_7 = (__pyx_v_commit_pending_transaction != 0);
  5067. if (__pyx_t_7) {
  5068. /* "lakesuperior/store/base_lmdb_store.pyx":294
  5069. * if self.is_txn_open is True:
  5070. * if commit_pending_transaction:
  5071. * self._txn_commit() # <<<<<<<<<<<<<<
  5072. * else:
  5073. * self._txn_abort()
  5074. */
  5075. ((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)
  5076. /* "lakesuperior/store/base_lmdb_store.pyx":293
  5077. * logger.debug('Closing store env.')
  5078. * if self.is_txn_open is True:
  5079. * if commit_pending_transaction: # <<<<<<<<<<<<<<
  5080. * self._txn_commit()
  5081. * else:
  5082. */
  5083. goto __pyx_L5;
  5084. }
  5085. /* "lakesuperior/store/base_lmdb_store.pyx":296
  5086. * self._txn_commit()
  5087. * else:
  5088. * self._txn_abort() # <<<<<<<<<<<<<<
  5089. *
  5090. * self._clear_stale_readers()
  5091. */
  5092. /*else*/ {
  5093. ((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)
  5094. }
  5095. __pyx_L5:;
  5096. /* "lakesuperior/store/base_lmdb_store.pyx":292
  5097. * if self.is_open:
  5098. * logger.debug('Closing store env.')
  5099. * if self.is_txn_open is True: # <<<<<<<<<<<<<<
  5100. * if commit_pending_transaction:
  5101. * self._txn_commit()
  5102. */
  5103. }
  5104. /* "lakesuperior/store/base_lmdb_store.pyx":298
  5105. * self._txn_abort()
  5106. *
  5107. * self._clear_stale_readers() # <<<<<<<<<<<<<<
  5108. *
  5109. * PyMem_Free(self.dbis)
  5110. */
  5111. ((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)
  5112. /* "lakesuperior/store/base_lmdb_store.pyx":300
  5113. * self._clear_stale_readers()
  5114. *
  5115. * PyMem_Free(self.dbis) # <<<<<<<<<<<<<<
  5116. * PyMem_Free(self.curs)
  5117. * lmdb.mdb_env_close(self.dbenv)
  5118. */
  5119. PyMem_Free(__pyx_v_self->dbis);
  5120. /* "lakesuperior/store/base_lmdb_store.pyx":301
  5121. *
  5122. * PyMem_Free(self.dbis)
  5123. * PyMem_Free(self.curs) # <<<<<<<<<<<<<<
  5124. * lmdb.mdb_env_close(self.dbenv)
  5125. *
  5126. */
  5127. PyMem_Free(__pyx_v_self->curs);
  5128. /* "lakesuperior/store/base_lmdb_store.pyx":302
  5129. * PyMem_Free(self.dbis)
  5130. * PyMem_Free(self.curs)
  5131. * lmdb.mdb_env_close(self.dbenv) # <<<<<<<<<<<<<<
  5132. *
  5133. * self._open = False
  5134. */
  5135. mdb_env_close(__pyx_v_self->dbenv);
  5136. /* "lakesuperior/store/base_lmdb_store.pyx":290
  5137. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  5138. * logger.debug('Cleaning up store env.')
  5139. * if self.is_open: # <<<<<<<<<<<<<<
  5140. * logger.debug('Closing store env.')
  5141. * if self.is_txn_open is True:
  5142. */
  5143. }
  5144. /* "lakesuperior/store/base_lmdb_store.pyx":304
  5145. * lmdb.mdb_env_close(self.dbenv)
  5146. *
  5147. * self._open = False # <<<<<<<<<<<<<<
  5148. *
  5149. *
  5150. */
  5151. __pyx_v_self->_open = 0;
  5152. /* "lakesuperior/store/base_lmdb_store.pyx":288
  5153. *
  5154. *
  5155. * cpdef void close_env(self, bint commit_pending_transaction=False) except *: # <<<<<<<<<<<<<<
  5156. * logger.debug('Cleaning up store env.')
  5157. * if self.is_open:
  5158. */
  5159. /* function exit code */
  5160. goto __pyx_L0;
  5161. __pyx_L1_error:;
  5162. __Pyx_XDECREF(__pyx_t_1);
  5163. __Pyx_XDECREF(__pyx_t_2);
  5164. __Pyx_XDECREF(__pyx_t_3);
  5165. __Pyx_XDECREF(__pyx_t_4);
  5166. __Pyx_XDECREF(__pyx_t_5);
  5167. __Pyx_XDECREF(__pyx_t_6);
  5168. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.close_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5169. __pyx_L0:;
  5170. __Pyx_TraceReturn(Py_None, 0);
  5171. __Pyx_RefNannyFinishContext();
  5172. }
  5173. /* Python wrapper */
  5174. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5175. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5176. int __pyx_v_commit_pending_transaction;
  5177. PyObject *__pyx_r = 0;
  5178. __Pyx_RefNannyDeclarations
  5179. __Pyx_RefNannySetupContext("close_env (wrapper)", 0);
  5180. {
  5181. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_commit_pending_transaction,0};
  5182. PyObject* values[1] = {0};
  5183. if (unlikely(__pyx_kwds)) {
  5184. Py_ssize_t kw_args;
  5185. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5186. switch (pos_args) {
  5187. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5188. CYTHON_FALLTHROUGH;
  5189. case 0: break;
  5190. default: goto __pyx_L5_argtuple_error;
  5191. }
  5192. kw_args = PyDict_Size(__pyx_kwds);
  5193. switch (pos_args) {
  5194. case 0:
  5195. if (kw_args > 0) {
  5196. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_commit_pending_transaction);
  5197. if (value) { values[0] = value; kw_args--; }
  5198. }
  5199. }
  5200. if (unlikely(kw_args > 0)) {
  5201. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "close_env") < 0)) __PYX_ERR(0, 288, __pyx_L3_error)
  5202. }
  5203. } else {
  5204. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5205. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5206. CYTHON_FALLTHROUGH;
  5207. case 0: break;
  5208. default: goto __pyx_L5_argtuple_error;
  5209. }
  5210. }
  5211. if (values[0]) {
  5212. __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)
  5213. } else {
  5214. __pyx_v_commit_pending_transaction = ((int)0);
  5215. }
  5216. }
  5217. goto __pyx_L4_argument_unpacking_done;
  5218. __pyx_L5_argtuple_error:;
  5219. __Pyx_RaiseArgtupleInvalid("close_env", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 288, __pyx_L3_error)
  5220. __pyx_L3_error:;
  5221. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.close_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5222. __Pyx_RefNannyFinishContext();
  5223. return NULL;
  5224. __pyx_L4_argument_unpacking_done:;
  5225. __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);
  5226. /* function exit code */
  5227. __Pyx_RefNannyFinishContext();
  5228. return __pyx_r;
  5229. }
  5230. 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) {
  5231. PyObject *__pyx_r = NULL;
  5232. __Pyx_TraceDeclarations
  5233. __Pyx_RefNannyDeclarations
  5234. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_close_env __pyx_t_1;
  5235. PyObject *__pyx_t_2 = NULL;
  5236. __Pyx_RefNannySetupContext("close_env", 0);
  5237. __Pyx_TraceCall("close_env (wrapper)", __pyx_f[0], 288, 0, __PYX_ERR(0, 288, __pyx_L1_error));
  5238. __Pyx_XDECREF(__pyx_r);
  5239. __pyx_t_1.__pyx_n = 1;
  5240. __pyx_t_1.commit_pending_transaction = __pyx_v_commit_pending_transaction;
  5241. __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)
  5242. __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
  5243. __Pyx_GOTREF(__pyx_t_2);
  5244. __pyx_r = __pyx_t_2;
  5245. __pyx_t_2 = 0;
  5246. goto __pyx_L0;
  5247. /* function exit code */
  5248. __pyx_L1_error:;
  5249. __Pyx_XDECREF(__pyx_t_2);
  5250. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.close_env", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5251. __pyx_r = NULL;
  5252. __pyx_L0:;
  5253. __Pyx_XGIVEREF(__pyx_r);
  5254. __Pyx_TraceReturn(__pyx_r, 0);
  5255. __Pyx_RefNannyFinishContext();
  5256. return __pyx_r;
  5257. }
  5258. /* "lakesuperior/store/base_lmdb_store.pyx":307
  5259. *
  5260. *
  5261. * cpdef void destroy(self, _path='') except *: # <<<<<<<<<<<<<<
  5262. * """
  5263. * Destroy the store.
  5264. */
  5265. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5266. 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) {
  5267. PyObject *__pyx_v__path = ((PyObject *)__pyx_kp_u_);
  5268. __Pyx_TraceDeclarations
  5269. __Pyx_RefNannyDeclarations
  5270. PyObject *__pyx_t_1 = NULL;
  5271. PyObject *__pyx_t_2 = NULL;
  5272. PyObject *__pyx_t_3 = NULL;
  5273. PyObject *__pyx_t_4 = NULL;
  5274. PyObject *__pyx_t_5 = NULL;
  5275. int __pyx_t_6;
  5276. PyObject *__pyx_t_7 = NULL;
  5277. PyObject *__pyx_t_8 = NULL;
  5278. PyObject *__pyx_t_9 = NULL;
  5279. int __pyx_t_10;
  5280. __Pyx_RefNannySetupContext("destroy", 0);
  5281. __Pyx_TraceCall("destroy", __pyx_f[0], 307, 0, __PYX_ERR(0, 307, __pyx_L1_error));
  5282. if (__pyx_optional_args) {
  5283. if (__pyx_optional_args->__pyx_n > 0) {
  5284. __pyx_v__path = __pyx_optional_args->_path;
  5285. }
  5286. }
  5287. /* Check if called by wrapper */
  5288. if (unlikely(__pyx_skip_dispatch)) ;
  5289. /* Check if overridden in Python */
  5290. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  5291. __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)
  5292. __Pyx_GOTREF(__pyx_t_1);
  5293. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy)) {
  5294. __Pyx_INCREF(__pyx_t_1);
  5295. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  5296. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  5297. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  5298. if (likely(__pyx_t_4)) {
  5299. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  5300. __Pyx_INCREF(__pyx_t_4);
  5301. __Pyx_INCREF(function);
  5302. __Pyx_DECREF_SET(__pyx_t_3, function);
  5303. }
  5304. }
  5305. if (!__pyx_t_4) {
  5306. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v__path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
  5307. __Pyx_GOTREF(__pyx_t_2);
  5308. } else {
  5309. #if CYTHON_FAST_PYCALL
  5310. if (PyFunction_Check(__pyx_t_3)) {
  5311. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v__path};
  5312. __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)
  5313. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5314. __Pyx_GOTREF(__pyx_t_2);
  5315. } else
  5316. #endif
  5317. #if CYTHON_FAST_PYCCALL
  5318. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  5319. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v__path};
  5320. __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)
  5321. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5322. __Pyx_GOTREF(__pyx_t_2);
  5323. } else
  5324. #endif
  5325. {
  5326. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 307, __pyx_L1_error)
  5327. __Pyx_GOTREF(__pyx_t_5);
  5328. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  5329. __Pyx_INCREF(__pyx_v__path);
  5330. __Pyx_GIVEREF(__pyx_v__path);
  5331. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v__path);
  5332. __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)
  5333. __Pyx_GOTREF(__pyx_t_2);
  5334. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5335. }
  5336. }
  5337. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5338. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5339. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5340. goto __pyx_L0;
  5341. }
  5342. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5343. }
  5344. /* "lakesuperior/store/base_lmdb_store.pyx":317
  5345. * general-purpose recursive file and folder delete method!)
  5346. * """
  5347. * if path.exists(self.env_path): # <<<<<<<<<<<<<<
  5348. * if lmdb.MDB_NOSUBDIR & self.flags:
  5349. * try:
  5350. */
  5351. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error)
  5352. __Pyx_GOTREF(__pyx_t_2);
  5353. __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)
  5354. __Pyx_GOTREF(__pyx_t_3);
  5355. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5356. __pyx_t_2 = NULL;
  5357. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  5358. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
  5359. if (likely(__pyx_t_2)) {
  5360. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  5361. __Pyx_INCREF(__pyx_t_2);
  5362. __Pyx_INCREF(function);
  5363. __Pyx_DECREF_SET(__pyx_t_3, function);
  5364. }
  5365. }
  5366. if (!__pyx_t_2) {
  5367. __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)
  5368. __Pyx_GOTREF(__pyx_t_1);
  5369. } else {
  5370. #if CYTHON_FAST_PYCALL
  5371. if (PyFunction_Check(__pyx_t_3)) {
  5372. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5373. __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)
  5374. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5375. __Pyx_GOTREF(__pyx_t_1);
  5376. } else
  5377. #endif
  5378. #if CYTHON_FAST_PYCCALL
  5379. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  5380. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5381. __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)
  5382. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5383. __Pyx_GOTREF(__pyx_t_1);
  5384. } else
  5385. #endif
  5386. {
  5387. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 317, __pyx_L1_error)
  5388. __Pyx_GOTREF(__pyx_t_5);
  5389. __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
  5390. __Pyx_INCREF(__pyx_v_self->env_path);
  5391. __Pyx_GIVEREF(__pyx_v_self->env_path);
  5392. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_self->env_path);
  5393. __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)
  5394. __Pyx_GOTREF(__pyx_t_1);
  5395. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5396. }
  5397. }
  5398. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5399. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 317, __pyx_L1_error)
  5400. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5401. if (__pyx_t_6) {
  5402. /* "lakesuperior/store/base_lmdb_store.pyx":318
  5403. * """
  5404. * if path.exists(self.env_path):
  5405. * if lmdb.MDB_NOSUBDIR & self.flags: # <<<<<<<<<<<<<<
  5406. * try:
  5407. * os.unlink(self.env_path)
  5408. */
  5409. __pyx_t_1 = __Pyx_PyInt_From_int(MDB_NOSUBDIR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error)
  5410. __Pyx_GOTREF(__pyx_t_1);
  5411. __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)
  5412. __Pyx_GOTREF(__pyx_t_3);
  5413. __pyx_t_5 = PyNumber_And(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 318, __pyx_L1_error)
  5414. __Pyx_GOTREF(__pyx_t_5);
  5415. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5416. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5417. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 318, __pyx_L1_error)
  5418. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5419. if (__pyx_t_6) {
  5420. /* "lakesuperior/store/base_lmdb_store.pyx":319
  5421. * if path.exists(self.env_path):
  5422. * if lmdb.MDB_NOSUBDIR & self.flags:
  5423. * try: # <<<<<<<<<<<<<<
  5424. * os.unlink(self.env_path)
  5425. * except FileNotFoundError:
  5426. */
  5427. {
  5428. __Pyx_PyThreadState_declare
  5429. __Pyx_PyThreadState_assign
  5430. __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
  5431. __Pyx_XGOTREF(__pyx_t_7);
  5432. __Pyx_XGOTREF(__pyx_t_8);
  5433. __Pyx_XGOTREF(__pyx_t_9);
  5434. /*try:*/ {
  5435. /* "lakesuperior/store/base_lmdb_store.pyx":320
  5436. * if lmdb.MDB_NOSUBDIR & self.flags:
  5437. * try:
  5438. * os.unlink(self.env_path) # <<<<<<<<<<<<<<
  5439. * except FileNotFoundError:
  5440. * pass
  5441. */
  5442. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L5_error)
  5443. __Pyx_GOTREF(__pyx_t_3);
  5444. __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)
  5445. __Pyx_GOTREF(__pyx_t_1);
  5446. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5447. __pyx_t_3 = NULL;
  5448. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  5449. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
  5450. if (likely(__pyx_t_3)) {
  5451. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  5452. __Pyx_INCREF(__pyx_t_3);
  5453. __Pyx_INCREF(function);
  5454. __Pyx_DECREF_SET(__pyx_t_1, function);
  5455. }
  5456. }
  5457. if (!__pyx_t_3) {
  5458. __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)
  5459. __Pyx_GOTREF(__pyx_t_5);
  5460. } else {
  5461. #if CYTHON_FAST_PYCALL
  5462. if (PyFunction_Check(__pyx_t_1)) {
  5463. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->env_path};
  5464. __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)
  5465. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5466. __Pyx_GOTREF(__pyx_t_5);
  5467. } else
  5468. #endif
  5469. #if CYTHON_FAST_PYCCALL
  5470. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  5471. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->env_path};
  5472. __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)
  5473. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5474. __Pyx_GOTREF(__pyx_t_5);
  5475. } else
  5476. #endif
  5477. {
  5478. __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L5_error)
  5479. __Pyx_GOTREF(__pyx_t_2);
  5480. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
  5481. __Pyx_INCREF(__pyx_v_self->env_path);
  5482. __Pyx_GIVEREF(__pyx_v_self->env_path);
  5483. PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_self->env_path);
  5484. __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)
  5485. __Pyx_GOTREF(__pyx_t_5);
  5486. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5487. }
  5488. }
  5489. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5490. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5491. /* "lakesuperior/store/base_lmdb_store.pyx":319
  5492. * if path.exists(self.env_path):
  5493. * if lmdb.MDB_NOSUBDIR & self.flags:
  5494. * try: # <<<<<<<<<<<<<<
  5495. * os.unlink(self.env_path)
  5496. * except FileNotFoundError:
  5497. */
  5498. }
  5499. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5500. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  5501. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  5502. goto __pyx_L10_try_end;
  5503. __pyx_L5_error:;
  5504. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5505. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5506. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5507. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5508. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5509. /* "lakesuperior/store/base_lmdb_store.pyx":321
  5510. * try:
  5511. * os.unlink(self.env_path)
  5512. * except FileNotFoundError: # <<<<<<<<<<<<<<
  5513. * pass
  5514. * try:
  5515. */
  5516. __Pyx_ErrFetch(&__pyx_t_5, &__pyx_t_1, &__pyx_t_2);
  5517. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_FileNotFoundError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L7_except_error)
  5518. __Pyx_GOTREF(__pyx_t_3);
  5519. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_5, __pyx_t_3);
  5520. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5521. __Pyx_ErrRestore(__pyx_t_5, __pyx_t_1, __pyx_t_2);
  5522. __pyx_t_5 = 0; __pyx_t_1 = 0; __pyx_t_2 = 0;
  5523. if (__pyx_t_10) {
  5524. __Pyx_ErrRestore(0,0,0);
  5525. goto __pyx_L6_exception_handled;
  5526. }
  5527. goto __pyx_L7_except_error;
  5528. __pyx_L7_except_error:;
  5529. /* "lakesuperior/store/base_lmdb_store.pyx":319
  5530. * if path.exists(self.env_path):
  5531. * if lmdb.MDB_NOSUBDIR & self.flags:
  5532. * try: # <<<<<<<<<<<<<<
  5533. * os.unlink(self.env_path)
  5534. * except FileNotFoundError:
  5535. */
  5536. __Pyx_XGIVEREF(__pyx_t_7);
  5537. __Pyx_XGIVEREF(__pyx_t_8);
  5538. __Pyx_XGIVEREF(__pyx_t_9);
  5539. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  5540. goto __pyx_L1_error;
  5541. __pyx_L6_exception_handled:;
  5542. __Pyx_XGIVEREF(__pyx_t_7);
  5543. __Pyx_XGIVEREF(__pyx_t_8);
  5544. __Pyx_XGIVEREF(__pyx_t_9);
  5545. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  5546. __pyx_L10_try_end:;
  5547. }
  5548. /* "lakesuperior/store/base_lmdb_store.pyx":323
  5549. * except FileNotFoundError:
  5550. * pass
  5551. * try: # <<<<<<<<<<<<<<
  5552. * os.unlink(self.env_path + '-lock')
  5553. * except FileNotFoundError:
  5554. */
  5555. {
  5556. __Pyx_PyThreadState_declare
  5557. __Pyx_PyThreadState_assign
  5558. __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
  5559. __Pyx_XGOTREF(__pyx_t_9);
  5560. __Pyx_XGOTREF(__pyx_t_8);
  5561. __Pyx_XGOTREF(__pyx_t_7);
  5562. /*try:*/ {
  5563. /* "lakesuperior/store/base_lmdb_store.pyx":324
  5564. * pass
  5565. * try:
  5566. * os.unlink(self.env_path + '-lock') # <<<<<<<<<<<<<<
  5567. * except FileNotFoundError:
  5568. * pass
  5569. */
  5570. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L11_error)
  5571. __Pyx_GOTREF(__pyx_t_1);
  5572. __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)
  5573. __Pyx_GOTREF(__pyx_t_5);
  5574. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5575. __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)
  5576. __Pyx_GOTREF(__pyx_t_1);
  5577. __pyx_t_3 = NULL;
  5578. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  5579. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
  5580. if (likely(__pyx_t_3)) {
  5581. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  5582. __Pyx_INCREF(__pyx_t_3);
  5583. __Pyx_INCREF(function);
  5584. __Pyx_DECREF_SET(__pyx_t_5, function);
  5585. }
  5586. }
  5587. if (!__pyx_t_3) {
  5588. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L11_error)
  5589. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5590. __Pyx_GOTREF(__pyx_t_2);
  5591. } else {
  5592. #if CYTHON_FAST_PYCALL
  5593. if (PyFunction_Check(__pyx_t_5)) {
  5594. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
  5595. __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)
  5596. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5597. __Pyx_GOTREF(__pyx_t_2);
  5598. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5599. } else
  5600. #endif
  5601. #if CYTHON_FAST_PYCCALL
  5602. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  5603. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
  5604. __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)
  5605. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5606. __Pyx_GOTREF(__pyx_t_2);
  5607. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5608. } else
  5609. #endif
  5610. {
  5611. __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 324, __pyx_L11_error)
  5612. __Pyx_GOTREF(__pyx_t_4);
  5613. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
  5614. __Pyx_GIVEREF(__pyx_t_1);
  5615. PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_1);
  5616. __pyx_t_1 = 0;
  5617. __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)
  5618. __Pyx_GOTREF(__pyx_t_2);
  5619. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5620. }
  5621. }
  5622. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5623. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5624. /* "lakesuperior/store/base_lmdb_store.pyx":323
  5625. * except FileNotFoundError:
  5626. * pass
  5627. * try: # <<<<<<<<<<<<<<
  5628. * os.unlink(self.env_path + '-lock')
  5629. * except FileNotFoundError:
  5630. */
  5631. }
  5632. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  5633. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  5634. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5635. goto __pyx_L16_try_end;
  5636. __pyx_L11_error:;
  5637. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5638. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5639. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5640. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5641. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5642. /* "lakesuperior/store/base_lmdb_store.pyx":325
  5643. * try:
  5644. * os.unlink(self.env_path + '-lock')
  5645. * except FileNotFoundError: # <<<<<<<<<<<<<<
  5646. * pass
  5647. * else:
  5648. */
  5649. __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_5, &__pyx_t_4);
  5650. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_FileNotFoundError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L13_except_error)
  5651. __Pyx_GOTREF(__pyx_t_1);
  5652. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_1);
  5653. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5654. __Pyx_ErrRestore(__pyx_t_2, __pyx_t_5, __pyx_t_4);
  5655. __pyx_t_2 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0;
  5656. if (__pyx_t_10) {
  5657. __Pyx_ErrRestore(0,0,0);
  5658. goto __pyx_L12_exception_handled;
  5659. }
  5660. goto __pyx_L13_except_error;
  5661. __pyx_L13_except_error:;
  5662. /* "lakesuperior/store/base_lmdb_store.pyx":323
  5663. * except FileNotFoundError:
  5664. * pass
  5665. * try: # <<<<<<<<<<<<<<
  5666. * os.unlink(self.env_path + '-lock')
  5667. * except FileNotFoundError:
  5668. */
  5669. __Pyx_XGIVEREF(__pyx_t_9);
  5670. __Pyx_XGIVEREF(__pyx_t_8);
  5671. __Pyx_XGIVEREF(__pyx_t_7);
  5672. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7);
  5673. goto __pyx_L1_error;
  5674. __pyx_L12_exception_handled:;
  5675. __Pyx_XGIVEREF(__pyx_t_9);
  5676. __Pyx_XGIVEREF(__pyx_t_8);
  5677. __Pyx_XGIVEREF(__pyx_t_7);
  5678. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7);
  5679. __pyx_L16_try_end:;
  5680. }
  5681. /* "lakesuperior/store/base_lmdb_store.pyx":318
  5682. * """
  5683. * if path.exists(self.env_path):
  5684. * if lmdb.MDB_NOSUBDIR & self.flags: # <<<<<<<<<<<<<<
  5685. * try:
  5686. * os.unlink(self.env_path)
  5687. */
  5688. goto __pyx_L4;
  5689. }
  5690. /* "lakesuperior/store/base_lmdb_store.pyx":328
  5691. * pass
  5692. * else:
  5693. * rmtree(self.env_path) # <<<<<<<<<<<<<<
  5694. *
  5695. *
  5696. */
  5697. /*else*/ {
  5698. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_rmtree); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 328, __pyx_L1_error)
  5699. __Pyx_GOTREF(__pyx_t_5);
  5700. __pyx_t_2 = NULL;
  5701. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  5702. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
  5703. if (likely(__pyx_t_2)) {
  5704. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  5705. __Pyx_INCREF(__pyx_t_2);
  5706. __Pyx_INCREF(function);
  5707. __Pyx_DECREF_SET(__pyx_t_5, function);
  5708. }
  5709. }
  5710. if (!__pyx_t_2) {
  5711. __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)
  5712. __Pyx_GOTREF(__pyx_t_4);
  5713. } else {
  5714. #if CYTHON_FAST_PYCALL
  5715. if (PyFunction_Check(__pyx_t_5)) {
  5716. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5717. __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)
  5718. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5719. __Pyx_GOTREF(__pyx_t_4);
  5720. } else
  5721. #endif
  5722. #if CYTHON_FAST_PYCCALL
  5723. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  5724. PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->env_path};
  5725. __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)
  5726. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5727. __Pyx_GOTREF(__pyx_t_4);
  5728. } else
  5729. #endif
  5730. {
  5731. __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __pyx_L1_error)
  5732. __Pyx_GOTREF(__pyx_t_1);
  5733. __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
  5734. __Pyx_INCREF(__pyx_v_self->env_path);
  5735. __Pyx_GIVEREF(__pyx_v_self->env_path);
  5736. PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_self->env_path);
  5737. __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)
  5738. __Pyx_GOTREF(__pyx_t_4);
  5739. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5740. }
  5741. }
  5742. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5743. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5744. }
  5745. __pyx_L4:;
  5746. /* "lakesuperior/store/base_lmdb_store.pyx":317
  5747. * general-purpose recursive file and folder delete method!)
  5748. * """
  5749. * if path.exists(self.env_path): # <<<<<<<<<<<<<<
  5750. * if lmdb.MDB_NOSUBDIR & self.flags:
  5751. * try:
  5752. */
  5753. }
  5754. /* "lakesuperior/store/base_lmdb_store.pyx":307
  5755. *
  5756. *
  5757. * cpdef void destroy(self, _path='') except *: # <<<<<<<<<<<<<<
  5758. * """
  5759. * Destroy the store.
  5760. */
  5761. /* function exit code */
  5762. goto __pyx_L0;
  5763. __pyx_L1_error:;
  5764. __Pyx_XDECREF(__pyx_t_1);
  5765. __Pyx_XDECREF(__pyx_t_2);
  5766. __Pyx_XDECREF(__pyx_t_3);
  5767. __Pyx_XDECREF(__pyx_t_4);
  5768. __Pyx_XDECREF(__pyx_t_5);
  5769. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5770. __pyx_L0:;
  5771. __Pyx_TraceReturn(Py_None, 0);
  5772. __Pyx_RefNannyFinishContext();
  5773. }
  5774. /* Python wrapper */
  5775. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5776. 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 ";
  5777. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5778. PyObject *__pyx_v__path = 0;
  5779. PyObject *__pyx_r = 0;
  5780. __Pyx_RefNannyDeclarations
  5781. __Pyx_RefNannySetupContext("destroy (wrapper)", 0);
  5782. {
  5783. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path_2,0};
  5784. PyObject* values[1] = {0};
  5785. values[0] = ((PyObject *)__pyx_kp_u_);
  5786. if (unlikely(__pyx_kwds)) {
  5787. Py_ssize_t kw_args;
  5788. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5789. switch (pos_args) {
  5790. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5791. CYTHON_FALLTHROUGH;
  5792. case 0: break;
  5793. default: goto __pyx_L5_argtuple_error;
  5794. }
  5795. kw_args = PyDict_Size(__pyx_kwds);
  5796. switch (pos_args) {
  5797. case 0:
  5798. if (kw_args > 0) {
  5799. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path_2);
  5800. if (value) { values[0] = value; kw_args--; }
  5801. }
  5802. }
  5803. if (unlikely(kw_args > 0)) {
  5804. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "destroy") < 0)) __PYX_ERR(0, 307, __pyx_L3_error)
  5805. }
  5806. } else {
  5807. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5808. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5809. CYTHON_FALLTHROUGH;
  5810. case 0: break;
  5811. default: goto __pyx_L5_argtuple_error;
  5812. }
  5813. }
  5814. __pyx_v__path = values[0];
  5815. }
  5816. goto __pyx_L4_argument_unpacking_done;
  5817. __pyx_L5_argtuple_error:;
  5818. __Pyx_RaiseArgtupleInvalid("destroy", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 307, __pyx_L3_error)
  5819. __pyx_L3_error:;
  5820. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5821. __Pyx_RefNannyFinishContext();
  5822. return NULL;
  5823. __pyx_L4_argument_unpacking_done:;
  5824. __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);
  5825. /* function exit code */
  5826. __Pyx_RefNannyFinishContext();
  5827. return __pyx_r;
  5828. }
  5829. 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) {
  5830. PyObject *__pyx_r = NULL;
  5831. __Pyx_TraceDeclarations
  5832. __Pyx_RefNannyDeclarations
  5833. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_destroy __pyx_t_1;
  5834. PyObject *__pyx_t_2 = NULL;
  5835. __Pyx_RefNannySetupContext("destroy", 0);
  5836. __Pyx_TraceCall("destroy (wrapper)", __pyx_f[0], 307, 0, __PYX_ERR(0, 307, __pyx_L1_error));
  5837. __Pyx_XDECREF(__pyx_r);
  5838. __pyx_t_1.__pyx_n = 1;
  5839. __pyx_t_1._path = __pyx_v__path;
  5840. __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)
  5841. __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
  5842. __Pyx_GOTREF(__pyx_t_2);
  5843. __pyx_r = __pyx_t_2;
  5844. __pyx_t_2 = 0;
  5845. goto __pyx_L0;
  5846. /* function exit code */
  5847. __pyx_L1_error:;
  5848. __Pyx_XDECREF(__pyx_t_2);
  5849. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5850. __pyx_r = NULL;
  5851. __pyx_L0:;
  5852. __Pyx_XGIVEREF(__pyx_r);
  5853. __Pyx_TraceReturn(__pyx_r, 0);
  5854. __Pyx_RefNannyFinishContext();
  5855. return __pyx_r;
  5856. }
  5857. 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 */
  5858. /* "lakesuperior/store/base_lmdb_store.pyx":334
  5859. *
  5860. * @contextmanager
  5861. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  5862. * """
  5863. * Transaction context manager.
  5864. */
  5865. /* Python wrapper */
  5866. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11txn_ctx(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5867. 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 ";
  5868. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11txn_ctx(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5869. PyObject *__pyx_v_write = 0;
  5870. PyObject *__pyx_r = 0;
  5871. __Pyx_RefNannyDeclarations
  5872. __Pyx_RefNannySetupContext("txn_ctx (wrapper)", 0);
  5873. {
  5874. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_write,0};
  5875. PyObject* values[1] = {0};
  5876. values[0] = ((PyObject *)Py_False);
  5877. if (unlikely(__pyx_kwds)) {
  5878. Py_ssize_t kw_args;
  5879. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5880. switch (pos_args) {
  5881. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5882. CYTHON_FALLTHROUGH;
  5883. case 0: break;
  5884. default: goto __pyx_L5_argtuple_error;
  5885. }
  5886. kw_args = PyDict_Size(__pyx_kwds);
  5887. switch (pos_args) {
  5888. case 0:
  5889. if (kw_args > 0) {
  5890. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_write);
  5891. if (value) { values[0] = value; kw_args--; }
  5892. }
  5893. }
  5894. if (unlikely(kw_args > 0)) {
  5895. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "txn_ctx") < 0)) __PYX_ERR(0, 334, __pyx_L3_error)
  5896. }
  5897. } else {
  5898. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5899. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5900. CYTHON_FALLTHROUGH;
  5901. case 0: break;
  5902. default: goto __pyx_L5_argtuple_error;
  5903. }
  5904. }
  5905. __pyx_v_write = values[0];
  5906. }
  5907. goto __pyx_L4_argument_unpacking_done;
  5908. __pyx_L5_argtuple_error:;
  5909. __Pyx_RaiseArgtupleInvalid("txn_ctx", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 334, __pyx_L3_error)
  5910. __pyx_L3_error:;
  5911. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5912. __Pyx_RefNannyFinishContext();
  5913. return NULL;
  5914. __pyx_L4_argument_unpacking_done:;
  5915. __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);
  5916. /* function exit code */
  5917. __Pyx_RefNannyFinishContext();
  5918. return __pyx_r;
  5919. }
  5920. 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) {
  5921. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *__pyx_cur_scope;
  5922. PyObject *__pyx_r = NULL;
  5923. __Pyx_RefNannyDeclarations
  5924. __Pyx_RefNannySetupContext("txn_ctx", 0);
  5925. __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);
  5926. if (unlikely(!__pyx_cur_scope)) {
  5927. __pyx_cur_scope = ((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx *)Py_None);
  5928. __Pyx_INCREF(Py_None);
  5929. __PYX_ERR(0, 334, __pyx_L1_error)
  5930. } else {
  5931. __Pyx_GOTREF(__pyx_cur_scope);
  5932. }
  5933. __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  5934. __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  5935. __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  5936. __pyx_cur_scope->__pyx_v_write = __pyx_v_write;
  5937. __Pyx_INCREF(__pyx_cur_scope->__pyx_v_write);
  5938. __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_write);
  5939. {
  5940. __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)
  5941. __Pyx_DECREF(__pyx_cur_scope);
  5942. __Pyx_RefNannyFinishContext();
  5943. return (PyObject *) gen;
  5944. }
  5945. /* function exit code */
  5946. __pyx_L1_error:;
  5947. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5948. __pyx_r = NULL;
  5949. __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  5950. __Pyx_XGIVEREF(__pyx_r);
  5951. __Pyx_RefNannyFinishContext();
  5952. return __pyx_r;
  5953. }
  5954. 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 */
  5955. {
  5956. 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);
  5957. PyObject *__pyx_r = NULL;
  5958. __Pyx_TraceDeclarations
  5959. PyObject *__pyx_t_1 = NULL;
  5960. int __pyx_t_2;
  5961. int __pyx_t_3;
  5962. PyObject *__pyx_t_4 = NULL;
  5963. PyObject *__pyx_t_5 = NULL;
  5964. PyObject *__pyx_t_6 = NULL;
  5965. PyObject *__pyx_t_7 = NULL;
  5966. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin __pyx_t_8;
  5967. PyObject *__pyx_t_9 = NULL;
  5968. __Pyx_RefNannyDeclarations
  5969. __Pyx_RefNannySetupContext("txn_ctx", 0);
  5970. __Pyx_TraceCall("txn_ctx", __pyx_f[0], 334, 0, __PYX_ERR(0, 334, __pyx_L1_error));
  5971. switch (__pyx_generator->resume_label) {
  5972. case 0: goto __pyx_L3_first_run;
  5973. case 1: goto __pyx_L6_resume_from_yield;
  5974. case 2: goto __pyx_L13_resume_from_yield;
  5975. default: /* CPython raises the right error here */
  5976. __Pyx_TraceReturn(Py_None, 0);
  5977. __Pyx_RefNannyFinishContext();
  5978. return NULL;
  5979. }
  5980. __pyx_L3_first_run:;
  5981. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 334, __pyx_L1_error)
  5982. /* "lakesuperior/store/base_lmdb_store.pyx":342
  5983. * :rtype: lmdb.Transaction
  5984. * """
  5985. * if not self.is_open: # <<<<<<<<<<<<<<
  5986. * raise LmdbError('Store is not open.')
  5987. *
  5988. */
  5989. __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)
  5990. __Pyx_GOTREF(__pyx_t_1);
  5991. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 342, __pyx_L1_error)
  5992. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5993. __pyx_t_3 = ((!__pyx_t_2) != 0);
  5994. if (unlikely(__pyx_t_3)) {
  5995. /* "lakesuperior/store/base_lmdb_store.pyx":343
  5996. * """
  5997. * if not self.is_open:
  5998. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  5999. *
  6000. * if self.is_txn_open:
  6001. */
  6002. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
  6003. __Pyx_GOTREF(__pyx_t_1);
  6004. __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)
  6005. __Pyx_GOTREF(__pyx_t_4);
  6006. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6007. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  6008. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6009. __PYX_ERR(0, 343, __pyx_L1_error)
  6010. /* "lakesuperior/store/base_lmdb_store.pyx":342
  6011. * :rtype: lmdb.Transaction
  6012. * """
  6013. * if not self.is_open: # <<<<<<<<<<<<<<
  6014. * raise LmdbError('Store is not open.')
  6015. *
  6016. */
  6017. }
  6018. /* "lakesuperior/store/base_lmdb_store.pyx":345
  6019. * raise LmdbError('Store is not open.')
  6020. *
  6021. * if self.is_txn_open: # <<<<<<<<<<<<<<
  6022. * logger.debug(
  6023. * 'Transaction is already active. Not opening another one.')
  6024. */
  6025. __pyx_t_3 = (__pyx_cur_scope->__pyx_v_self->is_txn_open != 0);
  6026. if (__pyx_t_3) {
  6027. /* "lakesuperior/store/base_lmdb_store.pyx":346
  6028. *
  6029. * if self.is_txn_open:
  6030. * logger.debug( # <<<<<<<<<<<<<<
  6031. * 'Transaction is already active. Not opening another one.')
  6032. * #logger.debug('before yield')
  6033. */
  6034. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 346, __pyx_L1_error)
  6035. __Pyx_GOTREF(__pyx_t_4);
  6036. __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)
  6037. __Pyx_GOTREF(__pyx_t_1);
  6038. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6039. __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)
  6040. __Pyx_GOTREF(__pyx_t_4);
  6041. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6042. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6043. /* "lakesuperior/store/base_lmdb_store.pyx":349
  6044. * 'Transaction is already active. Not opening another one.')
  6045. * #logger.debug('before yield')
  6046. * yield # <<<<<<<<<<<<<<
  6047. * #logger.debug('after yield')
  6048. * else:
  6049. */
  6050. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6051. __Pyx_XGIVEREF(__pyx_r);
  6052. __Pyx_TraceReturn(__pyx_r, 0);
  6053. __Pyx_RefNannyFinishContext();
  6054. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  6055. /* return from generator, yielding value */
  6056. __pyx_generator->resume_label = 1;
  6057. return __pyx_r;
  6058. __pyx_L6_resume_from_yield:;
  6059. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 349, __pyx_L1_error)
  6060. /* "lakesuperior/store/base_lmdb_store.pyx":345
  6061. * raise LmdbError('Store is not open.')
  6062. *
  6063. * if self.is_txn_open: # <<<<<<<<<<<<<<
  6064. * logger.debug(
  6065. * 'Transaction is already active. Not opening another one.')
  6066. */
  6067. goto __pyx_L5;
  6068. }
  6069. /* "lakesuperior/store/base_lmdb_store.pyx":354
  6070. * #logger.debug('Beginning {} transaction.'.format(
  6071. * # 'RW' if write else 'RO'))
  6072. * try: # <<<<<<<<<<<<<<
  6073. * self._txn_begin(write=write)
  6074. * self.is_txn_rw = write
  6075. */
  6076. /*else*/ {
  6077. {
  6078. __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
  6079. __Pyx_XGOTREF(__pyx_t_5);
  6080. __Pyx_XGOTREF(__pyx_t_6);
  6081. __Pyx_XGOTREF(__pyx_t_7);
  6082. /*try:*/ {
  6083. /* "lakesuperior/store/base_lmdb_store.pyx":355
  6084. * # 'RW' if write else 'RO'))
  6085. * try:
  6086. * self._txn_begin(write=write) # <<<<<<<<<<<<<<
  6087. * self.is_txn_rw = write
  6088. * #logger.debug('In txn_ctx, before yield')
  6089. */
  6090. __pyx_t_8.__pyx_n = 1;
  6091. __pyx_t_8.write = __pyx_cur_scope->__pyx_v_write;
  6092. ((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)
  6093. /* "lakesuperior/store/base_lmdb_store.pyx":356
  6094. * try:
  6095. * self._txn_begin(write=write)
  6096. * self.is_txn_rw = write # <<<<<<<<<<<<<<
  6097. * #logger.debug('In txn_ctx, before yield')
  6098. * yield
  6099. */
  6100. 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)
  6101. /* "lakesuperior/store/base_lmdb_store.pyx":358
  6102. * self.is_txn_rw = write
  6103. * #logger.debug('In txn_ctx, before yield')
  6104. * yield # <<<<<<<<<<<<<<
  6105. * #logger.debug('In txn_ctx, after yield')
  6106. * self._txn_commit()
  6107. */
  6108. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6109. __Pyx_XGIVEREF(__pyx_t_5);
  6110. __pyx_cur_scope->__pyx_t_0 = __pyx_t_5;
  6111. __Pyx_XGIVEREF(__pyx_t_6);
  6112. __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
  6113. __Pyx_XGIVEREF(__pyx_t_7);
  6114. __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
  6115. __Pyx_XGIVEREF(__pyx_r);
  6116. __Pyx_TraceReturn(__pyx_r, 0);
  6117. __Pyx_RefNannyFinishContext();
  6118. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  6119. /* return from generator, yielding value */
  6120. __pyx_generator->resume_label = 2;
  6121. return __pyx_r;
  6122. __pyx_L13_resume_from_yield:;
  6123. __pyx_t_5 = __pyx_cur_scope->__pyx_t_0;
  6124. __pyx_cur_scope->__pyx_t_0 = 0;
  6125. __Pyx_XGOTREF(__pyx_t_5);
  6126. __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
  6127. __pyx_cur_scope->__pyx_t_1 = 0;
  6128. __Pyx_XGOTREF(__pyx_t_6);
  6129. __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
  6130. __pyx_cur_scope->__pyx_t_2 = 0;
  6131. __Pyx_XGOTREF(__pyx_t_7);
  6132. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 358, __pyx_L7_error)
  6133. /* "lakesuperior/store/base_lmdb_store.pyx":360
  6134. * yield
  6135. * #logger.debug('In txn_ctx, after yield')
  6136. * self._txn_commit() # <<<<<<<<<<<<<<
  6137. * #logger.debug('after _txn_commit')
  6138. * except:
  6139. */
  6140. ((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)
  6141. /* "lakesuperior/store/base_lmdb_store.pyx":354
  6142. * #logger.debug('Beginning {} transaction.'.format(
  6143. * # 'RW' if write else 'RO'))
  6144. * try: # <<<<<<<<<<<<<<
  6145. * self._txn_begin(write=write)
  6146. * self.is_txn_rw = write
  6147. */
  6148. }
  6149. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6150. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6151. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6152. goto __pyx_L12_try_end;
  6153. __pyx_L7_error:;
  6154. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  6155. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  6156. /* "lakesuperior/store/base_lmdb_store.pyx":362
  6157. * self._txn_commit()
  6158. * #logger.debug('after _txn_commit')
  6159. * except: # <<<<<<<<<<<<<<
  6160. * self._txn_abort()
  6161. * raise
  6162. */
  6163. /*except:*/ {
  6164. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6165. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_9) < 0) __PYX_ERR(0, 362, __pyx_L9_except_error)
  6166. __Pyx_GOTREF(__pyx_t_4);
  6167. __Pyx_GOTREF(__pyx_t_1);
  6168. __Pyx_GOTREF(__pyx_t_9);
  6169. /* "lakesuperior/store/base_lmdb_store.pyx":363
  6170. * #logger.debug('after _txn_commit')
  6171. * except:
  6172. * self._txn_abort() # <<<<<<<<<<<<<<
  6173. * raise
  6174. *
  6175. */
  6176. ((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)
  6177. /* "lakesuperior/store/base_lmdb_store.pyx":364
  6178. * except:
  6179. * self._txn_abort()
  6180. * raise # <<<<<<<<<<<<<<
  6181. *
  6182. *
  6183. */
  6184. __Pyx_GIVEREF(__pyx_t_4);
  6185. __Pyx_GIVEREF(__pyx_t_1);
  6186. __Pyx_XGIVEREF(__pyx_t_9);
  6187. __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_1, __pyx_t_9);
  6188. __pyx_t_4 = 0; __pyx_t_1 = 0; __pyx_t_9 = 0;
  6189. __PYX_ERR(0, 364, __pyx_L9_except_error)
  6190. }
  6191. __pyx_L9_except_error:;
  6192. /* "lakesuperior/store/base_lmdb_store.pyx":354
  6193. * #logger.debug('Beginning {} transaction.'.format(
  6194. * # 'RW' if write else 'RO'))
  6195. * try: # <<<<<<<<<<<<<<
  6196. * self._txn_begin(write=write)
  6197. * self.is_txn_rw = write
  6198. */
  6199. __Pyx_XGIVEREF(__pyx_t_5);
  6200. __Pyx_XGIVEREF(__pyx_t_6);
  6201. __Pyx_XGIVEREF(__pyx_t_7);
  6202. __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
  6203. goto __pyx_L1_error;
  6204. __pyx_L12_try_end:;
  6205. }
  6206. }
  6207. __pyx_L5:;
  6208. CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
  6209. /* "lakesuperior/store/base_lmdb_store.pyx":334
  6210. *
  6211. * @contextmanager
  6212. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  6213. * """
  6214. * Transaction context manager.
  6215. */
  6216. /* function exit code */
  6217. PyErr_SetNone(PyExc_StopIteration);
  6218. goto __pyx_L0;
  6219. __pyx_L1_error:;
  6220. __Pyx_XDECREF(__pyx_t_1);
  6221. __Pyx_XDECREF(__pyx_t_4);
  6222. __Pyx_XDECREF(__pyx_t_9);
  6223. __Pyx_AddTraceback("txn_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6224. __pyx_L0:;
  6225. __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  6226. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  6227. __pyx_generator->resume_label = -1;
  6228. __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  6229. __Pyx_TraceReturn(__pyx_r, 0);
  6230. __Pyx_RefNannyFinishContext();
  6231. return __pyx_r;
  6232. }
  6233. /* "lakesuperior/store/base_lmdb_store.pyx":367
  6234. *
  6235. *
  6236. * def begin(self, write=False): # <<<<<<<<<<<<<<
  6237. * """
  6238. * Begin a transaction manually if not already in a txn context.
  6239. */
  6240. /* Python wrapper */
  6241. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_14begin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6242. 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 ";
  6243. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_14begin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6244. PyObject *__pyx_v_write = 0;
  6245. PyObject *__pyx_r = 0;
  6246. __Pyx_RefNannyDeclarations
  6247. __Pyx_RefNannySetupContext("begin (wrapper)", 0);
  6248. {
  6249. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_write,0};
  6250. PyObject* values[1] = {0};
  6251. values[0] = ((PyObject *)Py_False);
  6252. if (unlikely(__pyx_kwds)) {
  6253. Py_ssize_t kw_args;
  6254. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6255. switch (pos_args) {
  6256. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6257. CYTHON_FALLTHROUGH;
  6258. case 0: break;
  6259. default: goto __pyx_L5_argtuple_error;
  6260. }
  6261. kw_args = PyDict_Size(__pyx_kwds);
  6262. switch (pos_args) {
  6263. case 0:
  6264. if (kw_args > 0) {
  6265. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_write);
  6266. if (value) { values[0] = value; kw_args--; }
  6267. }
  6268. }
  6269. if (unlikely(kw_args > 0)) {
  6270. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "begin") < 0)) __PYX_ERR(0, 367, __pyx_L3_error)
  6271. }
  6272. } else {
  6273. switch (PyTuple_GET_SIZE(__pyx_args)) {
  6274. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6275. CYTHON_FALLTHROUGH;
  6276. case 0: break;
  6277. default: goto __pyx_L5_argtuple_error;
  6278. }
  6279. }
  6280. __pyx_v_write = values[0];
  6281. }
  6282. goto __pyx_L4_argument_unpacking_done;
  6283. __pyx_L5_argtuple_error:;
  6284. __Pyx_RaiseArgtupleInvalid("begin", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 367, __pyx_L3_error)
  6285. __pyx_L3_error:;
  6286. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.begin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6287. __Pyx_RefNannyFinishContext();
  6288. return NULL;
  6289. __pyx_L4_argument_unpacking_done:;
  6290. __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);
  6291. /* function exit code */
  6292. __Pyx_RefNannyFinishContext();
  6293. return __pyx_r;
  6294. }
  6295. 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) {
  6296. PyObject *__pyx_r = NULL;
  6297. __Pyx_TraceDeclarations
  6298. __Pyx_RefNannyDeclarations
  6299. PyObject *__pyx_t_1 = NULL;
  6300. int __pyx_t_2;
  6301. int __pyx_t_3;
  6302. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_begin __pyx_t_4;
  6303. __Pyx_RefNannySetupContext("begin", 0);
  6304. __Pyx_TraceCall("begin", __pyx_f[0], 367, 0, __PYX_ERR(0, 367, __pyx_L1_error));
  6305. /* "lakesuperior/store/base_lmdb_store.pyx":374
  6306. * possible rather than this method.
  6307. * """
  6308. * if not self.is_open: # <<<<<<<<<<<<<<
  6309. * raise RuntimeError('Store must be opened first.')
  6310. * #logger.debug('Beginning a {} transaction.'.format(
  6311. */
  6312. __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)
  6313. __Pyx_GOTREF(__pyx_t_1);
  6314. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 374, __pyx_L1_error)
  6315. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6316. __pyx_t_3 = ((!__pyx_t_2) != 0);
  6317. if (unlikely(__pyx_t_3)) {
  6318. /* "lakesuperior/store/base_lmdb_store.pyx":375
  6319. * """
  6320. * if not self.is_open:
  6321. * raise RuntimeError('Store must be opened first.') # <<<<<<<<<<<<<<
  6322. * #logger.debug('Beginning a {} transaction.'.format(
  6323. * # 'read/write' if write else 'read-only'))
  6324. */
  6325. __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)
  6326. __Pyx_GOTREF(__pyx_t_1);
  6327. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  6328. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6329. __PYX_ERR(0, 375, __pyx_L1_error)
  6330. /* "lakesuperior/store/base_lmdb_store.pyx":374
  6331. * possible rather than this method.
  6332. * """
  6333. * if not self.is_open: # <<<<<<<<<<<<<<
  6334. * raise RuntimeError('Store must be opened first.')
  6335. * #logger.debug('Beginning a {} transaction.'.format(
  6336. */
  6337. }
  6338. /* "lakesuperior/store/base_lmdb_store.pyx":379
  6339. * # 'read/write' if write else 'read-only'))
  6340. *
  6341. * self._txn_begin(write=write) # <<<<<<<<<<<<<<
  6342. *
  6343. *
  6344. */
  6345. __pyx_t_4.__pyx_n = 1;
  6346. __pyx_t_4.write = __pyx_v_write;
  6347. ((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)
  6348. /* "lakesuperior/store/base_lmdb_store.pyx":367
  6349. *
  6350. *
  6351. * def begin(self, write=False): # <<<<<<<<<<<<<<
  6352. * """
  6353. * Begin a transaction manually if not already in a txn context.
  6354. */
  6355. /* function exit code */
  6356. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6357. goto __pyx_L0;
  6358. __pyx_L1_error:;
  6359. __Pyx_XDECREF(__pyx_t_1);
  6360. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.begin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6361. __pyx_r = NULL;
  6362. __pyx_L0:;
  6363. __Pyx_XGIVEREF(__pyx_r);
  6364. __Pyx_TraceReturn(__pyx_r, 0);
  6365. __Pyx_RefNannyFinishContext();
  6366. return __pyx_r;
  6367. }
  6368. /* "lakesuperior/store/base_lmdb_store.pyx":382
  6369. *
  6370. *
  6371. * def commit(self): # <<<<<<<<<<<<<<
  6372. * """Commit main transaction."""
  6373. * #logger.debug('Committing transaction.')
  6374. */
  6375. /* Python wrapper */
  6376. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_16commit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6377. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit[] = "Commit main transaction.";
  6378. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_16commit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  6379. PyObject *__pyx_r = 0;
  6380. __Pyx_RefNannyDeclarations
  6381. __Pyx_RefNannySetupContext("commit (wrapper)", 0);
  6382. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  6383. /* function exit code */
  6384. __Pyx_RefNannyFinishContext();
  6385. return __pyx_r;
  6386. }
  6387. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  6388. PyObject *__pyx_r = NULL;
  6389. __Pyx_TraceDeclarations
  6390. __Pyx_RefNannyDeclarations
  6391. __Pyx_RefNannySetupContext("commit", 0);
  6392. __Pyx_TraceCall("commit", __pyx_f[0], 382, 0, __PYX_ERR(0, 382, __pyx_L1_error));
  6393. /* "lakesuperior/store/base_lmdb_store.pyx":385
  6394. * """Commit main transaction."""
  6395. * #logger.debug('Committing transaction.')
  6396. * self._txn_commit() # <<<<<<<<<<<<<<
  6397. *
  6398. *
  6399. */
  6400. ((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)
  6401. /* "lakesuperior/store/base_lmdb_store.pyx":382
  6402. *
  6403. *
  6404. * def commit(self): # <<<<<<<<<<<<<<
  6405. * """Commit main transaction."""
  6406. * #logger.debug('Committing transaction.')
  6407. */
  6408. /* function exit code */
  6409. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6410. goto __pyx_L0;
  6411. __pyx_L1_error:;
  6412. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.commit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6413. __pyx_r = NULL;
  6414. __pyx_L0:;
  6415. __Pyx_XGIVEREF(__pyx_r);
  6416. __Pyx_TraceReturn(__pyx_r, 0);
  6417. __Pyx_RefNannyFinishContext();
  6418. return __pyx_r;
  6419. }
  6420. /* "lakesuperior/store/base_lmdb_store.pyx":388
  6421. *
  6422. *
  6423. * def abort(self): # <<<<<<<<<<<<<<
  6424. * """Abort main transaction."""
  6425. * #logger.debug('Rolling back transaction.')
  6426. */
  6427. /* Python wrapper */
  6428. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_18abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6429. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort[] = "Abort main transaction.";
  6430. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_18abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  6431. PyObject *__pyx_r = 0;
  6432. __Pyx_RefNannyDeclarations
  6433. __Pyx_RefNannySetupContext("abort (wrapper)", 0);
  6434. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  6435. /* function exit code */
  6436. __Pyx_RefNannyFinishContext();
  6437. return __pyx_r;
  6438. }
  6439. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  6440. PyObject *__pyx_r = NULL;
  6441. __Pyx_TraceDeclarations
  6442. __Pyx_RefNannyDeclarations
  6443. __Pyx_RefNannySetupContext("abort", 0);
  6444. __Pyx_TraceCall("abort", __pyx_f[0], 388, 0, __PYX_ERR(0, 388, __pyx_L1_error));
  6445. /* "lakesuperior/store/base_lmdb_store.pyx":391
  6446. * """Abort main transaction."""
  6447. * #logger.debug('Rolling back transaction.')
  6448. * self._txn_abort() # <<<<<<<<<<<<<<
  6449. *
  6450. *
  6451. */
  6452. ((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)
  6453. /* "lakesuperior/store/base_lmdb_store.pyx":388
  6454. *
  6455. *
  6456. * def abort(self): # <<<<<<<<<<<<<<
  6457. * """Abort main transaction."""
  6458. * #logger.debug('Rolling back transaction.')
  6459. */
  6460. /* function exit code */
  6461. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6462. goto __pyx_L0;
  6463. __pyx_L1_error:;
  6464. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.abort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6465. __pyx_r = NULL;
  6466. __pyx_L0:;
  6467. __Pyx_XGIVEREF(__pyx_r);
  6468. __Pyx_TraceReturn(__pyx_r, 0);
  6469. __Pyx_RefNannyFinishContext();
  6470. return __pyx_r;
  6471. }
  6472. /* "lakesuperior/store/base_lmdb_store.pyx":394
  6473. *
  6474. *
  6475. * def rollback(self): # <<<<<<<<<<<<<<
  6476. * """Alias for :py:meth:`abort`"""
  6477. * self.abort()
  6478. */
  6479. /* Python wrapper */
  6480. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_20rollback(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6481. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback[] = "Alias for :py:meth:`abort`";
  6482. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_20rollback(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  6483. PyObject *__pyx_r = 0;
  6484. __Pyx_RefNannyDeclarations
  6485. __Pyx_RefNannySetupContext("rollback (wrapper)", 0);
  6486. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  6487. /* function exit code */
  6488. __Pyx_RefNannyFinishContext();
  6489. return __pyx_r;
  6490. }
  6491. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  6492. PyObject *__pyx_r = NULL;
  6493. __Pyx_TraceDeclarations
  6494. __Pyx_RefNannyDeclarations
  6495. PyObject *__pyx_t_1 = NULL;
  6496. PyObject *__pyx_t_2 = NULL;
  6497. PyObject *__pyx_t_3 = NULL;
  6498. __Pyx_RefNannySetupContext("rollback", 0);
  6499. __Pyx_TraceCall("rollback", __pyx_f[0], 394, 0, __PYX_ERR(0, 394, __pyx_L1_error));
  6500. /* "lakesuperior/store/base_lmdb_store.pyx":396
  6501. * def rollback(self):
  6502. * """Alias for :py:meth:`abort`"""
  6503. * self.abort() # <<<<<<<<<<<<<<
  6504. *
  6505. *
  6506. */
  6507. __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)
  6508. __Pyx_GOTREF(__pyx_t_2);
  6509. __pyx_t_3 = NULL;
  6510. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6511. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  6512. if (likely(__pyx_t_3)) {
  6513. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6514. __Pyx_INCREF(__pyx_t_3);
  6515. __Pyx_INCREF(function);
  6516. __Pyx_DECREF_SET(__pyx_t_2, function);
  6517. }
  6518. }
  6519. if (__pyx_t_3) {
  6520. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  6521. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6522. } else {
  6523. __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  6524. }
  6525. __Pyx_GOTREF(__pyx_t_1);
  6526. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6527. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6528. /* "lakesuperior/store/base_lmdb_store.pyx":394
  6529. *
  6530. *
  6531. * def rollback(self): # <<<<<<<<<<<<<<
  6532. * """Alias for :py:meth:`abort`"""
  6533. * self.abort()
  6534. */
  6535. /* function exit code */
  6536. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6537. goto __pyx_L0;
  6538. __pyx_L1_error:;
  6539. __Pyx_XDECREF(__pyx_t_1);
  6540. __Pyx_XDECREF(__pyx_t_2);
  6541. __Pyx_XDECREF(__pyx_t_3);
  6542. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.rollback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6543. __pyx_r = NULL;
  6544. __pyx_L0:;
  6545. __Pyx_XGIVEREF(__pyx_r);
  6546. __Pyx_TraceReturn(__pyx_r, 0);
  6547. __Pyx_RefNannyFinishContext();
  6548. return __pyx_r;
  6549. }
  6550. /* "lakesuperior/store/base_lmdb_store.pyx":399
  6551. *
  6552. *
  6553. * def key_exists(self, key, dblabel='', new_txn=True): # <<<<<<<<<<<<<<
  6554. * """
  6555. * Return whether a key exists in a database (Python-facing method).
  6556. */
  6557. /* Python wrapper */
  6558. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_22key_exists(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6559. 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 ";
  6560. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_22key_exists(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6561. PyObject *__pyx_v_key = 0;
  6562. PyObject *__pyx_v_dblabel = 0;
  6563. PyObject *__pyx_v_new_txn = 0;
  6564. PyObject *__pyx_r = 0;
  6565. __Pyx_RefNannyDeclarations
  6566. __Pyx_RefNannySetupContext("key_exists (wrapper)", 0);
  6567. {
  6568. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_dblabel,&__pyx_n_s_new_txn,0};
  6569. PyObject* values[3] = {0,0,0};
  6570. values[1] = ((PyObject *)__pyx_kp_u_);
  6571. values[2] = ((PyObject *)Py_True);
  6572. if (unlikely(__pyx_kwds)) {
  6573. Py_ssize_t kw_args;
  6574. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6575. switch (pos_args) {
  6576. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6577. CYTHON_FALLTHROUGH;
  6578. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6579. CYTHON_FALLTHROUGH;
  6580. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6581. CYTHON_FALLTHROUGH;
  6582. case 0: break;
  6583. default: goto __pyx_L5_argtuple_error;
  6584. }
  6585. kw_args = PyDict_Size(__pyx_kwds);
  6586. switch (pos_args) {
  6587. case 0:
  6588. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  6589. else goto __pyx_L5_argtuple_error;
  6590. CYTHON_FALLTHROUGH;
  6591. case 1:
  6592. if (kw_args > 0) {
  6593. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  6594. if (value) { values[1] = value; kw_args--; }
  6595. }
  6596. CYTHON_FALLTHROUGH;
  6597. case 2:
  6598. if (kw_args > 0) {
  6599. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_new_txn);
  6600. if (value) { values[2] = value; kw_args--; }
  6601. }
  6602. }
  6603. if (unlikely(kw_args > 0)) {
  6604. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "key_exists") < 0)) __PYX_ERR(0, 399, __pyx_L3_error)
  6605. }
  6606. } else {
  6607. switch (PyTuple_GET_SIZE(__pyx_args)) {
  6608. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6609. CYTHON_FALLTHROUGH;
  6610. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6611. CYTHON_FALLTHROUGH;
  6612. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6613. break;
  6614. default: goto __pyx_L5_argtuple_error;
  6615. }
  6616. }
  6617. __pyx_v_key = values[0];
  6618. __pyx_v_dblabel = values[1];
  6619. __pyx_v_new_txn = values[2];
  6620. }
  6621. goto __pyx_L4_argument_unpacking_done;
  6622. __pyx_L5_argtuple_error:;
  6623. __Pyx_RaiseArgtupleInvalid("key_exists", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 399, __pyx_L3_error)
  6624. __pyx_L3_error:;
  6625. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6626. __Pyx_RefNannyFinishContext();
  6627. return NULL;
  6628. __pyx_L4_argument_unpacking_done:;
  6629. __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);
  6630. /* function exit code */
  6631. __Pyx_RefNannyFinishContext();
  6632. return __pyx_r;
  6633. }
  6634. 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) {
  6635. PyObject *__pyx_r = NULL;
  6636. __Pyx_TraceDeclarations
  6637. __Pyx_RefNannyDeclarations
  6638. int __pyx_t_1;
  6639. int __pyx_t_2;
  6640. PyObject *__pyx_t_3 = NULL;
  6641. PyObject *__pyx_t_4 = NULL;
  6642. PyObject *__pyx_t_5 = NULL;
  6643. PyObject *__pyx_t_6 = NULL;
  6644. PyObject *__pyx_t_7 = NULL;
  6645. PyObject *__pyx_t_8 = NULL;
  6646. PyObject *__pyx_t_9 = NULL;
  6647. PyObject *__pyx_t_10 = NULL;
  6648. unsigned char *__pyx_t_11;
  6649. Py_ssize_t __pyx_t_12;
  6650. unsigned char *__pyx_t_13;
  6651. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__key_exists __pyx_t_14;
  6652. PyObject *__pyx_t_15 = NULL;
  6653. __Pyx_RefNannySetupContext("key_exists", 0);
  6654. __Pyx_TraceCall("key_exists", __pyx_f[0], 399, 0, __PYX_ERR(0, 399, __pyx_L1_error));
  6655. /* "lakesuperior/store/base_lmdb_store.pyx":406
  6656. * opened.
  6657. * """
  6658. * if new_txn is True: # <<<<<<<<<<<<<<
  6659. * with self.txn_ctx():
  6660. * return self._key_exists(
  6661. */
  6662. __pyx_t_1 = (__pyx_v_new_txn == Py_True);
  6663. __pyx_t_2 = (__pyx_t_1 != 0);
  6664. if (__pyx_t_2) {
  6665. /* "lakesuperior/store/base_lmdb_store.pyx":407
  6666. * """
  6667. * if new_txn is True:
  6668. * with self.txn_ctx(): # <<<<<<<<<<<<<<
  6669. * return self._key_exists(
  6670. * key, len(key), dblabel=dblabel.encode())
  6671. */
  6672. /*with:*/ {
  6673. __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)
  6674. __Pyx_GOTREF(__pyx_t_4);
  6675. __pyx_t_5 = NULL;
  6676. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  6677. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  6678. if (likely(__pyx_t_5)) {
  6679. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  6680. __Pyx_INCREF(__pyx_t_5);
  6681. __Pyx_INCREF(function);
  6682. __Pyx_DECREF_SET(__pyx_t_4, function);
  6683. }
  6684. }
  6685. if (__pyx_t_5) {
  6686. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error)
  6687. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6688. } else {
  6689. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error)
  6690. }
  6691. __Pyx_GOTREF(__pyx_t_3);
  6692. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6693. __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)
  6694. __Pyx_GOTREF(__pyx_t_6);
  6695. __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)
  6696. __Pyx_GOTREF(__pyx_t_5);
  6697. __pyx_t_7 = NULL;
  6698. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  6699. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  6700. if (likely(__pyx_t_7)) {
  6701. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  6702. __Pyx_INCREF(__pyx_t_7);
  6703. __Pyx_INCREF(function);
  6704. __Pyx_DECREF_SET(__pyx_t_5, function);
  6705. }
  6706. }
  6707. if (__pyx_t_7) {
  6708. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 407, __pyx_L4_error)
  6709. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6710. } else {
  6711. __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 407, __pyx_L4_error)
  6712. }
  6713. __Pyx_GOTREF(__pyx_t_4);
  6714. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6715. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6716. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6717. /*try:*/ {
  6718. {
  6719. __Pyx_PyThreadState_declare
  6720. __Pyx_PyThreadState_assign
  6721. __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
  6722. __Pyx_XGOTREF(__pyx_t_8);
  6723. __Pyx_XGOTREF(__pyx_t_9);
  6724. __Pyx_XGOTREF(__pyx_t_10);
  6725. /*try:*/ {
  6726. /* "lakesuperior/store/base_lmdb_store.pyx":408
  6727. * if new_txn is True:
  6728. * with self.txn_ctx():
  6729. * return self._key_exists( # <<<<<<<<<<<<<<
  6730. * key, len(key), dblabel=dblabel.encode())
  6731. * else:
  6732. */
  6733. __Pyx_XDECREF(__pyx_r);
  6734. /* "lakesuperior/store/base_lmdb_store.pyx":409
  6735. * with self.txn_ctx():
  6736. * return self._key_exists(
  6737. * key, len(key), dblabel=dblabel.encode()) # <<<<<<<<<<<<<<
  6738. * else:
  6739. * return self._key_exists(key, len(key), dblabel=dblabel.encode())
  6740. */
  6741. __pyx_t_11 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 409, __pyx_L8_error)
  6742. __pyx_t_12 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 409, __pyx_L8_error)
  6743. __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)
  6744. __Pyx_GOTREF(__pyx_t_4);
  6745. __pyx_t_5 = NULL;
  6746. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  6747. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  6748. if (likely(__pyx_t_5)) {
  6749. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  6750. __Pyx_INCREF(__pyx_t_5);
  6751. __Pyx_INCREF(function);
  6752. __Pyx_DECREF_SET(__pyx_t_4, function);
  6753. }
  6754. }
  6755. if (__pyx_t_5) {
  6756. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L8_error)
  6757. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6758. } else {
  6759. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L8_error)
  6760. }
  6761. __Pyx_GOTREF(__pyx_t_3);
  6762. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6763. __pyx_t_13 = __Pyx_PyObject_AsWritableUString(__pyx_t_3); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 409, __pyx_L8_error)
  6764. /* "lakesuperior/store/base_lmdb_store.pyx":408
  6765. * if new_txn is True:
  6766. * with self.txn_ctx():
  6767. * return self._key_exists( # <<<<<<<<<<<<<<
  6768. * key, len(key), dblabel=dblabel.encode())
  6769. * else:
  6770. */
  6771. __pyx_t_14.__pyx_n = 1;
  6772. __pyx_t_14.dblabel = __pyx_t_13;
  6773. __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)
  6774. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6775. __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 408, __pyx_L8_error)
  6776. __Pyx_GOTREF(__pyx_t_3);
  6777. __pyx_r = __pyx_t_3;
  6778. __pyx_t_3 = 0;
  6779. goto __pyx_L12_try_return;
  6780. /* "lakesuperior/store/base_lmdb_store.pyx":407
  6781. * """
  6782. * if new_txn is True:
  6783. * with self.txn_ctx(): # <<<<<<<<<<<<<<
  6784. * return self._key_exists(
  6785. * key, len(key), dblabel=dblabel.encode())
  6786. */
  6787. }
  6788. __pyx_L8_error:;
  6789. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6790. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6791. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  6792. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6793. /*except:*/ {
  6794. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6795. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5) < 0) __PYX_ERR(0, 407, __pyx_L10_except_error)
  6796. __Pyx_GOTREF(__pyx_t_3);
  6797. __Pyx_GOTREF(__pyx_t_4);
  6798. __Pyx_GOTREF(__pyx_t_5);
  6799. __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)
  6800. __Pyx_GOTREF(__pyx_t_7);
  6801. __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL);
  6802. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6803. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6804. if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 407, __pyx_L10_except_error)
  6805. __Pyx_GOTREF(__pyx_t_15);
  6806. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_15);
  6807. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  6808. if (__pyx_t_2 < 0) __PYX_ERR(0, 407, __pyx_L10_except_error)
  6809. __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
  6810. if (__pyx_t_1) {
  6811. __Pyx_GIVEREF(__pyx_t_3);
  6812. __Pyx_GIVEREF(__pyx_t_4);
  6813. __Pyx_XGIVEREF(__pyx_t_5);
  6814. __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_4, __pyx_t_5);
  6815. __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0;
  6816. __PYX_ERR(0, 407, __pyx_L10_except_error)
  6817. }
  6818. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6819. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6820. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6821. goto __pyx_L9_exception_handled;
  6822. }
  6823. __pyx_L10_except_error:;
  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. goto __pyx_L1_error;
  6829. __pyx_L12_try_return:;
  6830. __Pyx_XGIVEREF(__pyx_t_8);
  6831. __Pyx_XGIVEREF(__pyx_t_9);
  6832. __Pyx_XGIVEREF(__pyx_t_10);
  6833. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  6834. goto __pyx_L5_return;
  6835. __pyx_L9_exception_handled:;
  6836. __Pyx_XGIVEREF(__pyx_t_8);
  6837. __Pyx_XGIVEREF(__pyx_t_9);
  6838. __Pyx_XGIVEREF(__pyx_t_10);
  6839. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  6840. }
  6841. }
  6842. /*finally:*/ {
  6843. /*normal exit:*/{
  6844. if (__pyx_t_6) {
  6845. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__12, NULL);
  6846. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6847. if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 407, __pyx_L1_error)
  6848. __Pyx_GOTREF(__pyx_t_10);
  6849. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  6850. }
  6851. goto __pyx_L7;
  6852. }
  6853. __pyx_L5_return: {
  6854. __pyx_t_10 = __pyx_r;
  6855. __pyx_r = 0;
  6856. if (__pyx_t_6) {
  6857. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__13, NULL);
  6858. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6859. if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 407, __pyx_L1_error)
  6860. __Pyx_GOTREF(__pyx_t_9);
  6861. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6862. }
  6863. __pyx_r = __pyx_t_10;
  6864. __pyx_t_10 = 0;
  6865. goto __pyx_L0;
  6866. }
  6867. __pyx_L7:;
  6868. }
  6869. goto __pyx_L17;
  6870. __pyx_L4_error:;
  6871. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6872. goto __pyx_L1_error;
  6873. __pyx_L17:;
  6874. }
  6875. /* "lakesuperior/store/base_lmdb_store.pyx":406
  6876. * opened.
  6877. * """
  6878. * if new_txn is True: # <<<<<<<<<<<<<<
  6879. * with self.txn_ctx():
  6880. * return self._key_exists(
  6881. */
  6882. goto __pyx_L3;
  6883. }
  6884. /* "lakesuperior/store/base_lmdb_store.pyx":411
  6885. * key, len(key), dblabel=dblabel.encode())
  6886. * else:
  6887. * return self._key_exists(key, len(key), dblabel=dblabel.encode()) # <<<<<<<<<<<<<<
  6888. *
  6889. *
  6890. */
  6891. /*else*/ {
  6892. __Pyx_XDECREF(__pyx_r);
  6893. __pyx_t_13 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 411, __pyx_L1_error)
  6894. __pyx_t_12 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 411, __pyx_L1_error)
  6895. __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)
  6896. __Pyx_GOTREF(__pyx_t_4);
  6897. __pyx_t_3 = NULL;
  6898. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  6899. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
  6900. if (likely(__pyx_t_3)) {
  6901. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  6902. __Pyx_INCREF(__pyx_t_3);
  6903. __Pyx_INCREF(function);
  6904. __Pyx_DECREF_SET(__pyx_t_4, function);
  6905. }
  6906. }
  6907. if (__pyx_t_3) {
  6908. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 411, __pyx_L1_error)
  6909. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6910. } else {
  6911. __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 411, __pyx_L1_error)
  6912. }
  6913. __Pyx_GOTREF(__pyx_t_5);
  6914. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6915. __pyx_t_11 = __Pyx_PyObject_AsWritableUString(__pyx_t_5); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 411, __pyx_L1_error)
  6916. __pyx_t_14.__pyx_n = 1;
  6917. __pyx_t_14.dblabel = __pyx_t_11;
  6918. __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)
  6919. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6920. __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 411, __pyx_L1_error)
  6921. __Pyx_GOTREF(__pyx_t_5);
  6922. __pyx_r = __pyx_t_5;
  6923. __pyx_t_5 = 0;
  6924. goto __pyx_L0;
  6925. }
  6926. __pyx_L3:;
  6927. /* "lakesuperior/store/base_lmdb_store.pyx":399
  6928. *
  6929. *
  6930. * def key_exists(self, key, dblabel='', new_txn=True): # <<<<<<<<<<<<<<
  6931. * """
  6932. * Return whether a key exists in a database (Python-facing method).
  6933. */
  6934. /* function exit code */
  6935. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6936. goto __pyx_L0;
  6937. __pyx_L1_error:;
  6938. __Pyx_XDECREF(__pyx_t_3);
  6939. __Pyx_XDECREF(__pyx_t_4);
  6940. __Pyx_XDECREF(__pyx_t_5);
  6941. __Pyx_XDECREF(__pyx_t_7);
  6942. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6943. __pyx_r = NULL;
  6944. __pyx_L0:;
  6945. __Pyx_XGIVEREF(__pyx_r);
  6946. __Pyx_TraceReturn(__pyx_r, 0);
  6947. __Pyx_RefNannyFinishContext();
  6948. return __pyx_r;
  6949. }
  6950. /* "lakesuperior/store/base_lmdb_store.pyx":414
  6951. *
  6952. *
  6953. * cdef inline bint _key_exists( # <<<<<<<<<<<<<<
  6954. * self, unsigned char *key, unsigned char klen,
  6955. * unsigned char *dblabel=b'') except -1:
  6956. */
  6957. 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) {
  6958. unsigned char *__pyx_v_dblabel = __pyx_k__14;
  6959. struct MDB_val __pyx_v_key_v;
  6960. struct MDB_val __pyx_v_data_v;
  6961. int __pyx_r;
  6962. __Pyx_TraceDeclarations
  6963. __Pyx_RefNannyDeclarations
  6964. PyObject *__pyx_t_1 = NULL;
  6965. PyObject *__pyx_t_2 = NULL;
  6966. PyObject *__pyx_t_3 = NULL;
  6967. MDB_dbi __pyx_t_4;
  6968. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_5;
  6969. PyObject *__pyx_t_6 = NULL;
  6970. PyObject *__pyx_t_7 = NULL;
  6971. PyObject *__pyx_t_8 = NULL;
  6972. PyObject *__pyx_t_9 = NULL;
  6973. int __pyx_t_10;
  6974. __Pyx_RefNannySetupContext("_key_exists", 0);
  6975. __Pyx_TraceCall("_key_exists", __pyx_f[0], 414, 0, __PYX_ERR(0, 414, __pyx_L1_error));
  6976. if (__pyx_optional_args) {
  6977. if (__pyx_optional_args->__pyx_n > 0) {
  6978. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  6979. }
  6980. }
  6981. /* "lakesuperior/store/base_lmdb_store.pyx":424
  6982. * cdef lmdb.MDB_val key_v, data_v
  6983. *
  6984. * key_v.mv_data = key # <<<<<<<<<<<<<<
  6985. * key_v.mv_size = klen
  6986. * #logger.debug(
  6987. */
  6988. __pyx_v_key_v.mv_data = __pyx_v_key;
  6989. /* "lakesuperior/store/base_lmdb_store.pyx":425
  6990. *
  6991. * key_v.mv_data = key
  6992. * key_v.mv_size = klen # <<<<<<<<<<<<<<
  6993. * #logger.debug(
  6994. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  6995. */
  6996. __pyx_v_key_v.mv_size = __pyx_v_klen;
  6997. /* "lakesuperior/store/base_lmdb_store.pyx":428
  6998. * #logger.debug(
  6999. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  7000. * try: # <<<<<<<<<<<<<<
  7001. * _check(lmdb.mdb_get(
  7002. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7003. */
  7004. {
  7005. __Pyx_PyThreadState_declare
  7006. __Pyx_PyThreadState_assign
  7007. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  7008. __Pyx_XGOTREF(__pyx_t_1);
  7009. __Pyx_XGOTREF(__pyx_t_2);
  7010. __Pyx_XGOTREF(__pyx_t_3);
  7011. /*try:*/ {
  7012. /* "lakesuperior/store/base_lmdb_store.pyx":430
  7013. * try:
  7014. * _check(lmdb.mdb_get(
  7015. * self.txn, self.get_dbi(dblabel), &key_v, &data_v)) # <<<<<<<<<<<<<<
  7016. * except KeyNotFoundError:
  7017. * #logger.debug('...no.')
  7018. */
  7019. __pyx_t_5.__pyx_n = 1;
  7020. __pyx_t_5.dblabel = __pyx_v_dblabel;
  7021. __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);
  7022. /* "lakesuperior/store/base_lmdb_store.pyx":429
  7023. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  7024. * try:
  7025. * _check(lmdb.mdb_get( # <<<<<<<<<<<<<<
  7026. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7027. * except KeyNotFoundError:
  7028. */
  7029. __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)
  7030. /* "lakesuperior/store/base_lmdb_store.pyx":428
  7031. * #logger.debug(
  7032. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  7033. * try: # <<<<<<<<<<<<<<
  7034. * _check(lmdb.mdb_get(
  7035. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7036. */
  7037. }
  7038. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  7039. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  7040. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7041. goto __pyx_L8_try_end;
  7042. __pyx_L3_error:;
  7043. /* "lakesuperior/store/base_lmdb_store.pyx":431
  7044. * _check(lmdb.mdb_get(
  7045. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7046. * except KeyNotFoundError: # <<<<<<<<<<<<<<
  7047. * #logger.debug('...no.')
  7048. * return False
  7049. */
  7050. __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
  7051. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 431, __pyx_L5_except_error)
  7052. __Pyx_GOTREF(__pyx_t_9);
  7053. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_6, __pyx_t_9);
  7054. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  7055. __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  7056. __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0;
  7057. if (__pyx_t_10) {
  7058. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7059. if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0) __PYX_ERR(0, 431, __pyx_L5_except_error)
  7060. __Pyx_GOTREF(__pyx_t_8);
  7061. __Pyx_GOTREF(__pyx_t_7);
  7062. __Pyx_GOTREF(__pyx_t_6);
  7063. /* "lakesuperior/store/base_lmdb_store.pyx":433
  7064. * except KeyNotFoundError:
  7065. * #logger.debug('...no.')
  7066. * return False # <<<<<<<<<<<<<<
  7067. * #logger.debug('...yes.')
  7068. * return True
  7069. */
  7070. __pyx_r = 0;
  7071. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7072. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7073. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7074. goto __pyx_L6_except_return;
  7075. }
  7076. goto __pyx_L5_except_error;
  7077. __pyx_L5_except_error:;
  7078. /* "lakesuperior/store/base_lmdb_store.pyx":428
  7079. * #logger.debug(
  7080. * # 'Checking if key {} with size {} exists...'.format(key, klen))
  7081. * try: # <<<<<<<<<<<<<<
  7082. * _check(lmdb.mdb_get(
  7083. * self.txn, self.get_dbi(dblabel), &key_v, &data_v))
  7084. */
  7085. __Pyx_XGIVEREF(__pyx_t_1);
  7086. __Pyx_XGIVEREF(__pyx_t_2);
  7087. __Pyx_XGIVEREF(__pyx_t_3);
  7088. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7089. goto __pyx_L1_error;
  7090. __pyx_L6_except_return:;
  7091. __Pyx_XGIVEREF(__pyx_t_1);
  7092. __Pyx_XGIVEREF(__pyx_t_2);
  7093. __Pyx_XGIVEREF(__pyx_t_3);
  7094. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7095. goto __pyx_L0;
  7096. __pyx_L8_try_end:;
  7097. }
  7098. /* "lakesuperior/store/base_lmdb_store.pyx":435
  7099. * return False
  7100. * #logger.debug('...yes.')
  7101. * return True # <<<<<<<<<<<<<<
  7102. *
  7103. *
  7104. */
  7105. __pyx_r = 1;
  7106. goto __pyx_L0;
  7107. /* "lakesuperior/store/base_lmdb_store.pyx":414
  7108. *
  7109. *
  7110. * cdef inline bint _key_exists( # <<<<<<<<<<<<<<
  7111. * self, unsigned char *key, unsigned char klen,
  7112. * unsigned char *dblabel=b'') except -1:
  7113. */
  7114. /* function exit code */
  7115. __pyx_L1_error:;
  7116. __Pyx_XDECREF(__pyx_t_6);
  7117. __Pyx_XDECREF(__pyx_t_7);
  7118. __Pyx_XDECREF(__pyx_t_8);
  7119. __Pyx_XDECREF(__pyx_t_9);
  7120. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._key_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7121. __pyx_r = -1;
  7122. __pyx_L0:;
  7123. __Pyx_TraceReturn(Py_None, 0);
  7124. __Pyx_RefNannyFinishContext();
  7125. return __pyx_r;
  7126. }
  7127. /* "lakesuperior/store/base_lmdb_store.pyx":438
  7128. *
  7129. *
  7130. * def put(self, key, data, dblabel='', flags=0): # <<<<<<<<<<<<<<
  7131. * """
  7132. * Put one key/value pair (Python-facing method).
  7133. */
  7134. /* Python wrapper */
  7135. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_24put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7136. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_23put[] = "\n Put one key/value pair (Python-facing method).\n ";
  7137. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_24put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  7138. PyObject *__pyx_v_key = 0;
  7139. PyObject *__pyx_v_data = 0;
  7140. PyObject *__pyx_v_dblabel = 0;
  7141. PyObject *__pyx_v_flags = 0;
  7142. PyObject *__pyx_r = 0;
  7143. __Pyx_RefNannyDeclarations
  7144. __Pyx_RefNannySetupContext("put (wrapper)", 0);
  7145. {
  7146. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_data,&__pyx_n_s_dblabel,&__pyx_n_s_flags,0};
  7147. PyObject* values[4] = {0,0,0,0};
  7148. values[2] = ((PyObject *)__pyx_kp_u_);
  7149. values[3] = ((PyObject *)__pyx_int_0);
  7150. if (unlikely(__pyx_kwds)) {
  7151. Py_ssize_t kw_args;
  7152. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  7153. switch (pos_args) {
  7154. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  7155. CYTHON_FALLTHROUGH;
  7156. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  7157. CYTHON_FALLTHROUGH;
  7158. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7159. CYTHON_FALLTHROUGH;
  7160. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7161. CYTHON_FALLTHROUGH;
  7162. case 0: break;
  7163. default: goto __pyx_L5_argtuple_error;
  7164. }
  7165. kw_args = PyDict_Size(__pyx_kwds);
  7166. switch (pos_args) {
  7167. case 0:
  7168. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  7169. else goto __pyx_L5_argtuple_error;
  7170. CYTHON_FALLTHROUGH;
  7171. case 1:
  7172. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
  7173. else {
  7174. __Pyx_RaiseArgtupleInvalid("put", 0, 2, 4, 1); __PYX_ERR(0, 438, __pyx_L3_error)
  7175. }
  7176. CYTHON_FALLTHROUGH;
  7177. case 2:
  7178. if (kw_args > 0) {
  7179. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  7180. if (value) { values[2] = value; kw_args--; }
  7181. }
  7182. CYTHON_FALLTHROUGH;
  7183. case 3:
  7184. if (kw_args > 0) {
  7185. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags);
  7186. if (value) { values[3] = value; kw_args--; }
  7187. }
  7188. }
  7189. if (unlikely(kw_args > 0)) {
  7190. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "put") < 0)) __PYX_ERR(0, 438, __pyx_L3_error)
  7191. }
  7192. } else {
  7193. switch (PyTuple_GET_SIZE(__pyx_args)) {
  7194. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  7195. CYTHON_FALLTHROUGH;
  7196. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  7197. CYTHON_FALLTHROUGH;
  7198. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7199. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7200. break;
  7201. default: goto __pyx_L5_argtuple_error;
  7202. }
  7203. }
  7204. __pyx_v_key = values[0];
  7205. __pyx_v_data = values[1];
  7206. __pyx_v_dblabel = values[2];
  7207. __pyx_v_flags = values[3];
  7208. }
  7209. goto __pyx_L4_argument_unpacking_done;
  7210. __pyx_L5_argtuple_error:;
  7211. __Pyx_RaiseArgtupleInvalid("put", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 438, __pyx_L3_error)
  7212. __pyx_L3_error:;
  7213. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7214. __Pyx_RefNannyFinishContext();
  7215. return NULL;
  7216. __pyx_L4_argument_unpacking_done:;
  7217. __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);
  7218. /* function exit code */
  7219. __Pyx_RefNannyFinishContext();
  7220. return __pyx_r;
  7221. }
  7222. 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) {
  7223. PyObject *__pyx_r = NULL;
  7224. __Pyx_TraceDeclarations
  7225. __Pyx_RefNannyDeclarations
  7226. unsigned char *__pyx_t_1;
  7227. Py_ssize_t __pyx_t_2;
  7228. unsigned char *__pyx_t_3;
  7229. Py_ssize_t __pyx_t_4;
  7230. PyObject *__pyx_t_5 = NULL;
  7231. PyObject *__pyx_t_6 = NULL;
  7232. PyObject *__pyx_t_7 = NULL;
  7233. unsigned char *__pyx_t_8;
  7234. unsigned int __pyx_t_9;
  7235. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__put __pyx_t_10;
  7236. __Pyx_RefNannySetupContext("put", 0);
  7237. __Pyx_TraceCall("put", __pyx_f[0], 438, 0, __PYX_ERR(0, 438, __pyx_L1_error));
  7238. /* "lakesuperior/store/base_lmdb_store.pyx":443
  7239. * """
  7240. * self._put(
  7241. * key, len(key), data, len(data), dblabel=dblabel.encode(), # <<<<<<<<<<<<<<
  7242. * txn=self.txn, flags=flags)
  7243. *
  7244. */
  7245. __pyx_t_1 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 443, __pyx_L1_error)
  7246. __pyx_t_2 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 443, __pyx_L1_error)
  7247. __pyx_t_3 = __Pyx_PyObject_AsWritableUString(__pyx_v_data); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 443, __pyx_L1_error)
  7248. __pyx_t_4 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 443, __pyx_L1_error)
  7249. __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)
  7250. __Pyx_GOTREF(__pyx_t_6);
  7251. __pyx_t_7 = NULL;
  7252. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  7253. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  7254. if (likely(__pyx_t_7)) {
  7255. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  7256. __Pyx_INCREF(__pyx_t_7);
  7257. __Pyx_INCREF(function);
  7258. __Pyx_DECREF_SET(__pyx_t_6, function);
  7259. }
  7260. }
  7261. if (__pyx_t_7) {
  7262. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 443, __pyx_L1_error)
  7263. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7264. } else {
  7265. __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 443, __pyx_L1_error)
  7266. }
  7267. __Pyx_GOTREF(__pyx_t_5);
  7268. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7269. __pyx_t_8 = __Pyx_PyObject_AsWritableUString(__pyx_t_5); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 443, __pyx_L1_error)
  7270. /* "lakesuperior/store/base_lmdb_store.pyx":444
  7271. * self._put(
  7272. * key, len(key), data, len(data), dblabel=dblabel.encode(),
  7273. * txn=self.txn, flags=flags) # <<<<<<<<<<<<<<
  7274. *
  7275. *
  7276. */
  7277. __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)
  7278. /* "lakesuperior/store/base_lmdb_store.pyx":442
  7279. * Put one key/value pair (Python-facing method).
  7280. * """
  7281. * self._put( # <<<<<<<<<<<<<<
  7282. * key, len(key), data, len(data), dblabel=dblabel.encode(),
  7283. * txn=self.txn, flags=flags)
  7284. */
  7285. __pyx_t_10.__pyx_n = 3;
  7286. __pyx_t_10.dblabel = __pyx_t_8;
  7287. __pyx_t_10.txn = __pyx_v_self->txn;
  7288. __pyx_t_10.flags = __pyx_t_9;
  7289. ((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)
  7290. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7291. /* "lakesuperior/store/base_lmdb_store.pyx":438
  7292. *
  7293. *
  7294. * def put(self, key, data, dblabel='', flags=0): # <<<<<<<<<<<<<<
  7295. * """
  7296. * Put one key/value pair (Python-facing method).
  7297. */
  7298. /* function exit code */
  7299. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7300. goto __pyx_L0;
  7301. __pyx_L1_error:;
  7302. __Pyx_XDECREF(__pyx_t_5);
  7303. __Pyx_XDECREF(__pyx_t_6);
  7304. __Pyx_XDECREF(__pyx_t_7);
  7305. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7306. __pyx_r = NULL;
  7307. __pyx_L0:;
  7308. __Pyx_XGIVEREF(__pyx_r);
  7309. __Pyx_TraceReturn(__pyx_r, 0);
  7310. __Pyx_RefNannyFinishContext();
  7311. return __pyx_r;
  7312. }
  7313. /* "lakesuperior/store/base_lmdb_store.pyx":447
  7314. *
  7315. *
  7316. * cdef void _put( # <<<<<<<<<<<<<<
  7317. * self, unsigned char *key, size_t key_size, unsigned char *data,
  7318. * size_t data_size, unsigned char *dblabel='',
  7319. */
  7320. 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) {
  7321. unsigned char *__pyx_v_dblabel = __pyx_k__15;
  7322. /* "lakesuperior/store/base_lmdb_store.pyx":450
  7323. * self, unsigned char *key, size_t key_size, unsigned char *data,
  7324. * size_t data_size, unsigned char *dblabel='',
  7325. * lmdb.MDB_txn *txn=NULL, unsigned int flags=0) except *: # <<<<<<<<<<<<<<
  7326. * """
  7327. * Put one key/value pair.
  7328. */
  7329. MDB_txn *__pyx_v_txn = ((MDB_txn *)NULL);
  7330. unsigned int __pyx_v_flags = ((unsigned int)0);
  7331. int __pyx_v_rc;
  7332. __Pyx_TraceDeclarations
  7333. __Pyx_RefNannyDeclarations
  7334. int __pyx_t_1;
  7335. MDB_txn *__pyx_t_2;
  7336. MDB_dbi __pyx_t_3;
  7337. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_4;
  7338. PyObject *__pyx_t_5 = NULL;
  7339. PyObject *__pyx_t_6 = NULL;
  7340. PyObject *__pyx_t_7 = NULL;
  7341. PyObject *__pyx_t_8 = NULL;
  7342. PyObject *__pyx_t_9 = NULL;
  7343. int __pyx_t_10;
  7344. PyObject *__pyx_t_11 = NULL;
  7345. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_12;
  7346. __Pyx_RefNannySetupContext("_put", 0);
  7347. __Pyx_TraceCall("_put", __pyx_f[0], 447, 0, __PYX_ERR(0, 447, __pyx_L1_error));
  7348. if (__pyx_optional_args) {
  7349. if (__pyx_optional_args->__pyx_n > 0) {
  7350. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  7351. if (__pyx_optional_args->__pyx_n > 1) {
  7352. __pyx_v_txn = __pyx_optional_args->txn;
  7353. if (__pyx_optional_args->__pyx_n > 2) {
  7354. __pyx_v_flags = __pyx_optional_args->flags;
  7355. }
  7356. }
  7357. }
  7358. }
  7359. /* "lakesuperior/store/base_lmdb_store.pyx":454
  7360. * Put one key/value pair.
  7361. * """
  7362. * if txn is NULL: # <<<<<<<<<<<<<<
  7363. * txn = self.txn
  7364. *
  7365. */
  7366. __pyx_t_1 = ((__pyx_v_txn == NULL) != 0);
  7367. if (__pyx_t_1) {
  7368. /* "lakesuperior/store/base_lmdb_store.pyx":455
  7369. * """
  7370. * if txn is NULL:
  7371. * txn = self.txn # <<<<<<<<<<<<<<
  7372. *
  7373. * key_v.mv_data = key
  7374. */
  7375. __pyx_t_2 = __pyx_v_self->txn;
  7376. __pyx_v_txn = __pyx_t_2;
  7377. /* "lakesuperior/store/base_lmdb_store.pyx":454
  7378. * Put one key/value pair.
  7379. * """
  7380. * if txn is NULL: # <<<<<<<<<<<<<<
  7381. * txn = self.txn
  7382. *
  7383. */
  7384. }
  7385. /* "lakesuperior/store/base_lmdb_store.pyx":457
  7386. * txn = self.txn
  7387. *
  7388. * key_v.mv_data = key # <<<<<<<<<<<<<<
  7389. * key_v.mv_size = key_size
  7390. * data_v.mv_data = data
  7391. */
  7392. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_data = __pyx_v_key;
  7393. /* "lakesuperior/store/base_lmdb_store.pyx":458
  7394. *
  7395. * key_v.mv_data = key
  7396. * key_v.mv_size = key_size # <<<<<<<<<<<<<<
  7397. * data_v.mv_data = data
  7398. * data_v.mv_size = data_size
  7399. */
  7400. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_size = __pyx_v_key_size;
  7401. /* "lakesuperior/store/base_lmdb_store.pyx":459
  7402. * key_v.mv_data = key
  7403. * key_v.mv_size = key_size
  7404. * data_v.mv_data = data # <<<<<<<<<<<<<<
  7405. * data_v.mv_size = data_size
  7406. *
  7407. */
  7408. __pyx_v_12lakesuperior_5store_15base_lmdb_store_data_v.mv_data = __pyx_v_data;
  7409. /* "lakesuperior/store/base_lmdb_store.pyx":460
  7410. * key_v.mv_size = key_size
  7411. * data_v.mv_data = data
  7412. * data_v.mv_size = data_size # <<<<<<<<<<<<<<
  7413. *
  7414. * #logger.debug('Putting: {}, {} into DB {}'.format(key[: key_size],
  7415. */
  7416. __pyx_v_12lakesuperior_5store_15base_lmdb_store_data_v.mv_size = __pyx_v_data_size;
  7417. /* "lakesuperior/store/base_lmdb_store.pyx":464
  7418. * #logger.debug('Putting: {}, {} into DB {}'.format(key[: key_size],
  7419. * # data[: data_size], dblabel))
  7420. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags) # <<<<<<<<<<<<<<
  7421. * _check(rc, 'Error putting data: {}, {}'.format(
  7422. * key[: key_size], data[: data_size]))
  7423. */
  7424. __pyx_t_4.__pyx_n = 1;
  7425. __pyx_t_4.dblabel = __pyx_v_dblabel;
  7426. __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);
  7427. __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);
  7428. /* "lakesuperior/store/base_lmdb_store.pyx":465
  7429. * # data[: data_size], dblabel))
  7430. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags)
  7431. * _check(rc, 'Error putting data: {}, {}'.format( # <<<<<<<<<<<<<<
  7432. * key[: key_size], data[: data_size]))
  7433. *
  7434. */
  7435. __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)
  7436. __Pyx_GOTREF(__pyx_t_6);
  7437. /* "lakesuperior/store/base_lmdb_store.pyx":466
  7438. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags)
  7439. * _check(rc, 'Error putting data: {}, {}'.format(
  7440. * key[: key_size], data[: data_size])) # <<<<<<<<<<<<<<
  7441. *
  7442. *
  7443. */
  7444. __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)
  7445. __Pyx_GOTREF(__pyx_t_7);
  7446. __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)
  7447. __Pyx_GOTREF(__pyx_t_8);
  7448. __pyx_t_9 = NULL;
  7449. __pyx_t_10 = 0;
  7450. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  7451. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
  7452. if (likely(__pyx_t_9)) {
  7453. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  7454. __Pyx_INCREF(__pyx_t_9);
  7455. __Pyx_INCREF(function);
  7456. __Pyx_DECREF_SET(__pyx_t_6, function);
  7457. __pyx_t_10 = 1;
  7458. }
  7459. }
  7460. #if CYTHON_FAST_PYCALL
  7461. if (PyFunction_Check(__pyx_t_6)) {
  7462. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_7, __pyx_t_8};
  7463. __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)
  7464. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  7465. __Pyx_GOTREF(__pyx_t_5);
  7466. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7467. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7468. } else
  7469. #endif
  7470. #if CYTHON_FAST_PYCCALL
  7471. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  7472. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_7, __pyx_t_8};
  7473. __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)
  7474. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  7475. __Pyx_GOTREF(__pyx_t_5);
  7476. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7477. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7478. } else
  7479. #endif
  7480. {
  7481. __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 465, __pyx_L1_error)
  7482. __Pyx_GOTREF(__pyx_t_11);
  7483. if (__pyx_t_9) {
  7484. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
  7485. }
  7486. __Pyx_GIVEREF(__pyx_t_7);
  7487. PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_7);
  7488. __Pyx_GIVEREF(__pyx_t_8);
  7489. PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_8);
  7490. __pyx_t_7 = 0;
  7491. __pyx_t_8 = 0;
  7492. __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)
  7493. __Pyx_GOTREF(__pyx_t_5);
  7494. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  7495. }
  7496. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7497. /* "lakesuperior/store/base_lmdb_store.pyx":465
  7498. * # data[: data_size], dblabel))
  7499. * rc = lmdb.mdb_put(txn, self.get_dbi(dblabel), &key_v, &data_v, flags)
  7500. * _check(rc, 'Error putting data: {}, {}'.format( # <<<<<<<<<<<<<<
  7501. * key[: key_size], data[: data_size]))
  7502. *
  7503. */
  7504. 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)
  7505. __pyx_t_12.__pyx_n = 1;
  7506. __pyx_t_12.message = ((PyObject*)__pyx_t_5);
  7507. __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)
  7508. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7509. /* "lakesuperior/store/base_lmdb_store.pyx":447
  7510. *
  7511. *
  7512. * cdef void _put( # <<<<<<<<<<<<<<
  7513. * self, unsigned char *key, size_t key_size, unsigned char *data,
  7514. * size_t data_size, unsigned char *dblabel='',
  7515. */
  7516. /* function exit code */
  7517. goto __pyx_L0;
  7518. __pyx_L1_error:;
  7519. __Pyx_XDECREF(__pyx_t_5);
  7520. __Pyx_XDECREF(__pyx_t_6);
  7521. __Pyx_XDECREF(__pyx_t_7);
  7522. __Pyx_XDECREF(__pyx_t_8);
  7523. __Pyx_XDECREF(__pyx_t_9);
  7524. __Pyx_XDECREF(__pyx_t_11);
  7525. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7526. __pyx_L0:;
  7527. __Pyx_TraceReturn(Py_None, 0);
  7528. __Pyx_RefNannyFinishContext();
  7529. }
  7530. /* "lakesuperior/store/base_lmdb_store.pyx":469
  7531. *
  7532. *
  7533. * cpdef bytes get_data(self, key, dblabel=''): # <<<<<<<<<<<<<<
  7534. * """
  7535. * Get a single value (non-dup) for a key (Python-facing method).
  7536. */
  7537. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7538. 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) {
  7539. PyObject *__pyx_v_dblabel = ((PyObject *)__pyx_kp_u_);
  7540. struct MDB_val __pyx_v_rv;
  7541. PyObject *__pyx_r = NULL;
  7542. __Pyx_TraceDeclarations
  7543. __Pyx_RefNannyDeclarations
  7544. PyObject *__pyx_t_1 = NULL;
  7545. PyObject *__pyx_t_2 = NULL;
  7546. PyObject *__pyx_t_3 = NULL;
  7547. PyObject *__pyx_t_4 = NULL;
  7548. int __pyx_t_5;
  7549. PyObject *__pyx_t_6 = NULL;
  7550. PyObject *__pyx_t_7 = NULL;
  7551. PyObject *__pyx_t_8 = NULL;
  7552. PyObject *__pyx_t_9 = NULL;
  7553. unsigned char *__pyx_t_10;
  7554. Py_ssize_t __pyx_t_11;
  7555. unsigned char *__pyx_t_12;
  7556. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__get_data __pyx_t_13;
  7557. __Pyx_RefNannySetupContext("get_data", 0);
  7558. __Pyx_TraceCall("get_data", __pyx_f[0], 469, 0, __PYX_ERR(0, 469, __pyx_L1_error));
  7559. if (__pyx_optional_args) {
  7560. if (__pyx_optional_args->__pyx_n > 0) {
  7561. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  7562. }
  7563. }
  7564. /* Check if called by wrapper */
  7565. if (unlikely(__pyx_skip_dispatch)) ;
  7566. /* Check if overridden in Python */
  7567. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  7568. __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)
  7569. __Pyx_GOTREF(__pyx_t_1);
  7570. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data)) {
  7571. __Pyx_XDECREF(__pyx_r);
  7572. __Pyx_INCREF(__pyx_t_1);
  7573. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  7574. __pyx_t_5 = 0;
  7575. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  7576. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  7577. if (likely(__pyx_t_4)) {
  7578. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  7579. __Pyx_INCREF(__pyx_t_4);
  7580. __Pyx_INCREF(function);
  7581. __Pyx_DECREF_SET(__pyx_t_3, function);
  7582. __pyx_t_5 = 1;
  7583. }
  7584. }
  7585. #if CYTHON_FAST_PYCALL
  7586. if (PyFunction_Check(__pyx_t_3)) {
  7587. PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_key, __pyx_v_dblabel};
  7588. __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)
  7589. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7590. __Pyx_GOTREF(__pyx_t_2);
  7591. } else
  7592. #endif
  7593. #if CYTHON_FAST_PYCCALL
  7594. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  7595. PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_key, __pyx_v_dblabel};
  7596. __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)
  7597. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7598. __Pyx_GOTREF(__pyx_t_2);
  7599. } else
  7600. #endif
  7601. {
  7602. __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L1_error)
  7603. __Pyx_GOTREF(__pyx_t_6);
  7604. if (__pyx_t_4) {
  7605. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  7606. }
  7607. __Pyx_INCREF(__pyx_v_key);
  7608. __Pyx_GIVEREF(__pyx_v_key);
  7609. PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_key);
  7610. __Pyx_INCREF(__pyx_v_dblabel);
  7611. __Pyx_GIVEREF(__pyx_v_dblabel);
  7612. PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_dblabel);
  7613. __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)
  7614. __Pyx_GOTREF(__pyx_t_2);
  7615. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7616. }
  7617. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7618. 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)
  7619. __pyx_r = ((PyObject*)__pyx_t_2);
  7620. __pyx_t_2 = 0;
  7621. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7622. goto __pyx_L0;
  7623. }
  7624. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7625. }
  7626. /* "lakesuperior/store/base_lmdb_store.pyx":474
  7627. * """
  7628. * cdef lmdb.MDB_val rv
  7629. * try: # <<<<<<<<<<<<<<
  7630. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7631. *
  7632. */
  7633. {
  7634. __Pyx_PyThreadState_declare
  7635. __Pyx_PyThreadState_assign
  7636. __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
  7637. __Pyx_XGOTREF(__pyx_t_7);
  7638. __Pyx_XGOTREF(__pyx_t_8);
  7639. __Pyx_XGOTREF(__pyx_t_9);
  7640. /*try:*/ {
  7641. /* "lakesuperior/store/base_lmdb_store.pyx":475
  7642. * cdef lmdb.MDB_val rv
  7643. * try:
  7644. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode()) # <<<<<<<<<<<<<<
  7645. *
  7646. * return (<unsigned char *>rv.mv_data)[: rv.mv_size]
  7647. */
  7648. __pyx_t_10 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) __PYX_ERR(0, 475, __pyx_L3_error)
  7649. __pyx_t_11 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 475, __pyx_L3_error)
  7650. __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)
  7651. __Pyx_GOTREF(__pyx_t_2);
  7652. __pyx_t_3 = NULL;
  7653. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  7654. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  7655. if (likely(__pyx_t_3)) {
  7656. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  7657. __Pyx_INCREF(__pyx_t_3);
  7658. __Pyx_INCREF(function);
  7659. __Pyx_DECREF_SET(__pyx_t_2, function);
  7660. }
  7661. }
  7662. if (__pyx_t_3) {
  7663. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 475, __pyx_L3_error)
  7664. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7665. } else {
  7666. __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 475, __pyx_L3_error)
  7667. }
  7668. __Pyx_GOTREF(__pyx_t_1);
  7669. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7670. __pyx_t_12 = __Pyx_PyObject_AsWritableUString(__pyx_t_1); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 475, __pyx_L3_error)
  7671. __pyx_t_13.__pyx_n = 1;
  7672. __pyx_t_13.dblabel = __pyx_t_12;
  7673. ((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)
  7674. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7675. /* "lakesuperior/store/base_lmdb_store.pyx":477
  7676. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7677. *
  7678. * return (<unsigned char *>rv.mv_data)[: rv.mv_size] # <<<<<<<<<<<<<<
  7679. * except KeyNotFoundError:
  7680. * return None
  7681. */
  7682. __Pyx_XDECREF(__pyx_r);
  7683. __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)
  7684. __Pyx_GOTREF(__pyx_t_1);
  7685. __pyx_r = ((PyObject*)__pyx_t_1);
  7686. __pyx_t_1 = 0;
  7687. goto __pyx_L7_try_return;
  7688. /* "lakesuperior/store/base_lmdb_store.pyx":474
  7689. * """
  7690. * cdef lmdb.MDB_val rv
  7691. * try: # <<<<<<<<<<<<<<
  7692. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7693. *
  7694. */
  7695. }
  7696. __pyx_L3_error:;
  7697. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7698. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  7699. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7700. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  7701. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  7702. /* "lakesuperior/store/base_lmdb_store.pyx":478
  7703. *
  7704. * return (<unsigned char *>rv.mv_data)[: rv.mv_size]
  7705. * except KeyNotFoundError: # <<<<<<<<<<<<<<
  7706. * return None
  7707. *
  7708. */
  7709. __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  7710. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 478, __pyx_L5_except_error)
  7711. __Pyx_GOTREF(__pyx_t_6);
  7712. __pyx_t_5 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
  7713. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7714. __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7715. __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0;
  7716. if (__pyx_t_5) {
  7717. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7718. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 478, __pyx_L5_except_error)
  7719. __Pyx_GOTREF(__pyx_t_3);
  7720. __Pyx_GOTREF(__pyx_t_2);
  7721. __Pyx_GOTREF(__pyx_t_1);
  7722. /* "lakesuperior/store/base_lmdb_store.pyx":479
  7723. * return (<unsigned char *>rv.mv_data)[: rv.mv_size]
  7724. * except KeyNotFoundError:
  7725. * return None # <<<<<<<<<<<<<<
  7726. *
  7727. *
  7728. */
  7729. __Pyx_XDECREF(__pyx_r);
  7730. __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  7731. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7732. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7733. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7734. goto __pyx_L6_except_return;
  7735. }
  7736. goto __pyx_L5_except_error;
  7737. __pyx_L5_except_error:;
  7738. /* "lakesuperior/store/base_lmdb_store.pyx":474
  7739. * """
  7740. * cdef lmdb.MDB_val rv
  7741. * try: # <<<<<<<<<<<<<<
  7742. * self._get_data(key, len(key), &rv, dblabel=dblabel.encode())
  7743. *
  7744. */
  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_L1_error;
  7750. __pyx_L7_try_return:;
  7751. __Pyx_XGIVEREF(__pyx_t_7);
  7752. __Pyx_XGIVEREF(__pyx_t_8);
  7753. __Pyx_XGIVEREF(__pyx_t_9);
  7754. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  7755. goto __pyx_L0;
  7756. __pyx_L6_except_return:;
  7757. __Pyx_XGIVEREF(__pyx_t_7);
  7758. __Pyx_XGIVEREF(__pyx_t_8);
  7759. __Pyx_XGIVEREF(__pyx_t_9);
  7760. __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  7761. goto __pyx_L0;
  7762. }
  7763. /* "lakesuperior/store/base_lmdb_store.pyx":469
  7764. *
  7765. *
  7766. * cpdef bytes get_data(self, key, dblabel=''): # <<<<<<<<<<<<<<
  7767. * """
  7768. * Get a single value (non-dup) for a key (Python-facing method).
  7769. */
  7770. /* function exit code */
  7771. __pyx_L1_error:;
  7772. __Pyx_XDECREF(__pyx_t_1);
  7773. __Pyx_XDECREF(__pyx_t_2);
  7774. __Pyx_XDECREF(__pyx_t_3);
  7775. __Pyx_XDECREF(__pyx_t_4);
  7776. __Pyx_XDECREF(__pyx_t_6);
  7777. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7778. __pyx_r = 0;
  7779. __pyx_L0:;
  7780. __Pyx_XGIVEREF(__pyx_r);
  7781. __Pyx_TraceReturn(__pyx_r, 0);
  7782. __Pyx_RefNannyFinishContext();
  7783. return __pyx_r;
  7784. }
  7785. /* Python wrapper */
  7786. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7787. 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 ";
  7788. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_26get_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  7789. PyObject *__pyx_v_key = 0;
  7790. PyObject *__pyx_v_dblabel = 0;
  7791. PyObject *__pyx_r = 0;
  7792. __Pyx_RefNannyDeclarations
  7793. __Pyx_RefNannySetupContext("get_data (wrapper)", 0);
  7794. {
  7795. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_dblabel,0};
  7796. PyObject* values[2] = {0,0};
  7797. values[1] = ((PyObject *)__pyx_kp_u_);
  7798. if (unlikely(__pyx_kwds)) {
  7799. Py_ssize_t kw_args;
  7800. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  7801. switch (pos_args) {
  7802. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7803. CYTHON_FALLTHROUGH;
  7804. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7805. CYTHON_FALLTHROUGH;
  7806. case 0: break;
  7807. default: goto __pyx_L5_argtuple_error;
  7808. }
  7809. kw_args = PyDict_Size(__pyx_kwds);
  7810. switch (pos_args) {
  7811. case 0:
  7812. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  7813. else goto __pyx_L5_argtuple_error;
  7814. CYTHON_FALLTHROUGH;
  7815. case 1:
  7816. if (kw_args > 0) {
  7817. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  7818. if (value) { values[1] = value; kw_args--; }
  7819. }
  7820. }
  7821. if (unlikely(kw_args > 0)) {
  7822. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_data") < 0)) __PYX_ERR(0, 469, __pyx_L3_error)
  7823. }
  7824. } else {
  7825. switch (PyTuple_GET_SIZE(__pyx_args)) {
  7826. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7827. CYTHON_FALLTHROUGH;
  7828. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7829. break;
  7830. default: goto __pyx_L5_argtuple_error;
  7831. }
  7832. }
  7833. __pyx_v_key = values[0];
  7834. __pyx_v_dblabel = values[1];
  7835. }
  7836. goto __pyx_L4_argument_unpacking_done;
  7837. __pyx_L5_argtuple_error:;
  7838. __Pyx_RaiseArgtupleInvalid("get_data", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 469, __pyx_L3_error)
  7839. __pyx_L3_error:;
  7840. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7841. __Pyx_RefNannyFinishContext();
  7842. return NULL;
  7843. __pyx_L4_argument_unpacking_done:;
  7844. __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);
  7845. /* function exit code */
  7846. __Pyx_RefNannyFinishContext();
  7847. return __pyx_r;
  7848. }
  7849. 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) {
  7850. PyObject *__pyx_r = NULL;
  7851. __Pyx_TraceDeclarations
  7852. __Pyx_RefNannyDeclarations
  7853. PyObject *__pyx_t_1 = NULL;
  7854. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_data __pyx_t_2;
  7855. __Pyx_RefNannySetupContext("get_data", 0);
  7856. __Pyx_TraceCall("get_data (wrapper)", __pyx_f[0], 469, 0, __PYX_ERR(0, 469, __pyx_L1_error));
  7857. __Pyx_XDECREF(__pyx_r);
  7858. __pyx_t_2.__pyx_n = 1;
  7859. __pyx_t_2.dblabel = __pyx_v_dblabel;
  7860. __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)
  7861. __Pyx_GOTREF(__pyx_t_1);
  7862. __pyx_r = __pyx_t_1;
  7863. __pyx_t_1 = 0;
  7864. goto __pyx_L0;
  7865. /* function exit code */
  7866. __pyx_L1_error:;
  7867. __Pyx_XDECREF(__pyx_t_1);
  7868. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7869. __pyx_r = NULL;
  7870. __pyx_L0:;
  7871. __Pyx_XGIVEREF(__pyx_r);
  7872. __Pyx_TraceReturn(__pyx_r, 0);
  7873. __Pyx_RefNannyFinishContext();
  7874. return __pyx_r;
  7875. }
  7876. /* "lakesuperior/store/base_lmdb_store.pyx":482
  7877. *
  7878. *
  7879. * cdef void _get_data( # <<<<<<<<<<<<<<
  7880. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  7881. * unsigned char *dblabel='') except *:
  7882. */
  7883. 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) {
  7884. unsigned char *__pyx_v_dblabel = __pyx_k__16;
  7885. __Pyx_TraceDeclarations
  7886. __Pyx_RefNannyDeclarations
  7887. size_t __pyx_t_1;
  7888. MDB_dbi __pyx_t_2;
  7889. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_3;
  7890. PyObject *__pyx_t_4 = NULL;
  7891. PyObject *__pyx_t_5 = NULL;
  7892. PyObject *__pyx_t_6 = NULL;
  7893. PyObject *__pyx_t_7 = NULL;
  7894. PyObject *__pyx_t_8 = NULL;
  7895. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_9;
  7896. __Pyx_RefNannySetupContext("_get_data", 0);
  7897. __Pyx_TraceCall("_get_data", __pyx_f[0], 482, 0, __PYX_ERR(0, 482, __pyx_L1_error));
  7898. if (__pyx_optional_args) {
  7899. if (__pyx_optional_args->__pyx_n > 0) {
  7900. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  7901. }
  7902. }
  7903. /* "lakesuperior/store/base_lmdb_store.pyx":491
  7904. * unsigned char *ret
  7905. *
  7906. * key_v.mv_data = key # <<<<<<<<<<<<<<
  7907. * key_v.mv_size = len(key)
  7908. *
  7909. */
  7910. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_data = __pyx_v_key;
  7911. /* "lakesuperior/store/base_lmdb_store.pyx":492
  7912. *
  7913. * key_v.mv_data = key
  7914. * key_v.mv_size = len(key) # <<<<<<<<<<<<<<
  7915. *
  7916. * _check(
  7917. */
  7918. __pyx_t_1 = strlen(((char const *)__pyx_v_key));
  7919. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_size = __pyx_t_1;
  7920. /* "lakesuperior/store/base_lmdb_store.pyx":495
  7921. *
  7922. * _check(
  7923. * lmdb.mdb_get(self.txn, self.get_dbi(dblabel), &key_v, rv), # <<<<<<<<<<<<<<
  7924. * 'Error getting data for key \'{}\'.'.format(key.decode()))
  7925. *
  7926. */
  7927. __pyx_t_3.__pyx_n = 1;
  7928. __pyx_t_3.dblabel = __pyx_v_dblabel;
  7929. __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);
  7930. /* "lakesuperior/store/base_lmdb_store.pyx":496
  7931. * _check(
  7932. * lmdb.mdb_get(self.txn, self.get_dbi(dblabel), &key_v, rv),
  7933. * 'Error getting data for key \'{}\'.'.format(key.decode())) # <<<<<<<<<<<<<<
  7934. *
  7935. *
  7936. */
  7937. __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)
  7938. __Pyx_GOTREF(__pyx_t_5);
  7939. __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)
  7940. __Pyx_GOTREF(__pyx_t_6);
  7941. __pyx_t_7 = NULL;
  7942. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  7943. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  7944. if (likely(__pyx_t_7)) {
  7945. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  7946. __Pyx_INCREF(__pyx_t_7);
  7947. __Pyx_INCREF(function);
  7948. __Pyx_DECREF_SET(__pyx_t_5, function);
  7949. }
  7950. }
  7951. if (!__pyx_t_7) {
  7952. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 496, __pyx_L1_error)
  7953. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7954. __Pyx_GOTREF(__pyx_t_4);
  7955. } else {
  7956. #if CYTHON_FAST_PYCALL
  7957. if (PyFunction_Check(__pyx_t_5)) {
  7958. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  7959. __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)
  7960. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7961. __Pyx_GOTREF(__pyx_t_4);
  7962. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7963. } else
  7964. #endif
  7965. #if CYTHON_FAST_PYCCALL
  7966. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  7967. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
  7968. __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)
  7969. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7970. __Pyx_GOTREF(__pyx_t_4);
  7971. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7972. } else
  7973. #endif
  7974. {
  7975. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 496, __pyx_L1_error)
  7976. __Pyx_GOTREF(__pyx_t_8);
  7977. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  7978. __Pyx_GIVEREF(__pyx_t_6);
  7979. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
  7980. __pyx_t_6 = 0;
  7981. __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)
  7982. __Pyx_GOTREF(__pyx_t_4);
  7983. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7984. }
  7985. }
  7986. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7987. 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)
  7988. /* "lakesuperior/store/base_lmdb_store.pyx":494
  7989. * key_v.mv_size = len(key)
  7990. *
  7991. * _check( # <<<<<<<<<<<<<<
  7992. * lmdb.mdb_get(self.txn, self.get_dbi(dblabel), &key_v, rv),
  7993. * 'Error getting data for key \'{}\'.'.format(key.decode()))
  7994. */
  7995. __pyx_t_9.__pyx_n = 1;
  7996. __pyx_t_9.message = ((PyObject*)__pyx_t_4);
  7997. __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)
  7998. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7999. /* "lakesuperior/store/base_lmdb_store.pyx":482
  8000. *
  8001. *
  8002. * cdef void _get_data( # <<<<<<<<<<<<<<
  8003. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  8004. * unsigned char *dblabel='') except *:
  8005. */
  8006. /* function exit code */
  8007. goto __pyx_L0;
  8008. __pyx_L1_error:;
  8009. __Pyx_XDECREF(__pyx_t_4);
  8010. __Pyx_XDECREF(__pyx_t_5);
  8011. __Pyx_XDECREF(__pyx_t_6);
  8012. __Pyx_XDECREF(__pyx_t_7);
  8013. __Pyx_XDECREF(__pyx_t_8);
  8014. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._get_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8015. __pyx_L0:;
  8016. __Pyx_TraceReturn(Py_None, 0);
  8017. __Pyx_RefNannyFinishContext();
  8018. }
  8019. /* "lakesuperior/store/base_lmdb_store.pyx":499
  8020. *
  8021. *
  8022. * def delete(self, key, dblabel=''): # <<<<<<<<<<<<<<
  8023. * """
  8024. * Delete one single value by key. Python-facing method.
  8025. */
  8026. /* Python wrapper */
  8027. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_28delete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  8028. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_27delete[] = "\n Delete one single value by key. Python-facing method.\n ";
  8029. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_28delete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  8030. PyObject *__pyx_v_key = 0;
  8031. PyObject *__pyx_v_dblabel = 0;
  8032. PyObject *__pyx_r = 0;
  8033. __Pyx_RefNannyDeclarations
  8034. __Pyx_RefNannySetupContext("delete (wrapper)", 0);
  8035. {
  8036. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_dblabel,0};
  8037. PyObject* values[2] = {0,0};
  8038. values[1] = ((PyObject *)__pyx_kp_u_);
  8039. if (unlikely(__pyx_kwds)) {
  8040. Py_ssize_t kw_args;
  8041. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  8042. switch (pos_args) {
  8043. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  8044. CYTHON_FALLTHROUGH;
  8045. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8046. CYTHON_FALLTHROUGH;
  8047. case 0: break;
  8048. default: goto __pyx_L5_argtuple_error;
  8049. }
  8050. kw_args = PyDict_Size(__pyx_kwds);
  8051. switch (pos_args) {
  8052. case 0:
  8053. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  8054. else goto __pyx_L5_argtuple_error;
  8055. CYTHON_FALLTHROUGH;
  8056. case 1:
  8057. if (kw_args > 0) {
  8058. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dblabel);
  8059. if (value) { values[1] = value; kw_args--; }
  8060. }
  8061. }
  8062. if (unlikely(kw_args > 0)) {
  8063. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "delete") < 0)) __PYX_ERR(0, 499, __pyx_L3_error)
  8064. }
  8065. } else {
  8066. switch (PyTuple_GET_SIZE(__pyx_args)) {
  8067. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  8068. CYTHON_FALLTHROUGH;
  8069. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8070. break;
  8071. default: goto __pyx_L5_argtuple_error;
  8072. }
  8073. }
  8074. __pyx_v_key = values[0];
  8075. __pyx_v_dblabel = values[1];
  8076. }
  8077. goto __pyx_L4_argument_unpacking_done;
  8078. __pyx_L5_argtuple_error:;
  8079. __Pyx_RaiseArgtupleInvalid("delete", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 499, __pyx_L3_error)
  8080. __pyx_L3_error:;
  8081. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8082. __Pyx_RefNannyFinishContext();
  8083. return NULL;
  8084. __pyx_L4_argument_unpacking_done:;
  8085. __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);
  8086. /* function exit code */
  8087. __Pyx_RefNannyFinishContext();
  8088. return __pyx_r;
  8089. }
  8090. 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) {
  8091. PyObject *__pyx_r = NULL;
  8092. __Pyx_TraceDeclarations
  8093. __Pyx_RefNannyDeclarations
  8094. unsigned char *__pyx_t_1;
  8095. Py_ssize_t __pyx_t_2;
  8096. PyObject *__pyx_t_3 = NULL;
  8097. PyObject *__pyx_t_4 = NULL;
  8098. PyObject *__pyx_t_5 = NULL;
  8099. unsigned char *__pyx_t_6;
  8100. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__delete __pyx_t_7;
  8101. __Pyx_RefNannySetupContext("delete", 0);
  8102. __Pyx_TraceCall("delete", __pyx_f[0], 499, 0, __PYX_ERR(0, 499, __pyx_L1_error));
  8103. /* "lakesuperior/store/base_lmdb_store.pyx":503
  8104. * Delete one single value by key. Python-facing method.
  8105. * """
  8106. * self._delete(key, len(key), dblabel.encode()) # <<<<<<<<<<<<<<
  8107. *
  8108. *
  8109. */
  8110. __pyx_t_1 = __Pyx_PyObject_AsWritableUString(__pyx_v_key); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 503, __pyx_L1_error)
  8111. __pyx_t_2 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 503, __pyx_L1_error)
  8112. __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)
  8113. __Pyx_GOTREF(__pyx_t_4);
  8114. __pyx_t_5 = NULL;
  8115. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  8116. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  8117. if (likely(__pyx_t_5)) {
  8118. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  8119. __Pyx_INCREF(__pyx_t_5);
  8120. __Pyx_INCREF(function);
  8121. __Pyx_DECREF_SET(__pyx_t_4, function);
  8122. }
  8123. }
  8124. if (__pyx_t_5) {
  8125. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __pyx_L1_error)
  8126. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8127. } else {
  8128. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __pyx_L1_error)
  8129. }
  8130. __Pyx_GOTREF(__pyx_t_3);
  8131. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8132. __pyx_t_6 = __Pyx_PyObject_AsWritableUString(__pyx_t_3); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 503, __pyx_L1_error)
  8133. __pyx_t_7.__pyx_n = 1;
  8134. __pyx_t_7.dblabel = __pyx_t_6;
  8135. ((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)
  8136. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8137. /* "lakesuperior/store/base_lmdb_store.pyx":499
  8138. *
  8139. *
  8140. * def delete(self, key, dblabel=''): # <<<<<<<<<<<<<<
  8141. * """
  8142. * Delete one single value by key. Python-facing method.
  8143. */
  8144. /* function exit code */
  8145. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  8146. goto __pyx_L0;
  8147. __pyx_L1_error:;
  8148. __Pyx_XDECREF(__pyx_t_3);
  8149. __Pyx_XDECREF(__pyx_t_4);
  8150. __Pyx_XDECREF(__pyx_t_5);
  8151. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8152. __pyx_r = NULL;
  8153. __pyx_L0:;
  8154. __Pyx_XGIVEREF(__pyx_r);
  8155. __Pyx_TraceReturn(__pyx_r, 0);
  8156. __Pyx_RefNannyFinishContext();
  8157. return __pyx_r;
  8158. }
  8159. /* "lakesuperior/store/base_lmdb_store.pyx":506
  8160. *
  8161. *
  8162. * cdef void _delete( # <<<<<<<<<<<<<<
  8163. * self, unsigned char *key, size_t klen,
  8164. * unsigned char *dblabel=b'') except *:
  8165. */
  8166. 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) {
  8167. unsigned char *__pyx_v_dblabel = __pyx_k__17;
  8168. __Pyx_TraceDeclarations
  8169. __Pyx_RefNannyDeclarations
  8170. PyObject *__pyx_t_1 = NULL;
  8171. PyObject *__pyx_t_2 = NULL;
  8172. PyObject *__pyx_t_3 = NULL;
  8173. MDB_dbi __pyx_t_4;
  8174. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_5;
  8175. PyObject *__pyx_t_6 = NULL;
  8176. PyObject *__pyx_t_7 = NULL;
  8177. PyObject *__pyx_t_8 = NULL;
  8178. PyObject *__pyx_t_9 = NULL;
  8179. int __pyx_t_10;
  8180. __Pyx_RefNannySetupContext("_delete", 0);
  8181. __Pyx_TraceCall("_delete", __pyx_f[0], 506, 0, __PYX_ERR(0, 506, __pyx_L1_error));
  8182. if (__pyx_optional_args) {
  8183. if (__pyx_optional_args->__pyx_n > 0) {
  8184. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  8185. }
  8186. }
  8187. /* "lakesuperior/store/base_lmdb_store.pyx":514
  8188. * TODO Allow deleting duplicate keys.
  8189. * """
  8190. * key_v.mv_data = key # <<<<<<<<<<<<<<
  8191. * key_v.mv_size = klen
  8192. * try:
  8193. */
  8194. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_data = __pyx_v_key;
  8195. /* "lakesuperior/store/base_lmdb_store.pyx":515
  8196. * """
  8197. * key_v.mv_data = key
  8198. * key_v.mv_size = klen # <<<<<<<<<<<<<<
  8199. * try:
  8200. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8201. */
  8202. __pyx_v_12lakesuperior_5store_15base_lmdb_store_key_v.mv_size = __pyx_v_klen;
  8203. /* "lakesuperior/store/base_lmdb_store.pyx":516
  8204. * key_v.mv_data = key
  8205. * key_v.mv_size = klen
  8206. * try: # <<<<<<<<<<<<<<
  8207. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8208. * except KeyNotFoundError:
  8209. */
  8210. {
  8211. __Pyx_PyThreadState_declare
  8212. __Pyx_PyThreadState_assign
  8213. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  8214. __Pyx_XGOTREF(__pyx_t_1);
  8215. __Pyx_XGOTREF(__pyx_t_2);
  8216. __Pyx_XGOTREF(__pyx_t_3);
  8217. /*try:*/ {
  8218. /* "lakesuperior/store/base_lmdb_store.pyx":517
  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. * pass
  8224. */
  8225. __pyx_t_5.__pyx_n = 1;
  8226. __pyx_t_5.dblabel = __pyx_v_dblabel;
  8227. __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);
  8228. __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)
  8229. /* "lakesuperior/store/base_lmdb_store.pyx":516
  8230. * key_v.mv_data = key
  8231. * key_v.mv_size = klen
  8232. * try: # <<<<<<<<<<<<<<
  8233. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8234. * except KeyNotFoundError:
  8235. */
  8236. }
  8237. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  8238. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  8239. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  8240. goto __pyx_L8_try_end;
  8241. __pyx_L3_error:;
  8242. /* "lakesuperior/store/base_lmdb_store.pyx":518
  8243. * try:
  8244. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8245. * except KeyNotFoundError: # <<<<<<<<<<<<<<
  8246. * pass
  8247. *
  8248. */
  8249. __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
  8250. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_KeyNotFoundError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 518, __pyx_L5_except_error)
  8251. __Pyx_GOTREF(__pyx_t_9);
  8252. __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_6, __pyx_t_9);
  8253. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8254. __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  8255. __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0;
  8256. if (__pyx_t_10) {
  8257. __Pyx_ErrRestore(0,0,0);
  8258. goto __pyx_L4_exception_handled;
  8259. }
  8260. goto __pyx_L5_except_error;
  8261. __pyx_L5_except_error:;
  8262. /* "lakesuperior/store/base_lmdb_store.pyx":516
  8263. * key_v.mv_data = key
  8264. * key_v.mv_size = klen
  8265. * try: # <<<<<<<<<<<<<<
  8266. * _check(lmdb.mdb_del(self.txn, self.get_dbi(dblabel), &key_v, NULL))
  8267. * except KeyNotFoundError:
  8268. */
  8269. __Pyx_XGIVEREF(__pyx_t_1);
  8270. __Pyx_XGIVEREF(__pyx_t_2);
  8271. __Pyx_XGIVEREF(__pyx_t_3);
  8272. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8273. goto __pyx_L1_error;
  8274. __pyx_L4_exception_handled:;
  8275. __Pyx_XGIVEREF(__pyx_t_1);
  8276. __Pyx_XGIVEREF(__pyx_t_2);
  8277. __Pyx_XGIVEREF(__pyx_t_3);
  8278. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8279. __pyx_L8_try_end:;
  8280. }
  8281. /* "lakesuperior/store/base_lmdb_store.pyx":506
  8282. *
  8283. *
  8284. * cdef void _delete( # <<<<<<<<<<<<<<
  8285. * self, unsigned char *key, size_t klen,
  8286. * unsigned char *dblabel=b'') except *:
  8287. */
  8288. /* function exit code */
  8289. goto __pyx_L0;
  8290. __pyx_L1_error:;
  8291. __Pyx_XDECREF(__pyx_t_6);
  8292. __Pyx_XDECREF(__pyx_t_7);
  8293. __Pyx_XDECREF(__pyx_t_8);
  8294. __Pyx_XDECREF(__pyx_t_9);
  8295. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8296. __pyx_L0:;
  8297. __Pyx_TraceReturn(Py_None, 0);
  8298. __Pyx_RefNannyFinishContext();
  8299. }
  8300. /* "lakesuperior/store/base_lmdb_store.pyx":522
  8301. *
  8302. *
  8303. * cpdef dict stats(self, new_txn=True): # <<<<<<<<<<<<<<
  8304. * """Gather statistics about the database."""
  8305. * return self._stats()
  8306. */
  8307. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  8308. 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, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats *__pyx_optional_args) {
  8309. PyObject *__pyx_v_new_txn = ((PyObject *)Py_True);
  8310. PyObject *__pyx_r = NULL;
  8311. __Pyx_TraceDeclarations
  8312. __Pyx_RefNannyDeclarations
  8313. PyObject *__pyx_t_1 = NULL;
  8314. PyObject *__pyx_t_2 = NULL;
  8315. PyObject *__pyx_t_3 = NULL;
  8316. PyObject *__pyx_t_4 = NULL;
  8317. PyObject *__pyx_t_5 = NULL;
  8318. __Pyx_RefNannySetupContext("stats", 0);
  8319. __Pyx_TraceCall("stats", __pyx_f[0], 522, 0, __PYX_ERR(0, 522, __pyx_L1_error));
  8320. if (__pyx_optional_args) {
  8321. if (__pyx_optional_args->__pyx_n > 0) {
  8322. __pyx_v_new_txn = __pyx_optional_args->new_txn;
  8323. }
  8324. }
  8325. /* Check if called by wrapper */
  8326. if (unlikely(__pyx_skip_dispatch)) ;
  8327. /* Check if overridden in Python */
  8328. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  8329. __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)
  8330. __Pyx_GOTREF(__pyx_t_1);
  8331. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats)) {
  8332. __Pyx_XDECREF(__pyx_r);
  8333. __Pyx_INCREF(__pyx_t_1);
  8334. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  8335. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  8336. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  8337. if (likely(__pyx_t_4)) {
  8338. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  8339. __Pyx_INCREF(__pyx_t_4);
  8340. __Pyx_INCREF(function);
  8341. __Pyx_DECREF_SET(__pyx_t_3, function);
  8342. }
  8343. }
  8344. if (!__pyx_t_4) {
  8345. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_new_txn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 522, __pyx_L1_error)
  8346. __Pyx_GOTREF(__pyx_t_2);
  8347. } else {
  8348. #if CYTHON_FAST_PYCALL
  8349. if (PyFunction_Check(__pyx_t_3)) {
  8350. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_new_txn};
  8351. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 522, __pyx_L1_error)
  8352. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  8353. __Pyx_GOTREF(__pyx_t_2);
  8354. } else
  8355. #endif
  8356. #if CYTHON_FAST_PYCCALL
  8357. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  8358. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_new_txn};
  8359. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 522, __pyx_L1_error)
  8360. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  8361. __Pyx_GOTREF(__pyx_t_2);
  8362. } else
  8363. #endif
  8364. {
  8365. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 522, __pyx_L1_error)
  8366. __Pyx_GOTREF(__pyx_t_5);
  8367. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  8368. __Pyx_INCREF(__pyx_v_new_txn);
  8369. __Pyx_GIVEREF(__pyx_v_new_txn);
  8370. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_new_txn);
  8371. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 522, __pyx_L1_error)
  8372. __Pyx_GOTREF(__pyx_t_2);
  8373. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8374. }
  8375. }
  8376. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8377. 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)
  8378. __pyx_r = ((PyObject*)__pyx_t_2);
  8379. __pyx_t_2 = 0;
  8380. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8381. goto __pyx_L0;
  8382. }
  8383. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8384. }
  8385. /* "lakesuperior/store/base_lmdb_store.pyx":524
  8386. * cpdef dict stats(self, new_txn=True):
  8387. * """Gather statistics about the database."""
  8388. * return self._stats() # <<<<<<<<<<<<<<
  8389. *
  8390. *
  8391. */
  8392. __Pyx_XDECREF(__pyx_r);
  8393. __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)
  8394. __Pyx_GOTREF(__pyx_t_1);
  8395. __pyx_r = ((PyObject*)__pyx_t_1);
  8396. __pyx_t_1 = 0;
  8397. goto __pyx_L0;
  8398. /* "lakesuperior/store/base_lmdb_store.pyx":522
  8399. *
  8400. *
  8401. * cpdef dict stats(self, new_txn=True): # <<<<<<<<<<<<<<
  8402. * """Gather statistics about the database."""
  8403. * return self._stats()
  8404. */
  8405. /* function exit code */
  8406. __pyx_L1_error:;
  8407. __Pyx_XDECREF(__pyx_t_1);
  8408. __Pyx_XDECREF(__pyx_t_2);
  8409. __Pyx_XDECREF(__pyx_t_3);
  8410. __Pyx_XDECREF(__pyx_t_4);
  8411. __Pyx_XDECREF(__pyx_t_5);
  8412. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8413. __pyx_r = 0;
  8414. __pyx_L0:;
  8415. __Pyx_XGIVEREF(__pyx_r);
  8416. __Pyx_TraceReturn(__pyx_r, 0);
  8417. __Pyx_RefNannyFinishContext();
  8418. return __pyx_r;
  8419. }
  8420. /* Python wrapper */
  8421. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  8422. static char __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats[] = "Gather statistics about the database.";
  8423. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  8424. PyObject *__pyx_v_new_txn = 0;
  8425. PyObject *__pyx_r = 0;
  8426. __Pyx_RefNannyDeclarations
  8427. __Pyx_RefNannySetupContext("stats (wrapper)", 0);
  8428. {
  8429. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_new_txn,0};
  8430. PyObject* values[1] = {0};
  8431. values[0] = ((PyObject *)Py_True);
  8432. if (unlikely(__pyx_kwds)) {
  8433. Py_ssize_t kw_args;
  8434. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  8435. switch (pos_args) {
  8436. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8437. CYTHON_FALLTHROUGH;
  8438. case 0: break;
  8439. default: goto __pyx_L5_argtuple_error;
  8440. }
  8441. kw_args = PyDict_Size(__pyx_kwds);
  8442. switch (pos_args) {
  8443. case 0:
  8444. if (kw_args > 0) {
  8445. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_new_txn);
  8446. if (value) { values[0] = value; kw_args--; }
  8447. }
  8448. }
  8449. if (unlikely(kw_args > 0)) {
  8450. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "stats") < 0)) __PYX_ERR(0, 522, __pyx_L3_error)
  8451. }
  8452. } else {
  8453. switch (PyTuple_GET_SIZE(__pyx_args)) {
  8454. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8455. CYTHON_FALLTHROUGH;
  8456. case 0: break;
  8457. default: goto __pyx_L5_argtuple_error;
  8458. }
  8459. }
  8460. __pyx_v_new_txn = values[0];
  8461. }
  8462. goto __pyx_L4_argument_unpacking_done;
  8463. __pyx_L5_argtuple_error:;
  8464. __Pyx_RaiseArgtupleInvalid("stats", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 522, __pyx_L3_error)
  8465. __pyx_L3_error:;
  8466. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8467. __Pyx_RefNannyFinishContext();
  8468. return NULL;
  8469. __pyx_L4_argument_unpacking_done:;
  8470. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self), __pyx_v_new_txn);
  8471. /* function exit code */
  8472. __Pyx_RefNannyFinishContext();
  8473. return __pyx_r;
  8474. }
  8475. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self, PyObject *__pyx_v_new_txn) {
  8476. PyObject *__pyx_r = NULL;
  8477. __Pyx_TraceDeclarations
  8478. __Pyx_RefNannyDeclarations
  8479. PyObject *__pyx_t_1 = NULL;
  8480. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats __pyx_t_2;
  8481. __Pyx_RefNannySetupContext("stats", 0);
  8482. __Pyx_TraceCall("stats (wrapper)", __pyx_f[0], 522, 0, __PYX_ERR(0, 522, __pyx_L1_error));
  8483. __Pyx_XDECREF(__pyx_r);
  8484. __pyx_t_2.__pyx_n = 1;
  8485. __pyx_t_2.new_txn = __pyx_v_new_txn;
  8486. __pyx_t_1 = __pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore->stats(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 522, __pyx_L1_error)
  8487. __Pyx_GOTREF(__pyx_t_1);
  8488. __pyx_r = __pyx_t_1;
  8489. __pyx_t_1 = 0;
  8490. goto __pyx_L0;
  8491. /* function exit code */
  8492. __pyx_L1_error:;
  8493. __Pyx_XDECREF(__pyx_t_1);
  8494. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8495. __pyx_r = NULL;
  8496. __pyx_L0:;
  8497. __Pyx_XGIVEREF(__pyx_r);
  8498. __Pyx_TraceReturn(__pyx_r, 0);
  8499. __Pyx_RefNannyFinishContext();
  8500. return __pyx_r;
  8501. }
  8502. /* "lakesuperior/store/base_lmdb_store.pyx":527
  8503. *
  8504. *
  8505. * cdef dict _stats(self): # <<<<<<<<<<<<<<
  8506. * """
  8507. * Gather statistics about the database.
  8508. */
  8509. static PyObject *__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__stats(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  8510. struct MDB_stat __pyx_v_stat;
  8511. CYTHON_UNUSED size_t __pyx_v_entries;
  8512. PyObject *__pyx_v_env_stats = NULL;
  8513. PyObject *__pyx_v_db_stats = NULL;
  8514. PyObject *__pyx_v_i = NULL;
  8515. PyObject *__pyx_v_dblabel = NULL;
  8516. PyObject *__pyx_7genexpr__pyx_v_db_label = NULL;
  8517. PyObject *__pyx_r = NULL;
  8518. __Pyx_TraceDeclarations
  8519. __Pyx_RefNannyDeclarations
  8520. PyObject *__pyx_t_1 = NULL;
  8521. PyObject *__pyx_t_2 = NULL;
  8522. PyObject *__pyx_t_3 = NULL;
  8523. Py_ssize_t __pyx_t_4;
  8524. PyObject *(*__pyx_t_5)(PyObject *);
  8525. Py_ssize_t __pyx_t_6;
  8526. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_7;
  8527. size_t __pyx_t_8;
  8528. PyObject *__pyx_t_9 = NULL;
  8529. PyObject *__pyx_t_10 = NULL;
  8530. PyObject *__pyx_t_11 = NULL;
  8531. __Pyx_RefNannySetupContext("_stats", 0);
  8532. __Pyx_TraceCall("_stats", __pyx_f[0], 527, 0, __PYX_ERR(0, 527, __pyx_L1_error));
  8533. /* "lakesuperior/store/base_lmdb_store.pyx":537
  8534. * size_t entries
  8535. *
  8536. * lmdb.mdb_env_stat(self.dbenv, &stat) # <<<<<<<<<<<<<<
  8537. * env_stats = <dict>stat
  8538. *
  8539. */
  8540. (void)(mdb_env_stat(__pyx_v_self->dbenv, (&__pyx_v_stat)));
  8541. /* "lakesuperior/store/base_lmdb_store.pyx":538
  8542. *
  8543. * lmdb.mdb_env_stat(self.dbenv, &stat)
  8544. * env_stats = <dict>stat # <<<<<<<<<<<<<<
  8545. *
  8546. * db_stats = {}
  8547. */
  8548. __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)
  8549. __Pyx_GOTREF(__pyx_t_1);
  8550. 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)
  8551. __pyx_t_2 = __pyx_t_1;
  8552. __Pyx_INCREF(__pyx_t_2);
  8553. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8554. __pyx_v_env_stats = ((PyObject*)__pyx_t_2);
  8555. __pyx_t_2 = 0;
  8556. /* "lakesuperior/store/base_lmdb_store.pyx":540
  8557. * env_stats = <dict>stat
  8558. *
  8559. * db_stats = {} # <<<<<<<<<<<<<<
  8560. * for i, dblabel in enumerate(self.dbi_labels):
  8561. * _check(
  8562. */
  8563. __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 540, __pyx_L1_error)
  8564. __Pyx_GOTREF(__pyx_t_2);
  8565. __pyx_v_db_stats = ((PyObject*)__pyx_t_2);
  8566. __pyx_t_2 = 0;
  8567. /* "lakesuperior/store/base_lmdb_store.pyx":541
  8568. *
  8569. * db_stats = {}
  8570. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  8571. * _check(
  8572. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8573. */
  8574. __Pyx_INCREF(__pyx_int_0);
  8575. __pyx_t_2 = __pyx_int_0;
  8576. __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)
  8577. __Pyx_GOTREF(__pyx_t_1);
  8578. if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
  8579. __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  8580. __pyx_t_5 = NULL;
  8581. } else {
  8582. __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 541, __pyx_L1_error)
  8583. __Pyx_GOTREF(__pyx_t_3);
  8584. __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 541, __pyx_L1_error)
  8585. }
  8586. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8587. for (;;) {
  8588. if (likely(!__pyx_t_5)) {
  8589. if (likely(PyList_CheckExact(__pyx_t_3))) {
  8590. if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
  8591. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8592. __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)
  8593. #else
  8594. __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)
  8595. __Pyx_GOTREF(__pyx_t_1);
  8596. #endif
  8597. } else {
  8598. if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
  8599. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8600. __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)
  8601. #else
  8602. __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)
  8603. __Pyx_GOTREF(__pyx_t_1);
  8604. #endif
  8605. }
  8606. } else {
  8607. __pyx_t_1 = __pyx_t_5(__pyx_t_3);
  8608. if (unlikely(!__pyx_t_1)) {
  8609. PyObject* exc_type = PyErr_Occurred();
  8610. if (exc_type) {
  8611. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  8612. else __PYX_ERR(0, 541, __pyx_L1_error)
  8613. }
  8614. break;
  8615. }
  8616. __Pyx_GOTREF(__pyx_t_1);
  8617. }
  8618. __Pyx_XDECREF_SET(__pyx_v_dblabel, __pyx_t_1);
  8619. __pyx_t_1 = 0;
  8620. __Pyx_INCREF(__pyx_t_2);
  8621. __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
  8622. __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)
  8623. __Pyx_GOTREF(__pyx_t_1);
  8624. __Pyx_DECREF(__pyx_t_2);
  8625. __pyx_t_2 = __pyx_t_1;
  8626. __pyx_t_1 = 0;
  8627. /* "lakesuperior/store/base_lmdb_store.pyx":543
  8628. * for i, dblabel in enumerate(self.dbi_labels):
  8629. * _check(
  8630. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat), # <<<<<<<<<<<<<<
  8631. * 'Error getting datbase stats: {}')
  8632. * entries = stat.ms_entries
  8633. */
  8634. __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)
  8635. /* "lakesuperior/store/base_lmdb_store.pyx":542
  8636. * db_stats = {}
  8637. * for i, dblabel in enumerate(self.dbi_labels):
  8638. * _check( # <<<<<<<<<<<<<<
  8639. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8640. * 'Error getting datbase stats: {}')
  8641. */
  8642. __pyx_t_7.__pyx_n = 1;
  8643. __pyx_t_7.message = __pyx_kp_u_Error_getting_datbase_stats;
  8644. __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)
  8645. /* "lakesuperior/store/base_lmdb_store.pyx":545
  8646. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8647. * 'Error getting datbase stats: {}')
  8648. * entries = stat.ms_entries # <<<<<<<<<<<<<<
  8649. * db_stats[dblabel.encode()] = <dict>stat
  8650. *
  8651. */
  8652. __pyx_t_8 = __pyx_v_stat.ms_entries;
  8653. __pyx_v_entries = __pyx_t_8;
  8654. /* "lakesuperior/store/base_lmdb_store.pyx":546
  8655. * 'Error getting datbase stats: {}')
  8656. * entries = stat.ms_entries
  8657. * db_stats[dblabel.encode()] = <dict>stat # <<<<<<<<<<<<<<
  8658. *
  8659. * return {
  8660. */
  8661. __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)
  8662. __Pyx_GOTREF(__pyx_t_1);
  8663. 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)
  8664. __pyx_t_9 = __pyx_t_1;
  8665. __Pyx_INCREF(__pyx_t_9);
  8666. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8667. __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)
  8668. __Pyx_GOTREF(__pyx_t_10);
  8669. __pyx_t_11 = NULL;
  8670. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
  8671. __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
  8672. if (likely(__pyx_t_11)) {
  8673. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  8674. __Pyx_INCREF(__pyx_t_11);
  8675. __Pyx_INCREF(function);
  8676. __Pyx_DECREF_SET(__pyx_t_10, function);
  8677. }
  8678. }
  8679. if (__pyx_t_11) {
  8680. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error)
  8681. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  8682. } else {
  8683. __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error)
  8684. }
  8685. __Pyx_GOTREF(__pyx_t_1);
  8686. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8687. if (unlikely(PyDict_SetItem(__pyx_v_db_stats, __pyx_t_1, __pyx_t_9) < 0)) __PYX_ERR(0, 546, __pyx_L1_error)
  8688. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8689. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8690. /* "lakesuperior/store/base_lmdb_store.pyx":541
  8691. *
  8692. * db_stats = {}
  8693. * for i, dblabel in enumerate(self.dbi_labels): # <<<<<<<<<<<<<<
  8694. * _check(
  8695. * lmdb.mdb_stat(self.txn, self.dbis[i], &stat),
  8696. */
  8697. }
  8698. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8699. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8700. /* "lakesuperior/store/base_lmdb_store.pyx":548
  8701. * db_stats[dblabel.encode()] = <dict>stat
  8702. *
  8703. * return { # <<<<<<<<<<<<<<
  8704. * 'env_stats': env_stats,
  8705. * 'env_size': os.stat(self.env_path).st_size,
  8706. */
  8707. __Pyx_XDECREF(__pyx_r);
  8708. /* "lakesuperior/store/base_lmdb_store.pyx":549
  8709. *
  8710. * return {
  8711. * 'env_stats': env_stats, # <<<<<<<<<<<<<<
  8712. * 'env_size': os.stat(self.env_path).st_size,
  8713. * 'db_stats': {
  8714. */
  8715. __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 549, __pyx_L1_error)
  8716. __Pyx_GOTREF(__pyx_t_2);
  8717. if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_env_stats, __pyx_v_env_stats) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  8718. /* "lakesuperior/store/base_lmdb_store.pyx":550
  8719. * return {
  8720. * 'env_stats': env_stats,
  8721. * 'env_size': os.stat(self.env_path).st_size, # <<<<<<<<<<<<<<
  8722. * 'db_stats': {
  8723. * db_label: db_stats[db_label.encode()]
  8724. */
  8725. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 550, __pyx_L1_error)
  8726. __Pyx_GOTREF(__pyx_t_9);
  8727. __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)
  8728. __Pyx_GOTREF(__pyx_t_1);
  8729. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8730. __pyx_t_9 = NULL;
  8731. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  8732. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
  8733. if (likely(__pyx_t_9)) {
  8734. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  8735. __Pyx_INCREF(__pyx_t_9);
  8736. __Pyx_INCREF(function);
  8737. __Pyx_DECREF_SET(__pyx_t_1, function);
  8738. }
  8739. }
  8740. if (!__pyx_t_9) {
  8741. __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)
  8742. __Pyx_GOTREF(__pyx_t_3);
  8743. } else {
  8744. #if CYTHON_FAST_PYCALL
  8745. if (PyFunction_Check(__pyx_t_1)) {
  8746. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_self->env_path};
  8747. __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)
  8748. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  8749. __Pyx_GOTREF(__pyx_t_3);
  8750. } else
  8751. #endif
  8752. #if CYTHON_FAST_PYCCALL
  8753. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  8754. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_self->env_path};
  8755. __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)
  8756. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  8757. __Pyx_GOTREF(__pyx_t_3);
  8758. } else
  8759. #endif
  8760. {
  8761. __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 550, __pyx_L1_error)
  8762. __Pyx_GOTREF(__pyx_t_10);
  8763. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
  8764. __Pyx_INCREF(__pyx_v_self->env_path);
  8765. __Pyx_GIVEREF(__pyx_v_self->env_path);
  8766. PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_self->env_path);
  8767. __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)
  8768. __Pyx_GOTREF(__pyx_t_3);
  8769. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8770. }
  8771. }
  8772. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8773. __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)
  8774. __Pyx_GOTREF(__pyx_t_1);
  8775. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8776. if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_env_size, __pyx_t_1) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  8777. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8778. { /* enter inner scope */
  8779. /* "lakesuperior/store/base_lmdb_store.pyx":551
  8780. * 'env_stats': env_stats,
  8781. * 'env_size': os.stat(self.env_path).st_size,
  8782. * 'db_stats': { # <<<<<<<<<<<<<<
  8783. * db_label: db_stats[db_label.encode()]
  8784. * for db_label in self.dbi_labels
  8785. */
  8786. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 551, __pyx_L7_error)
  8787. __Pyx_GOTREF(__pyx_t_1);
  8788. /* "lakesuperior/store/base_lmdb_store.pyx":553
  8789. * 'db_stats': {
  8790. * db_label: db_stats[db_label.encode()]
  8791. * for db_label in self.dbi_labels # <<<<<<<<<<<<<<
  8792. * },
  8793. * }
  8794. */
  8795. __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)
  8796. __Pyx_GOTREF(__pyx_t_3);
  8797. if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
  8798. __pyx_t_10 = __pyx_t_3; __Pyx_INCREF(__pyx_t_10); __pyx_t_4 = 0;
  8799. __pyx_t_5 = NULL;
  8800. } else {
  8801. __pyx_t_4 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 553, __pyx_L7_error)
  8802. __Pyx_GOTREF(__pyx_t_10);
  8803. __pyx_t_5 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 553, __pyx_L7_error)
  8804. }
  8805. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8806. for (;;) {
  8807. if (likely(!__pyx_t_5)) {
  8808. if (likely(PyList_CheckExact(__pyx_t_10))) {
  8809. if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_10)) break;
  8810. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8811. __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)
  8812. #else
  8813. __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)
  8814. __Pyx_GOTREF(__pyx_t_3);
  8815. #endif
  8816. } else {
  8817. if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
  8818. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8819. __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)
  8820. #else
  8821. __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)
  8822. __Pyx_GOTREF(__pyx_t_3);
  8823. #endif
  8824. }
  8825. } else {
  8826. __pyx_t_3 = __pyx_t_5(__pyx_t_10);
  8827. if (unlikely(!__pyx_t_3)) {
  8828. PyObject* exc_type = PyErr_Occurred();
  8829. if (exc_type) {
  8830. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  8831. else __PYX_ERR(0, 553, __pyx_L7_error)
  8832. }
  8833. break;
  8834. }
  8835. __Pyx_GOTREF(__pyx_t_3);
  8836. }
  8837. __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_db_label, __pyx_t_3);
  8838. __pyx_t_3 = 0;
  8839. /* "lakesuperior/store/base_lmdb_store.pyx":552
  8840. * 'env_size': os.stat(self.env_path).st_size,
  8841. * 'db_stats': {
  8842. * db_label: db_stats[db_label.encode()] # <<<<<<<<<<<<<<
  8843. * for db_label in self.dbi_labels
  8844. * },
  8845. */
  8846. __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)
  8847. __Pyx_GOTREF(__pyx_t_9);
  8848. __pyx_t_11 = NULL;
  8849. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
  8850. __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
  8851. if (likely(__pyx_t_11)) {
  8852. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
  8853. __Pyx_INCREF(__pyx_t_11);
  8854. __Pyx_INCREF(function);
  8855. __Pyx_DECREF_SET(__pyx_t_9, function);
  8856. }
  8857. }
  8858. if (__pyx_t_11) {
  8859. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L7_error)
  8860. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  8861. } else {
  8862. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L7_error)
  8863. }
  8864. __Pyx_GOTREF(__pyx_t_3);
  8865. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8866. __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)
  8867. __Pyx_GOTREF(__pyx_t_9);
  8868. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8869. 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)
  8870. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8871. /* "lakesuperior/store/base_lmdb_store.pyx":553
  8872. * 'db_stats': {
  8873. * db_label: db_stats[db_label.encode()]
  8874. * for db_label in self.dbi_labels # <<<<<<<<<<<<<<
  8875. * },
  8876. * }
  8877. */
  8878. }
  8879. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8880. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_db_label); __pyx_7genexpr__pyx_v_db_label = 0;
  8881. goto __pyx_L10_exit_scope;
  8882. __pyx_L7_error:;
  8883. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_db_label); __pyx_7genexpr__pyx_v_db_label = 0;
  8884. goto __pyx_L1_error;
  8885. __pyx_L10_exit_scope:;
  8886. } /* exit inner scope */
  8887. if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_db_stats, __pyx_t_1) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  8888. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8889. __pyx_r = ((PyObject*)__pyx_t_2);
  8890. __pyx_t_2 = 0;
  8891. goto __pyx_L0;
  8892. /* "lakesuperior/store/base_lmdb_store.pyx":527
  8893. *
  8894. *
  8895. * cdef dict _stats(self): # <<<<<<<<<<<<<<
  8896. * """
  8897. * Gather statistics about the database.
  8898. */
  8899. /* function exit code */
  8900. __pyx_L1_error:;
  8901. __Pyx_XDECREF(__pyx_t_1);
  8902. __Pyx_XDECREF(__pyx_t_2);
  8903. __Pyx_XDECREF(__pyx_t_3);
  8904. __Pyx_XDECREF(__pyx_t_9);
  8905. __Pyx_XDECREF(__pyx_t_10);
  8906. __Pyx_XDECREF(__pyx_t_11);
  8907. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8908. __pyx_r = 0;
  8909. __pyx_L0:;
  8910. __Pyx_XDECREF(__pyx_v_env_stats);
  8911. __Pyx_XDECREF(__pyx_v_db_stats);
  8912. __Pyx_XDECREF(__pyx_v_i);
  8913. __Pyx_XDECREF(__pyx_v_dblabel);
  8914. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_db_label);
  8915. __Pyx_XGIVEREF(__pyx_r);
  8916. __Pyx_TraceReturn(__pyx_r, 0);
  8917. __Pyx_RefNannyFinishContext();
  8918. return __pyx_r;
  8919. }
  8920. /* "lakesuperior/store/base_lmdb_store.pyx":606
  8921. * ### CYTHON METHODS ###
  8922. *
  8923. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *: # <<<<<<<<<<<<<<
  8924. * if not self.is_open:
  8925. * raise LmdbError('Store is not open.')
  8926. */
  8927. 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) {
  8928. PyObject *__pyx_v_write = ((PyObject *)Py_True);
  8929. MDB_txn *__pyx_v_parent = ((MDB_txn *)NULL);
  8930. unsigned int __pyx_v_flags;
  8931. int __pyx_v_rc;
  8932. __Pyx_TraceDeclarations
  8933. __Pyx_RefNannyDeclarations
  8934. PyObject *__pyx_t_1 = NULL;
  8935. int __pyx_t_2;
  8936. int __pyx_t_3;
  8937. PyObject *__pyx_t_4 = NULL;
  8938. unsigned int __pyx_t_5;
  8939. PyObject *__pyx_t_6 = NULL;
  8940. PyObject *__pyx_t_7 = NULL;
  8941. PyObject *__pyx_t_8 = NULL;
  8942. PyObject *__pyx_t_9 = NULL;
  8943. PyObject *__pyx_t_10 = NULL;
  8944. PyObject *__pyx_t_11 = NULL;
  8945. PyObject *__pyx_t_12 = NULL;
  8946. PyObject *__pyx_t_13 = NULL;
  8947. int __pyx_t_14;
  8948. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_15;
  8949. __Pyx_RefNannySetupContext("_txn_begin", 0);
  8950. __Pyx_TraceCall("_txn_begin", __pyx_f[0], 606, 0, __PYX_ERR(0, 606, __pyx_L1_error));
  8951. if (__pyx_optional_args) {
  8952. if (__pyx_optional_args->__pyx_n > 0) {
  8953. __pyx_v_write = __pyx_optional_args->write;
  8954. if (__pyx_optional_args->__pyx_n > 1) {
  8955. __pyx_v_parent = __pyx_optional_args->parent;
  8956. }
  8957. }
  8958. }
  8959. /* "lakesuperior/store/base_lmdb_store.pyx":607
  8960. *
  8961. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  8962. * if not self.is_open: # <<<<<<<<<<<<<<
  8963. * raise LmdbError('Store is not open.')
  8964. *
  8965. */
  8966. __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)
  8967. __Pyx_GOTREF(__pyx_t_1);
  8968. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 607, __pyx_L1_error)
  8969. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8970. __pyx_t_3 = ((!__pyx_t_2) != 0);
  8971. if (unlikely(__pyx_t_3)) {
  8972. /* "lakesuperior/store/base_lmdb_store.pyx":608
  8973. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  8974. * if not self.is_open:
  8975. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  8976. *
  8977. * cdef:
  8978. */
  8979. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
  8980. __Pyx_GOTREF(__pyx_t_1);
  8981. __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)
  8982. __Pyx_GOTREF(__pyx_t_4);
  8983. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8984. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  8985. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8986. __PYX_ERR(0, 608, __pyx_L1_error)
  8987. /* "lakesuperior/store/base_lmdb_store.pyx":607
  8988. *
  8989. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  8990. * if not self.is_open: # <<<<<<<<<<<<<<
  8991. * raise LmdbError('Store is not open.')
  8992. *
  8993. */
  8994. }
  8995. /* "lakesuperior/store/base_lmdb_store.pyx":613
  8996. * unsigned int flags
  8997. *
  8998. * flags = 0 if write else lmdb.MDB_RDONLY # <<<<<<<<<<<<<<
  8999. *
  9000. * logger.debug('Opening {} transaction in PID {}, thread {}'.format(
  9001. */
  9002. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_write); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 613, __pyx_L1_error)
  9003. if (__pyx_t_3) {
  9004. __pyx_t_5 = 0;
  9005. } else {
  9006. __pyx_t_5 = MDB_RDONLY;
  9007. }
  9008. __pyx_v_flags = __pyx_t_5;
  9009. /* "lakesuperior/store/base_lmdb_store.pyx":615
  9010. * flags = 0 if write else lmdb.MDB_RDONLY
  9011. *
  9012. * logger.debug('Opening {} transaction in PID {}, thread {}'.format( # <<<<<<<<<<<<<<
  9013. * 'RW' if write else 'RO',
  9014. * multiprocessing.current_process().pid,
  9015. */
  9016. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 615, __pyx_L1_error)
  9017. __Pyx_GOTREF(__pyx_t_1);
  9018. __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)
  9019. __Pyx_GOTREF(__pyx_t_6);
  9020. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9021. __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)
  9022. __Pyx_GOTREF(__pyx_t_7);
  9023. /* "lakesuperior/store/base_lmdb_store.pyx":616
  9024. *
  9025. * logger.debug('Opening {} transaction in PID {}, thread {}'.format(
  9026. * 'RW' if write else 'RO', # <<<<<<<<<<<<<<
  9027. * multiprocessing.current_process().pid,
  9028. * threading.currentThread().getName()))
  9029. */
  9030. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_write); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 616, __pyx_L1_error)
  9031. if (__pyx_t_3) {
  9032. __Pyx_INCREF(__pyx_n_u_RW);
  9033. __pyx_t_8 = __pyx_n_u_RW;
  9034. } else {
  9035. __Pyx_INCREF(__pyx_n_u_RO);
  9036. __pyx_t_8 = __pyx_n_u_RO;
  9037. }
  9038. /* "lakesuperior/store/base_lmdb_store.pyx":617
  9039. * logger.debug('Opening {} transaction in PID {}, thread {}'.format(
  9040. * 'RW' if write else 'RO',
  9041. * multiprocessing.current_process().pid, # <<<<<<<<<<<<<<
  9042. * threading.currentThread().getName()))
  9043. * #logger.debug('Readers: {}'.format(self.reader_list()))
  9044. */
  9045. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiprocessing); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 617, __pyx_L1_error)
  9046. __Pyx_GOTREF(__pyx_t_10);
  9047. __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)
  9048. __Pyx_GOTREF(__pyx_t_11);
  9049. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9050. __pyx_t_10 = NULL;
  9051. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
  9052. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
  9053. if (likely(__pyx_t_10)) {
  9054. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
  9055. __Pyx_INCREF(__pyx_t_10);
  9056. __Pyx_INCREF(function);
  9057. __Pyx_DECREF_SET(__pyx_t_11, function);
  9058. }
  9059. }
  9060. if (__pyx_t_10) {
  9061. __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 617, __pyx_L1_error)
  9062. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9063. } else {
  9064. __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 617, __pyx_L1_error)
  9065. }
  9066. __Pyx_GOTREF(__pyx_t_9);
  9067. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9068. __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)
  9069. __Pyx_GOTREF(__pyx_t_11);
  9070. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9071. /* "lakesuperior/store/base_lmdb_store.pyx":618
  9072. * 'RW' if write else 'RO',
  9073. * multiprocessing.current_process().pid,
  9074. * threading.currentThread().getName())) # <<<<<<<<<<<<<<
  9075. * #logger.debug('Readers: {}'.format(self.reader_list()))
  9076. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn)
  9077. */
  9078. __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 618, __pyx_L1_error)
  9079. __Pyx_GOTREF(__pyx_t_12);
  9080. __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)
  9081. __Pyx_GOTREF(__pyx_t_13);
  9082. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  9083. __pyx_t_12 = NULL;
  9084. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
  9085. __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
  9086. if (likely(__pyx_t_12)) {
  9087. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  9088. __Pyx_INCREF(__pyx_t_12);
  9089. __Pyx_INCREF(function);
  9090. __Pyx_DECREF_SET(__pyx_t_13, function);
  9091. }
  9092. }
  9093. if (__pyx_t_12) {
  9094. __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 618, __pyx_L1_error)
  9095. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  9096. } else {
  9097. __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 618, __pyx_L1_error)
  9098. }
  9099. __Pyx_GOTREF(__pyx_t_10);
  9100. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  9101. __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)
  9102. __Pyx_GOTREF(__pyx_t_13);
  9103. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9104. __pyx_t_10 = NULL;
  9105. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
  9106. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_13);
  9107. if (likely(__pyx_t_10)) {
  9108. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  9109. __Pyx_INCREF(__pyx_t_10);
  9110. __Pyx_INCREF(function);
  9111. __Pyx_DECREF_SET(__pyx_t_13, function);
  9112. }
  9113. }
  9114. if (__pyx_t_10) {
  9115. __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 618, __pyx_L1_error)
  9116. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9117. } else {
  9118. __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 618, __pyx_L1_error)
  9119. }
  9120. __Pyx_GOTREF(__pyx_t_9);
  9121. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  9122. __pyx_t_13 = NULL;
  9123. __pyx_t_14 = 0;
  9124. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
  9125. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
  9126. if (likely(__pyx_t_13)) {
  9127. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  9128. __Pyx_INCREF(__pyx_t_13);
  9129. __Pyx_INCREF(function);
  9130. __Pyx_DECREF_SET(__pyx_t_7, function);
  9131. __pyx_t_14 = 1;
  9132. }
  9133. }
  9134. #if CYTHON_FAST_PYCALL
  9135. if (PyFunction_Check(__pyx_t_7)) {
  9136. PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_8, __pyx_t_11, __pyx_t_9};
  9137. __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)
  9138. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  9139. __Pyx_GOTREF(__pyx_t_1);
  9140. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  9141. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9142. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9143. } else
  9144. #endif
  9145. #if CYTHON_FAST_PYCCALL
  9146. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  9147. PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_8, __pyx_t_11, __pyx_t_9};
  9148. __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)
  9149. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  9150. __Pyx_GOTREF(__pyx_t_1);
  9151. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  9152. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9153. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9154. } else
  9155. #endif
  9156. {
  9157. __pyx_t_10 = PyTuple_New(3+__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 615, __pyx_L1_error)
  9158. __Pyx_GOTREF(__pyx_t_10);
  9159. if (__pyx_t_13) {
  9160. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_13); __pyx_t_13 = NULL;
  9161. }
  9162. __Pyx_GIVEREF(__pyx_t_8);
  9163. PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_14, __pyx_t_8);
  9164. __Pyx_GIVEREF(__pyx_t_11);
  9165. PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_14, __pyx_t_11);
  9166. __Pyx_GIVEREF(__pyx_t_9);
  9167. PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_14, __pyx_t_9);
  9168. __pyx_t_8 = 0;
  9169. __pyx_t_11 = 0;
  9170. __pyx_t_9 = 0;
  9171. __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)
  9172. __Pyx_GOTREF(__pyx_t_1);
  9173. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9174. }
  9175. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9176. __pyx_t_7 = NULL;
  9177. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
  9178. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  9179. if (likely(__pyx_t_7)) {
  9180. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  9181. __Pyx_INCREF(__pyx_t_7);
  9182. __Pyx_INCREF(function);
  9183. __Pyx_DECREF_SET(__pyx_t_6, function);
  9184. }
  9185. }
  9186. if (!__pyx_t_7) {
  9187. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error)
  9188. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9189. __Pyx_GOTREF(__pyx_t_4);
  9190. } else {
  9191. #if CYTHON_FAST_PYCALL
  9192. if (PyFunction_Check(__pyx_t_6)) {
  9193. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9194. __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)
  9195. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9196. __Pyx_GOTREF(__pyx_t_4);
  9197. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9198. } else
  9199. #endif
  9200. #if CYTHON_FAST_PYCCALL
  9201. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  9202. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9203. __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)
  9204. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9205. __Pyx_GOTREF(__pyx_t_4);
  9206. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9207. } else
  9208. #endif
  9209. {
  9210. __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 615, __pyx_L1_error)
  9211. __Pyx_GOTREF(__pyx_t_10);
  9212. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
  9213. __Pyx_GIVEREF(__pyx_t_1);
  9214. PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_1);
  9215. __pyx_t_1 = 0;
  9216. __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)
  9217. __Pyx_GOTREF(__pyx_t_4);
  9218. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9219. }
  9220. }
  9221. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9222. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9223. /* "lakesuperior/store/base_lmdb_store.pyx":620
  9224. * threading.currentThread().getName()))
  9225. * #logger.debug('Readers: {}'.format(self.reader_list()))
  9226. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn) # <<<<<<<<<<<<<<
  9227. * _check(rc, 'Error opening transaction.')
  9228. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn))
  9229. */
  9230. __pyx_v_rc = mdb_txn_begin(__pyx_v_self->dbenv, __pyx_v_parent, __pyx_v_flags, (&__pyx_v_self->txn));
  9231. /* "lakesuperior/store/base_lmdb_store.pyx":621
  9232. * #logger.debug('Readers: {}'.format(self.reader_list()))
  9233. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn)
  9234. * _check(rc, 'Error opening transaction.') # <<<<<<<<<<<<<<
  9235. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn))
  9236. *
  9237. */
  9238. __pyx_t_15.__pyx_n = 1;
  9239. __pyx_t_15.message = __pyx_kp_u_Error_opening_transaction;
  9240. __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)
  9241. /* "lakesuperior/store/base_lmdb_store.pyx":622
  9242. * rc = lmdb.mdb_txn_begin(self.dbenv, parent, flags, &self.txn)
  9243. * _check(rc, 'Error opening transaction.')
  9244. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn)) # <<<<<<<<<<<<<<
  9245. *
  9246. * self.is_txn_open = True
  9247. */
  9248. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 622, __pyx_L1_error)
  9249. __Pyx_GOTREF(__pyx_t_6);
  9250. __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)
  9251. __Pyx_GOTREF(__pyx_t_10);
  9252. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9253. __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)
  9254. __Pyx_GOTREF(__pyx_t_1);
  9255. __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)
  9256. __Pyx_GOTREF(__pyx_t_7);
  9257. __pyx_t_9 = NULL;
  9258. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  9259. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
  9260. if (likely(__pyx_t_9)) {
  9261. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  9262. __Pyx_INCREF(__pyx_t_9);
  9263. __Pyx_INCREF(function);
  9264. __Pyx_DECREF_SET(__pyx_t_1, function);
  9265. }
  9266. }
  9267. if (!__pyx_t_9) {
  9268. __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 622, __pyx_L1_error)
  9269. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9270. __Pyx_GOTREF(__pyx_t_6);
  9271. } else {
  9272. #if CYTHON_FAST_PYCALL
  9273. if (PyFunction_Check(__pyx_t_1)) {
  9274. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
  9275. __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)
  9276. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  9277. __Pyx_GOTREF(__pyx_t_6);
  9278. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9279. } else
  9280. #endif
  9281. #if CYTHON_FAST_PYCCALL
  9282. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  9283. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
  9284. __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)
  9285. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  9286. __Pyx_GOTREF(__pyx_t_6);
  9287. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  9288. } else
  9289. #endif
  9290. {
  9291. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 622, __pyx_L1_error)
  9292. __Pyx_GOTREF(__pyx_t_11);
  9293. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
  9294. __Pyx_GIVEREF(__pyx_t_7);
  9295. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_7);
  9296. __pyx_t_7 = 0;
  9297. __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)
  9298. __Pyx_GOTREF(__pyx_t_6);
  9299. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9300. }
  9301. }
  9302. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9303. __pyx_t_1 = NULL;
  9304. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
  9305. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
  9306. if (likely(__pyx_t_1)) {
  9307. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  9308. __Pyx_INCREF(__pyx_t_1);
  9309. __Pyx_INCREF(function);
  9310. __Pyx_DECREF_SET(__pyx_t_10, function);
  9311. }
  9312. }
  9313. if (!__pyx_t_1) {
  9314. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 622, __pyx_L1_error)
  9315. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9316. __Pyx_GOTREF(__pyx_t_4);
  9317. } else {
  9318. #if CYTHON_FAST_PYCALL
  9319. if (PyFunction_Check(__pyx_t_10)) {
  9320. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6};
  9321. __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)
  9322. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9323. __Pyx_GOTREF(__pyx_t_4);
  9324. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9325. } else
  9326. #endif
  9327. #if CYTHON_FAST_PYCCALL
  9328. if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
  9329. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6};
  9330. __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)
  9331. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9332. __Pyx_GOTREF(__pyx_t_4);
  9333. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9334. } else
  9335. #endif
  9336. {
  9337. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 622, __pyx_L1_error)
  9338. __Pyx_GOTREF(__pyx_t_11);
  9339. __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL;
  9340. __Pyx_GIVEREF(__pyx_t_6);
  9341. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_6);
  9342. __pyx_t_6 = 0;
  9343. __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)
  9344. __Pyx_GOTREF(__pyx_t_4);
  9345. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9346. }
  9347. }
  9348. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9349. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9350. /* "lakesuperior/store/base_lmdb_store.pyx":624
  9351. * logger.debug('Opened transaction @ {:x}'.format(<unsigned long>self.txn))
  9352. *
  9353. * self.is_txn_open = True # <<<<<<<<<<<<<<
  9354. * self.is_txn_rw = write
  9355. * logger.debug('txn is open: {}'.format(self.is_txn_open))
  9356. */
  9357. __pyx_v_self->is_txn_open = 1;
  9358. /* "lakesuperior/store/base_lmdb_store.pyx":625
  9359. *
  9360. * self.is_txn_open = True
  9361. * self.is_txn_rw = write # <<<<<<<<<<<<<<
  9362. * logger.debug('txn is open: {}'.format(self.is_txn_open))
  9363. *
  9364. */
  9365. 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)
  9366. /* "lakesuperior/store/base_lmdb_store.pyx":626
  9367. * self.is_txn_open = True
  9368. * self.is_txn_rw = write
  9369. * logger.debug('txn is open: {}'.format(self.is_txn_open)) # <<<<<<<<<<<<<<
  9370. *
  9371. *
  9372. */
  9373. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 626, __pyx_L1_error)
  9374. __Pyx_GOTREF(__pyx_t_10);
  9375. __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)
  9376. __Pyx_GOTREF(__pyx_t_11);
  9377. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9378. __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)
  9379. __Pyx_GOTREF(__pyx_t_6);
  9380. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_txn_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L1_error)
  9381. __Pyx_GOTREF(__pyx_t_1);
  9382. __pyx_t_7 = NULL;
  9383. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  9384. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  9385. if (likely(__pyx_t_7)) {
  9386. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  9387. __Pyx_INCREF(__pyx_t_7);
  9388. __Pyx_INCREF(function);
  9389. __Pyx_DECREF_SET(__pyx_t_6, function);
  9390. }
  9391. }
  9392. if (!__pyx_t_7) {
  9393. __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 626, __pyx_L1_error)
  9394. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9395. __Pyx_GOTREF(__pyx_t_10);
  9396. } else {
  9397. #if CYTHON_FAST_PYCALL
  9398. if (PyFunction_Check(__pyx_t_6)) {
  9399. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9400. __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)
  9401. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9402. __Pyx_GOTREF(__pyx_t_10);
  9403. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9404. } else
  9405. #endif
  9406. #if CYTHON_FAST_PYCCALL
  9407. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  9408. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
  9409. __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)
  9410. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9411. __Pyx_GOTREF(__pyx_t_10);
  9412. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9413. } else
  9414. #endif
  9415. {
  9416. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 626, __pyx_L1_error)
  9417. __Pyx_GOTREF(__pyx_t_9);
  9418. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
  9419. __Pyx_GIVEREF(__pyx_t_1);
  9420. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_1);
  9421. __pyx_t_1 = 0;
  9422. __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)
  9423. __Pyx_GOTREF(__pyx_t_10);
  9424. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9425. }
  9426. }
  9427. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9428. __pyx_t_6 = NULL;
  9429. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
  9430. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11);
  9431. if (likely(__pyx_t_6)) {
  9432. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
  9433. __Pyx_INCREF(__pyx_t_6);
  9434. __Pyx_INCREF(function);
  9435. __Pyx_DECREF_SET(__pyx_t_11, function);
  9436. }
  9437. }
  9438. if (!__pyx_t_6) {
  9439. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 626, __pyx_L1_error)
  9440. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9441. __Pyx_GOTREF(__pyx_t_4);
  9442. } else {
  9443. #if CYTHON_FAST_PYCALL
  9444. if (PyFunction_Check(__pyx_t_11)) {
  9445. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  9446. __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)
  9447. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  9448. __Pyx_GOTREF(__pyx_t_4);
  9449. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9450. } else
  9451. #endif
  9452. #if CYTHON_FAST_PYCCALL
  9453. if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
  9454. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  9455. __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)
  9456. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  9457. __Pyx_GOTREF(__pyx_t_4);
  9458. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  9459. } else
  9460. #endif
  9461. {
  9462. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 626, __pyx_L1_error)
  9463. __Pyx_GOTREF(__pyx_t_9);
  9464. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
  9465. __Pyx_GIVEREF(__pyx_t_10);
  9466. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_10);
  9467. __pyx_t_10 = 0;
  9468. __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)
  9469. __Pyx_GOTREF(__pyx_t_4);
  9470. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9471. }
  9472. }
  9473. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  9474. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9475. /* "lakesuperior/store/base_lmdb_store.pyx":606
  9476. * ### CYTHON METHODS ###
  9477. *
  9478. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *: # <<<<<<<<<<<<<<
  9479. * if not self.is_open:
  9480. * raise LmdbError('Store is not open.')
  9481. */
  9482. /* function exit code */
  9483. goto __pyx_L0;
  9484. __pyx_L1_error:;
  9485. __Pyx_XDECREF(__pyx_t_1);
  9486. __Pyx_XDECREF(__pyx_t_4);
  9487. __Pyx_XDECREF(__pyx_t_6);
  9488. __Pyx_XDECREF(__pyx_t_7);
  9489. __Pyx_XDECREF(__pyx_t_8);
  9490. __Pyx_XDECREF(__pyx_t_9);
  9491. __Pyx_XDECREF(__pyx_t_10);
  9492. __Pyx_XDECREF(__pyx_t_11);
  9493. __Pyx_XDECREF(__pyx_t_12);
  9494. __Pyx_XDECREF(__pyx_t_13);
  9495. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_begin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9496. __pyx_L0:;
  9497. __Pyx_TraceReturn(Py_None, 0);
  9498. __Pyx_RefNannyFinishContext();
  9499. }
  9500. /* "lakesuperior/store/base_lmdb_store.pyx":629
  9501. *
  9502. *
  9503. * cdef void _txn_commit(self) except *: # <<<<<<<<<<<<<<
  9504. * txid = '{:x}'.format(<unsigned long>self.txn)
  9505. * try:
  9506. */
  9507. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_commit(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  9508. PyObject *__pyx_v_txid = NULL;
  9509. __Pyx_TraceDeclarations
  9510. __Pyx_RefNannyDeclarations
  9511. PyObject *__pyx_t_1 = NULL;
  9512. PyObject *__pyx_t_2 = NULL;
  9513. PyObject *__pyx_t_3 = NULL;
  9514. PyObject *__pyx_t_4 = NULL;
  9515. PyObject *__pyx_t_5 = NULL;
  9516. PyObject *__pyx_t_6 = NULL;
  9517. PyObject *__pyx_t_7 = NULL;
  9518. PyObject *__pyx_t_8 = NULL;
  9519. PyObject *__pyx_t_9 = NULL;
  9520. __Pyx_RefNannySetupContext("_txn_commit", 0);
  9521. __Pyx_TraceCall("_txn_commit", __pyx_f[0], 629, 0, __PYX_ERR(0, 629, __pyx_L1_error));
  9522. /* "lakesuperior/store/base_lmdb_store.pyx":630
  9523. *
  9524. * cdef void _txn_commit(self) except *:
  9525. * txid = '{:x}'.format(<unsigned long>self.txn) # <<<<<<<<<<<<<<
  9526. * try:
  9527. * _check(lmdb.mdb_txn_commit(self.txn))
  9528. */
  9529. __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)
  9530. __Pyx_GOTREF(__pyx_t_2);
  9531. __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)
  9532. __Pyx_GOTREF(__pyx_t_3);
  9533. __pyx_t_4 = NULL;
  9534. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  9535. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
  9536. if (likely(__pyx_t_4)) {
  9537. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  9538. __Pyx_INCREF(__pyx_t_4);
  9539. __Pyx_INCREF(function);
  9540. __Pyx_DECREF_SET(__pyx_t_2, function);
  9541. }
  9542. }
  9543. if (!__pyx_t_4) {
  9544. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error)
  9545. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9546. __Pyx_GOTREF(__pyx_t_1);
  9547. } else {
  9548. #if CYTHON_FAST_PYCALL
  9549. if (PyFunction_Check(__pyx_t_2)) {
  9550. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9551. __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)
  9552. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9553. __Pyx_GOTREF(__pyx_t_1);
  9554. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9555. } else
  9556. #endif
  9557. #if CYTHON_FAST_PYCCALL
  9558. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  9559. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9560. __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)
  9561. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9562. __Pyx_GOTREF(__pyx_t_1);
  9563. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9564. } else
  9565. #endif
  9566. {
  9567. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 630, __pyx_L1_error)
  9568. __Pyx_GOTREF(__pyx_t_5);
  9569. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9570. __Pyx_GIVEREF(__pyx_t_3);
  9571. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
  9572. __pyx_t_3 = 0;
  9573. __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)
  9574. __Pyx_GOTREF(__pyx_t_1);
  9575. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  9576. }
  9577. }
  9578. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9579. __pyx_v_txid = __pyx_t_1;
  9580. __pyx_t_1 = 0;
  9581. /* "lakesuperior/store/base_lmdb_store.pyx":631
  9582. * cdef void _txn_commit(self) except *:
  9583. * txid = '{:x}'.format(<unsigned long>self.txn)
  9584. * try: # <<<<<<<<<<<<<<
  9585. * _check(lmdb.mdb_txn_commit(self.txn))
  9586. * logger.debug('Transaction @ {} committed.'.format(txid))
  9587. */
  9588. {
  9589. __Pyx_PyThreadState_declare
  9590. __Pyx_PyThreadState_assign
  9591. __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
  9592. __Pyx_XGOTREF(__pyx_t_6);
  9593. __Pyx_XGOTREF(__pyx_t_7);
  9594. __Pyx_XGOTREF(__pyx_t_8);
  9595. /*try:*/ {
  9596. /* "lakesuperior/store/base_lmdb_store.pyx":632
  9597. * txid = '{:x}'.format(<unsigned long>self.txn)
  9598. * try:
  9599. * _check(lmdb.mdb_txn_commit(self.txn)) # <<<<<<<<<<<<<<
  9600. * logger.debug('Transaction @ {} committed.'.format(txid))
  9601. * self.is_txn_open = False
  9602. */
  9603. __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)
  9604. /* "lakesuperior/store/base_lmdb_store.pyx":633
  9605. * try:
  9606. * _check(lmdb.mdb_txn_commit(self.txn))
  9607. * logger.debug('Transaction @ {} committed.'.format(txid)) # <<<<<<<<<<<<<<
  9608. * self.is_txn_open = False
  9609. * self.is_txn_rw = False
  9610. */
  9611. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L3_error)
  9612. __Pyx_GOTREF(__pyx_t_2);
  9613. __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)
  9614. __Pyx_GOTREF(__pyx_t_5);
  9615. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9616. __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)
  9617. __Pyx_GOTREF(__pyx_t_3);
  9618. __pyx_t_4 = NULL;
  9619. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  9620. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  9621. if (likely(__pyx_t_4)) {
  9622. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  9623. __Pyx_INCREF(__pyx_t_4);
  9624. __Pyx_INCREF(function);
  9625. __Pyx_DECREF_SET(__pyx_t_3, function);
  9626. }
  9627. }
  9628. if (!__pyx_t_4) {
  9629. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_txid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L3_error)
  9630. __Pyx_GOTREF(__pyx_t_2);
  9631. } else {
  9632. #if CYTHON_FAST_PYCALL
  9633. if (PyFunction_Check(__pyx_t_3)) {
  9634. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9635. __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)
  9636. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9637. __Pyx_GOTREF(__pyx_t_2);
  9638. } else
  9639. #endif
  9640. #if CYTHON_FAST_PYCCALL
  9641. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  9642. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9643. __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)
  9644. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9645. __Pyx_GOTREF(__pyx_t_2);
  9646. } else
  9647. #endif
  9648. {
  9649. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 633, __pyx_L3_error)
  9650. __Pyx_GOTREF(__pyx_t_9);
  9651. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9652. __Pyx_INCREF(__pyx_v_txid);
  9653. __Pyx_GIVEREF(__pyx_v_txid);
  9654. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_txid);
  9655. __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)
  9656. __Pyx_GOTREF(__pyx_t_2);
  9657. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9658. }
  9659. }
  9660. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9661. __pyx_t_3 = NULL;
  9662. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  9663. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
  9664. if (likely(__pyx_t_3)) {
  9665. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  9666. __Pyx_INCREF(__pyx_t_3);
  9667. __Pyx_INCREF(function);
  9668. __Pyx_DECREF_SET(__pyx_t_5, function);
  9669. }
  9670. }
  9671. if (!__pyx_t_3) {
  9672. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L3_error)
  9673. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9674. __Pyx_GOTREF(__pyx_t_1);
  9675. } else {
  9676. #if CYTHON_FAST_PYCALL
  9677. if (PyFunction_Check(__pyx_t_5)) {
  9678. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  9679. __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)
  9680. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9681. __Pyx_GOTREF(__pyx_t_1);
  9682. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9683. } else
  9684. #endif
  9685. #if CYTHON_FAST_PYCCALL
  9686. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  9687. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  9688. __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)
  9689. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9690. __Pyx_GOTREF(__pyx_t_1);
  9691. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9692. } else
  9693. #endif
  9694. {
  9695. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 633, __pyx_L3_error)
  9696. __Pyx_GOTREF(__pyx_t_9);
  9697. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = NULL;
  9698. __Pyx_GIVEREF(__pyx_t_2);
  9699. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_2);
  9700. __pyx_t_2 = 0;
  9701. __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)
  9702. __Pyx_GOTREF(__pyx_t_1);
  9703. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  9704. }
  9705. }
  9706. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  9707. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9708. /* "lakesuperior/store/base_lmdb_store.pyx":634
  9709. * _check(lmdb.mdb_txn_commit(self.txn))
  9710. * logger.debug('Transaction @ {} committed.'.format(txid))
  9711. * self.is_txn_open = False # <<<<<<<<<<<<<<
  9712. * self.is_txn_rw = False
  9713. * except:
  9714. */
  9715. __pyx_v_self->is_txn_open = 0;
  9716. /* "lakesuperior/store/base_lmdb_store.pyx":635
  9717. * logger.debug('Transaction @ {} committed.'.format(txid))
  9718. * self.is_txn_open = False
  9719. * self.is_txn_rw = False # <<<<<<<<<<<<<<
  9720. * except:
  9721. * self._txn_abort()
  9722. */
  9723. if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_txn_rw, Py_False) < 0) __PYX_ERR(0, 635, __pyx_L3_error)
  9724. /* "lakesuperior/store/base_lmdb_store.pyx":631
  9725. * cdef void _txn_commit(self) except *:
  9726. * txid = '{:x}'.format(<unsigned long>self.txn)
  9727. * try: # <<<<<<<<<<<<<<
  9728. * _check(lmdb.mdb_txn_commit(self.txn))
  9729. * logger.debug('Transaction @ {} committed.'.format(txid))
  9730. */
  9731. }
  9732. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  9733. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  9734. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  9735. goto __pyx_L8_try_end;
  9736. __pyx_L3_error:;
  9737. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9738. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9739. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  9740. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  9741. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  9742. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9743. /* "lakesuperior/store/base_lmdb_store.pyx":636
  9744. * self.is_txn_open = False
  9745. * self.is_txn_rw = False
  9746. * except: # <<<<<<<<<<<<<<
  9747. * self._txn_abort()
  9748. * raise
  9749. */
  9750. /*except:*/ {
  9751. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_commit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9752. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) __PYX_ERR(0, 636, __pyx_L5_except_error)
  9753. __Pyx_GOTREF(__pyx_t_1);
  9754. __Pyx_GOTREF(__pyx_t_5);
  9755. __Pyx_GOTREF(__pyx_t_9);
  9756. /* "lakesuperior/store/base_lmdb_store.pyx":637
  9757. * self.is_txn_rw = False
  9758. * except:
  9759. * self._txn_abort() # <<<<<<<<<<<<<<
  9760. * raise
  9761. *
  9762. */
  9763. ((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)
  9764. /* "lakesuperior/store/base_lmdb_store.pyx":638
  9765. * except:
  9766. * self._txn_abort()
  9767. * raise # <<<<<<<<<<<<<<
  9768. *
  9769. *
  9770. */
  9771. __Pyx_GIVEREF(__pyx_t_1);
  9772. __Pyx_GIVEREF(__pyx_t_5);
  9773. __Pyx_XGIVEREF(__pyx_t_9);
  9774. __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_5, __pyx_t_9);
  9775. __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
  9776. __PYX_ERR(0, 638, __pyx_L5_except_error)
  9777. }
  9778. __pyx_L5_except_error:;
  9779. /* "lakesuperior/store/base_lmdb_store.pyx":631
  9780. * cdef void _txn_commit(self) except *:
  9781. * txid = '{:x}'.format(<unsigned long>self.txn)
  9782. * try: # <<<<<<<<<<<<<<
  9783. * _check(lmdb.mdb_txn_commit(self.txn))
  9784. * logger.debug('Transaction @ {} committed.'.format(txid))
  9785. */
  9786. __Pyx_XGIVEREF(__pyx_t_6);
  9787. __Pyx_XGIVEREF(__pyx_t_7);
  9788. __Pyx_XGIVEREF(__pyx_t_8);
  9789. __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  9790. goto __pyx_L1_error;
  9791. __pyx_L8_try_end:;
  9792. }
  9793. /* "lakesuperior/store/base_lmdb_store.pyx":629
  9794. *
  9795. *
  9796. * cdef void _txn_commit(self) except *: # <<<<<<<<<<<<<<
  9797. * txid = '{:x}'.format(<unsigned long>self.txn)
  9798. * try:
  9799. */
  9800. /* function exit code */
  9801. goto __pyx_L0;
  9802. __pyx_L1_error:;
  9803. __Pyx_XDECREF(__pyx_t_1);
  9804. __Pyx_XDECREF(__pyx_t_2);
  9805. __Pyx_XDECREF(__pyx_t_3);
  9806. __Pyx_XDECREF(__pyx_t_4);
  9807. __Pyx_XDECREF(__pyx_t_5);
  9808. __Pyx_XDECREF(__pyx_t_9);
  9809. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_commit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9810. __pyx_L0:;
  9811. __Pyx_XDECREF(__pyx_v_txid);
  9812. __Pyx_TraceReturn(Py_None, 0);
  9813. __Pyx_RefNannyFinishContext();
  9814. }
  9815. /* "lakesuperior/store/base_lmdb_store.pyx":641
  9816. *
  9817. *
  9818. * cdef void _txn_abort(self) except *: # <<<<<<<<<<<<<<
  9819. * txid = '{:x}'.format(<unsigned long>self.txn)
  9820. * lmdb.mdb_txn_abort(self.txn)
  9821. */
  9822. static void __pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__txn_abort(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  9823. PyObject *__pyx_v_txid = NULL;
  9824. __Pyx_TraceDeclarations
  9825. __Pyx_RefNannyDeclarations
  9826. PyObject *__pyx_t_1 = NULL;
  9827. PyObject *__pyx_t_2 = NULL;
  9828. PyObject *__pyx_t_3 = NULL;
  9829. PyObject *__pyx_t_4 = NULL;
  9830. PyObject *__pyx_t_5 = NULL;
  9831. PyObject *__pyx_t_6 = NULL;
  9832. __Pyx_RefNannySetupContext("_txn_abort", 0);
  9833. __Pyx_TraceCall("_txn_abort", __pyx_f[0], 641, 0, __PYX_ERR(0, 641, __pyx_L1_error));
  9834. /* "lakesuperior/store/base_lmdb_store.pyx":642
  9835. *
  9836. * cdef void _txn_abort(self) except *:
  9837. * txid = '{:x}'.format(<unsigned long>self.txn) # <<<<<<<<<<<<<<
  9838. * lmdb.mdb_txn_abort(self.txn)
  9839. * self.is_txn_open = False
  9840. */
  9841. __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)
  9842. __Pyx_GOTREF(__pyx_t_2);
  9843. __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)
  9844. __Pyx_GOTREF(__pyx_t_3);
  9845. __pyx_t_4 = NULL;
  9846. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  9847. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
  9848. if (likely(__pyx_t_4)) {
  9849. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  9850. __Pyx_INCREF(__pyx_t_4);
  9851. __Pyx_INCREF(function);
  9852. __Pyx_DECREF_SET(__pyx_t_2, function);
  9853. }
  9854. }
  9855. if (!__pyx_t_4) {
  9856. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error)
  9857. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9858. __Pyx_GOTREF(__pyx_t_1);
  9859. } else {
  9860. #if CYTHON_FAST_PYCALL
  9861. if (PyFunction_Check(__pyx_t_2)) {
  9862. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9863. __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)
  9864. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9865. __Pyx_GOTREF(__pyx_t_1);
  9866. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9867. } else
  9868. #endif
  9869. #if CYTHON_FAST_PYCCALL
  9870. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  9871. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
  9872. __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)
  9873. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9874. __Pyx_GOTREF(__pyx_t_1);
  9875. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9876. } else
  9877. #endif
  9878. {
  9879. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 642, __pyx_L1_error)
  9880. __Pyx_GOTREF(__pyx_t_5);
  9881. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9882. __Pyx_GIVEREF(__pyx_t_3);
  9883. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
  9884. __pyx_t_3 = 0;
  9885. __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)
  9886. __Pyx_GOTREF(__pyx_t_1);
  9887. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  9888. }
  9889. }
  9890. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9891. __pyx_v_txid = __pyx_t_1;
  9892. __pyx_t_1 = 0;
  9893. /* "lakesuperior/store/base_lmdb_store.pyx":643
  9894. * cdef void _txn_abort(self) except *:
  9895. * txid = '{:x}'.format(<unsigned long>self.txn)
  9896. * lmdb.mdb_txn_abort(self.txn) # <<<<<<<<<<<<<<
  9897. * self.is_txn_open = False
  9898. * self.is_txn_rw = False
  9899. */
  9900. mdb_txn_abort(__pyx_v_self->txn);
  9901. /* "lakesuperior/store/base_lmdb_store.pyx":644
  9902. * txid = '{:x}'.format(<unsigned long>self.txn)
  9903. * lmdb.mdb_txn_abort(self.txn)
  9904. * self.is_txn_open = False # <<<<<<<<<<<<<<
  9905. * self.is_txn_rw = False
  9906. * logger.info('Transaction @ {} aborted.'.format(txid))
  9907. */
  9908. __pyx_v_self->is_txn_open = 0;
  9909. /* "lakesuperior/store/base_lmdb_store.pyx":645
  9910. * lmdb.mdb_txn_abort(self.txn)
  9911. * self.is_txn_open = False
  9912. * self.is_txn_rw = False # <<<<<<<<<<<<<<
  9913. * logger.info('Transaction @ {} aborted.'.format(txid))
  9914. *
  9915. */
  9916. if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_txn_rw, Py_False) < 0) __PYX_ERR(0, 645, __pyx_L1_error)
  9917. /* "lakesuperior/store/base_lmdb_store.pyx":646
  9918. * self.is_txn_open = False
  9919. * self.is_txn_rw = False
  9920. * logger.info('Transaction @ {} aborted.'.format(txid)) # <<<<<<<<<<<<<<
  9921. *
  9922. *
  9923. */
  9924. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
  9925. __Pyx_GOTREF(__pyx_t_2);
  9926. __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)
  9927. __Pyx_GOTREF(__pyx_t_5);
  9928. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9929. __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)
  9930. __Pyx_GOTREF(__pyx_t_3);
  9931. __pyx_t_4 = NULL;
  9932. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  9933. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  9934. if (likely(__pyx_t_4)) {
  9935. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  9936. __Pyx_INCREF(__pyx_t_4);
  9937. __Pyx_INCREF(function);
  9938. __Pyx_DECREF_SET(__pyx_t_3, function);
  9939. }
  9940. }
  9941. if (!__pyx_t_4) {
  9942. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_txid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
  9943. __Pyx_GOTREF(__pyx_t_2);
  9944. } else {
  9945. #if CYTHON_FAST_PYCALL
  9946. if (PyFunction_Check(__pyx_t_3)) {
  9947. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9948. __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)
  9949. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9950. __Pyx_GOTREF(__pyx_t_2);
  9951. } else
  9952. #endif
  9953. #if CYTHON_FAST_PYCCALL
  9954. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  9955. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_txid};
  9956. __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)
  9957. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  9958. __Pyx_GOTREF(__pyx_t_2);
  9959. } else
  9960. #endif
  9961. {
  9962. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 646, __pyx_L1_error)
  9963. __Pyx_GOTREF(__pyx_t_6);
  9964. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  9965. __Pyx_INCREF(__pyx_v_txid);
  9966. __Pyx_GIVEREF(__pyx_v_txid);
  9967. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_txid);
  9968. __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)
  9969. __Pyx_GOTREF(__pyx_t_2);
  9970. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  9971. }
  9972. }
  9973. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9974. __pyx_t_3 = NULL;
  9975. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  9976. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
  9977. if (likely(__pyx_t_3)) {
  9978. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  9979. __Pyx_INCREF(__pyx_t_3);
  9980. __Pyx_INCREF(function);
  9981. __Pyx_DECREF_SET(__pyx_t_5, function);
  9982. }
  9983. }
  9984. if (!__pyx_t_3) {
  9985. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
  9986. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9987. __Pyx_GOTREF(__pyx_t_1);
  9988. } else {
  9989. #if CYTHON_FAST_PYCALL
  9990. if (PyFunction_Check(__pyx_t_5)) {
  9991. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  9992. __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)
  9993. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9994. __Pyx_GOTREF(__pyx_t_1);
  9995. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9996. } else
  9997. #endif
  9998. #if CYTHON_FAST_PYCCALL
  9999. if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
  10000. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  10001. __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)
  10002. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  10003. __Pyx_GOTREF(__pyx_t_1);
  10004. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  10005. } else
  10006. #endif
  10007. {
  10008. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 646, __pyx_L1_error)
  10009. __Pyx_GOTREF(__pyx_t_6);
  10010. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
  10011. __Pyx_GIVEREF(__pyx_t_2);
  10012. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_2);
  10013. __pyx_t_2 = 0;
  10014. __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)
  10015. __Pyx_GOTREF(__pyx_t_1);
  10016. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10017. }
  10018. }
  10019. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10020. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10021. /* "lakesuperior/store/base_lmdb_store.pyx":641
  10022. *
  10023. *
  10024. * cdef void _txn_abort(self) except *: # <<<<<<<<<<<<<<
  10025. * txid = '{:x}'.format(<unsigned long>self.txn)
  10026. * lmdb.mdb_txn_abort(self.txn)
  10027. */
  10028. /* function exit code */
  10029. goto __pyx_L0;
  10030. __pyx_L1_error:;
  10031. __Pyx_XDECREF(__pyx_t_1);
  10032. __Pyx_XDECREF(__pyx_t_2);
  10033. __Pyx_XDECREF(__pyx_t_3);
  10034. __Pyx_XDECREF(__pyx_t_4);
  10035. __Pyx_XDECREF(__pyx_t_5);
  10036. __Pyx_XDECREF(__pyx_t_6);
  10037. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_abort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10038. __pyx_L0:;
  10039. __Pyx_XDECREF(__pyx_v_txid);
  10040. __Pyx_TraceReturn(Py_None, 0);
  10041. __Pyx_RefNannyFinishContext();
  10042. }
  10043. /* "lakesuperior/store/base_lmdb_store.pyx":649
  10044. *
  10045. *
  10046. * cpdef int txn_id(self): # <<<<<<<<<<<<<<
  10047. * return self._txn_id()
  10048. *
  10049. */
  10050. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  10051. 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) {
  10052. int __pyx_r;
  10053. __Pyx_TraceDeclarations
  10054. __Pyx_RefNannyDeclarations
  10055. PyObject *__pyx_t_1 = NULL;
  10056. PyObject *__pyx_t_2 = NULL;
  10057. PyObject *__pyx_t_3 = NULL;
  10058. PyObject *__pyx_t_4 = NULL;
  10059. int __pyx_t_5;
  10060. size_t __pyx_t_6;
  10061. __Pyx_RefNannySetupContext("txn_id", 0);
  10062. __Pyx_TraceCall("txn_id", __pyx_f[0], 649, 0, __PYX_ERR(0, 649, __pyx_L1_error));
  10063. /* Check if called by wrapper */
  10064. if (unlikely(__pyx_skip_dispatch)) ;
  10065. /* Check if overridden in Python */
  10066. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  10067. __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)
  10068. __Pyx_GOTREF(__pyx_t_1);
  10069. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id)) {
  10070. __Pyx_INCREF(__pyx_t_1);
  10071. __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
  10072. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  10073. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  10074. if (likely(__pyx_t_4)) {
  10075. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  10076. __Pyx_INCREF(__pyx_t_4);
  10077. __Pyx_INCREF(function);
  10078. __Pyx_DECREF_SET(__pyx_t_3, function);
  10079. }
  10080. }
  10081. if (__pyx_t_4) {
  10082. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error)
  10083. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10084. } else {
  10085. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error)
  10086. }
  10087. __Pyx_GOTREF(__pyx_t_2);
  10088. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  10089. __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)
  10090. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  10091. __pyx_r = __pyx_t_5;
  10092. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10093. goto __pyx_L0;
  10094. }
  10095. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10096. }
  10097. /* "lakesuperior/store/base_lmdb_store.pyx":650
  10098. *
  10099. * cpdef int txn_id(self):
  10100. * return self._txn_id() # <<<<<<<<<<<<<<
  10101. *
  10102. *
  10103. */
  10104. __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)
  10105. __pyx_r = __pyx_t_6;
  10106. goto __pyx_L0;
  10107. /* "lakesuperior/store/base_lmdb_store.pyx":649
  10108. *
  10109. *
  10110. * cpdef int txn_id(self): # <<<<<<<<<<<<<<
  10111. * return self._txn_id()
  10112. *
  10113. */
  10114. /* function exit code */
  10115. __pyx_L1_error:;
  10116. __Pyx_XDECREF(__pyx_t_1);
  10117. __Pyx_XDECREF(__pyx_t_2);
  10118. __Pyx_XDECREF(__pyx_t_3);
  10119. __Pyx_XDECREF(__pyx_t_4);
  10120. __Pyx_WriteUnraisable("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_id", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  10121. __pyx_r = 0;
  10122. __pyx_L0:;
  10123. __Pyx_TraceReturn(Py_None, 0);
  10124. __Pyx_RefNannyFinishContext();
  10125. return __pyx_r;
  10126. }
  10127. /* Python wrapper */
  10128. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  10129. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  10130. PyObject *__pyx_r = 0;
  10131. __Pyx_RefNannyDeclarations
  10132. __Pyx_RefNannySetupContext("txn_id (wrapper)", 0);
  10133. __pyx_r = __pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_31txn_id(((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)__pyx_v_self));
  10134. /* function exit code */
  10135. __Pyx_RefNannyFinishContext();
  10136. return __pyx_r;
  10137. }
  10138. static PyObject *__pyx_pf_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_31txn_id(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *__pyx_v_self) {
  10139. PyObject *__pyx_r = NULL;
  10140. __Pyx_TraceDeclarations
  10141. __Pyx_RefNannyDeclarations
  10142. PyObject *__pyx_t_1 = NULL;
  10143. __Pyx_RefNannySetupContext("txn_id", 0);
  10144. __Pyx_TraceCall("txn_id (wrapper)", __pyx_f[0], 649, 0, __PYX_ERR(0, 649, __pyx_L1_error));
  10145. __Pyx_XDECREF(__pyx_r);
  10146. __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)
  10147. __Pyx_GOTREF(__pyx_t_1);
  10148. __pyx_r = __pyx_t_1;
  10149. __pyx_t_1 = 0;
  10150. goto __pyx_L0;
  10151. /* function exit code */
  10152. __pyx_L1_error:;
  10153. __Pyx_XDECREF(__pyx_t_1);
  10154. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.txn_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10155. __pyx_r = NULL;
  10156. __pyx_L0:;
  10157. __Pyx_XGIVEREF(__pyx_r);
  10158. __Pyx_TraceReturn(__pyx_r, 0);
  10159. __Pyx_RefNannyFinishContext();
  10160. return __pyx_r;
  10161. }
  10162. /* "lakesuperior/store/base_lmdb_store.pyx":653
  10163. *
  10164. *
  10165. * cdef size_t _txn_id(self) except -1: # <<<<<<<<<<<<<<
  10166. * return lmdb.mdb_txn_id(self.txn)
  10167. *
  10168. */
  10169. 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) {
  10170. size_t __pyx_r;
  10171. __Pyx_TraceDeclarations
  10172. __Pyx_RefNannyDeclarations
  10173. __Pyx_RefNannySetupContext("_txn_id", 0);
  10174. __Pyx_TraceCall("_txn_id", __pyx_f[0], 653, 0, __PYX_ERR(0, 653, __pyx_L1_error));
  10175. /* "lakesuperior/store/base_lmdb_store.pyx":654
  10176. *
  10177. * cdef size_t _txn_id(self) except -1:
  10178. * return lmdb.mdb_txn_id(self.txn) # <<<<<<<<<<<<<<
  10179. *
  10180. *
  10181. */
  10182. __pyx_r = mdb_txn_id(__pyx_v_self->txn);
  10183. goto __pyx_L0;
  10184. /* "lakesuperior/store/base_lmdb_store.pyx":653
  10185. *
  10186. *
  10187. * cdef size_t _txn_id(self) except -1: # <<<<<<<<<<<<<<
  10188. * return lmdb.mdb_txn_id(self.txn)
  10189. *
  10190. */
  10191. /* function exit code */
  10192. __pyx_L1_error:;
  10193. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._txn_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10194. __pyx_r = -1L;
  10195. __pyx_L0:;
  10196. __Pyx_TraceReturn(Py_None, 0);
  10197. __Pyx_RefNannyFinishContext();
  10198. return __pyx_r;
  10199. }
  10200. /* "lakesuperior/store/base_lmdb_store.pyx":657
  10201. *
  10202. *
  10203. * cdef lmdb.MDB_dbi get_dbi( # <<<<<<<<<<<<<<
  10204. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL):
  10205. * """
  10206. */
  10207. 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) {
  10208. /* "lakesuperior/store/base_lmdb_store.pyx":658
  10209. *
  10210. * cdef lmdb.MDB_dbi get_dbi(
  10211. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL): # <<<<<<<<<<<<<<
  10212. * """
  10213. * Return a DB handle by database name.
  10214. */
  10215. unsigned char *__pyx_v_dblabel = ((unsigned char *)NULL);
  10216. MDB_txn *__pyx_v_txn = ((MDB_txn *)NULL);
  10217. size_t __pyx_v_dbidx;
  10218. MDB_dbi __pyx_r;
  10219. __Pyx_TraceDeclarations
  10220. __Pyx_RefNannyDeclarations
  10221. int __pyx_t_1;
  10222. MDB_txn *__pyx_t_2;
  10223. PyObject *__pyx_t_3 = NULL;
  10224. PyObject *__pyx_t_4 = NULL;
  10225. size_t __pyx_t_5;
  10226. PyObject *__pyx_t_6 = NULL;
  10227. PyObject *__pyx_t_7 = NULL;
  10228. PyObject *__pyx_t_8 = NULL;
  10229. size_t __pyx_t_9;
  10230. __Pyx_RefNannySetupContext("get_dbi", 0);
  10231. __Pyx_TraceCall("get_dbi", __pyx_f[0], 657, 0, __PYX_ERR(0, 657, __pyx_L1_error));
  10232. if (__pyx_optional_args) {
  10233. if (__pyx_optional_args->__pyx_n > 0) {
  10234. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  10235. if (__pyx_optional_args->__pyx_n > 1) {
  10236. __pyx_v_txn = __pyx_optional_args->txn;
  10237. }
  10238. }
  10239. }
  10240. /* "lakesuperior/store/base_lmdb_store.pyx":664
  10241. * cdef size_t dbidx
  10242. *
  10243. * if txn is NULL: # <<<<<<<<<<<<<<
  10244. * txn = self.txn
  10245. *
  10246. */
  10247. __pyx_t_1 = ((__pyx_v_txn == NULL) != 0);
  10248. if (__pyx_t_1) {
  10249. /* "lakesuperior/store/base_lmdb_store.pyx":665
  10250. *
  10251. * if txn is NULL:
  10252. * txn = self.txn # <<<<<<<<<<<<<<
  10253. *
  10254. * if dblabel is NULL:
  10255. */
  10256. __pyx_t_2 = __pyx_v_self->txn;
  10257. __pyx_v_txn = __pyx_t_2;
  10258. /* "lakesuperior/store/base_lmdb_store.pyx":664
  10259. * cdef size_t dbidx
  10260. *
  10261. * if txn is NULL: # <<<<<<<<<<<<<<
  10262. * txn = self.txn
  10263. *
  10264. */
  10265. }
  10266. /* "lakesuperior/store/base_lmdb_store.pyx":667
  10267. * txn = self.txn
  10268. *
  10269. * if dblabel is NULL: # <<<<<<<<<<<<<<
  10270. * logger.debug('Getting DBI without label.')
  10271. * dbidx = (
  10272. */
  10273. __pyx_t_1 = ((__pyx_v_dblabel == NULL) != 0);
  10274. if (__pyx_t_1) {
  10275. /* "lakesuperior/store/base_lmdb_store.pyx":668
  10276. *
  10277. * if dblabel is NULL:
  10278. * logger.debug('Getting DBI without label.') # <<<<<<<<<<<<<<
  10279. * dbidx = (
  10280. * 0 if dblabel is NULL
  10281. */
  10282. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 668, __pyx_L1_error)
  10283. __Pyx_GOTREF(__pyx_t_3);
  10284. __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)
  10285. __Pyx_GOTREF(__pyx_t_4);
  10286. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  10287. __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)
  10288. __Pyx_GOTREF(__pyx_t_3);
  10289. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10290. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  10291. /* "lakesuperior/store/base_lmdb_store.pyx":667
  10292. * txn = self.txn
  10293. *
  10294. * if dblabel is NULL: # <<<<<<<<<<<<<<
  10295. * logger.debug('Getting DBI without label.')
  10296. * dbidx = (
  10297. */
  10298. }
  10299. /* "lakesuperior/store/base_lmdb_store.pyx":670
  10300. * logger.debug('Getting DBI without label.')
  10301. * dbidx = (
  10302. * 0 if dblabel is NULL # <<<<<<<<<<<<<<
  10303. * else self.dbi_labels.index(dblabel.decode()))
  10304. * #logger.debug(
  10305. */
  10306. if (((__pyx_v_dblabel == NULL) != 0)) {
  10307. __pyx_t_5 = 0;
  10308. } else {
  10309. /* "lakesuperior/store/base_lmdb_store.pyx":671
  10310. * dbidx = (
  10311. * 0 if dblabel is NULL
  10312. * else self.dbi_labels.index(dblabel.decode())) # <<<<<<<<<<<<<<
  10313. * #logger.debug(
  10314. * # f'Got DBI {self.dbis[dbidx]} with label {dblabel} '
  10315. */
  10316. __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)
  10317. __Pyx_GOTREF(__pyx_t_4);
  10318. __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)
  10319. __Pyx_GOTREF(__pyx_t_6);
  10320. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10321. __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)
  10322. __Pyx_GOTREF(__pyx_t_4);
  10323. __pyx_t_7 = NULL;
  10324. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  10325. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  10326. if (likely(__pyx_t_7)) {
  10327. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  10328. __Pyx_INCREF(__pyx_t_7);
  10329. __Pyx_INCREF(function);
  10330. __Pyx_DECREF_SET(__pyx_t_6, function);
  10331. }
  10332. }
  10333. if (!__pyx_t_7) {
  10334. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 671, __pyx_L1_error)
  10335. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10336. __Pyx_GOTREF(__pyx_t_3);
  10337. } else {
  10338. #if CYTHON_FAST_PYCALL
  10339. if (PyFunction_Check(__pyx_t_6)) {
  10340. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
  10341. __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)
  10342. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  10343. __Pyx_GOTREF(__pyx_t_3);
  10344. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10345. } else
  10346. #endif
  10347. #if CYTHON_FAST_PYCCALL
  10348. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  10349. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
  10350. __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)
  10351. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  10352. __Pyx_GOTREF(__pyx_t_3);
  10353. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  10354. } else
  10355. #endif
  10356. {
  10357. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 671, __pyx_L1_error)
  10358. __Pyx_GOTREF(__pyx_t_8);
  10359. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
  10360. __Pyx_GIVEREF(__pyx_t_4);
  10361. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4);
  10362. __pyx_t_4 = 0;
  10363. __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)
  10364. __Pyx_GOTREF(__pyx_t_3);
  10365. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  10366. }
  10367. }
  10368. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10369. __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)
  10370. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  10371. __pyx_t_5 = __pyx_t_9;
  10372. }
  10373. __pyx_v_dbidx = __pyx_t_5;
  10374. /* "lakesuperior/store/base_lmdb_store.pyx":676
  10375. * # f'and index #{dbidx}')
  10376. *
  10377. * return self.dbis[dbidx] # <<<<<<<<<<<<<<
  10378. *
  10379. *
  10380. */
  10381. __pyx_r = (__pyx_v_self->dbis[__pyx_v_dbidx]);
  10382. goto __pyx_L0;
  10383. /* "lakesuperior/store/base_lmdb_store.pyx":657
  10384. *
  10385. *
  10386. * cdef lmdb.MDB_dbi get_dbi( # <<<<<<<<<<<<<<
  10387. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL):
  10388. * """
  10389. */
  10390. /* function exit code */
  10391. __pyx_L1_error:;
  10392. __Pyx_XDECREF(__pyx_t_3);
  10393. __Pyx_XDECREF(__pyx_t_4);
  10394. __Pyx_XDECREF(__pyx_t_6);
  10395. __Pyx_XDECREF(__pyx_t_7);
  10396. __Pyx_XDECREF(__pyx_t_8);
  10397. __Pyx_WriteUnraisable("lakesuperior.store.base_lmdb_store.BaseLmdbStore.get_dbi", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  10398. __pyx_r = 0;
  10399. __pyx_L0:;
  10400. __Pyx_TraceReturn(Py_None, 0);
  10401. __Pyx_RefNannyFinishContext();
  10402. return __pyx_r;
  10403. }
  10404. /* "lakesuperior/store/base_lmdb_store.pyx":679
  10405. *
  10406. *
  10407. * cdef lmdb.MDB_cursor *_cur_open( # <<<<<<<<<<<<<<
  10408. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL) except *:
  10409. * cdef:
  10410. */
  10411. 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) {
  10412. /* "lakesuperior/store/base_lmdb_store.pyx":680
  10413. *
  10414. * cdef lmdb.MDB_cursor *_cur_open(
  10415. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL) except *: # <<<<<<<<<<<<<<
  10416. * cdef:
  10417. * lmdb.MDB_dbi dbi
  10418. */
  10419. unsigned char *__pyx_v_dblabel = ((unsigned char *)NULL);
  10420. MDB_txn *__pyx_v_txn = ((MDB_txn *)NULL);
  10421. MDB_dbi __pyx_v_dbi;
  10422. MDB_cursor *__pyx_r;
  10423. __Pyx_TraceDeclarations
  10424. __Pyx_RefNannyDeclarations
  10425. int __pyx_t_1;
  10426. MDB_txn *__pyx_t_2;
  10427. MDB_dbi __pyx_t_3;
  10428. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_get_dbi __pyx_t_4;
  10429. PyObject *__pyx_t_5 = NULL;
  10430. PyObject *__pyx_t_6 = NULL;
  10431. PyObject *__pyx_t_7 = NULL;
  10432. Py_ssize_t __pyx_t_8;
  10433. Py_UCS4 __pyx_t_9;
  10434. PyObject *__pyx_t_10 = NULL;
  10435. PyObject *__pyx_t_11 = NULL;
  10436. struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store__check __pyx_t_12;
  10437. PyObject *__pyx_t_13 = NULL;
  10438. PyObject *__pyx_t_14 = NULL;
  10439. __Pyx_RefNannySetupContext("_cur_open", 0);
  10440. __Pyx_TraceCall("_cur_open", __pyx_f[0], 679, 0, __PYX_ERR(0, 679, __pyx_L1_error));
  10441. if (__pyx_optional_args) {
  10442. if (__pyx_optional_args->__pyx_n > 0) {
  10443. __pyx_v_dblabel = __pyx_optional_args->dblabel;
  10444. if (__pyx_optional_args->__pyx_n > 1) {
  10445. __pyx_v_txn = __pyx_optional_args->txn;
  10446. }
  10447. }
  10448. }
  10449. /* "lakesuperior/store/base_lmdb_store.pyx":684
  10450. * lmdb.MDB_dbi dbi
  10451. *
  10452. * if txn is NULL: # <<<<<<<<<<<<<<
  10453. * txn = self.txn
  10454. *
  10455. */
  10456. __pyx_t_1 = ((__pyx_v_txn == NULL) != 0);
  10457. if (__pyx_t_1) {
  10458. /* "lakesuperior/store/base_lmdb_store.pyx":685
  10459. *
  10460. * if txn is NULL:
  10461. * txn = self.txn # <<<<<<<<<<<<<<
  10462. *
  10463. * dbi = self.get_dbi(dblabel, txn=txn)
  10464. */
  10465. __pyx_t_2 = __pyx_v_self->txn;
  10466. __pyx_v_txn = __pyx_t_2;
  10467. /* "lakesuperior/store/base_lmdb_store.pyx":684
  10468. * lmdb.MDB_dbi dbi
  10469. *
  10470. * if txn is NULL: # <<<<<<<<<<<<<<
  10471. * txn = self.txn
  10472. *
  10473. */
  10474. }
  10475. /* "lakesuperior/store/base_lmdb_store.pyx":687
  10476. * txn = self.txn
  10477. *
  10478. * dbi = self.get_dbi(dblabel, txn=txn) # <<<<<<<<<<<<<<
  10479. *
  10480. * logger.debug(f'Opening cursor for DB {dblabel} (DBI {dbi})...')
  10481. */
  10482. __pyx_t_4.__pyx_n = 2;
  10483. __pyx_t_4.dblabel = __pyx_v_dblabel;
  10484. __pyx_t_4.txn = __pyx_v_txn;
  10485. __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);
  10486. __pyx_v_dbi = __pyx_t_3;
  10487. /* "lakesuperior/store/base_lmdb_store.pyx":689
  10488. * dbi = self.get_dbi(dblabel, txn=txn)
  10489. *
  10490. * logger.debug(f'Opening cursor for DB {dblabel} (DBI {dbi})...') # <<<<<<<<<<<<<<
  10491. * #try:
  10492. * # # FIXME Either reuse the cursor, if it works, or remove this code.
  10493. */
  10494. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 689, __pyx_L1_error)
  10495. __Pyx_GOTREF(__pyx_t_6);
  10496. __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)
  10497. __Pyx_GOTREF(__pyx_t_7);
  10498. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10499. __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 689, __pyx_L1_error)
  10500. __Pyx_GOTREF(__pyx_t_6);
  10501. __pyx_t_8 = 0;
  10502. __pyx_t_9 = 127;
  10503. __Pyx_INCREF(__pyx_kp_u_Opening_cursor_for_DB);
  10504. __pyx_t_8 += 22;
  10505. __Pyx_GIVEREF(__pyx_kp_u_Opening_cursor_for_DB);
  10506. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_Opening_cursor_for_DB);
  10507. __pyx_t_10 = __Pyx_PyBytes_FromCString(__pyx_v_dblabel); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 689, __pyx_L1_error)
  10508. __Pyx_GOTREF(__pyx_t_10);
  10509. __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_t_10, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L1_error)
  10510. __Pyx_GOTREF(__pyx_t_11);
  10511. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10512. __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;
  10513. __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11);
  10514. __Pyx_GIVEREF(__pyx_t_11);
  10515. PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_11);
  10516. __pyx_t_11 = 0;
  10517. __Pyx_INCREF(__pyx_kp_u_DBI);
  10518. __pyx_t_8 += 6;
  10519. __Pyx_GIVEREF(__pyx_kp_u_DBI);
  10520. PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u_DBI);
  10521. __pyx_t_11 = __Pyx_PyInt_From_MDB_dbi(__pyx_v_dbi); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L1_error)
  10522. __Pyx_GOTREF(__pyx_t_11);
  10523. __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_t_11, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 689, __pyx_L1_error)
  10524. __Pyx_GOTREF(__pyx_t_10);
  10525. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  10526. __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;
  10527. __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10);
  10528. __Pyx_GIVEREF(__pyx_t_10);
  10529. PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_10);
  10530. __pyx_t_10 = 0;
  10531. __Pyx_INCREF(__pyx_kp_u__20);
  10532. __pyx_t_8 += 4;
  10533. __Pyx_GIVEREF(__pyx_kp_u__20);
  10534. PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_kp_u__20);
  10535. __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)
  10536. __Pyx_GOTREF(__pyx_t_10);
  10537. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10538. __pyx_t_6 = NULL;
  10539. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
  10540. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
  10541. if (likely(__pyx_t_6)) {
  10542. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  10543. __Pyx_INCREF(__pyx_t_6);
  10544. __Pyx_INCREF(function);
  10545. __Pyx_DECREF_SET(__pyx_t_7, function);
  10546. }
  10547. }
  10548. if (!__pyx_t_6) {
  10549. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error)
  10550. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10551. __Pyx_GOTREF(__pyx_t_5);
  10552. } else {
  10553. #if CYTHON_FAST_PYCALL
  10554. if (PyFunction_Check(__pyx_t_7)) {
  10555. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  10556. __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)
  10557. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  10558. __Pyx_GOTREF(__pyx_t_5);
  10559. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10560. } else
  10561. #endif
  10562. #if CYTHON_FAST_PYCCALL
  10563. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  10564. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
  10565. __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)
  10566. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  10567. __Pyx_GOTREF(__pyx_t_5);
  10568. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10569. } else
  10570. #endif
  10571. {
  10572. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L1_error)
  10573. __Pyx_GOTREF(__pyx_t_11);
  10574. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
  10575. __Pyx_GIVEREF(__pyx_t_10);
  10576. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_10);
  10577. __pyx_t_10 = 0;
  10578. __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)
  10579. __Pyx_GOTREF(__pyx_t_5);
  10580. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  10581. }
  10582. }
  10583. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10584. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10585. /* "lakesuperior/store/base_lmdb_store.pyx":701
  10586. * _check(
  10587. * lmdb.mdb_cursor_open(txn, dbi, self.curs + dbi),
  10588. * f'Error opening cursor: {dblabel}') # <<<<<<<<<<<<<<
  10589. * logger.debug('...opened @ {:x}.'.format(<unsigned long>self.curs[dbi]))
  10590. *
  10591. */
  10592. __pyx_t_5 = __Pyx_PyBytes_FromCString(__pyx_v_dblabel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 701, __pyx_L1_error)
  10593. __Pyx_GOTREF(__pyx_t_5);
  10594. __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 701, __pyx_L1_error)
  10595. __Pyx_GOTREF(__pyx_t_7);
  10596. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10597. __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)
  10598. __Pyx_GOTREF(__pyx_t_5);
  10599. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10600. /* "lakesuperior/store/base_lmdb_store.pyx":699
  10601. * # f'Error opening cursor: {dblabel}')
  10602. * # logger.debug(f'Created brand new cursor for DBI {dbi}.')
  10603. * _check( # <<<<<<<<<<<<<<
  10604. * lmdb.mdb_cursor_open(txn, dbi, self.curs + dbi),
  10605. * f'Error opening cursor: {dblabel}')
  10606. */
  10607. __pyx_t_12.__pyx_n = 1;
  10608. __pyx_t_12.message = ((PyObject*)__pyx_t_5);
  10609. __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)
  10610. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10611. /* "lakesuperior/store/base_lmdb_store.pyx":702
  10612. * lmdb.mdb_cursor_open(txn, dbi, self.curs + dbi),
  10613. * f'Error opening cursor: {dblabel}')
  10614. * logger.debug('...opened @ {:x}.'.format(<unsigned long>self.curs[dbi])) # <<<<<<<<<<<<<<
  10615. *
  10616. * return self.curs[dbi]
  10617. */
  10618. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 702, __pyx_L1_error)
  10619. __Pyx_GOTREF(__pyx_t_7);
  10620. __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)
  10621. __Pyx_GOTREF(__pyx_t_11);
  10622. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10623. __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)
  10624. __Pyx_GOTREF(__pyx_t_10);
  10625. __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)
  10626. __Pyx_GOTREF(__pyx_t_6);
  10627. __pyx_t_13 = NULL;
  10628. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
  10629. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10);
  10630. if (likely(__pyx_t_13)) {
  10631. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  10632. __Pyx_INCREF(__pyx_t_13);
  10633. __Pyx_INCREF(function);
  10634. __Pyx_DECREF_SET(__pyx_t_10, function);
  10635. }
  10636. }
  10637. if (!__pyx_t_13) {
  10638. __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 702, __pyx_L1_error)
  10639. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10640. __Pyx_GOTREF(__pyx_t_7);
  10641. } else {
  10642. #if CYTHON_FAST_PYCALL
  10643. if (PyFunction_Check(__pyx_t_10)) {
  10644. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  10645. __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)
  10646. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  10647. __Pyx_GOTREF(__pyx_t_7);
  10648. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10649. } else
  10650. #endif
  10651. #if CYTHON_FAST_PYCCALL
  10652. if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
  10653. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_6};
  10654. __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)
  10655. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  10656. __Pyx_GOTREF(__pyx_t_7);
  10657. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  10658. } else
  10659. #endif
  10660. {
  10661. __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 702, __pyx_L1_error)
  10662. __Pyx_GOTREF(__pyx_t_14);
  10663. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
  10664. __Pyx_GIVEREF(__pyx_t_6);
  10665. PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_6);
  10666. __pyx_t_6 = 0;
  10667. __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)
  10668. __Pyx_GOTREF(__pyx_t_7);
  10669. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  10670. }
  10671. }
  10672. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  10673. __pyx_t_10 = NULL;
  10674. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
  10675. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
  10676. if (likely(__pyx_t_10)) {
  10677. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
  10678. __Pyx_INCREF(__pyx_t_10);
  10679. __Pyx_INCREF(function);
  10680. __Pyx_DECREF_SET(__pyx_t_11, function);
  10681. }
  10682. }
  10683. if (!__pyx_t_10) {
  10684. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 702, __pyx_L1_error)
  10685. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10686. __Pyx_GOTREF(__pyx_t_5);
  10687. } else {
  10688. #if CYTHON_FAST_PYCALL
  10689. if (PyFunction_Check(__pyx_t_11)) {
  10690. PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_7};
  10691. __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)
  10692. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  10693. __Pyx_GOTREF(__pyx_t_5);
  10694. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10695. } else
  10696. #endif
  10697. #if CYTHON_FAST_PYCCALL
  10698. if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
  10699. PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_7};
  10700. __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)
  10701. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  10702. __Pyx_GOTREF(__pyx_t_5);
  10703. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  10704. } else
  10705. #endif
  10706. {
  10707. __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 702, __pyx_L1_error)
  10708. __Pyx_GOTREF(__pyx_t_14);
  10709. __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_10); __pyx_t_10 = NULL;
  10710. __Pyx_GIVEREF(__pyx_t_7);
  10711. PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_7);
  10712. __pyx_t_7 = 0;
  10713. __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)
  10714. __Pyx_GOTREF(__pyx_t_5);
  10715. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  10716. }
  10717. }
  10718. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  10719. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  10720. /* "lakesuperior/store/base_lmdb_store.pyx":704
  10721. * logger.debug('...opened @ {:x}.'.format(<unsigned long>self.curs[dbi]))
  10722. *
  10723. * return self.curs[dbi] # <<<<<<<<<<<<<<
  10724. *
  10725. *
  10726. */
  10727. __pyx_r = (__pyx_v_self->curs[__pyx_v_dbi]);
  10728. goto __pyx_L0;
  10729. /* "lakesuperior/store/base_lmdb_store.pyx":679
  10730. *
  10731. *
  10732. * cdef lmdb.MDB_cursor *_cur_open( # <<<<<<<<<<<<<<
  10733. * self, unsigned char *dblabel=NULL, lmdb.MDB_txn *txn=NULL) except *:
  10734. * cdef:
  10735. */
  10736. /* function exit code */
  10737. __pyx_L1_error:;
  10738. __Pyx_XDECREF(__pyx_t_5);
  10739. __Pyx_XDECREF(__pyx_t_6);
  10740. __Pyx_XDECREF(__pyx_t_7);
  10741. __Pyx_XDECREF(__pyx_t_10);
  10742. __Pyx_XDECREF(__pyx_t_11);
  10743. __Pyx_XDECREF(__pyx_t_13);
  10744. __Pyx_XDECREF(__pyx_t_14);
  10745. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._cur_open", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10746. __pyx_r = 0;
  10747. __pyx_L0:;
  10748. __Pyx_TraceReturn(Py_None, 0);
  10749. __Pyx_RefNannyFinishContext();
  10750. return __pyx_r;
  10751. }
  10752. /* "lakesuperior/store/base_lmdb_store.pyx":707
  10753. *
  10754. *
  10755. * cdef void _cur_close(self, lmdb.MDB_cursor *cur) except *: # <<<<<<<<<<<<<<
  10756. * """Close a cursor."""
  10757. * #logger.info('Closing cursor @ {:x} for DBI {}...'.format(
  10758. */
  10759. 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) {
  10760. __Pyx_TraceDeclarations
  10761. __Pyx_RefNannyDeclarations
  10762. __Pyx_RefNannySetupContext("_cur_close", 0);
  10763. __Pyx_TraceCall("_cur_close", __pyx_f[0], 707, 0, __PYX_ERR(0, 707, __pyx_L1_error));
  10764. /* "lakesuperior/store/base_lmdb_store.pyx":711
  10765. * #logger.info('Closing cursor @ {:x} for DBI {}...'.format(
  10766. * # <unsigned long>cur, lmdb.mdb_cursor_dbi(cur) ))
  10767. * lmdb.mdb_cursor_close(cur) # <<<<<<<<<<<<<<
  10768. * #logger.info('...closed.')
  10769. *
  10770. */
  10771. mdb_cursor_close(__pyx_v_cur);
  10772. /* "lakesuperior/store/base_lmdb_store.pyx":707
  10773. *
  10774. *
  10775. * cdef void _cur_close(self, lmdb.MDB_cursor *cur) except *: # <<<<<<<<<<<<<<
  10776. * """Close a cursor."""
  10777. * #logger.info('Closing cursor @ {:x} for DBI {}...'.format(
  10778. */
  10779. /* function exit code */
  10780. goto __pyx_L0;
  10781. __pyx_L1_error:;
  10782. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._cur_close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10783. __pyx_L0:;
  10784. __Pyx_TraceReturn(Py_None, 0);
  10785. __Pyx_RefNannyFinishContext();
  10786. }
  10787. /* "lakesuperior/store/base_lmdb_store.pxd":15
  10788. * cdef class BaseLmdbStore:
  10789. * cdef:
  10790. * readonly bint is_txn_open # <<<<<<<<<<<<<<
  10791. * public bint _open
  10792. * unsigned int _readers
  10793. */
  10794. /* Python wrapper */
  10795. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open_1__get__(PyObject *__pyx_v_self); /*proto*/
  10796. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open_1__get__(PyObject *__pyx_v_self) {
  10797. PyObject *__pyx_r = 0;
  10798. __Pyx_RefNannyDeclarations
  10799. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  10800. __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));
  10801. /* function exit code */
  10802. __Pyx_RefNannyFinishContext();
  10803. return __pyx_r;
  10804. }
  10805. 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) {
  10806. PyObject *__pyx_r = NULL;
  10807. __Pyx_TraceDeclarations
  10808. __Pyx_RefNannyDeclarations
  10809. PyObject *__pyx_t_1 = NULL;
  10810. __Pyx_RefNannySetupContext("__get__", 0);
  10811. __Pyx_TraceCall("__get__", __pyx_f[2], 15, 0, __PYX_ERR(2, 15, __pyx_L1_error));
  10812. __Pyx_XDECREF(__pyx_r);
  10813. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_txn_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  10814. __Pyx_GOTREF(__pyx_t_1);
  10815. __pyx_r = __pyx_t_1;
  10816. __pyx_t_1 = 0;
  10817. goto __pyx_L0;
  10818. /* function exit code */
  10819. __pyx_L1_error:;
  10820. __Pyx_XDECREF(__pyx_t_1);
  10821. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.is_txn_open.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10822. __pyx_r = NULL;
  10823. __pyx_L0:;
  10824. __Pyx_XGIVEREF(__pyx_r);
  10825. __Pyx_TraceReturn(__pyx_r, 0);
  10826. __Pyx_RefNannyFinishContext();
  10827. return __pyx_r;
  10828. }
  10829. /* "lakesuperior/store/base_lmdb_store.pxd":16
  10830. * cdef:
  10831. * readonly bint is_txn_open
  10832. * public bint _open # <<<<<<<<<<<<<<
  10833. * unsigned int _readers
  10834. * readonly str env_path
  10835. */
  10836. /* Python wrapper */
  10837. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_1__get__(PyObject *__pyx_v_self); /*proto*/
  10838. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_1__get__(PyObject *__pyx_v_self) {
  10839. PyObject *__pyx_r = 0;
  10840. __Pyx_RefNannyDeclarations
  10841. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  10842. __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));
  10843. /* function exit code */
  10844. __Pyx_RefNannyFinishContext();
  10845. return __pyx_r;
  10846. }
  10847. 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) {
  10848. PyObject *__pyx_r = NULL;
  10849. __Pyx_TraceDeclarations
  10850. __Pyx_RefNannyDeclarations
  10851. PyObject *__pyx_t_1 = NULL;
  10852. __Pyx_RefNannySetupContext("__get__", 0);
  10853. __Pyx_TraceCall("__get__", __pyx_f[2], 16, 0, __PYX_ERR(2, 16, __pyx_L1_error));
  10854. __Pyx_XDECREF(__pyx_r);
  10855. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 16, __pyx_L1_error)
  10856. __Pyx_GOTREF(__pyx_t_1);
  10857. __pyx_r = __pyx_t_1;
  10858. __pyx_t_1 = 0;
  10859. goto __pyx_L0;
  10860. /* function exit code */
  10861. __pyx_L1_error:;
  10862. __Pyx_XDECREF(__pyx_t_1);
  10863. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._open.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10864. __pyx_r = NULL;
  10865. __pyx_L0:;
  10866. __Pyx_XGIVEREF(__pyx_r);
  10867. __Pyx_TraceReturn(__pyx_r, 0);
  10868. __Pyx_RefNannyFinishContext();
  10869. return __pyx_r;
  10870. }
  10871. /* Python wrapper */
  10872. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
  10873. static int __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  10874. int __pyx_r;
  10875. __Pyx_RefNannyDeclarations
  10876. __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  10877. __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));
  10878. /* function exit code */
  10879. __Pyx_RefNannyFinishContext();
  10880. return __pyx_r;
  10881. }
  10882. 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) {
  10883. int __pyx_r;
  10884. __Pyx_TraceDeclarations
  10885. __Pyx_RefNannyDeclarations
  10886. int __pyx_t_1;
  10887. __Pyx_RefNannySetupContext("__set__", 0);
  10888. __Pyx_TraceCall("__set__", __pyx_f[2], 16, 0, __PYX_ERR(2, 16, __pyx_L1_error));
  10889. __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)
  10890. __pyx_v_self->_open = __pyx_t_1;
  10891. /* function exit code */
  10892. __pyx_r = 0;
  10893. goto __pyx_L0;
  10894. __pyx_L1_error:;
  10895. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore._open.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10896. __pyx_r = -1;
  10897. __pyx_L0:;
  10898. __Pyx_TraceReturn(Py_None, 0);
  10899. __Pyx_RefNannyFinishContext();
  10900. return __pyx_r;
  10901. }
  10902. /* "lakesuperior/store/base_lmdb_store.pxd":18
  10903. * public bint _open
  10904. * unsigned int _readers
  10905. * readonly str env_path # <<<<<<<<<<<<<<
  10906. * lmdb.MDB_dbi *dbis
  10907. * lmdb.MDB_env *dbenv
  10908. */
  10909. /* Python wrapper */
  10910. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path_1__get__(PyObject *__pyx_v_self); /*proto*/
  10911. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path_1__get__(PyObject *__pyx_v_self) {
  10912. PyObject *__pyx_r = 0;
  10913. __Pyx_RefNannyDeclarations
  10914. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  10915. __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));
  10916. /* function exit code */
  10917. __Pyx_RefNannyFinishContext();
  10918. return __pyx_r;
  10919. }
  10920. 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) {
  10921. PyObject *__pyx_r = NULL;
  10922. __Pyx_TraceDeclarations
  10923. __Pyx_RefNannyDeclarations
  10924. __Pyx_RefNannySetupContext("__get__", 0);
  10925. __Pyx_TraceCall("__get__", __pyx_f[2], 18, 0, __PYX_ERR(2, 18, __pyx_L1_error));
  10926. __Pyx_XDECREF(__pyx_r);
  10927. __Pyx_INCREF(__pyx_v_self->env_path);
  10928. __pyx_r = __pyx_v_self->env_path;
  10929. goto __pyx_L0;
  10930. /* function exit code */
  10931. __pyx_L1_error:;
  10932. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.env_path.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10933. __pyx_r = NULL;
  10934. __pyx_L0:;
  10935. __Pyx_XGIVEREF(__pyx_r);
  10936. __Pyx_TraceReturn(__pyx_r, 0);
  10937. __Pyx_RefNannyFinishContext();
  10938. return __pyx_r;
  10939. }
  10940. /* "(tree fragment)":1
  10941. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  10942. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10943. * def __setstate_cython__(self, __pyx_state):
  10944. */
  10945. /* Python wrapper */
  10946. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_34__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  10947. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_34__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  10948. PyObject *__pyx_r = 0;
  10949. __Pyx_RefNannyDeclarations
  10950. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  10951. __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));
  10952. /* function exit code */
  10953. __Pyx_RefNannyFinishContext();
  10954. return __pyx_r;
  10955. }
  10956. 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) {
  10957. PyObject *__pyx_r = NULL;
  10958. __Pyx_TraceDeclarations
  10959. __Pyx_RefNannyDeclarations
  10960. PyObject *__pyx_t_1 = NULL;
  10961. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  10962. __Pyx_TraceCall("__reduce_cython__", __pyx_f[1], 1, 0, __PYX_ERR(1, 1, __pyx_L1_error));
  10963. /* "(tree fragment)":2
  10964. * def __reduce_cython__(self):
  10965. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  10966. * def __setstate_cython__(self, __pyx_state):
  10967. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10968. */
  10969. __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)
  10970. __Pyx_GOTREF(__pyx_t_1);
  10971. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  10972. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10973. __PYX_ERR(1, 2, __pyx_L1_error)
  10974. /* "(tree fragment)":1
  10975. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  10976. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10977. * def __setstate_cython__(self, __pyx_state):
  10978. */
  10979. /* function exit code */
  10980. __pyx_L1_error:;
  10981. __Pyx_XDECREF(__pyx_t_1);
  10982. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10983. __pyx_r = NULL;
  10984. __Pyx_XGIVEREF(__pyx_r);
  10985. __Pyx_TraceReturn(__pyx_r, 0);
  10986. __Pyx_RefNannyFinishContext();
  10987. return __pyx_r;
  10988. }
  10989. /* "(tree fragment)":3
  10990. * def __reduce_cython__(self):
  10991. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10992. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  10993. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  10994. */
  10995. /* Python wrapper */
  10996. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_36__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  10997. static PyObject *__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_36__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  10998. PyObject *__pyx_r = 0;
  10999. __Pyx_RefNannyDeclarations
  11000. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  11001. __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));
  11002. /* function exit code */
  11003. __Pyx_RefNannyFinishContext();
  11004. return __pyx_r;
  11005. }
  11006. 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) {
  11007. PyObject *__pyx_r = NULL;
  11008. __Pyx_TraceDeclarations
  11009. __Pyx_RefNannyDeclarations
  11010. PyObject *__pyx_t_1 = NULL;
  11011. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  11012. __Pyx_TraceCall("__setstate_cython__", __pyx_f[1], 3, 0, __PYX_ERR(1, 3, __pyx_L1_error));
  11013. /* "(tree fragment)":4
  11014. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  11015. * def __setstate_cython__(self, __pyx_state):
  11016. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  11017. */
  11018. __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)
  11019. __Pyx_GOTREF(__pyx_t_1);
  11020. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  11021. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11022. __PYX_ERR(1, 4, __pyx_L1_error)
  11023. /* "(tree fragment)":3
  11024. * def __reduce_cython__(self):
  11025. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  11026. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  11027. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  11028. */
  11029. /* function exit code */
  11030. __pyx_L1_error:;
  11031. __Pyx_XDECREF(__pyx_t_1);
  11032. __Pyx_AddTraceback("lakesuperior.store.base_lmdb_store.BaseLmdbStore.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  11033. __pyx_r = NULL;
  11034. __Pyx_XGIVEREF(__pyx_r);
  11035. __Pyx_TraceReturn(__pyx_r, 0);
  11036. __Pyx_RefNannyFinishContext();
  11037. return __pyx_r;
  11038. }
  11039. static struct __pyx_vtabstruct_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  11040. static PyObject *__pyx_tp_new_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  11041. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *p;
  11042. PyObject *o;
  11043. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  11044. o = (*t->tp_alloc)(t, 0);
  11045. } else {
  11046. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  11047. }
  11048. if (unlikely(!o)) return 0;
  11049. p = ((struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)o);
  11050. p->__pyx_vtab = __pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  11051. p->env_path = ((PyObject*)Py_None); Py_INCREF(Py_None);
  11052. return o;
  11053. }
  11054. static void __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore(PyObject *o) {
  11055. struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *p = (struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *)o;
  11056. #if CYTHON_USE_TP_FINALIZE
  11057. 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))) {
  11058. if (PyObject_CallFinalizerFromDealloc(o)) return;
  11059. }
  11060. #endif
  11061. {
  11062. PyObject *etype, *eval, *etb;
  11063. PyErr_Fetch(&etype, &eval, &etb);
  11064. ++Py_REFCNT(o);
  11065. __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_3__dealloc__(o);
  11066. --Py_REFCNT(o);
  11067. PyErr_Restore(etype, eval, etb);
  11068. }
  11069. Py_CLEAR(p->env_path);
  11070. (*Py_TYPE(o)->tp_free)(o);
  11071. }
  11072. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_open(PyObject *o, CYTHON_UNUSED void *x) {
  11073. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7is_open_1__get__(o);
  11074. }
  11075. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_readers(PyObject *o, CYTHON_UNUSED void *x) {
  11076. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7readers_1__get__(o);
  11077. }
  11078. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_txn_open(PyObject *o, CYTHON_UNUSED void *x) {
  11079. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_11is_txn_open_1__get__(o);
  11080. }
  11081. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open(PyObject *o, CYTHON_UNUSED void *x) {
  11082. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_1__get__(o);
  11083. }
  11084. static int __pyx_setprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  11085. if (v) {
  11086. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_5_open_3__set__(o, v);
  11087. }
  11088. else {
  11089. PyErr_SetString(PyExc_NotImplementedError, "__del__");
  11090. return -1;
  11091. }
  11092. }
  11093. static PyObject *__pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_env_path(PyObject *o, CYTHON_UNUSED void *x) {
  11094. return __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8env_path_1__get__(o);
  11095. }
  11096. static PyMethodDef __pyx_methods_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore[] = {
  11097. {"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},
  11098. {"close_env", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_7close_env, METH_VARARGS|METH_KEYWORDS, 0},
  11099. {"destroy", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_9destroy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_8destroy},
  11100. {"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},
  11101. {"begin", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_14begin, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_13begin},
  11102. {"commit", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_16commit, METH_NOARGS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_15commit},
  11103. {"abort", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_18abort, METH_NOARGS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_17abort},
  11104. {"rollback", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_20rollback, METH_NOARGS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_19rollback},
  11105. {"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},
  11106. {"put", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_24put, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_23put},
  11107. {"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},
  11108. {"delete", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_28delete, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_27delete},
  11109. {"stats", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_30stats, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_29stats},
  11110. {"txn_id", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_32txn_id, METH_NOARGS, 0},
  11111. {"__reduce_cython__", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_34__reduce_cython__, METH_NOARGS, 0},
  11112. {"__setstate_cython__", (PyCFunction)__pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_36__setstate_cython__, METH_O, 0},
  11113. {0, 0, 0, 0}
  11114. };
  11115. static struct PyGetSetDef __pyx_getsets_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore[] = {
  11116. {(char *)"is_open", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_open, 0, (char *)0, 0},
  11117. {(char *)"readers", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_readers, 0, (char *)0, 0},
  11118. {(char *)"is_txn_open", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_is_txn_open, 0, (char *)0, 0},
  11119. {(char *)"_open", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open, __pyx_setprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore__open, (char *)0, 0},
  11120. {(char *)"env_path", __pyx_getprop_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_env_path, 0, (char *)0, 0},
  11121. {0, 0, 0, 0, 0}
  11122. };
  11123. static PyTypeObject __pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = {
  11124. PyVarObject_HEAD_INIT(0, 0)
  11125. "lakesuperior.store.base_lmdb_store.BaseLmdbStore", /*tp_name*/
  11126. sizeof(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore), /*tp_basicsize*/
  11127. 0, /*tp_itemsize*/
  11128. __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_dealloc*/
  11129. 0, /*tp_print*/
  11130. 0, /*tp_getattr*/
  11131. 0, /*tp_setattr*/
  11132. #if PY_MAJOR_VERSION < 3
  11133. 0, /*tp_compare*/
  11134. #endif
  11135. #if PY_MAJOR_VERSION >= 3
  11136. 0, /*tp_as_async*/
  11137. #endif
  11138. 0, /*tp_repr*/
  11139. 0, /*tp_as_number*/
  11140. 0, /*tp_as_sequence*/
  11141. 0, /*tp_as_mapping*/
  11142. 0, /*tp_hash*/
  11143. 0, /*tp_call*/
  11144. 0, /*tp_str*/
  11145. 0, /*tp_getattro*/
  11146. 0, /*tp_setattro*/
  11147. 0, /*tp_as_buffer*/
  11148. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  11149. "\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*/
  11150. 0, /*tp_traverse*/
  11151. 0, /*tp_clear*/
  11152. 0, /*tp_richcompare*/
  11153. 0, /*tp_weaklistoffset*/
  11154. 0, /*tp_iter*/
  11155. 0, /*tp_iternext*/
  11156. __pyx_methods_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_methods*/
  11157. 0, /*tp_members*/
  11158. __pyx_getsets_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_getset*/
  11159. 0, /*tp_base*/
  11160. 0, /*tp_dict*/
  11161. 0, /*tp_descr_get*/
  11162. 0, /*tp_descr_set*/
  11163. 0, /*tp_dictoffset*/
  11164. __pyx_pw_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_1__init__, /*tp_init*/
  11165. 0, /*tp_alloc*/
  11166. __pyx_tp_new_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, /*tp_new*/
  11167. 0, /*tp_free*/
  11168. 0, /*tp_is_gc*/
  11169. 0, /*tp_bases*/
  11170. 0, /*tp_mro*/
  11171. 0, /*tp_cache*/
  11172. 0, /*tp_subclasses*/
  11173. 0, /*tp_weaklist*/
  11174. 0, /*tp_del*/
  11175. 0, /*tp_version_tag*/
  11176. #if PY_VERSION_HEX >= 0x030400a1
  11177. 0, /*tp_finalize*/
  11178. #endif
  11179. };
  11180. 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];
  11181. static int __pyx_freecount_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = 0;
  11182. 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) {
  11183. PyObject *o;
  11184. 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)))) {
  11185. 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];
  11186. memset(o, 0, sizeof(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx));
  11187. (void) PyObject_INIT(o, t);
  11188. PyObject_GC_Track(o);
  11189. } else {
  11190. o = (*t->tp_alloc)(t, 0);
  11191. if (unlikely(!o)) return 0;
  11192. }
  11193. return o;
  11194. }
  11195. static void __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx(PyObject *o) {
  11196. 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;
  11197. PyObject_GC_UnTrack(o);
  11198. Py_CLEAR(p->__pyx_v_self);
  11199. Py_CLEAR(p->__pyx_v_write);
  11200. Py_CLEAR(p->__pyx_t_0);
  11201. Py_CLEAR(p->__pyx_t_1);
  11202. Py_CLEAR(p->__pyx_t_2);
  11203. 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)))) {
  11204. __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);
  11205. } else {
  11206. (*Py_TYPE(o)->tp_free)(o);
  11207. }
  11208. }
  11209. static int __pyx_tp_traverse_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx(PyObject *o, visitproc v, void *a) {
  11210. int e;
  11211. 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;
  11212. if (p->__pyx_v_self) {
  11213. e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  11214. }
  11215. if (p->__pyx_v_write) {
  11216. e = (*v)(p->__pyx_v_write, a); if (e) return e;
  11217. }
  11218. if (p->__pyx_t_0) {
  11219. e = (*v)(p->__pyx_t_0, a); if (e) return e;
  11220. }
  11221. if (p->__pyx_t_1) {
  11222. e = (*v)(p->__pyx_t_1, a); if (e) return e;
  11223. }
  11224. if (p->__pyx_t_2) {
  11225. e = (*v)(p->__pyx_t_2, a); if (e) return e;
  11226. }
  11227. return 0;
  11228. }
  11229. static PyTypeObject __pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = {
  11230. PyVarObject_HEAD_INIT(0, 0)
  11231. "lakesuperior.store.base_lmdb_store.__pyx_scope_struct__txn_ctx", /*tp_name*/
  11232. sizeof(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx), /*tp_basicsize*/
  11233. 0, /*tp_itemsize*/
  11234. __pyx_tp_dealloc_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx, /*tp_dealloc*/
  11235. 0, /*tp_print*/
  11236. 0, /*tp_getattr*/
  11237. 0, /*tp_setattr*/
  11238. #if PY_MAJOR_VERSION < 3
  11239. 0, /*tp_compare*/
  11240. #endif
  11241. #if PY_MAJOR_VERSION >= 3
  11242. 0, /*tp_as_async*/
  11243. #endif
  11244. 0, /*tp_repr*/
  11245. 0, /*tp_as_number*/
  11246. 0, /*tp_as_sequence*/
  11247. 0, /*tp_as_mapping*/
  11248. 0, /*tp_hash*/
  11249. 0, /*tp_call*/
  11250. 0, /*tp_str*/
  11251. 0, /*tp_getattro*/
  11252. 0, /*tp_setattro*/
  11253. 0, /*tp_as_buffer*/
  11254. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  11255. 0, /*tp_doc*/
  11256. __pyx_tp_traverse_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx, /*tp_traverse*/
  11257. 0, /*tp_clear*/
  11258. 0, /*tp_richcompare*/
  11259. 0, /*tp_weaklistoffset*/
  11260. 0, /*tp_iter*/
  11261. 0, /*tp_iternext*/
  11262. 0, /*tp_methods*/
  11263. 0, /*tp_members*/
  11264. 0, /*tp_getset*/
  11265. 0, /*tp_base*/
  11266. 0, /*tp_dict*/
  11267. 0, /*tp_descr_get*/
  11268. 0, /*tp_descr_set*/
  11269. 0, /*tp_dictoffset*/
  11270. 0, /*tp_init*/
  11271. 0, /*tp_alloc*/
  11272. __pyx_tp_new_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx, /*tp_new*/
  11273. 0, /*tp_free*/
  11274. 0, /*tp_is_gc*/
  11275. 0, /*tp_bases*/
  11276. 0, /*tp_mro*/
  11277. 0, /*tp_cache*/
  11278. 0, /*tp_subclasses*/
  11279. 0, /*tp_weaklist*/
  11280. 0, /*tp_del*/
  11281. 0, /*tp_version_tag*/
  11282. #if PY_VERSION_HEX >= 0x030400a1
  11283. 0, /*tp_finalize*/
  11284. #endif
  11285. };
  11286. static PyMethodDef __pyx_methods[] = {
  11287. {0, 0, 0, 0}
  11288. };
  11289. #if PY_MAJOR_VERSION >= 3
  11290. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11291. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  11292. static int __pyx_pymod_exec_base_lmdb_store(PyObject* module); /*proto*/
  11293. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  11294. {Py_mod_create, (void*)__pyx_pymod_create},
  11295. {Py_mod_exec, (void*)__pyx_pymod_exec_base_lmdb_store},
  11296. {0, NULL}
  11297. };
  11298. #endif
  11299. static struct PyModuleDef __pyx_moduledef = {
  11300. PyModuleDef_HEAD_INIT,
  11301. "base_lmdb_store",
  11302. 0, /* m_doc */
  11303. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11304. 0, /* m_size */
  11305. #else
  11306. -1, /* m_size */
  11307. #endif
  11308. __pyx_methods /* m_methods */,
  11309. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11310. __pyx_moduledef_slots, /* m_slots */
  11311. #else
  11312. NULL, /* m_reload */
  11313. #endif
  11314. NULL, /* m_traverse */
  11315. NULL, /* m_clear */
  11316. NULL /* m_free */
  11317. };
  11318. #endif
  11319. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  11320. {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
  11321. {&__pyx_n_s_BaseLmdbStore_txn_ctx, __pyx_k_BaseLmdbStore_txn_ctx, sizeof(__pyx_k_BaseLmdbStore_txn_ctx), 0, 0, 1, 1},
  11322. {&__pyx_kp_u_Cleaning_up_store_env, __pyx_k_Cleaning_up_store_env, sizeof(__pyx_k_Cleaning_up_store_env), 0, 1, 0, 0},
  11323. {&__pyx_kp_u_Cleared_stale_readers, __pyx_k_Cleared_stale_readers, sizeof(__pyx_k_Cleared_stale_readers), 0, 1, 0, 0},
  11324. {&__pyx_kp_u_Closing_store_env, __pyx_k_Closing_store_env, sizeof(__pyx_k_Closing_store_env), 0, 1, 0, 0},
  11325. {&__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},
  11326. {&__pyx_kp_u_Created_DB, __pyx_k_Created_DB, sizeof(__pyx_k_Created_DB), 0, 1, 0, 0},
  11327. {&__pyx_kp_u_Created_DBenv_x, __pyx_k_Created_DBenv_x, sizeof(__pyx_k_Created_DBenv_x), 0, 1, 0, 0},
  11328. {&__pyx_kp_u_Creating_DBs, __pyx_k_Creating_DBs, sizeof(__pyx_k_Creating_DBs), 0, 1, 0, 0},
  11329. {&__pyx_kp_u_DBI, __pyx_k_DBI, sizeof(__pyx_k_DBI), 0, 1, 0, 0},
  11330. {&__pyx_kp_u_DBenv_address_x, __pyx_k_DBenv_address_x, sizeof(__pyx_k_DBenv_address_x), 0, 1, 0, 0},
  11331. {&__pyx_kp_u_Environment_already_open, __pyx_k_Environment_already_open, sizeof(__pyx_k_Environment_already_open), 0, 1, 0, 0},
  11332. {&__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},
  11333. {&__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},
  11334. {&__pyx_kp_u_Error_getting_datbase_stats, __pyx_k_Error_getting_datbase_stats, sizeof(__pyx_k_Error_getting_datbase_stats), 0, 1, 0, 0},
  11335. {&__pyx_kp_u_Error_opening_cursor, __pyx_k_Error_opening_cursor, sizeof(__pyx_k_Error_opening_cursor), 0, 1, 0, 0},
  11336. {&__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},
  11337. {&__pyx_kp_u_Error_opening_transaction, __pyx_k_Error_opening_transaction, sizeof(__pyx_k_Error_opening_transaction), 0, 1, 0, 0},
  11338. {&__pyx_kp_u_Error_putting_data, __pyx_k_Error_putting_data, sizeof(__pyx_k_Error_putting_data), 0, 1, 0, 0},
  11339. {&__pyx_kp_u_Error_setting_map_size, __pyx_k_Error_setting_map_size, sizeof(__pyx_k_Error_setting_map_size), 0, 1, 0, 0},
  11340. {&__pyx_kp_u_Error_setting_max_databases, __pyx_k_Error_setting_max_databases, sizeof(__pyx_k_Error_setting_max_databases), 0, 1, 0, 0},
  11341. {&__pyx_kp_u_Error_setting_max_readers, __pyx_k_Error_setting_max_readers, sizeof(__pyx_k_Error_setting_max_readers), 0, 1, 0, 0},
  11342. {&__pyx_n_s_FileNotFoundError, __pyx_k_FileNotFoundError, sizeof(__pyx_k_FileNotFoundError), 0, 0, 1, 1},
  11343. {&__pyx_kp_u_Getting_DBI_without_label, __pyx_k_Getting_DBI_without_label, sizeof(__pyx_k_Getting_DBI_without_label), 0, 1, 0, 0},
  11344. {&__pyx_kp_u_Internal_error, __pyx_k_Internal_error, sizeof(__pyx_k_Internal_error), 0, 1, 0, 0},
  11345. {&__pyx_n_s_KeyExistsError, __pyx_k_KeyExistsError, sizeof(__pyx_k_KeyExistsError), 0, 0, 1, 1},
  11346. {&__pyx_n_s_KeyNotFoundError, __pyx_k_KeyNotFoundError, sizeof(__pyx_k_KeyNotFoundError), 0, 0, 1, 1},
  11347. {&__pyx_kp_u_LMDB_Error, __pyx_k_LMDB_Error, sizeof(__pyx_k_LMDB_Error), 0, 1, 0, 0},
  11348. {&__pyx_n_s_LmdbError, __pyx_k_LmdbError, sizeof(__pyx_k_LmdbError), 0, 0, 1, 1},
  11349. {&__pyx_kp_u_Max_readers, __pyx_k_Max_readers, sizeof(__pyx_k_Max_readers), 0, 1, 0, 0},
  11350. {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  11351. {&__pyx_kp_u_None, __pyx_k_None, sizeof(__pyx_k_None), 0, 1, 0, 0},
  11352. {&__pyx_kp_u_Opened_transaction_x, __pyx_k_Opened_transaction_x, sizeof(__pyx_k_Opened_transaction_x), 0, 1, 0, 0},
  11353. {&__pyx_kp_u_Opening_cursor_for_DB, __pyx_k_Opening_cursor_for_DB, sizeof(__pyx_k_Opening_cursor_for_DB), 0, 1, 0, 0},
  11354. {&__pyx_kp_u_Opening_environment_at, __pyx_k_Opening_environment_at, sizeof(__pyx_k_Opening_environment_at), 0, 1, 0, 0},
  11355. {&__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},
  11356. {&__pyx_n_u_RO, __pyx_k_RO, sizeof(__pyx_k_RO), 0, 1, 0, 1},
  11357. {&__pyx_n_u_RW, __pyx_k_RW, sizeof(__pyx_k_RW), 0, 1, 0, 1},
  11358. {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  11359. {&__pyx_kp_u_Store_is_not_open, __pyx_k_Store_is_not_open, sizeof(__pyx_k_Store_is_not_open), 0, 1, 0, 0},
  11360. {&__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},
  11361. {&__pyx_kp_u_Transaction_aborted, __pyx_k_Transaction_aborted, sizeof(__pyx_k_Transaction_aborted), 0, 1, 0, 0},
  11362. {&__pyx_kp_u_Transaction_committed, __pyx_k_Transaction_committed, sizeof(__pyx_k_Transaction_committed), 0, 1, 0, 0},
  11363. {&__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},
  11364. {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  11365. {&__pyx_kp_u__20, __pyx_k__20, sizeof(__pyx_k__20), 0, 1, 0, 0},
  11366. {&__pyx_kp_u__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 1, 0, 0},
  11367. {&__pyx_kp_u__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 1, 0, 0},
  11368. {&__pyx_n_s_abort, __pyx_k_abort, sizeof(__pyx_k_abort), 0, 0, 1, 1},
  11369. {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  11370. {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  11371. {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  11372. {&__pyx_n_s_close_env, __pyx_k_close_env, sizeof(__pyx_k_close_env), 0, 0, 1, 1},
  11373. {&__pyx_n_s_commit_pending_transaction, __pyx_k_commit_pending_transaction, sizeof(__pyx_k_commit_pending_transaction), 0, 0, 1, 1},
  11374. {&__pyx_n_s_contextlib, __pyx_k_contextlib, sizeof(__pyx_k_contextlib), 0, 0, 1, 1},
  11375. {&__pyx_n_s_contextmanager, __pyx_k_contextmanager, sizeof(__pyx_k_contextmanager), 0, 0, 1, 1},
  11376. {&__pyx_n_s_create, __pyx_k_create, sizeof(__pyx_k_create), 0, 0, 1, 1},
  11377. {&__pyx_n_s_currentThread, __pyx_k_currentThread, sizeof(__pyx_k_currentThread), 0, 0, 1, 1},
  11378. {&__pyx_n_s_current_process, __pyx_k_current_process, sizeof(__pyx_k_current_process), 0, 0, 1, 1},
  11379. {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  11380. {&__pyx_n_s_data_v, __pyx_k_data_v, sizeof(__pyx_k_data_v), 0, 0, 1, 1},
  11381. {&__pyx_n_u_db_stats, __pyx_k_db_stats, sizeof(__pyx_k_db_stats), 0, 1, 0, 1},
  11382. {&__pyx_n_s_dbi, __pyx_k_dbi, sizeof(__pyx_k_dbi), 0, 0, 1, 1},
  11383. {&__pyx_n_s_dbi_flags, __pyx_k_dbi_flags, sizeof(__pyx_k_dbi_flags), 0, 0, 1, 1},
  11384. {&__pyx_n_s_dbi_labels, __pyx_k_dbi_labels, sizeof(__pyx_k_dbi_labels), 0, 0, 1, 1},
  11385. {&__pyx_n_s_dblabel, __pyx_k_dblabel, sizeof(__pyx_k_dblabel), 0, 0, 1, 1},
  11386. {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  11387. {&__pyx_n_s_destroy, __pyx_k_destroy, sizeof(__pyx_k_destroy), 0, 0, 1, 1},
  11388. {&__pyx_n_s_dirname, __pyx_k_dirname, sizeof(__pyx_k_dirname), 0, 0, 1, 1},
  11389. {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  11390. {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  11391. {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
  11392. {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  11393. {&__pyx_n_s_env, __pyx_k_env, sizeof(__pyx_k_env), 0, 0, 1, 1},
  11394. {&__pyx_n_s_env_flags, __pyx_k_env_flags, sizeof(__pyx_k_env_flags), 0, 0, 1, 1},
  11395. {&__pyx_n_s_env_path, __pyx_k_env_path, sizeof(__pyx_k_env_path), 0, 0, 1, 1},
  11396. {&__pyx_n_s_env_perms, __pyx_k_env_perms, sizeof(__pyx_k_env_perms), 0, 0, 1, 1},
  11397. {&__pyx_n_u_env_size, __pyx_k_env_size, sizeof(__pyx_k_env_size), 0, 1, 0, 1},
  11398. {&__pyx_n_u_env_stats, __pyx_k_env_stats, sizeof(__pyx_k_env_stats), 0, 1, 0, 1},
  11399. {&__pyx_n_s_exist_ok, __pyx_k_exist_ok, sizeof(__pyx_k_exist_ok), 0, 0, 1, 1},
  11400. {&__pyx_n_s_exists, __pyx_k_exists, sizeof(__pyx_k_exists), 0, 0, 1, 1},
  11401. {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  11402. {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
  11403. {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  11404. {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  11405. {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1},
  11406. {&__pyx_n_s_getName, __pyx_k_getName, sizeof(__pyx_k_getName), 0, 0, 1, 1},
  11407. {&__pyx_n_s_get_data, __pyx_k_get_data, sizeof(__pyx_k_get_data), 0, 0, 1, 1},
  11408. {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  11409. {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  11410. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  11411. {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  11412. {&__pyx_n_s_info, __pyx_k_info, sizeof(__pyx_k_info), 0, 0, 1, 1},
  11413. {&__pyx_n_s_is_open, __pyx_k_is_open, sizeof(__pyx_k_is_open), 0, 0, 1, 1},
  11414. {&__pyx_n_s_is_txn_rw, __pyx_k_is_txn_rw, sizeof(__pyx_k_is_txn_rw), 0, 0, 1, 1},
  11415. {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  11416. {&__pyx_n_s_key_v, __pyx_k_key_v, sizeof(__pyx_k_key_v), 0, 0, 1, 1},
  11417. {&__pyx_n_s_lakesuperior, __pyx_k_lakesuperior, sizeof(__pyx_k_lakesuperior), 0, 0, 1, 1},
  11418. {&__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},
  11419. {&__pyx_kp_u_lock, __pyx_k_lock, sizeof(__pyx_k_lock), 0, 1, 0, 0},
  11420. {&__pyx_n_s_logger, __pyx_k_logger, sizeof(__pyx_k_logger), 0, 0, 1, 1},
  11421. {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
  11422. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  11423. {&__pyx_n_s_makedirs, __pyx_k_makedirs, sizeof(__pyx_k_makedirs), 0, 0, 1, 1},
  11424. {&__pyx_n_u_map_size, __pyx_k_map_size, sizeof(__pyx_k_map_size), 0, 1, 0, 1},
  11425. {&__pyx_n_u_max_dbs, __pyx_k_max_dbs, sizeof(__pyx_k_max_dbs), 0, 1, 0, 1},
  11426. {&__pyx_n_u_max_spare_txns, __pyx_k_max_spare_txns, sizeof(__pyx_k_max_spare_txns), 0, 1, 0, 1},
  11427. {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  11428. {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  11429. {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  11430. {&__pyx_n_s_ms_branch_pages, __pyx_k_ms_branch_pages, sizeof(__pyx_k_ms_branch_pages), 0, 0, 1, 1},
  11431. {&__pyx_n_s_ms_depth, __pyx_k_ms_depth, sizeof(__pyx_k_ms_depth), 0, 0, 1, 1},
  11432. {&__pyx_n_s_ms_entries, __pyx_k_ms_entries, sizeof(__pyx_k_ms_entries), 0, 0, 1, 1},
  11433. {&__pyx_n_s_ms_leaf_pages, __pyx_k_ms_leaf_pages, sizeof(__pyx_k_ms_leaf_pages), 0, 0, 1, 1},
  11434. {&__pyx_n_s_ms_overflow_pages, __pyx_k_ms_overflow_pages, sizeof(__pyx_k_ms_overflow_pages), 0, 0, 1, 1},
  11435. {&__pyx_n_s_ms_psize, __pyx_k_ms_psize, sizeof(__pyx_k_ms_psize), 0, 0, 1, 1},
  11436. {&__pyx_n_s_multiprocessing, __pyx_k_multiprocessing, sizeof(__pyx_k_multiprocessing), 0, 0, 1, 1},
  11437. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  11438. {&__pyx_n_s_new_txn, __pyx_k_new_txn, sizeof(__pyx_k_new_txn), 0, 0, 1, 1},
  11439. {&__pyx_n_s_open_env, __pyx_k_open_env, sizeof(__pyx_k_open_env), 0, 0, 1, 1},
  11440. {&__pyx_kp_u_opened_x, __pyx_k_opened_x, sizeof(__pyx_k_opened_x), 0, 1, 0, 0},
  11441. {&__pyx_n_s_options, __pyx_k_options, sizeof(__pyx_k_options), 0, 0, 1, 1},
  11442. {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
  11443. {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
  11444. {&__pyx_n_s_path_2, __pyx_k_path_2, sizeof(__pyx_k_path_2), 0, 0, 1, 1},
  11445. {&__pyx_n_s_pid, __pyx_k_pid, sizeof(__pyx_k_pid), 0, 0, 1, 1},
  11446. {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  11447. {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
  11448. {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  11449. {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  11450. {&__pyx_n_s_rc, __pyx_k_rc, sizeof(__pyx_k_rc), 0, 0, 1, 1},
  11451. {&__pyx_n_s_readers_mult, __pyx_k_readers_mult, sizeof(__pyx_k_readers_mult), 0, 0, 1, 1},
  11452. {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  11453. {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  11454. {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  11455. {&__pyx_n_s_rmtree, __pyx_k_rmtree, sizeof(__pyx_k_rmtree), 0, 0, 1, 1},
  11456. {&__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},
  11457. {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  11458. {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  11459. {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  11460. {&__pyx_n_s_shutil, __pyx_k_shutil, sizeof(__pyx_k_shutil), 0, 0, 1, 1},
  11461. {&__pyx_n_s_st_size, __pyx_k_st_size, sizeof(__pyx_k_st_size), 0, 0, 1, 1},
  11462. {&__pyx_n_s_stat, __pyx_k_stat, sizeof(__pyx_k_stat), 0, 0, 1, 1},
  11463. {&__pyx_n_s_stats, __pyx_k_stats, sizeof(__pyx_k_stats), 0, 0, 1, 1},
  11464. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  11465. {&__pyx_n_s_threading, __pyx_k_threading, sizeof(__pyx_k_threading), 0, 0, 1, 1},
  11466. {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  11467. {&__pyx_n_s_txn_ctx, __pyx_k_txn_ctx, sizeof(__pyx_k_txn_ctx), 0, 0, 1, 1},
  11468. {&__pyx_n_s_txn_id, __pyx_k_txn_id, sizeof(__pyx_k_txn_id), 0, 0, 1, 1},
  11469. {&__pyx_kp_u_txn_is_open, __pyx_k_txn_is_open, sizeof(__pyx_k_txn_is_open), 0, 1, 0, 0},
  11470. {&__pyx_n_s_unlink, __pyx_k_unlink, sizeof(__pyx_k_unlink), 0, 0, 1, 1},
  11471. {&__pyx_n_s_warning, __pyx_k_warning, sizeof(__pyx_k_warning), 0, 0, 1, 1},
  11472. {&__pyx_n_s_workers, __pyx_k_workers, sizeof(__pyx_k_workers), 0, 0, 1, 1},
  11473. {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
  11474. {&__pyx_n_s_wsgi, __pyx_k_wsgi, sizeof(__pyx_k_wsgi), 0, 0, 1, 1},
  11475. {&__pyx_kp_u_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 1, 0, 0},
  11476. {0, 0, 0, 0, 0, 0, 0}
  11477. };
  11478. static int __Pyx_InitCachedBuiltins(void) {
  11479. __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 252, __pyx_L1_error)
  11480. __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 267, __pyx_L1_error)
  11481. __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 375, __pyx_L1_error)
  11482. __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
  11483. return 0;
  11484. __pyx_L1_error:;
  11485. return -1;
  11486. }
  11487. static int __Pyx_InitCachedConstants(void) {
  11488. __Pyx_RefNannyDeclarations
  11489. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  11490. /* "lakesuperior/store/base_lmdb_store.pyx":166
  11491. * """
  11492. * if self.is_open:
  11493. * logger.warning('Environment already open.') # <<<<<<<<<<<<<<
  11494. * return
  11495. *
  11496. */
  11497. __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Environment_already_open); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 166, __pyx_L1_error)
  11498. __Pyx_GOTREF(__pyx_tuple__2);
  11499. __Pyx_GIVEREF(__pyx_tuple__2);
  11500. /* "lakesuperior/store/base_lmdb_store.pyx":195
  11501. * # Set map size.
  11502. * _check(
  11503. * lmdb.mdb_env_set_mapsize(self.dbenv, self.options.get( # <<<<<<<<<<<<<<
  11504. * 'map_size', 1024 ** 3)),
  11505. * 'Error setting map size: {}')
  11506. */
  11507. __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)
  11508. __Pyx_GOTREF(__pyx_tuple__3);
  11509. __Pyx_GIVEREF(__pyx_tuple__3);
  11510. /* "lakesuperior/store/base_lmdb_store.pyx":264
  11511. * txn_flags = 0 if create else lmdb.MDB_RDONLY
  11512. * rc = lmdb.mdb_txn_begin(self.dbenv, NULL, txn_flags, &txn)
  11513. * logger.info(f'Creating DBs.') # <<<<<<<<<<<<<<
  11514. * try:
  11515. * if len(self.dbi_labels):
  11516. */
  11517. __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Creating_DBs); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 264, __pyx_L1_error)
  11518. __Pyx_GOTREF(__pyx_tuple__5);
  11519. __Pyx_GIVEREF(__pyx_tuple__5);
  11520. /* "lakesuperior/store/base_lmdb_store.pyx":289
  11521. *
  11522. * cpdef void close_env(self, bint commit_pending_transaction=False) except *:
  11523. * logger.debug('Cleaning up store env.') # <<<<<<<<<<<<<<
  11524. * if self.is_open:
  11525. * logger.debug('Closing store env.')
  11526. */
  11527. __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)
  11528. __Pyx_GOTREF(__pyx_tuple__7);
  11529. __Pyx_GIVEREF(__pyx_tuple__7);
  11530. /* "lakesuperior/store/base_lmdb_store.pyx":291
  11531. * logger.debug('Cleaning up store env.')
  11532. * if self.is_open:
  11533. * logger.debug('Closing store env.') # <<<<<<<<<<<<<<
  11534. * if self.is_txn_open is True:
  11535. * if commit_pending_transaction:
  11536. */
  11537. __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Closing_store_env); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 291, __pyx_L1_error)
  11538. __Pyx_GOTREF(__pyx_tuple__8);
  11539. __Pyx_GIVEREF(__pyx_tuple__8);
  11540. /* "lakesuperior/store/base_lmdb_store.pyx":343
  11541. * """
  11542. * if not self.is_open:
  11543. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  11544. *
  11545. * if self.is_txn_open:
  11546. */
  11547. __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)
  11548. __Pyx_GOTREF(__pyx_tuple__9);
  11549. __Pyx_GIVEREF(__pyx_tuple__9);
  11550. /* "lakesuperior/store/base_lmdb_store.pyx":346
  11551. *
  11552. * if self.is_txn_open:
  11553. * logger.debug( # <<<<<<<<<<<<<<
  11554. * 'Transaction is already active. Not opening another one.')
  11555. * #logger.debug('before yield')
  11556. */
  11557. __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)
  11558. __Pyx_GOTREF(__pyx_tuple__10);
  11559. __Pyx_GIVEREF(__pyx_tuple__10);
  11560. /* "lakesuperior/store/base_lmdb_store.pyx":375
  11561. * """
  11562. * if not self.is_open:
  11563. * raise RuntimeError('Store must be opened first.') # <<<<<<<<<<<<<<
  11564. * #logger.debug('Beginning a {} transaction.'.format(
  11565. * # 'read/write' if write else 'read-only'))
  11566. */
  11567. __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)
  11568. __Pyx_GOTREF(__pyx_tuple__11);
  11569. __Pyx_GIVEREF(__pyx_tuple__11);
  11570. /* "lakesuperior/store/base_lmdb_store.pyx":407
  11571. * """
  11572. * if new_txn is True:
  11573. * with self.txn_ctx(): # <<<<<<<<<<<<<<
  11574. * return self._key_exists(
  11575. * key, len(key), dblabel=dblabel.encode())
  11576. */
  11577. __pyx_tuple__12 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 407, __pyx_L1_error)
  11578. __Pyx_GOTREF(__pyx_tuple__12);
  11579. __Pyx_GIVEREF(__pyx_tuple__12);
  11580. __pyx_tuple__13 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 407, __pyx_L1_error)
  11581. __Pyx_GOTREF(__pyx_tuple__13);
  11582. __Pyx_GIVEREF(__pyx_tuple__13);
  11583. /* "lakesuperior/store/base_lmdb_store.pyx":608
  11584. * cdef void _txn_begin(self, write=True, lmdb.MDB_txn *parent=NULL) except *:
  11585. * if not self.is_open:
  11586. * raise LmdbError('Store is not open.') # <<<<<<<<<<<<<<
  11587. *
  11588. * cdef:
  11589. */
  11590. __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)
  11591. __Pyx_GOTREF(__pyx_tuple__18);
  11592. __Pyx_GIVEREF(__pyx_tuple__18);
  11593. /* "lakesuperior/store/base_lmdb_store.pyx":668
  11594. *
  11595. * if dblabel is NULL:
  11596. * logger.debug('Getting DBI without label.') # <<<<<<<<<<<<<<
  11597. * dbidx = (
  11598. * 0 if dblabel is NULL
  11599. */
  11600. __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)
  11601. __Pyx_GOTREF(__pyx_tuple__19);
  11602. __Pyx_GIVEREF(__pyx_tuple__19);
  11603. /* "(tree fragment)":2
  11604. * def __reduce_cython__(self):
  11605. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  11606. * def __setstate_cython__(self, __pyx_state):
  11607. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  11608. */
  11609. __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)
  11610. __Pyx_GOTREF(__pyx_tuple__21);
  11611. __Pyx_GIVEREF(__pyx_tuple__21);
  11612. /* "(tree fragment)":4
  11613. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling")
  11614. * def __setstate_cython__(self, __pyx_state):
  11615. * raise TypeError("self.curs,self.dbenv,self.dbis,self.txn cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
  11616. */
  11617. __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)
  11618. __Pyx_GOTREF(__pyx_tuple__22);
  11619. __Pyx_GIVEREF(__pyx_tuple__22);
  11620. __Pyx_RefNannyFinishContext();
  11621. return 0;
  11622. __pyx_L1_error:;
  11623. __Pyx_RefNannyFinishContext();
  11624. return -1;
  11625. }
  11626. static int __Pyx_InitGlobals(void) {
  11627. /* InitThreads.init */
  11628. #ifdef WITH_THREAD
  11629. PyEval_InitThreads();
  11630. #endif
  11631. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  11632. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  11633. __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  11634. __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  11635. __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  11636. __pyx_int_416 = PyInt_FromLong(416); if (unlikely(!__pyx_int_416)) __PYX_ERR(0, 1, __pyx_L1_error)
  11637. __pyx_int_488 = PyInt_FromLong(488); if (unlikely(!__pyx_int_488)) __PYX_ERR(0, 1, __pyx_L1_error)
  11638. __pyx_int_1073741824 = PyInt_FromLong(1073741824L); if (unlikely(!__pyx_int_1073741824)) __PYX_ERR(0, 1, __pyx_L1_error)
  11639. return 0;
  11640. __pyx_L1_error:;
  11641. return -1;
  11642. }
  11643. static int __Pyx_modinit_global_init_code(void); /*proto*/
  11644. static int __Pyx_modinit_variable_export_code(void); /*proto*/
  11645. static int __Pyx_modinit_function_export_code(void); /*proto*/
  11646. static int __Pyx_modinit_type_init_code(void); /*proto*/
  11647. static int __Pyx_modinit_type_import_code(void); /*proto*/
  11648. static int __Pyx_modinit_variable_import_code(void); /*proto*/
  11649. static int __Pyx_modinit_function_import_code(void); /*proto*/
  11650. static int __Pyx_modinit_global_init_code(void) {
  11651. __Pyx_RefNannyDeclarations
  11652. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  11653. /*--- Global init code ---*/
  11654. __Pyx_RefNannyFinishContext();
  11655. return 0;
  11656. }
  11657. static int __Pyx_modinit_variable_export_code(void) {
  11658. __Pyx_RefNannyDeclarations
  11659. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  11660. /*--- Variable export code ---*/
  11661. 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)
  11662. 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)
  11663. 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)
  11664. 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)
  11665. 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)
  11666. __Pyx_RefNannyFinishContext();
  11667. return 0;
  11668. __pyx_L1_error:;
  11669. __Pyx_RefNannyFinishContext();
  11670. return -1;
  11671. }
  11672. static int __Pyx_modinit_function_export_code(void) {
  11673. __Pyx_RefNannyDeclarations
  11674. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  11675. /*--- Function export code ---*/
  11676. 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)
  11677. __Pyx_RefNannyFinishContext();
  11678. return 0;
  11679. __pyx_L1_error:;
  11680. __Pyx_RefNannyFinishContext();
  11681. return -1;
  11682. }
  11683. static int __Pyx_modinit_type_init_code(void) {
  11684. __Pyx_RefNannyDeclarations
  11685. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  11686. /*--- Type init code ---*/
  11687. __pyx_vtabptr_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = &__pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  11688. __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;
  11689. __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;
  11690. __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;
  11691. __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;
  11692. __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;
  11693. __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;
  11694. __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;
  11695. __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;
  11696. __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;
  11697. __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;
  11698. __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;
  11699. __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;
  11700. __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;
  11701. __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;
  11702. __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;
  11703. __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;
  11704. __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;
  11705. __pyx_vtable_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.stats = (PyObject *(*)(struct __pyx_obj_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore *, int __pyx_skip_dispatch, struct __pyx_opt_args_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats *__pyx_optional_args))__pyx_f_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore_stats;
  11706. __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;
  11707. if (PyType_Ready(&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  11708. __pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.tp_print = 0;
  11709. 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)) {
  11710. __pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  11711. }
  11712. #if CYTHON_COMPILING_IN_CPYTHON
  11713. {
  11714. PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 49, __pyx_L1_error)
  11715. if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
  11716. __pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
  11717. __pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__.doc = __pyx_doc_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__;
  11718. ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_12lakesuperior_5store_15base_lmdb_store_13BaseLmdbStore___init__;
  11719. }
  11720. }
  11721. #endif
  11722. 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)
  11723. if (PyObject_SetAttrString(__pyx_m, "BaseLmdbStore", (PyObject *)&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  11724. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  11725. __pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore = &__pyx_type_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore;
  11726. if (PyType_Ready(&__pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx) < 0) __PYX_ERR(0, 334, __pyx_L1_error)
  11727. __pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx.tp_print = 0;
  11728. 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)) {
  11729. __pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  11730. }
  11731. __pyx_ptype_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx = &__pyx_type_12lakesuperior_5store_15base_lmdb_store___pyx_scope_struct__txn_ctx;
  11732. __Pyx_RefNannyFinishContext();
  11733. return 0;
  11734. __pyx_L1_error:;
  11735. __Pyx_RefNannyFinishContext();
  11736. return -1;
  11737. }
  11738. static int __Pyx_modinit_type_import_code(void) {
  11739. __Pyx_RefNannyDeclarations
  11740. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  11741. /*--- Type import code ---*/
  11742. __Pyx_RefNannyFinishContext();
  11743. return 0;
  11744. }
  11745. static int __Pyx_modinit_variable_import_code(void) {
  11746. __Pyx_RefNannyDeclarations
  11747. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  11748. /*--- Variable import code ---*/
  11749. __Pyx_RefNannyFinishContext();
  11750. return 0;
  11751. }
  11752. static int __Pyx_modinit_function_import_code(void) {
  11753. __Pyx_RefNannyDeclarations
  11754. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  11755. /*--- Function import code ---*/
  11756. __Pyx_RefNannyFinishContext();
  11757. return 0;
  11758. }
  11759. #if PY_MAJOR_VERSION < 3
  11760. #ifdef CYTHON_NO_PYINIT_EXPORT
  11761. #define __Pyx_PyMODINIT_FUNC void
  11762. #else
  11763. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  11764. #endif
  11765. #else
  11766. #ifdef CYTHON_NO_PYINIT_EXPORT
  11767. #define __Pyx_PyMODINIT_FUNC PyObject *
  11768. #else
  11769. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  11770. #endif
  11771. #endif
  11772. #ifndef CYTHON_SMALL_CODE
  11773. #if defined(__clang__)
  11774. #define CYTHON_SMALL_CODE
  11775. #elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
  11776. #define CYTHON_SMALL_CODE __attribute__((optimize("Os")))
  11777. #else
  11778. #define CYTHON_SMALL_CODE
  11779. #endif
  11780. #endif
  11781. #if PY_MAJOR_VERSION < 3
  11782. __Pyx_PyMODINIT_FUNC initbase_lmdb_store(void) CYTHON_SMALL_CODE; /*proto*/
  11783. __Pyx_PyMODINIT_FUNC initbase_lmdb_store(void)
  11784. #else
  11785. __Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void) CYTHON_SMALL_CODE; /*proto*/
  11786. __Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void)
  11787. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11788. {
  11789. return PyModuleDef_Init(&__pyx_moduledef);
  11790. }
  11791. static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
  11792. PyObject *value = PyObject_GetAttrString(spec, from_name);
  11793. int result = 0;
  11794. if (likely(value)) {
  11795. result = PyDict_SetItemString(moddict, to_name, value);
  11796. Py_DECREF(value);
  11797. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  11798. PyErr_Clear();
  11799. } else {
  11800. result = -1;
  11801. }
  11802. return result;
  11803. }
  11804. static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
  11805. PyObject *module = NULL, *moddict, *modname;
  11806. if (__pyx_m)
  11807. return __Pyx_NewRef(__pyx_m);
  11808. modname = PyObject_GetAttrString(spec, "name");
  11809. if (unlikely(!modname)) goto bad;
  11810. module = PyModule_NewObject(modname);
  11811. Py_DECREF(modname);
  11812. if (unlikely(!module)) goto bad;
  11813. moddict = PyModule_GetDict(module);
  11814. if (unlikely(!moddict)) goto bad;
  11815. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
  11816. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
  11817. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
  11818. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
  11819. return module;
  11820. bad:
  11821. Py_XDECREF(module);
  11822. return NULL;
  11823. }
  11824. static int __pyx_pymod_exec_base_lmdb_store(PyObject *__pyx_pyinit_module)
  11825. #endif
  11826. #endif
  11827. {
  11828. __Pyx_TraceDeclarations
  11829. PyObject *__pyx_t_1 = NULL;
  11830. PyObject *__pyx_t_2 = NULL;
  11831. PyObject *__pyx_t_3 = NULL;
  11832. PyObject *__pyx_t_4 = NULL;
  11833. PyObject *__pyx_t_5 = NULL;
  11834. __Pyx_RefNannyDeclarations
  11835. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11836. if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
  11837. #elif PY_MAJOR_VERSION >= 3
  11838. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  11839. #endif
  11840. #if CYTHON_REFNANNY
  11841. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  11842. if (!__Pyx_RefNanny) {
  11843. PyErr_Clear();
  11844. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  11845. if (!__Pyx_RefNanny)
  11846. Py_FatalError("failed to import 'refnanny' module");
  11847. }
  11848. #endif
  11849. __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void)", 0);
  11850. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11851. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  11852. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  11853. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  11854. #ifdef __Pyx_CyFunction_USED
  11855. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11856. #endif
  11857. #ifdef __Pyx_FusedFunction_USED
  11858. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11859. #endif
  11860. #ifdef __Pyx_Coroutine_USED
  11861. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11862. #endif
  11863. #ifdef __Pyx_Generator_USED
  11864. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11865. #endif
  11866. #ifdef __Pyx_AsyncGen_USED
  11867. if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11868. #endif
  11869. #ifdef __Pyx_StopAsyncIteration_USED
  11870. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11871. #endif
  11872. /*--- Library function declarations ---*/
  11873. /*--- Threads initialization code ---*/
  11874. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  11875. #ifdef WITH_THREAD /* Python build with threading support? */
  11876. PyEval_InitThreads();
  11877. #endif
  11878. #endif
  11879. /*--- Module creation code ---*/
  11880. #if CYTHON_PEP489_MULTI_PHASE_INIT
  11881. __pyx_m = __pyx_pyinit_module;
  11882. Py_INCREF(__pyx_m);
  11883. #else
  11884. #if PY_MAJOR_VERSION < 3
  11885. __pyx_m = Py_InitModule4("base_lmdb_store", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  11886. #else
  11887. __pyx_m = PyModule_Create(&__pyx_moduledef);
  11888. #endif
  11889. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  11890. #endif
  11891. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  11892. Py_INCREF(__pyx_d);
  11893. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  11894. __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  11895. #if CYTHON_COMPILING_IN_PYPY
  11896. Py_INCREF(__pyx_b);
  11897. #endif
  11898. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  11899. /*--- Initialize various global constants etc. ---*/
  11900. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11901. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  11902. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11903. #endif
  11904. if (__pyx_module_is_main_lakesuperior__store__base_lmdb_store) {
  11905. if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11906. }
  11907. #if PY_MAJOR_VERSION >= 3
  11908. {
  11909. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  11910. if (!PyDict_GetItemString(modules, "lakesuperior.store.base_lmdb_store")) {
  11911. if (unlikely(PyDict_SetItemString(modules, "lakesuperior.store.base_lmdb_store", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  11912. }
  11913. }
  11914. #endif
  11915. /*--- Builtin init code ---*/
  11916. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11917. /*--- Constants init code ---*/
  11918. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11919. /*--- Global type/function init code ---*/
  11920. (void)__Pyx_modinit_global_init_code();
  11921. if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
  11922. if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
  11923. if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  11924. (void)__Pyx_modinit_type_import_code();
  11925. (void)__Pyx_modinit_variable_import_code();
  11926. (void)__Pyx_modinit_function_import_code();
  11927. /*--- Execution code ---*/
  11928. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  11929. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11930. #endif
  11931. __Pyx_TraceCall("__Pyx_PyMODINIT_FUNC PyInit_base_lmdb_store(void)", __pyx_f[0], 1, 0, __PYX_ERR(0, 1, __pyx_L1_error));
  11932. /* "lakesuperior/store/base_lmdb_store.pyx":1
  11933. * import logging # <<<<<<<<<<<<<<
  11934. * import os
  11935. * import threading
  11936. */
  11937. __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  11938. __Pyx_GOTREF(__pyx_t_1);
  11939. if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  11940. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11941. /* "lakesuperior/store/base_lmdb_store.pyx":2
  11942. * import logging
  11943. * import os # <<<<<<<<<<<<<<
  11944. * import threading
  11945. * import multiprocessing
  11946. */
  11947. __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)
  11948. __Pyx_GOTREF(__pyx_t_1);
  11949. if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
  11950. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11951. /* "lakesuperior/store/base_lmdb_store.pyx":3
  11952. * import logging
  11953. * import os
  11954. * import threading # <<<<<<<<<<<<<<
  11955. * import multiprocessing
  11956. *
  11957. */
  11958. __pyx_t_1 = __Pyx_Import(__pyx_n_s_threading, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
  11959. __Pyx_GOTREF(__pyx_t_1);
  11960. if (PyDict_SetItem(__pyx_d, __pyx_n_s_threading, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
  11961. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11962. /* "lakesuperior/store/base_lmdb_store.pyx":4
  11963. * import os
  11964. * import threading
  11965. * import multiprocessing # <<<<<<<<<<<<<<
  11966. *
  11967. * from contextlib import contextmanager
  11968. */
  11969. __pyx_t_1 = __Pyx_Import(__pyx_n_s_multiprocessing, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
  11970. __Pyx_GOTREF(__pyx_t_1);
  11971. if (PyDict_SetItem(__pyx_d, __pyx_n_s_multiprocessing, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
  11972. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11973. /* "lakesuperior/store/base_lmdb_store.pyx":6
  11974. * import multiprocessing
  11975. *
  11976. * from contextlib import contextmanager # <<<<<<<<<<<<<<
  11977. * from os import makedirs, path
  11978. * from shutil import rmtree
  11979. */
  11980. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
  11981. __Pyx_GOTREF(__pyx_t_1);
  11982. __Pyx_INCREF(__pyx_n_s_contextmanager);
  11983. __Pyx_GIVEREF(__pyx_n_s_contextmanager);
  11984. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_contextmanager);
  11985. __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)
  11986. __Pyx_GOTREF(__pyx_t_2);
  11987. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11988. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_contextmanager); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
  11989. __Pyx_GOTREF(__pyx_t_1);
  11990. if (PyDict_SetItem(__pyx_d, __pyx_n_s_contextmanager, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  11991. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  11992. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  11993. /* "lakesuperior/store/base_lmdb_store.pyx":7
  11994. *
  11995. * from contextlib import contextmanager
  11996. * from os import makedirs, path # <<<<<<<<<<<<<<
  11997. * from shutil import rmtree
  11998. *
  11999. */
  12000. __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  12001. __Pyx_GOTREF(__pyx_t_2);
  12002. __Pyx_INCREF(__pyx_n_s_makedirs);
  12003. __Pyx_GIVEREF(__pyx_n_s_makedirs);
  12004. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_makedirs);
  12005. __Pyx_INCREF(__pyx_n_s_path);
  12006. __Pyx_GIVEREF(__pyx_n_s_path);
  12007. PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_path);
  12008. __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)
  12009. __Pyx_GOTREF(__pyx_t_1);
  12010. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12011. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_makedirs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  12012. __Pyx_GOTREF(__pyx_t_2);
  12013. if (PyDict_SetItem(__pyx_d, __pyx_n_s_makedirs, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  12014. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12015. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  12016. __Pyx_GOTREF(__pyx_t_2);
  12017. if (PyDict_SetItem(__pyx_d, __pyx_n_s_path, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  12018. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12019. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12020. /* "lakesuperior/store/base_lmdb_store.pyx":8
  12021. * from contextlib import contextmanager
  12022. * from os import makedirs, path
  12023. * from shutil import rmtree # <<<<<<<<<<<<<<
  12024. *
  12025. * from lakesuperior import env, wsgi
  12026. */
  12027. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  12028. __Pyx_GOTREF(__pyx_t_1);
  12029. __Pyx_INCREF(__pyx_n_s_rmtree);
  12030. __Pyx_GIVEREF(__pyx_n_s_rmtree);
  12031. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_rmtree);
  12032. __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)
  12033. __Pyx_GOTREF(__pyx_t_2);
  12034. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12035. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_rmtree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  12036. __Pyx_GOTREF(__pyx_t_1);
  12037. if (PyDict_SetItem(__pyx_d, __pyx_n_s_rmtree, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  12038. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12039. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12040. /* "lakesuperior/store/base_lmdb_store.pyx":10
  12041. * from shutil import rmtree
  12042. *
  12043. * from lakesuperior import env, wsgi # <<<<<<<<<<<<<<
  12044. *
  12045. * from lakesuperior.cy_include cimport cylmdb as lmdb
  12046. */
  12047. __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  12048. __Pyx_GOTREF(__pyx_t_2);
  12049. __Pyx_INCREF(__pyx_n_s_env);
  12050. __Pyx_GIVEREF(__pyx_n_s_env);
  12051. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_env);
  12052. __Pyx_INCREF(__pyx_n_s_wsgi);
  12053. __Pyx_GIVEREF(__pyx_n_s_wsgi);
  12054. PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_wsgi);
  12055. __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)
  12056. __Pyx_GOTREF(__pyx_t_1);
  12057. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12058. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_env); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  12059. __Pyx_GOTREF(__pyx_t_2);
  12060. if (PyDict_SetItem(__pyx_d, __pyx_n_s_env, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  12061. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12062. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_wsgi); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  12063. __Pyx_GOTREF(__pyx_t_2);
  12064. if (PyDict_SetItem(__pyx_d, __pyx_n_s_wsgi, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  12065. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12066. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12067. /* "lakesuperior/store/base_lmdb_store.pyx":19
  12068. *
  12069. *
  12070. * logger = logging.getLogger(__name__) # <<<<<<<<<<<<<<
  12071. *
  12072. *
  12073. */
  12074. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  12075. __Pyx_GOTREF(__pyx_t_1);
  12076. __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)
  12077. __Pyx_GOTREF(__pyx_t_2);
  12078. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12079. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  12080. __Pyx_GOTREF(__pyx_t_1);
  12081. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error)
  12082. __Pyx_GOTREF(__pyx_t_3);
  12083. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12084. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12085. if (PyDict_SetItem(__pyx_d, __pyx_n_s_logger, __pyx_t_3) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
  12086. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12087. /* "lakesuperior/store/base_lmdb_store.pyx":38
  12088. *
  12089. *
  12090. * class LmdbError(Exception): # <<<<<<<<<<<<<<
  12091. * pass
  12092. *
  12093. */
  12094. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error)
  12095. __Pyx_GOTREF(__pyx_t_3);
  12096. __Pyx_INCREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  12097. __Pyx_GIVEREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  12098. PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  12099. __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  12100. __Pyx_GOTREF(__pyx_t_1);
  12101. __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)
  12102. __Pyx_GOTREF(__pyx_t_2);
  12103. __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)
  12104. __Pyx_GOTREF(__pyx_t_4);
  12105. if (PyDict_SetItem(__pyx_d, __pyx_n_s_LmdbError, __pyx_t_4) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
  12106. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  12107. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12108. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12109. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12110. /* "lakesuperior/store/base_lmdb_store.pyx":41
  12111. * pass
  12112. *
  12113. * class KeyNotFoundError(LmdbError): # <<<<<<<<<<<<<<
  12114. * pass
  12115. *
  12116. */
  12117. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error)
  12118. __Pyx_GOTREF(__pyx_t_3);
  12119. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
  12120. __Pyx_GOTREF(__pyx_t_1);
  12121. __Pyx_GIVEREF(__pyx_t_3);
  12122. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  12123. __pyx_t_3 = 0;
  12124. __pyx_t_3 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error)
  12125. __Pyx_GOTREF(__pyx_t_3);
  12126. __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)
  12127. __Pyx_GOTREF(__pyx_t_2);
  12128. __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)
  12129. __Pyx_GOTREF(__pyx_t_4);
  12130. if (PyDict_SetItem(__pyx_d, __pyx_n_s_KeyNotFoundError, __pyx_t_4) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
  12131. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  12132. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12133. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12134. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12135. /* "lakesuperior/store/base_lmdb_store.pyx":44
  12136. * pass
  12137. *
  12138. * class KeyExistsError(LmdbError): # <<<<<<<<<<<<<<
  12139. * pass
  12140. *
  12141. */
  12142. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LmdbError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
  12143. __Pyx_GOTREF(__pyx_t_1);
  12144. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error)
  12145. __Pyx_GOTREF(__pyx_t_3);
  12146. __Pyx_GIVEREF(__pyx_t_1);
  12147. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  12148. __pyx_t_1 = 0;
  12149. __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
  12150. __Pyx_GOTREF(__pyx_t_1);
  12151. __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)
  12152. __Pyx_GOTREF(__pyx_t_2);
  12153. __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)
  12154. __Pyx_GOTREF(__pyx_t_4);
  12155. if (PyDict_SetItem(__pyx_d, __pyx_n_s_KeyExistsError, __pyx_t_4) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
  12156. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  12157. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12158. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12159. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12160. /* "lakesuperior/store/base_lmdb_store.pyx":71
  12161. * """
  12162. *
  12163. * dbi_labels = [] # <<<<<<<<<<<<<<
  12164. * dbi_flags = {}
  12165. * """
  12166. */
  12167. __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
  12168. __Pyx_GOTREF(__pyx_t_3);
  12169. 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)
  12170. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12171. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12172. /* "lakesuperior/store/base_lmdb_store.pyx":72
  12173. *
  12174. * dbi_labels = []
  12175. * dbi_flags = {} # <<<<<<<<<<<<<<
  12176. * """
  12177. * Configuration of databases in the environment.
  12178. */
  12179. __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
  12180. __Pyx_GOTREF(__pyx_t_3);
  12181. 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)
  12182. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12183. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12184. /* "lakesuperior/store/base_lmdb_store.pyx":87
  12185. * """
  12186. *
  12187. * env_flags = 0 # <<<<<<<<<<<<<<
  12188. * """
  12189. * LMDB environment flags.
  12190. */
  12191. 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)
  12192. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12193. /* "lakesuperior/store/base_lmdb_store.pyx":95
  12194. * """
  12195. *
  12196. * env_perms = 0o640 # <<<<<<<<<<<<<<
  12197. * """
  12198. * The UNIX permissions to set on created environment files and semaphores.
  12199. */
  12200. 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)
  12201. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12202. /* "lakesuperior/store/base_lmdb_store.pyx":103
  12203. * """
  12204. *
  12205. * options = {} # <<<<<<<<<<<<<<
  12206. * """
  12207. * LMDB environment option overrides. Setting this is not required.
  12208. */
  12209. __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 103, __pyx_L1_error)
  12210. __Pyx_GOTREF(__pyx_t_3);
  12211. 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)
  12212. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12213. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12214. /* "lakesuperior/store/base_lmdb_store.pyx":122
  12215. * """
  12216. *
  12217. * readers_mult = 4 # <<<<<<<<<<<<<<
  12218. * """
  12219. * Number to multiply WSGI workers by to set the numer of LMDB reader slots.
  12220. */
  12221. 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)
  12222. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12223. /* "lakesuperior/store/base_lmdb_store.pyx":333
  12224. * ### PYTHON-ACCESSIBLE METHODS ###
  12225. *
  12226. * @contextmanager # <<<<<<<<<<<<<<
  12227. * def txn_ctx(self, write=False):
  12228. * """
  12229. */
  12230. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_contextmanager); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
  12231. __Pyx_GOTREF(__pyx_t_1);
  12232. /* "lakesuperior/store/base_lmdb_store.pyx":334
  12233. *
  12234. * @contextmanager
  12235. * def txn_ctx(self, write=False): # <<<<<<<<<<<<<<
  12236. * """
  12237. * Transaction context manager.
  12238. */
  12239. __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)
  12240. __Pyx_GOTREF(__pyx_t_2);
  12241. __pyx_t_4 = NULL;
  12242. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  12243. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
  12244. if (likely(__pyx_t_4)) {
  12245. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  12246. __Pyx_INCREF(__pyx_t_4);
  12247. __Pyx_INCREF(function);
  12248. __Pyx_DECREF_SET(__pyx_t_1, function);
  12249. }
  12250. }
  12251. if (!__pyx_t_4) {
  12252. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L1_error)
  12253. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12254. __Pyx_GOTREF(__pyx_t_3);
  12255. } else {
  12256. #if CYTHON_FAST_PYCALL
  12257. if (PyFunction_Check(__pyx_t_1)) {
  12258. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
  12259. __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)
  12260. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  12261. __Pyx_GOTREF(__pyx_t_3);
  12262. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12263. } else
  12264. #endif
  12265. #if CYTHON_FAST_PYCCALL
  12266. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  12267. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
  12268. __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)
  12269. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  12270. __Pyx_GOTREF(__pyx_t_3);
  12271. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  12272. } else
  12273. #endif
  12274. {
  12275. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 333, __pyx_L1_error)
  12276. __Pyx_GOTREF(__pyx_t_5);
  12277. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  12278. __Pyx_GIVEREF(__pyx_t_2);
  12279. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
  12280. __pyx_t_2 = 0;
  12281. __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)
  12282. __Pyx_GOTREF(__pyx_t_3);
  12283. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  12284. }
  12285. }
  12286. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  12287. 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)
  12288. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12289. PyType_Modified(__pyx_ptype_12lakesuperior_5store_15base_lmdb_store_BaseLmdbStore);
  12290. /* "lakesuperior/store/base_lmdb_store.pyx":416
  12291. * cdef inline bint _key_exists(
  12292. * self, unsigned char *key, unsigned char klen,
  12293. * unsigned char *dblabel=b'') except -1: # <<<<<<<<<<<<<<
  12294. * """
  12295. * Return whether a key exists in a database.
  12296. */
  12297. __pyx_k__14 = ((unsigned char *)((char const *)""));
  12298. /* "lakesuperior/store/base_lmdb_store.pyx":449
  12299. * cdef void _put(
  12300. * self, unsigned char *key, size_t key_size, unsigned char *data,
  12301. * size_t data_size, unsigned char *dblabel='', # <<<<<<<<<<<<<<
  12302. * lmdb.MDB_txn *txn=NULL, unsigned int flags=0) except *:
  12303. * """
  12304. */
  12305. __pyx_k__15 = ((unsigned char *)((char const *)""));
  12306. /* "lakesuperior/store/base_lmdb_store.pyx":484
  12307. * cdef void _get_data(
  12308. * self, unsigned char *key, size_t klen, lmdb.MDB_val *rv,
  12309. * unsigned char *dblabel='') except *: # <<<<<<<<<<<<<<
  12310. * """
  12311. * Get a single value (non-dup) for a key.
  12312. */
  12313. __pyx_k__16 = ((unsigned char *)((char const *)""));
  12314. /* "lakesuperior/store/base_lmdb_store.pyx":508
  12315. * cdef void _delete(
  12316. * self, unsigned char *key, size_t klen,
  12317. * unsigned char *dblabel=b'') except *: # <<<<<<<<<<<<<<
  12318. * """
  12319. * Delete one single value by key from a non-dup database.
  12320. */
  12321. __pyx_k__17 = ((unsigned char *)((char const *)""));
  12322. /* "lakesuperior/store/base_lmdb_store.pyx":1
  12323. * import logging # <<<<<<<<<<<<<<
  12324. * import os
  12325. * import threading
  12326. */
  12327. __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  12328. __Pyx_GOTREF(__pyx_t_3);
  12329. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  12330. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  12331. __Pyx_TraceReturn(Py_None, 0);
  12332. /*--- Wrapped vars code ---*/
  12333. goto __pyx_L0;
  12334. __pyx_L1_error:;
  12335. __Pyx_XDECREF(__pyx_t_1);
  12336. __Pyx_XDECREF(__pyx_t_2);
  12337. __Pyx_XDECREF(__pyx_t_3);
  12338. __Pyx_XDECREF(__pyx_t_4);
  12339. __Pyx_XDECREF(__pyx_t_5);
  12340. if (__pyx_m) {
  12341. if (__pyx_d) {
  12342. __Pyx_AddTraceback("init lakesuperior.store.base_lmdb_store", 0, __pyx_lineno, __pyx_filename);
  12343. }
  12344. Py_DECREF(__pyx_m); __pyx_m = 0;
  12345. } else if (!PyErr_Occurred()) {
  12346. PyErr_SetString(PyExc_ImportError, "init lakesuperior.store.base_lmdb_store");
  12347. }
  12348. __pyx_L0:;
  12349. __Pyx_RefNannyFinishContext();
  12350. #if CYTHON_PEP489_MULTI_PHASE_INIT
  12351. return (__pyx_m != NULL) ? 0 : -1;
  12352. #elif PY_MAJOR_VERSION >= 3
  12353. return __pyx_m;
  12354. #else
  12355. return;
  12356. #endif
  12357. }
  12358. /* --- Runtime support code --- */
  12359. /* Refnanny */
  12360. #if CYTHON_REFNANNY
  12361. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  12362. PyObject *m = NULL, *p = NULL;
  12363. void *r = NULL;
  12364. m = PyImport_ImportModule((char *)modname);
  12365. if (!m) goto end;
  12366. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  12367. if (!p) goto end;
  12368. r = PyLong_AsVoidPtr(p);
  12369. end:
  12370. Py_XDECREF(p);
  12371. Py_XDECREF(m);
  12372. return (__Pyx_RefNannyAPIStruct *)r;
  12373. }
  12374. #endif
  12375. /* PyObjectGetAttrStr */
  12376. #if CYTHON_USE_TYPE_SLOTS
  12377. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  12378. PyTypeObject* tp = Py_TYPE(obj);
  12379. if (likely(tp->tp_getattro))
  12380. return tp->tp_getattro(obj, attr_name);
  12381. #if PY_MAJOR_VERSION < 3
  12382. if (likely(tp->tp_getattr))
  12383. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  12384. #endif
  12385. return PyObject_GetAttr(obj, attr_name);
  12386. }
  12387. #endif
  12388. /* GetBuiltinName */
  12389. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  12390. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  12391. if (unlikely(!result)) {
  12392. PyErr_Format(PyExc_NameError,
  12393. #if PY_MAJOR_VERSION >= 3
  12394. "name '%U' is not defined", name);
  12395. #else
  12396. "name '%.200s' is not defined", PyString_AS_STRING(name));
  12397. #endif
  12398. }
  12399. return result;
  12400. }
  12401. /* PyErrFetchRestore */
  12402. #if CYTHON_FAST_THREAD_STATE
  12403. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  12404. PyObject *tmp_type, *tmp_value, *tmp_tb;
  12405. tmp_type = tstate->curexc_type;
  12406. tmp_value = tstate->curexc_value;
  12407. tmp_tb = tstate->curexc_traceback;
  12408. tstate->curexc_type = type;
  12409. tstate->curexc_value = value;
  12410. tstate->curexc_traceback = tb;
  12411. Py_XDECREF(tmp_type);
  12412. Py_XDECREF(tmp_value);
  12413. Py_XDECREF(tmp_tb);
  12414. }
  12415. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  12416. *type = tstate->curexc_type;
  12417. *value = tstate->curexc_value;
  12418. *tb = tstate->curexc_traceback;
  12419. tstate->curexc_type = 0;
  12420. tstate->curexc_value = 0;
  12421. tstate->curexc_traceback = 0;
  12422. }
  12423. #endif
  12424. /* Profile */
  12425. #if CYTHON_PROFILE
  12426. static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
  12427. PyFrameObject** frame,
  12428. PyThreadState* tstate,
  12429. const char *funcname,
  12430. const char *srcfile,
  12431. int firstlineno) {
  12432. PyObject *type, *value, *traceback;
  12433. int retval;
  12434. if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
  12435. if (*code == NULL) {
  12436. *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
  12437. if (*code == NULL) return 0;
  12438. }
  12439. *frame = PyFrame_New(
  12440. tstate, /*PyThreadState *tstate*/
  12441. *code, /*PyCodeObject *code*/
  12442. __pyx_d, /*PyObject *globals*/
  12443. 0 /*PyObject *locals*/
  12444. );
  12445. if (*frame == NULL) return 0;
  12446. if (CYTHON_TRACE && (*frame)->f_trace == NULL) {
  12447. Py_INCREF(Py_None);
  12448. (*frame)->f_trace = Py_None;
  12449. }
  12450. #if PY_VERSION_HEX < 0x030400B1
  12451. } else {
  12452. (*frame)->f_tstate = tstate;
  12453. #endif
  12454. }
  12455. __Pyx_PyFrame_SetLineNumber(*frame, firstlineno);
  12456. retval = 1;
  12457. tstate->tracing++;
  12458. tstate->use_tracing = 0;
  12459. __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
  12460. #if CYTHON_TRACE
  12461. if (tstate->c_tracefunc)
  12462. retval = tstate->c_tracefunc(tstate->c_traceobj, *frame, PyTrace_CALL, NULL) == 0;
  12463. if (retval && tstate->c_profilefunc)
  12464. #endif
  12465. retval = tstate->c_profilefunc(tstate->c_profileobj, *frame, PyTrace_CALL, NULL) == 0;
  12466. tstate->use_tracing = (tstate->c_profilefunc ||
  12467. (CYTHON_TRACE && tstate->c_tracefunc));
  12468. tstate->tracing--;
  12469. if (retval) {
  12470. __Pyx_ErrRestoreInState(tstate, type, value, traceback);
  12471. return tstate->use_tracing && retval;
  12472. } else {
  12473. Py_XDECREF(type);
  12474. Py_XDECREF(value);
  12475. Py_XDECREF(traceback);
  12476. return -1;
  12477. }
  12478. }
  12479. static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) {
  12480. PyObject *py_srcfile = 0;
  12481. PyObject *py_funcname = 0;
  12482. PyCodeObject *py_code = 0;
  12483. #if PY_MAJOR_VERSION < 3
  12484. py_funcname = PyString_FromString(funcname);
  12485. py_srcfile = PyString_FromString(srcfile);
  12486. #else
  12487. py_funcname = PyUnicode_FromString(funcname);
  12488. py_srcfile = PyUnicode_FromString(srcfile);
  12489. #endif
  12490. if (!py_funcname | !py_srcfile) goto bad;
  12491. py_code = PyCode_New(
  12492. 0,
  12493. #if PY_MAJOR_VERSION >= 3
  12494. 0,
  12495. #endif
  12496. 0,
  12497. 0,
  12498. CO_OPTIMIZED | CO_NEWLOCALS,
  12499. __pyx_empty_bytes, /*PyObject *code,*/
  12500. __pyx_empty_tuple, /*PyObject *consts,*/
  12501. __pyx_empty_tuple, /*PyObject *names,*/
  12502. __pyx_empty_tuple, /*PyObject *varnames,*/
  12503. __pyx_empty_tuple, /*PyObject *freevars,*/
  12504. __pyx_empty_tuple, /*PyObject *cellvars,*/
  12505. py_srcfile, /*PyObject *filename,*/
  12506. py_funcname, /*PyObject *name,*/
  12507. firstlineno,
  12508. __pyx_empty_bytes /*PyObject *lnotab*/
  12509. );
  12510. bad:
  12511. Py_XDECREF(py_srcfile);
  12512. Py_XDECREF(py_funcname);
  12513. return py_code;
  12514. }
  12515. #endif
  12516. /* GetModuleGlobalName */
  12517. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  12518. PyObject *result;
  12519. #if !CYTHON_AVOID_BORROWED_REFS
  12520. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
  12521. result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
  12522. if (likely(result)) {
  12523. Py_INCREF(result);
  12524. } else if (unlikely(PyErr_Occurred())) {
  12525. result = NULL;
  12526. } else {
  12527. #else
  12528. result = PyDict_GetItem(__pyx_d, name);
  12529. if (likely(result)) {
  12530. Py_INCREF(result);
  12531. } else {
  12532. #endif
  12533. #else
  12534. result = PyObject_GetItem(__pyx_d, name);
  12535. if (!result) {
  12536. PyErr_Clear();
  12537. #endif
  12538. result = __Pyx_GetBuiltinName(name);
  12539. }
  12540. return result;
  12541. }
  12542. /* PyCFunctionFastCall */
  12543. #if CYTHON_FAST_PYCCALL
  12544. static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
  12545. PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
  12546. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  12547. PyObject *self = PyCFunction_GET_SELF(func);
  12548. int flags = PyCFunction_GET_FLAGS(func);
  12549. assert(PyCFunction_Check(func));
  12550. assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
  12551. assert(nargs >= 0);
  12552. assert(nargs == 0 || args != NULL);
  12553. /* _PyCFunction_FastCallDict() must not be called with an exception set,
  12554. because it may clear it (directly or indirectly) and so the
  12555. caller loses its exception */
  12556. assert(!PyErr_Occurred());
  12557. if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
  12558. return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
  12559. } else {
  12560. return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
  12561. }
  12562. }
  12563. #endif
  12564. /* PyFunctionFastCall */
  12565. #if CYTHON_FAST_PYCALL
  12566. #include "frameobject.h"
  12567. static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
  12568. PyObject *globals) {
  12569. PyFrameObject *f;
  12570. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  12571. PyObject **fastlocals;
  12572. Py_ssize_t i;
  12573. PyObject *result;
  12574. assert(globals != NULL);
  12575. /* XXX Perhaps we should create a specialized
  12576. PyFrame_New() that doesn't take locals, but does
  12577. take builtins without sanity checking them.
  12578. */
  12579. assert(tstate != NULL);
  12580. f = PyFrame_New(tstate, co, globals, NULL);
  12581. if (f == NULL) {
  12582. return NULL;
  12583. }
  12584. fastlocals = f->f_localsplus;
  12585. for (i = 0; i < na; i++) {
  12586. Py_INCREF(*args);
  12587. fastlocals[i] = *args++;
  12588. }
  12589. result = PyEval_EvalFrameEx(f,0);
  12590. ++tstate->recursion_depth;
  12591. Py_DECREF(f);
  12592. --tstate->recursion_depth;
  12593. return result;
  12594. }
  12595. #if 1 || PY_VERSION_HEX < 0x030600B1
  12596. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
  12597. PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
  12598. PyObject *globals = PyFunction_GET_GLOBALS(func);
  12599. PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
  12600. PyObject *closure;
  12601. #if PY_MAJOR_VERSION >= 3
  12602. PyObject *kwdefs;
  12603. #endif
  12604. PyObject *kwtuple, **k;
  12605. PyObject **d;
  12606. Py_ssize_t nd;
  12607. Py_ssize_t nk;
  12608. PyObject *result;
  12609. assert(kwargs == NULL || PyDict_Check(kwargs));
  12610. nk = kwargs ? PyDict_Size(kwargs) : 0;
  12611. if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
  12612. return NULL;
  12613. }
  12614. if (
  12615. #if PY_MAJOR_VERSION >= 3
  12616. co->co_kwonlyargcount == 0 &&
  12617. #endif
  12618. likely(kwargs == NULL || nk == 0) &&
  12619. co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
  12620. if (argdefs == NULL && co->co_argcount == nargs) {
  12621. result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
  12622. goto done;
  12623. }
  12624. else if (nargs == 0 && argdefs != NULL
  12625. && co->co_argcount == Py_SIZE(argdefs)) {
  12626. /* function called with no arguments, but all parameters have
  12627. a default value: use default values as arguments .*/
  12628. args = &PyTuple_GET_ITEM(argdefs, 0);
  12629. result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
  12630. goto done;
  12631. }
  12632. }
  12633. if (kwargs != NULL) {
  12634. Py_ssize_t pos, i;
  12635. kwtuple = PyTuple_New(2 * nk);
  12636. if (kwtuple == NULL) {
  12637. result = NULL;
  12638. goto done;
  12639. }
  12640. k = &PyTuple_GET_ITEM(kwtuple, 0);
  12641. pos = i = 0;
  12642. while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
  12643. Py_INCREF(k[i]);
  12644. Py_INCREF(k[i+1]);
  12645. i += 2;
  12646. }
  12647. nk = i / 2;
  12648. }
  12649. else {
  12650. kwtuple = NULL;
  12651. k = NULL;
  12652. }
  12653. closure = PyFunction_GET_CLOSURE(func);
  12654. #if PY_MAJOR_VERSION >= 3
  12655. kwdefs = PyFunction_GET_KW_DEFAULTS(func);
  12656. #endif
  12657. if (argdefs != NULL) {
  12658. d = &PyTuple_GET_ITEM(argdefs, 0);
  12659. nd = Py_SIZE(argdefs);
  12660. }
  12661. else {
  12662. d = NULL;
  12663. nd = 0;
  12664. }
  12665. #if PY_MAJOR_VERSION >= 3
  12666. result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
  12667. args, nargs,
  12668. k, (int)nk,
  12669. d, (int)nd, kwdefs, closure);
  12670. #else
  12671. result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
  12672. args, nargs,
  12673. k, (int)nk,
  12674. d, (int)nd, closure);
  12675. #endif
  12676. Py_XDECREF(kwtuple);
  12677. done:
  12678. Py_LeaveRecursiveCall();
  12679. return result;
  12680. }
  12681. #endif
  12682. #endif
  12683. /* PyObjectCall */
  12684. #if CYTHON_COMPILING_IN_CPYTHON
  12685. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  12686. PyObject *result;
  12687. ternaryfunc call = func->ob_type->tp_call;
  12688. if (unlikely(!call))
  12689. return PyObject_Call(func, arg, kw);
  12690. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  12691. return NULL;
  12692. result = (*call)(func, arg, kw);
  12693. Py_LeaveRecursiveCall();
  12694. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  12695. PyErr_SetString(
  12696. PyExc_SystemError,
  12697. "NULL result without error in PyObject_Call");
  12698. }
  12699. return result;
  12700. }
  12701. #endif
  12702. /* PyObjectCallMethO */
  12703. #if CYTHON_COMPILING_IN_CPYTHON
  12704. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  12705. PyObject *self, *result;
  12706. PyCFunction cfunc;
  12707. cfunc = PyCFunction_GET_FUNCTION(func);
  12708. self = PyCFunction_GET_SELF(func);
  12709. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  12710. return NULL;
  12711. result = cfunc(self, arg);
  12712. Py_LeaveRecursiveCall();
  12713. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  12714. PyErr_SetString(
  12715. PyExc_SystemError,
  12716. "NULL result without error in PyObject_Call");
  12717. }
  12718. return result;
  12719. }
  12720. #endif
  12721. /* PyObjectCallOneArg */
  12722. #if CYTHON_COMPILING_IN_CPYTHON
  12723. static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  12724. PyObject *result;
  12725. PyObject *args = PyTuple_New(1);
  12726. if (unlikely(!args)) return NULL;
  12727. Py_INCREF(arg);
  12728. PyTuple_SET_ITEM(args, 0, arg);
  12729. result = __Pyx_PyObject_Call(func, args, NULL);
  12730. Py_DECREF(args);
  12731. return result;
  12732. }
  12733. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  12734. #if CYTHON_FAST_PYCALL
  12735. if (PyFunction_Check(func)) {
  12736. return __Pyx_PyFunction_FastCall(func, &arg, 1);
  12737. }
  12738. #endif
  12739. if (likely(PyCFunction_Check(func))) {
  12740. if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
  12741. return __Pyx_PyObject_CallMethO(func, arg);
  12742. #if CYTHON_FAST_PYCCALL
  12743. } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
  12744. return __Pyx_PyCFunction_FastCall(func, &arg, 1);
  12745. #endif
  12746. }
  12747. }
  12748. return __Pyx__PyObject_CallOneArg(func, arg);
  12749. }
  12750. #else
  12751. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  12752. PyObject *result;
  12753. PyObject *args = PyTuple_Pack(1, arg);
  12754. if (unlikely(!args)) return NULL;
  12755. result = __Pyx_PyObject_Call(func, args, NULL);
  12756. Py_DECREF(args);
  12757. return result;
  12758. }
  12759. #endif
  12760. /* PyObjectCallNoArg */
  12761. #if CYTHON_COMPILING_IN_CPYTHON
  12762. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  12763. #if CYTHON_FAST_PYCALL
  12764. if (PyFunction_Check(func)) {
  12765. return __Pyx_PyFunction_FastCall(func, NULL, 0);
  12766. }
  12767. #endif
  12768. #ifdef __Pyx_CyFunction_USED
  12769. if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
  12770. #else
  12771. if (likely(PyCFunction_Check(func))) {
  12772. #endif
  12773. if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
  12774. return __Pyx_PyObject_CallMethO(func, NULL);
  12775. }
  12776. }
  12777. return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
  12778. }
  12779. #endif
  12780. /* RaiseException */
  12781. #if PY_MAJOR_VERSION < 3
  12782. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  12783. CYTHON_UNUSED PyObject *cause) {
  12784. __Pyx_PyThreadState_declare
  12785. Py_XINCREF(type);
  12786. if (!value || value == Py_None)
  12787. value = NULL;
  12788. else
  12789. Py_INCREF(value);
  12790. if (!tb || tb == Py_None)
  12791. tb = NULL;
  12792. else {
  12793. Py_INCREF(tb);
  12794. if (!PyTraceBack_Check(tb)) {
  12795. PyErr_SetString(PyExc_TypeError,
  12796. "raise: arg 3 must be a traceback or None");
  12797. goto raise_error;
  12798. }
  12799. }
  12800. if (PyType_Check(type)) {
  12801. #if CYTHON_COMPILING_IN_PYPY
  12802. if (!value) {
  12803. Py_INCREF(Py_None);
  12804. value = Py_None;
  12805. }
  12806. #endif
  12807. PyErr_NormalizeException(&type, &value, &tb);
  12808. } else {
  12809. if (value) {
  12810. PyErr_SetString(PyExc_TypeError,
  12811. "instance exception may not have a separate value");
  12812. goto raise_error;
  12813. }
  12814. value = type;
  12815. type = (PyObject*) Py_TYPE(type);
  12816. Py_INCREF(type);
  12817. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  12818. PyErr_SetString(PyExc_TypeError,
  12819. "raise: exception class must be a subclass of BaseException");
  12820. goto raise_error;
  12821. }
  12822. }
  12823. __Pyx_PyThreadState_assign
  12824. __Pyx_ErrRestore(type, value, tb);
  12825. return;
  12826. raise_error:
  12827. Py_XDECREF(value);
  12828. Py_XDECREF(type);
  12829. Py_XDECREF(tb);
  12830. return;
  12831. }
  12832. #else
  12833. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  12834. PyObject* owned_instance = NULL;
  12835. if (tb == Py_None) {
  12836. tb = 0;
  12837. } else if (tb && !PyTraceBack_Check(tb)) {
  12838. PyErr_SetString(PyExc_TypeError,
  12839. "raise: arg 3 must be a traceback or None");
  12840. goto bad;
  12841. }
  12842. if (value == Py_None)
  12843. value = 0;
  12844. if (PyExceptionInstance_Check(type)) {
  12845. if (value) {
  12846. PyErr_SetString(PyExc_TypeError,
  12847. "instance exception may not have a separate value");
  12848. goto bad;
  12849. }
  12850. value = type;
  12851. type = (PyObject*) Py_TYPE(value);
  12852. } else if (PyExceptionClass_Check(type)) {
  12853. PyObject *instance_class = NULL;
  12854. if (value && PyExceptionInstance_Check(value)) {
  12855. instance_class = (PyObject*) Py_TYPE(value);
  12856. if (instance_class != type) {
  12857. int is_subclass = PyObject_IsSubclass(instance_class, type);
  12858. if (!is_subclass) {
  12859. instance_class = NULL;
  12860. } else if (unlikely(is_subclass == -1)) {
  12861. goto bad;
  12862. } else {
  12863. type = instance_class;
  12864. }
  12865. }
  12866. }
  12867. if (!instance_class) {
  12868. PyObject *args;
  12869. if (!value)
  12870. args = PyTuple_New(0);
  12871. else if (PyTuple_Check(value)) {
  12872. Py_INCREF(value);
  12873. args = value;
  12874. } else
  12875. args = PyTuple_Pack(1, value);
  12876. if (!args)
  12877. goto bad;
  12878. owned_instance = PyObject_Call(type, args, NULL);
  12879. Py_DECREF(args);
  12880. if (!owned_instance)
  12881. goto bad;
  12882. value = owned_instance;
  12883. if (!PyExceptionInstance_Check(value)) {
  12884. PyErr_Format(PyExc_TypeError,
  12885. "calling %R should have returned an instance of "
  12886. "BaseException, not %R",
  12887. type, Py_TYPE(value));
  12888. goto bad;
  12889. }
  12890. }
  12891. } else {
  12892. PyErr_SetString(PyExc_TypeError,
  12893. "raise: exception class must be a subclass of BaseException");
  12894. goto bad;
  12895. }
  12896. if (cause) {
  12897. PyObject *fixed_cause;
  12898. if (cause == Py_None) {
  12899. fixed_cause = NULL;
  12900. } else if (PyExceptionClass_Check(cause)) {
  12901. fixed_cause = PyObject_CallObject(cause, NULL);
  12902. if (fixed_cause == NULL)
  12903. goto bad;
  12904. } else if (PyExceptionInstance_Check(cause)) {
  12905. fixed_cause = cause;
  12906. Py_INCREF(fixed_cause);
  12907. } else {
  12908. PyErr_SetString(PyExc_TypeError,
  12909. "exception causes must derive from "
  12910. "BaseException");
  12911. goto bad;
  12912. }
  12913. PyException_SetCause(value, fixed_cause);
  12914. }
  12915. PyErr_SetObject(type, value);
  12916. if (tb) {
  12917. #if CYTHON_COMPILING_IN_PYPY
  12918. PyObject *tmp_type, *tmp_value, *tmp_tb;
  12919. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  12920. Py_INCREF(tb);
  12921. PyErr_Restore(tmp_type, tmp_value, tb);
  12922. Py_XDECREF(tmp_tb);
  12923. #else
  12924. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  12925. PyObject* tmp_tb = tstate->curexc_traceback;
  12926. if (tb != tmp_tb) {
  12927. Py_INCREF(tb);
  12928. tstate->curexc_traceback = tb;
  12929. Py_XDECREF(tmp_tb);
  12930. }
  12931. #endif
  12932. }
  12933. bad:
  12934. Py_XDECREF(owned_instance);
  12935. return;
  12936. }
  12937. #endif
  12938. /* decode_c_string */
  12939. static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
  12940. const char* cstring, Py_ssize_t start, Py_ssize_t stop,
  12941. const char* encoding, const char* errors,
  12942. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
  12943. Py_ssize_t length;
  12944. if (unlikely((start < 0) | (stop < 0))) {
  12945. size_t slen = strlen(cstring);
  12946. if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
  12947. PyErr_SetString(PyExc_OverflowError,
  12948. "c-string too long to convert to Python");
  12949. return NULL;
  12950. }
  12951. length = (Py_ssize_t) slen;
  12952. if (start < 0) {
  12953. start += length;
  12954. if (start < 0)
  12955. start = 0;
  12956. }
  12957. if (stop < 0)
  12958. stop += length;
  12959. }
  12960. length = stop - start;
  12961. if (unlikely(length <= 0))
  12962. return PyUnicode_FromUnicode(NULL, 0);
  12963. cstring += start;
  12964. if (decode_func) {
  12965. return decode_func(cstring, length, errors);
  12966. } else {
  12967. return PyUnicode_Decode(cstring, length, encoding, errors);
  12968. }
  12969. }
  12970. /* RaiseDoubleKeywords */
  12971. static void __Pyx_RaiseDoubleKeywordsError(
  12972. const char* func_name,
  12973. PyObject* kw_name)
  12974. {
  12975. PyErr_Format(PyExc_TypeError,
  12976. #if PY_MAJOR_VERSION >= 3
  12977. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  12978. #else
  12979. "%s() got multiple values for keyword argument '%s'", func_name,
  12980. PyString_AsString(kw_name));
  12981. #endif
  12982. }
  12983. /* ParseKeywords */
  12984. static int __Pyx_ParseOptionalKeywords(
  12985. PyObject *kwds,
  12986. PyObject **argnames[],
  12987. PyObject *kwds2,
  12988. PyObject *values[],
  12989. Py_ssize_t num_pos_args,
  12990. const char* function_name)
  12991. {
  12992. PyObject *key = 0, *value = 0;
  12993. Py_ssize_t pos = 0;
  12994. PyObject*** name;
  12995. PyObject*** first_kw_arg = argnames + num_pos_args;
  12996. while (PyDict_Next(kwds, &pos, &key, &value)) {
  12997. name = first_kw_arg;
  12998. while (*name && (**name != key)) name++;
  12999. if (*name) {
  13000. values[name-argnames] = value;
  13001. continue;
  13002. }
  13003. name = first_kw_arg;
  13004. #if PY_MAJOR_VERSION < 3
  13005. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  13006. while (*name) {
  13007. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  13008. && _PyString_Eq(**name, key)) {
  13009. values[name-argnames] = value;
  13010. break;
  13011. }
  13012. name++;
  13013. }
  13014. if (*name) continue;
  13015. else {
  13016. PyObject*** argname = argnames;
  13017. while (argname != first_kw_arg) {
  13018. if ((**argname == key) || (
  13019. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  13020. && _PyString_Eq(**argname, key))) {
  13021. goto arg_passed_twice;
  13022. }
  13023. argname++;
  13024. }
  13025. }
  13026. } else
  13027. #endif
  13028. if (likely(PyUnicode_Check(key))) {
  13029. while (*name) {
  13030. int cmp = (**name == key) ? 0 :
  13031. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  13032. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  13033. #endif
  13034. PyUnicode_Compare(**name, key);
  13035. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  13036. if (cmp == 0) {
  13037. values[name-argnames] = value;
  13038. break;
  13039. }
  13040. name++;
  13041. }
  13042. if (*name) continue;
  13043. else {
  13044. PyObject*** argname = argnames;
  13045. while (argname != first_kw_arg) {
  13046. int cmp = (**argname == key) ? 0 :
  13047. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  13048. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  13049. #endif
  13050. PyUnicode_Compare(**argname, key);
  13051. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  13052. if (cmp == 0) goto arg_passed_twice;
  13053. argname++;
  13054. }
  13055. }
  13056. } else
  13057. goto invalid_keyword_type;
  13058. if (kwds2) {
  13059. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  13060. } else {
  13061. goto invalid_keyword;
  13062. }
  13063. }
  13064. return 0;
  13065. arg_passed_twice:
  13066. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  13067. goto bad;
  13068. invalid_keyword_type:
  13069. PyErr_Format(PyExc_TypeError,
  13070. "%.200s() keywords must be strings", function_name);
  13071. goto bad;
  13072. invalid_keyword:
  13073. PyErr_Format(PyExc_TypeError,
  13074. #if PY_MAJOR_VERSION < 3
  13075. "%.200s() got an unexpected keyword argument '%.200s'",
  13076. function_name, PyString_AsString(key));
  13077. #else
  13078. "%s() got an unexpected keyword argument '%U'",
  13079. function_name, key);
  13080. #endif
  13081. bad:
  13082. return -1;
  13083. }
  13084. /* RaiseArgTupleInvalid */
  13085. static void __Pyx_RaiseArgtupleInvalid(
  13086. const char* func_name,
  13087. int exact,
  13088. Py_ssize_t num_min,
  13089. Py_ssize_t num_max,
  13090. Py_ssize_t num_found)
  13091. {
  13092. Py_ssize_t num_expected;
  13093. const char *more_or_less;
  13094. if (num_found < num_min) {
  13095. num_expected = num_min;
  13096. more_or_less = "at least";
  13097. } else {
  13098. num_expected = num_max;
  13099. more_or_less = "at most";
  13100. }
  13101. if (exact) {
  13102. more_or_less = "exactly";
  13103. }
  13104. PyErr_Format(PyExc_TypeError,
  13105. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  13106. func_name, more_or_less, num_expected,
  13107. (num_expected == 1) ? "" : "s", num_found);
  13108. }
  13109. /* WriteUnraisableException */
  13110. static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
  13111. CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
  13112. int full_traceback, CYTHON_UNUSED int nogil) {
  13113. PyObject *old_exc, *old_val, *old_tb;
  13114. PyObject *ctx;
  13115. __Pyx_PyThreadState_declare
  13116. #ifdef WITH_THREAD
  13117. PyGILState_STATE state;
  13118. if (nogil)
  13119. state = PyGILState_Ensure();
  13120. #ifdef _MSC_VER
  13121. else state = (PyGILState_STATE)-1;
  13122. #endif
  13123. #endif
  13124. __Pyx_PyThreadState_assign
  13125. __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
  13126. if (full_traceback) {
  13127. Py_XINCREF(old_exc);
  13128. Py_XINCREF(old_val);
  13129. Py_XINCREF(old_tb);
  13130. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  13131. PyErr_PrintEx(1);
  13132. }
  13133. #if PY_MAJOR_VERSION < 3
  13134. ctx = PyString_FromString(name);
  13135. #else
  13136. ctx = PyUnicode_FromString(name);
  13137. #endif
  13138. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  13139. if (!ctx) {
  13140. PyErr_WriteUnraisable(Py_None);
  13141. } else {
  13142. PyErr_WriteUnraisable(ctx);
  13143. Py_DECREF(ctx);
  13144. }
  13145. #ifdef WITH_THREAD
  13146. if (nogil)
  13147. PyGILState_Release(state);
  13148. #endif
  13149. }
  13150. /* SaveResetException */
  13151. #if CYTHON_FAST_THREAD_STATE
  13152. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13153. #if PY_VERSION_HEX >= 0x030700A3
  13154. *type = tstate->exc_state.exc_type;
  13155. *value = tstate->exc_state.exc_value;
  13156. *tb = tstate->exc_state.exc_traceback;
  13157. #else
  13158. *type = tstate->exc_type;
  13159. *value = tstate->exc_value;
  13160. *tb = tstate->exc_traceback;
  13161. #endif
  13162. Py_XINCREF(*type);
  13163. Py_XINCREF(*value);
  13164. Py_XINCREF(*tb);
  13165. }
  13166. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  13167. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13168. #if PY_VERSION_HEX >= 0x030700A3
  13169. tmp_type = tstate->exc_state.exc_type;
  13170. tmp_value = tstate->exc_state.exc_value;
  13171. tmp_tb = tstate->exc_state.exc_traceback;
  13172. tstate->exc_state.exc_type = type;
  13173. tstate->exc_state.exc_value = value;
  13174. tstate->exc_state.exc_traceback = tb;
  13175. #else
  13176. tmp_type = tstate->exc_type;
  13177. tmp_value = tstate->exc_value;
  13178. tmp_tb = tstate->exc_traceback;
  13179. tstate->exc_type = type;
  13180. tstate->exc_value = value;
  13181. tstate->exc_traceback = tb;
  13182. #endif
  13183. Py_XDECREF(tmp_type);
  13184. Py_XDECREF(tmp_value);
  13185. Py_XDECREF(tmp_tb);
  13186. }
  13187. #endif
  13188. /* PyErrExceptionMatches */
  13189. #if CYTHON_FAST_THREAD_STATE
  13190. static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  13191. Py_ssize_t i, n;
  13192. n = PyTuple_GET_SIZE(tuple);
  13193. #if PY_MAJOR_VERSION >= 3
  13194. for (i=0; i<n; i++) {
  13195. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  13196. }
  13197. #endif
  13198. for (i=0; i<n; i++) {
  13199. if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
  13200. }
  13201. return 0;
  13202. }
  13203. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  13204. PyObject *exc_type = tstate->curexc_type;
  13205. if (exc_type == err) return 1;
  13206. if (unlikely(!exc_type)) return 0;
  13207. if (unlikely(PyTuple_Check(err)))
  13208. return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
  13209. return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
  13210. }
  13211. #endif
  13212. /* GetException */
  13213. #if CYTHON_FAST_THREAD_STATE
  13214. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13215. #else
  13216. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
  13217. #endif
  13218. PyObject *local_type, *local_value, *local_tb;
  13219. #if CYTHON_FAST_THREAD_STATE
  13220. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13221. local_type = tstate->curexc_type;
  13222. local_value = tstate->curexc_value;
  13223. local_tb = tstate->curexc_traceback;
  13224. tstate->curexc_type = 0;
  13225. tstate->curexc_value = 0;
  13226. tstate->curexc_traceback = 0;
  13227. #else
  13228. PyErr_Fetch(&local_type, &local_value, &local_tb);
  13229. #endif
  13230. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  13231. #if CYTHON_FAST_THREAD_STATE
  13232. if (unlikely(tstate->curexc_type))
  13233. #else
  13234. if (unlikely(PyErr_Occurred()))
  13235. #endif
  13236. goto bad;
  13237. #if PY_MAJOR_VERSION >= 3
  13238. if (local_tb) {
  13239. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  13240. goto bad;
  13241. }
  13242. #endif
  13243. Py_XINCREF(local_tb);
  13244. Py_XINCREF(local_type);
  13245. Py_XINCREF(local_value);
  13246. *type = local_type;
  13247. *value = local_value;
  13248. *tb = local_tb;
  13249. #if CYTHON_FAST_THREAD_STATE
  13250. #if PY_VERSION_HEX >= 0x030700A3
  13251. tmp_type = tstate->exc_state.exc_type;
  13252. tmp_value = tstate->exc_state.exc_value;
  13253. tmp_tb = tstate->exc_state.exc_traceback;
  13254. tstate->exc_state.exc_type = local_type;
  13255. tstate->exc_state.exc_value = local_value;
  13256. tstate->exc_state.exc_traceback = local_tb;
  13257. #else
  13258. tmp_type = tstate->exc_type;
  13259. tmp_value = tstate->exc_value;
  13260. tmp_tb = tstate->exc_traceback;
  13261. tstate->exc_type = local_type;
  13262. tstate->exc_value = local_value;
  13263. tstate->exc_traceback = local_tb;
  13264. #endif
  13265. Py_XDECREF(tmp_type);
  13266. Py_XDECREF(tmp_value);
  13267. Py_XDECREF(tmp_tb);
  13268. #else
  13269. PyErr_SetExcInfo(local_type, local_value, local_tb);
  13270. #endif
  13271. return 0;
  13272. bad:
  13273. *type = 0;
  13274. *value = 0;
  13275. *tb = 0;
  13276. Py_XDECREF(local_type);
  13277. Py_XDECREF(local_value);
  13278. Py_XDECREF(local_tb);
  13279. return -1;
  13280. }
  13281. /* SwapException */
  13282. #if CYTHON_FAST_THREAD_STATE
  13283. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13284. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13285. #if PY_VERSION_HEX >= 0x030700A3
  13286. tmp_type = tstate->exc_state.exc_type;
  13287. tmp_value = tstate->exc_state.exc_value;
  13288. tmp_tb = tstate->exc_state.exc_traceback;
  13289. tstate->exc_state.exc_type = *type;
  13290. tstate->exc_state.exc_value = *value;
  13291. tstate->exc_state.exc_traceback = *tb;
  13292. #else
  13293. tmp_type = tstate->exc_type;
  13294. tmp_value = tstate->exc_value;
  13295. tmp_tb = tstate->exc_traceback;
  13296. tstate->exc_type = *type;
  13297. tstate->exc_value = *value;
  13298. tstate->exc_traceback = *tb;
  13299. #endif
  13300. *type = tmp_type;
  13301. *value = tmp_value;
  13302. *tb = tmp_tb;
  13303. }
  13304. #else
  13305. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  13306. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13307. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  13308. PyErr_SetExcInfo(*type, *value, *tb);
  13309. *type = tmp_type;
  13310. *value = tmp_value;
  13311. *tb = tmp_tb;
  13312. }
  13313. #endif
  13314. /* PyUnicode_Unicode */
  13315. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj) {
  13316. if (unlikely(obj == Py_None))
  13317. obj = __pyx_kp_u_None;
  13318. return __Pyx_NewRef(obj);
  13319. }
  13320. /* JoinPyUnicode */
  13321. static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
  13322. CYTHON_UNUSED Py_UCS4 max_char) {
  13323. #if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  13324. PyObject *result_uval;
  13325. int result_ukind;
  13326. Py_ssize_t i, char_pos;
  13327. void *result_udata;
  13328. #if CYTHON_PEP393_ENABLED
  13329. result_uval = PyUnicode_New(result_ulength, max_char);
  13330. if (unlikely(!result_uval)) return NULL;
  13331. result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
  13332. result_udata = PyUnicode_DATA(result_uval);
  13333. #else
  13334. result_uval = PyUnicode_FromUnicode(NULL, result_ulength);
  13335. if (unlikely(!result_uval)) return NULL;
  13336. result_ukind = sizeof(Py_UNICODE);
  13337. result_udata = PyUnicode_AS_UNICODE(result_uval);
  13338. #endif
  13339. char_pos = 0;
  13340. for (i=0; i < value_count; i++) {
  13341. int ukind;
  13342. Py_ssize_t ulength;
  13343. void *udata;
  13344. PyObject *uval = PyTuple_GET_ITEM(value_tuple, i);
  13345. if (unlikely(__Pyx_PyUnicode_READY(uval)))
  13346. goto bad;
  13347. ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
  13348. if (unlikely(!ulength))
  13349. continue;
  13350. if (unlikely(char_pos + ulength < 0))
  13351. goto overflow;
  13352. ukind = __Pyx_PyUnicode_KIND(uval);
  13353. udata = __Pyx_PyUnicode_DATA(uval);
  13354. if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
  13355. memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
  13356. } else {
  13357. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
  13358. _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
  13359. #else
  13360. Py_ssize_t j;
  13361. for (j=0; j < ulength; j++) {
  13362. Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
  13363. __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
  13364. }
  13365. #endif
  13366. }
  13367. char_pos += ulength;
  13368. }
  13369. return result_uval;
  13370. overflow:
  13371. PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
  13372. bad:
  13373. Py_DECREF(result_uval);
  13374. return NULL;
  13375. #else
  13376. result_ulength++;
  13377. value_count++;
  13378. return PyUnicode_Join(__pyx_empty_unicode, value_tuple);
  13379. #endif
  13380. }
  13381. /* FastTypeChecks */
  13382. #if CYTHON_COMPILING_IN_CPYTHON
  13383. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  13384. while (a) {
  13385. a = a->tp_base;
  13386. if (a == b)
  13387. return 1;
  13388. }
  13389. return b == &PyBaseObject_Type;
  13390. }
  13391. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  13392. PyObject *mro;
  13393. if (a == b) return 1;
  13394. mro = a->tp_mro;
  13395. if (likely(mro)) {
  13396. Py_ssize_t i, n;
  13397. n = PyTuple_GET_SIZE(mro);
  13398. for (i = 0; i < n; i++) {
  13399. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  13400. return 1;
  13401. }
  13402. return 0;
  13403. }
  13404. return __Pyx_InBases(a, b);
  13405. }
  13406. #if PY_MAJOR_VERSION == 2
  13407. static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
  13408. PyObject *exception, *value, *tb;
  13409. int res;
  13410. __Pyx_PyThreadState_declare
  13411. __Pyx_PyThreadState_assign
  13412. __Pyx_ErrFetch(&exception, &value, &tb);
  13413. res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
  13414. if (unlikely(res == -1)) {
  13415. PyErr_WriteUnraisable(err);
  13416. res = 0;
  13417. }
  13418. if (!res) {
  13419. res = PyObject_IsSubclass(err, exc_type2);
  13420. if (unlikely(res == -1)) {
  13421. PyErr_WriteUnraisable(err);
  13422. res = 0;
  13423. }
  13424. }
  13425. __Pyx_ErrRestore(exception, value, tb);
  13426. return res;
  13427. }
  13428. #else
  13429. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  13430. int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
  13431. if (!res) {
  13432. res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  13433. }
  13434. return res;
  13435. }
  13436. #endif
  13437. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  13438. Py_ssize_t i, n;
  13439. assert(PyExceptionClass_Check(exc_type));
  13440. n = PyTuple_GET_SIZE(tuple);
  13441. #if PY_MAJOR_VERSION >= 3
  13442. for (i=0; i<n; i++) {
  13443. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  13444. }
  13445. #endif
  13446. for (i=0; i<n; i++) {
  13447. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  13448. #if PY_MAJOR_VERSION < 3
  13449. if (likely(exc_type == t)) return 1;
  13450. #endif
  13451. if (likely(PyExceptionClass_Check(t))) {
  13452. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  13453. } else {
  13454. }
  13455. }
  13456. return 0;
  13457. }
  13458. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  13459. if (likely(err == exc_type)) return 1;
  13460. if (likely(PyExceptionClass_Check(err))) {
  13461. if (likely(PyExceptionClass_Check(exc_type))) {
  13462. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  13463. } else if (likely(PyTuple_Check(exc_type))) {
  13464. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  13465. } else {
  13466. }
  13467. }
  13468. return PyErr_GivenExceptionMatches(err, exc_type);
  13469. }
  13470. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  13471. assert(PyExceptionClass_Check(exc_type1));
  13472. assert(PyExceptionClass_Check(exc_type2));
  13473. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  13474. if (likely(PyExceptionClass_Check(err))) {
  13475. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  13476. }
  13477. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  13478. }
  13479. #endif
  13480. /* PyObjectSetAttrStr */
  13481. #if CYTHON_USE_TYPE_SLOTS
  13482. static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
  13483. PyTypeObject* tp = Py_TYPE(obj);
  13484. if (likely(tp->tp_setattro))
  13485. return tp->tp_setattro(obj, attr_name, value);
  13486. #if PY_MAJOR_VERSION < 3
  13487. if (likely(tp->tp_setattr))
  13488. return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
  13489. #endif
  13490. return PyObject_SetAttr(obj, attr_name, value);
  13491. }
  13492. #endif
  13493. /* PyIntBinop */
  13494. #if !CYTHON_COMPILING_IN_PYPY
  13495. static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
  13496. #if PY_MAJOR_VERSION < 3
  13497. if (likely(PyInt_CheckExact(op1))) {
  13498. const long b = intval;
  13499. long x;
  13500. long a = PyInt_AS_LONG(op1);
  13501. x = (long)((unsigned long)a + b);
  13502. if (likely((x^a) >= 0 || (x^b) >= 0))
  13503. return PyInt_FromLong(x);
  13504. return PyLong_Type.tp_as_number->nb_add(op1, op2);
  13505. }
  13506. #endif
  13507. #if CYTHON_USE_PYLONG_INTERNALS
  13508. if (likely(PyLong_CheckExact(op1))) {
  13509. const long b = intval;
  13510. long a, x;
  13511. #ifdef HAVE_LONG_LONG
  13512. const PY_LONG_LONG llb = intval;
  13513. PY_LONG_LONG lla, llx;
  13514. #endif
  13515. const digit* digits = ((PyLongObject*)op1)->ob_digit;
  13516. const Py_ssize_t size = Py_SIZE(op1);
  13517. if (likely(__Pyx_sst_abs(size) <= 1)) {
  13518. a = likely(size) ? digits[0] : 0;
  13519. if (size == -1) a = -a;
  13520. } else {
  13521. switch (size) {
  13522. case -2:
  13523. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  13524. a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13525. break;
  13526. #ifdef HAVE_LONG_LONG
  13527. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  13528. lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  13529. goto long_long;
  13530. #endif
  13531. }
  13532. CYTHON_FALLTHROUGH;
  13533. case 2:
  13534. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  13535. a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13536. break;
  13537. #ifdef HAVE_LONG_LONG
  13538. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  13539. lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  13540. goto long_long;
  13541. #endif
  13542. }
  13543. CYTHON_FALLTHROUGH;
  13544. case -3:
  13545. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  13546. a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13547. break;
  13548. #ifdef HAVE_LONG_LONG
  13549. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  13550. 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]));
  13551. goto long_long;
  13552. #endif
  13553. }
  13554. CYTHON_FALLTHROUGH;
  13555. case 3:
  13556. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  13557. a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13558. break;
  13559. #ifdef HAVE_LONG_LONG
  13560. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  13561. 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]));
  13562. goto long_long;
  13563. #endif
  13564. }
  13565. CYTHON_FALLTHROUGH;
  13566. case -4:
  13567. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  13568. a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13569. break;
  13570. #ifdef HAVE_LONG_LONG
  13571. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  13572. 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]));
  13573. goto long_long;
  13574. #endif
  13575. }
  13576. CYTHON_FALLTHROUGH;
  13577. case 4:
  13578. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  13579. a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  13580. break;
  13581. #ifdef HAVE_LONG_LONG
  13582. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  13583. 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]));
  13584. goto long_long;
  13585. #endif
  13586. }
  13587. CYTHON_FALLTHROUGH;
  13588. default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
  13589. }
  13590. }
  13591. x = a + b;
  13592. return PyLong_FromLong(x);
  13593. #ifdef HAVE_LONG_LONG
  13594. long_long:
  13595. llx = lla + llb;
  13596. return PyLong_FromLongLong(llx);
  13597. #endif
  13598. }
  13599. #endif
  13600. if (PyFloat_CheckExact(op1)) {
  13601. const long b = intval;
  13602. double a = PyFloat_AS_DOUBLE(op1);
  13603. double result;
  13604. PyFPE_START_PROTECT("add", return NULL)
  13605. result = ((double)a) + (double)b;
  13606. PyFPE_END_PROTECT(result)
  13607. return PyFloat_FromDouble(result);
  13608. }
  13609. return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
  13610. }
  13611. #endif
  13612. /* DictGetItem */
  13613. #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
  13614. static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
  13615. PyObject *value;
  13616. value = PyDict_GetItemWithError(d, key);
  13617. if (unlikely(!value)) {
  13618. if (!PyErr_Occurred()) {
  13619. PyObject* args = PyTuple_Pack(1, key);
  13620. if (likely(args))
  13621. PyErr_SetObject(PyExc_KeyError, args);
  13622. Py_XDECREF(args);
  13623. }
  13624. return NULL;
  13625. }
  13626. Py_INCREF(value);
  13627. return value;
  13628. }
  13629. #endif
  13630. /* PyObject_GenericGetAttrNoDict */
  13631. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  13632. static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
  13633. PyErr_Format(PyExc_AttributeError,
  13634. #if PY_MAJOR_VERSION >= 3
  13635. "'%.50s' object has no attribute '%U'",
  13636. tp->tp_name, attr_name);
  13637. #else
  13638. "'%.50s' object has no attribute '%.400s'",
  13639. tp->tp_name, PyString_AS_STRING(attr_name));
  13640. #endif
  13641. return NULL;
  13642. }
  13643. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
  13644. PyObject *descr;
  13645. PyTypeObject *tp = Py_TYPE(obj);
  13646. if (unlikely(!PyString_Check(attr_name))) {
  13647. return PyObject_GenericGetAttr(obj, attr_name);
  13648. }
  13649. assert(!tp->tp_dictoffset);
  13650. descr = _PyType_Lookup(tp, attr_name);
  13651. if (unlikely(!descr)) {
  13652. return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
  13653. }
  13654. Py_INCREF(descr);
  13655. #if PY_MAJOR_VERSION < 3
  13656. if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
  13657. #endif
  13658. {
  13659. descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
  13660. if (unlikely(f)) {
  13661. PyObject *res = f(descr, obj, (PyObject *)tp);
  13662. Py_DECREF(descr);
  13663. return res;
  13664. }
  13665. }
  13666. return descr;
  13667. }
  13668. #endif
  13669. /* PyObject_GenericGetAttr */
  13670. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  13671. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
  13672. if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
  13673. return PyObject_GenericGetAttr(obj, attr_name);
  13674. }
  13675. return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
  13676. }
  13677. #endif
  13678. /* SetVTable */
  13679. static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
  13680. #if PY_VERSION_HEX >= 0x02070000
  13681. PyObject *ob = PyCapsule_New(vtable, 0, 0);
  13682. #else
  13683. PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
  13684. #endif
  13685. if (!ob)
  13686. goto bad;
  13687. if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
  13688. goto bad;
  13689. Py_DECREF(ob);
  13690. return 0;
  13691. bad:
  13692. Py_XDECREF(ob);
  13693. return -1;
  13694. }
  13695. /* SetupReduce */
  13696. static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  13697. int ret;
  13698. PyObject *name_attr;
  13699. name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  13700. if (likely(name_attr)) {
  13701. ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  13702. } else {
  13703. ret = -1;
  13704. }
  13705. if (unlikely(ret < 0)) {
  13706. PyErr_Clear();
  13707. ret = 0;
  13708. }
  13709. Py_XDECREF(name_attr);
  13710. return ret;
  13711. }
  13712. static int __Pyx_setup_reduce(PyObject* type_obj) {
  13713. int ret = 0;
  13714. PyObject *object_reduce = NULL;
  13715. PyObject *object_reduce_ex = NULL;
  13716. PyObject *reduce = NULL;
  13717. PyObject *reduce_ex = NULL;
  13718. PyObject *reduce_cython = NULL;
  13719. PyObject *setstate = NULL;
  13720. PyObject *setstate_cython = NULL;
  13721. #if CYTHON_USE_PYTYPE_LOOKUP
  13722. if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
  13723. #else
  13724. if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
  13725. #endif
  13726. #if CYTHON_USE_PYTYPE_LOOKUP
  13727. object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  13728. #else
  13729. object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  13730. #endif
  13731. reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
  13732. if (reduce_ex == object_reduce_ex) {
  13733. #if CYTHON_USE_PYTYPE_LOOKUP
  13734. object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  13735. #else
  13736. object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  13737. #endif
  13738. reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
  13739. if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
  13740. reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
  13741. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
  13742. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
  13743. setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
  13744. if (!setstate) PyErr_Clear();
  13745. if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
  13746. setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
  13747. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
  13748. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
  13749. }
  13750. PyType_Modified((PyTypeObject*)type_obj);
  13751. }
  13752. }
  13753. goto GOOD;
  13754. BAD:
  13755. if (!PyErr_Occurred())
  13756. PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
  13757. ret = -1;
  13758. GOOD:
  13759. #if !CYTHON_USE_PYTYPE_LOOKUP
  13760. Py_XDECREF(object_reduce);
  13761. Py_XDECREF(object_reduce_ex);
  13762. #endif
  13763. Py_XDECREF(reduce);
  13764. Py_XDECREF(reduce_ex);
  13765. Py_XDECREF(reduce_cython);
  13766. Py_XDECREF(setstate);
  13767. Py_XDECREF(setstate_cython);
  13768. return ret;
  13769. }
  13770. /* Import */
  13771. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  13772. PyObject *empty_list = 0;
  13773. PyObject *module = 0;
  13774. PyObject *global_dict = 0;
  13775. PyObject *empty_dict = 0;
  13776. PyObject *list;
  13777. #if PY_MAJOR_VERSION < 3
  13778. PyObject *py_import;
  13779. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  13780. if (!py_import)
  13781. goto bad;
  13782. #endif
  13783. if (from_list)
  13784. list = from_list;
  13785. else {
  13786. empty_list = PyList_New(0);
  13787. if (!empty_list)
  13788. goto bad;
  13789. list = empty_list;
  13790. }
  13791. global_dict = PyModule_GetDict(__pyx_m);
  13792. if (!global_dict)
  13793. goto bad;
  13794. empty_dict = PyDict_New();
  13795. if (!empty_dict)
  13796. goto bad;
  13797. {
  13798. #if PY_MAJOR_VERSION >= 3
  13799. if (level == -1) {
  13800. if (strchr(__Pyx_MODULE_NAME, '.')) {
  13801. module = PyImport_ImportModuleLevelObject(
  13802. name, global_dict, empty_dict, list, 1);
  13803. if (!module) {
  13804. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  13805. goto bad;
  13806. PyErr_Clear();
  13807. }
  13808. }
  13809. level = 0;
  13810. }
  13811. #endif
  13812. if (!module) {
  13813. #if PY_MAJOR_VERSION < 3
  13814. PyObject *py_level = PyInt_FromLong(level);
  13815. if (!py_level)
  13816. goto bad;
  13817. module = PyObject_CallFunctionObjArgs(py_import,
  13818. name, global_dict, empty_dict, list, py_level, NULL);
  13819. Py_DECREF(py_level);
  13820. #else
  13821. module = PyImport_ImportModuleLevelObject(
  13822. name, global_dict, empty_dict, list, level);
  13823. #endif
  13824. }
  13825. }
  13826. bad:
  13827. #if PY_MAJOR_VERSION < 3
  13828. Py_XDECREF(py_import);
  13829. #endif
  13830. Py_XDECREF(empty_list);
  13831. Py_XDECREF(empty_dict);
  13832. return module;
  13833. }
  13834. /* ImportFrom */
  13835. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  13836. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  13837. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  13838. PyErr_Format(PyExc_ImportError,
  13839. #if PY_MAJOR_VERSION < 3
  13840. "cannot import name %.230s", PyString_AS_STRING(name));
  13841. #else
  13842. "cannot import name %S", name);
  13843. #endif
  13844. }
  13845. return value;
  13846. }
  13847. /* CalculateMetaclass */
  13848. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
  13849. Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
  13850. for (i=0; i < nbases; i++) {
  13851. PyTypeObject *tmptype;
  13852. PyObject *tmp = PyTuple_GET_ITEM(bases, i);
  13853. tmptype = Py_TYPE(tmp);
  13854. #if PY_MAJOR_VERSION < 3
  13855. if (tmptype == &PyClass_Type)
  13856. continue;
  13857. #endif
  13858. if (!metaclass) {
  13859. metaclass = tmptype;
  13860. continue;
  13861. }
  13862. if (PyType_IsSubtype(metaclass, tmptype))
  13863. continue;
  13864. if (PyType_IsSubtype(tmptype, metaclass)) {
  13865. metaclass = tmptype;
  13866. continue;
  13867. }
  13868. PyErr_SetString(PyExc_TypeError,
  13869. "metaclass conflict: "
  13870. "the metaclass of a derived class "
  13871. "must be a (non-strict) subclass "
  13872. "of the metaclasses of all its bases");
  13873. return NULL;
  13874. }
  13875. if (!metaclass) {
  13876. #if PY_MAJOR_VERSION < 3
  13877. metaclass = &PyClass_Type;
  13878. #else
  13879. metaclass = &PyType_Type;
  13880. #endif
  13881. }
  13882. Py_INCREF((PyObject*) metaclass);
  13883. return (PyObject*) metaclass;
  13884. }
  13885. /* Py3ClassCreate */
  13886. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
  13887. PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
  13888. PyObject *ns;
  13889. if (metaclass) {
  13890. PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
  13891. if (prep) {
  13892. PyObject *pargs = PyTuple_Pack(2, name, bases);
  13893. if (unlikely(!pargs)) {
  13894. Py_DECREF(prep);
  13895. return NULL;
  13896. }
  13897. ns = PyObject_Call(prep, pargs, mkw);
  13898. Py_DECREF(prep);
  13899. Py_DECREF(pargs);
  13900. } else {
  13901. if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
  13902. return NULL;
  13903. PyErr_Clear();
  13904. ns = PyDict_New();
  13905. }
  13906. } else {
  13907. ns = PyDict_New();
  13908. }
  13909. if (unlikely(!ns))
  13910. return NULL;
  13911. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
  13912. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
  13913. if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
  13914. return ns;
  13915. bad:
  13916. Py_DECREF(ns);
  13917. return NULL;
  13918. }
  13919. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
  13920. PyObject *dict, PyObject *mkw,
  13921. int calculate_metaclass, int allow_py2_metaclass) {
  13922. PyObject *result, *margs;
  13923. PyObject *owned_metaclass = NULL;
  13924. if (allow_py2_metaclass) {
  13925. owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
  13926. if (owned_metaclass) {
  13927. metaclass = owned_metaclass;
  13928. } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
  13929. PyErr_Clear();
  13930. } else {
  13931. return NULL;
  13932. }
  13933. }
  13934. if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
  13935. metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
  13936. Py_XDECREF(owned_metaclass);
  13937. if (unlikely(!metaclass))
  13938. return NULL;
  13939. owned_metaclass = metaclass;
  13940. }
  13941. margs = PyTuple_Pack(3, name, bases, dict);
  13942. if (unlikely(!margs)) {
  13943. result = NULL;
  13944. } else {
  13945. result = PyObject_Call(metaclass, margs, mkw);
  13946. Py_DECREF(margs);
  13947. }
  13948. Py_XDECREF(owned_metaclass);
  13949. return result;
  13950. }
  13951. /* GetNameInClass */
  13952. static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
  13953. __Pyx_PyThreadState_declare
  13954. __Pyx_PyThreadState_assign
  13955. if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
  13956. return NULL;
  13957. __Pyx_PyErr_Clear();
  13958. return __Pyx_GetModuleGlobalName(name);
  13959. }
  13960. static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
  13961. PyObject *result;
  13962. result = __Pyx_PyObject_GetAttrStr(nmspace, name);
  13963. if (!result) {
  13964. result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
  13965. }
  13966. return result;
  13967. }
  13968. /* CLineInTraceback */
  13969. #ifndef CYTHON_CLINE_IN_TRACEBACK
  13970. static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
  13971. PyObject *use_cline;
  13972. PyObject *ptype, *pvalue, *ptraceback;
  13973. #if CYTHON_COMPILING_IN_CPYTHON
  13974. PyObject **cython_runtime_dict;
  13975. #endif
  13976. if (unlikely(!__pyx_cython_runtime)) {
  13977. return c_line;
  13978. }
  13979. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  13980. #if CYTHON_COMPILING_IN_CPYTHON
  13981. cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
  13982. if (likely(cython_runtime_dict)) {
  13983. use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
  13984. } else
  13985. #endif
  13986. {
  13987. PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
  13988. if (use_cline_obj) {
  13989. use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
  13990. Py_DECREF(use_cline_obj);
  13991. } else {
  13992. PyErr_Clear();
  13993. use_cline = NULL;
  13994. }
  13995. }
  13996. if (!use_cline) {
  13997. c_line = 0;
  13998. PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
  13999. }
  14000. else if (PyObject_Not(use_cline) != 0) {
  14001. c_line = 0;
  14002. }
  14003. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  14004. return c_line;
  14005. }
  14006. #endif
  14007. /* CodeObjectCache */
  14008. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  14009. int start = 0, mid = 0, end = count - 1;
  14010. if (end >= 0 && code_line > entries[end].code_line) {
  14011. return count;
  14012. }
  14013. while (start < end) {
  14014. mid = start + (end - start) / 2;
  14015. if (code_line < entries[mid].code_line) {
  14016. end = mid;
  14017. } else if (code_line > entries[mid].code_line) {
  14018. start = mid + 1;
  14019. } else {
  14020. return mid;
  14021. }
  14022. }
  14023. if (code_line <= entries[mid].code_line) {
  14024. return mid;
  14025. } else {
  14026. return mid + 1;
  14027. }
  14028. }
  14029. static PyCodeObject *__pyx_find_code_object(int code_line) {
  14030. PyCodeObject* code_object;
  14031. int pos;
  14032. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  14033. return NULL;
  14034. }
  14035. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  14036. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  14037. return NULL;
  14038. }
  14039. code_object = __pyx_code_cache.entries[pos].code_object;
  14040. Py_INCREF(code_object);
  14041. return code_object;
  14042. }
  14043. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  14044. int pos, i;
  14045. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  14046. if (unlikely(!code_line)) {
  14047. return;
  14048. }
  14049. if (unlikely(!entries)) {
  14050. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  14051. if (likely(entries)) {
  14052. __pyx_code_cache.entries = entries;
  14053. __pyx_code_cache.max_count = 64;
  14054. __pyx_code_cache.count = 1;
  14055. entries[0].code_line = code_line;
  14056. entries[0].code_object = code_object;
  14057. Py_INCREF(code_object);
  14058. }
  14059. return;
  14060. }
  14061. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  14062. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  14063. PyCodeObject* tmp = entries[pos].code_object;
  14064. entries[pos].code_object = code_object;
  14065. Py_DECREF(tmp);
  14066. return;
  14067. }
  14068. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  14069. int new_max = __pyx_code_cache.max_count + 64;
  14070. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  14071. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  14072. if (unlikely(!entries)) {
  14073. return;
  14074. }
  14075. __pyx_code_cache.entries = entries;
  14076. __pyx_code_cache.max_count = new_max;
  14077. }
  14078. for (i=__pyx_code_cache.count; i>pos; i--) {
  14079. entries[i] = entries[i-1];
  14080. }
  14081. entries[pos].code_line = code_line;
  14082. entries[pos].code_object = code_object;
  14083. __pyx_code_cache.count++;
  14084. Py_INCREF(code_object);
  14085. }
  14086. /* AddTraceback */
  14087. #include "compile.h"
  14088. #include "frameobject.h"
  14089. #include "traceback.h"
  14090. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  14091. const char *funcname, int c_line,
  14092. int py_line, const char *filename) {
  14093. PyCodeObject *py_code = 0;
  14094. PyObject *py_srcfile = 0;
  14095. PyObject *py_funcname = 0;
  14096. #if PY_MAJOR_VERSION < 3
  14097. py_srcfile = PyString_FromString(filename);
  14098. #else
  14099. py_srcfile = PyUnicode_FromString(filename);
  14100. #endif
  14101. if (!py_srcfile) goto bad;
  14102. if (c_line) {
  14103. #if PY_MAJOR_VERSION < 3
  14104. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  14105. #else
  14106. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  14107. #endif
  14108. }
  14109. else {
  14110. #if PY_MAJOR_VERSION < 3
  14111. py_funcname = PyString_FromString(funcname);
  14112. #else
  14113. py_funcname = PyUnicode_FromString(funcname);
  14114. #endif
  14115. }
  14116. if (!py_funcname) goto bad;
  14117. py_code = __Pyx_PyCode_New(
  14118. 0,
  14119. 0,
  14120. 0,
  14121. 0,
  14122. 0,
  14123. __pyx_empty_bytes, /*PyObject *code,*/
  14124. __pyx_empty_tuple, /*PyObject *consts,*/
  14125. __pyx_empty_tuple, /*PyObject *names,*/
  14126. __pyx_empty_tuple, /*PyObject *varnames,*/
  14127. __pyx_empty_tuple, /*PyObject *freevars,*/
  14128. __pyx_empty_tuple, /*PyObject *cellvars,*/
  14129. py_srcfile, /*PyObject *filename,*/
  14130. py_funcname, /*PyObject *name,*/
  14131. py_line,
  14132. __pyx_empty_bytes /*PyObject *lnotab*/
  14133. );
  14134. Py_DECREF(py_srcfile);
  14135. Py_DECREF(py_funcname);
  14136. return py_code;
  14137. bad:
  14138. Py_XDECREF(py_srcfile);
  14139. Py_XDECREF(py_funcname);
  14140. return NULL;
  14141. }
  14142. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  14143. int py_line, const char *filename) {
  14144. PyCodeObject *py_code = 0;
  14145. PyFrameObject *py_frame = 0;
  14146. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  14147. if (c_line) {
  14148. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  14149. }
  14150. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  14151. if (!py_code) {
  14152. py_code = __Pyx_CreateCodeObjectForTraceback(
  14153. funcname, c_line, py_line, filename);
  14154. if (!py_code) goto bad;
  14155. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  14156. }
  14157. py_frame = PyFrame_New(
  14158. tstate, /*PyThreadState *tstate,*/
  14159. py_code, /*PyCodeObject *code,*/
  14160. __pyx_d, /*PyObject *globals,*/
  14161. 0 /*PyObject *locals*/
  14162. );
  14163. if (!py_frame) goto bad;
  14164. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  14165. PyTraceBack_Here(py_frame);
  14166. bad:
  14167. Py_XDECREF(py_code);
  14168. Py_XDECREF(py_frame);
  14169. }
  14170. /* CIntToPy */
  14171. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
  14172. const int neg_one = (int) -1, const_zero = (int) 0;
  14173. const int is_unsigned = neg_one > const_zero;
  14174. if (is_unsigned) {
  14175. if (sizeof(int) < sizeof(long)) {
  14176. return PyInt_FromLong((long) value);
  14177. } else if (sizeof(int) <= sizeof(unsigned long)) {
  14178. return PyLong_FromUnsignedLong((unsigned long) value);
  14179. #ifdef HAVE_LONG_LONG
  14180. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  14181. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14182. #endif
  14183. }
  14184. } else {
  14185. if (sizeof(int) <= sizeof(long)) {
  14186. return PyInt_FromLong((long) value);
  14187. #ifdef HAVE_LONG_LONG
  14188. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  14189. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14190. #endif
  14191. }
  14192. }
  14193. {
  14194. int one = 1; int little = (int)*(unsigned char *)&one;
  14195. unsigned char *bytes = (unsigned char *)&value;
  14196. return _PyLong_FromByteArray(bytes, sizeof(int),
  14197. little, !is_unsigned);
  14198. }
  14199. }
  14200. /* CIntToPy */
  14201. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
  14202. const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
  14203. const int is_unsigned = neg_one > const_zero;
  14204. if (is_unsigned) {
  14205. if (sizeof(unsigned int) < sizeof(long)) {
  14206. return PyInt_FromLong((long) value);
  14207. } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
  14208. return PyLong_FromUnsignedLong((unsigned long) value);
  14209. #ifdef HAVE_LONG_LONG
  14210. } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
  14211. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14212. #endif
  14213. }
  14214. } else {
  14215. if (sizeof(unsigned int) <= sizeof(long)) {
  14216. return PyInt_FromLong((long) value);
  14217. #ifdef HAVE_LONG_LONG
  14218. } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
  14219. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14220. #endif
  14221. }
  14222. }
  14223. {
  14224. int one = 1; int little = (int)*(unsigned char *)&one;
  14225. unsigned char *bytes = (unsigned char *)&value;
  14226. return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
  14227. little, !is_unsigned);
  14228. }
  14229. }
  14230. /* CIntToPy */
  14231. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) {
  14232. const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0;
  14233. const int is_unsigned = neg_one > const_zero;
  14234. if (is_unsigned) {
  14235. if (sizeof(unsigned long) < sizeof(long)) {
  14236. return PyInt_FromLong((long) value);
  14237. } else if (sizeof(unsigned long) <= sizeof(unsigned long)) {
  14238. return PyLong_FromUnsignedLong((unsigned long) value);
  14239. #ifdef HAVE_LONG_LONG
  14240. } else if (sizeof(unsigned long) <= sizeof(unsigned PY_LONG_LONG)) {
  14241. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14242. #endif
  14243. }
  14244. } else {
  14245. if (sizeof(unsigned long) <= sizeof(long)) {
  14246. return PyInt_FromLong((long) value);
  14247. #ifdef HAVE_LONG_LONG
  14248. } else if (sizeof(unsigned long) <= sizeof(PY_LONG_LONG)) {
  14249. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14250. #endif
  14251. }
  14252. }
  14253. {
  14254. int one = 1; int little = (int)*(unsigned char *)&one;
  14255. unsigned char *bytes = (unsigned char *)&value;
  14256. return _PyLong_FromByteArray(bytes, sizeof(unsigned long),
  14257. little, !is_unsigned);
  14258. }
  14259. }
  14260. /* CIntFromPyVerify */
  14261. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  14262. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  14263. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  14264. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  14265. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  14266. {\
  14267. func_type value = func_value;\
  14268. if (sizeof(target_type) < sizeof(func_type)) {\
  14269. if (unlikely(value != (func_type) (target_type) value)) {\
  14270. func_type zero = 0;\
  14271. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  14272. return (target_type) -1;\
  14273. if (is_unsigned && unlikely(value < zero))\
  14274. goto raise_neg_overflow;\
  14275. else\
  14276. goto raise_overflow;\
  14277. }\
  14278. }\
  14279. return (target_type) value;\
  14280. }
  14281. /* CIntToPy */
  14282. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  14283. const long neg_one = (long) -1, const_zero = (long) 0;
  14284. const int is_unsigned = neg_one > const_zero;
  14285. if (is_unsigned) {
  14286. if (sizeof(long) < sizeof(long)) {
  14287. return PyInt_FromLong((long) value);
  14288. } else if (sizeof(long) <= sizeof(unsigned long)) {
  14289. return PyLong_FromUnsignedLong((unsigned long) value);
  14290. #ifdef HAVE_LONG_LONG
  14291. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  14292. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14293. #endif
  14294. }
  14295. } else {
  14296. if (sizeof(long) <= sizeof(long)) {
  14297. return PyInt_FromLong((long) value);
  14298. #ifdef HAVE_LONG_LONG
  14299. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  14300. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14301. #endif
  14302. }
  14303. }
  14304. {
  14305. int one = 1; int little = (int)*(unsigned char *)&one;
  14306. unsigned char *bytes = (unsigned char *)&value;
  14307. return _PyLong_FromByteArray(bytes, sizeof(long),
  14308. little, !is_unsigned);
  14309. }
  14310. }
  14311. /* CIntToPy */
  14312. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_MDB_dbi(MDB_dbi value) {
  14313. const MDB_dbi neg_one = (MDB_dbi) -1, const_zero = (MDB_dbi) 0;
  14314. const int is_unsigned = neg_one > const_zero;
  14315. if (is_unsigned) {
  14316. if (sizeof(MDB_dbi) < sizeof(long)) {
  14317. return PyInt_FromLong((long) value);
  14318. } else if (sizeof(MDB_dbi) <= sizeof(unsigned long)) {
  14319. return PyLong_FromUnsignedLong((unsigned long) value);
  14320. #ifdef HAVE_LONG_LONG
  14321. } else if (sizeof(MDB_dbi) <= sizeof(unsigned PY_LONG_LONG)) {
  14322. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14323. #endif
  14324. }
  14325. } else {
  14326. if (sizeof(MDB_dbi) <= sizeof(long)) {
  14327. return PyInt_FromLong((long) value);
  14328. #ifdef HAVE_LONG_LONG
  14329. } else if (sizeof(MDB_dbi) <= sizeof(PY_LONG_LONG)) {
  14330. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14331. #endif
  14332. }
  14333. }
  14334. {
  14335. int one = 1; int little = (int)*(unsigned char *)&one;
  14336. unsigned char *bytes = (unsigned char *)&value;
  14337. return _PyLong_FromByteArray(bytes, sizeof(MDB_dbi),
  14338. little, !is_unsigned);
  14339. }
  14340. }
  14341. static PyObject* __pyx_convert__to_py_struct__MDB_stat(struct MDB_stat s) {
  14342. PyObject* res;
  14343. PyObject* member;
  14344. res = __Pyx_PyDict_NewPresized(6); if (unlikely(!res)) return NULL;
  14345. member = __Pyx_PyInt_From_unsigned_int(s.ms_psize); if (unlikely(!member)) goto bad;
  14346. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_psize, member) < 0)) goto bad;
  14347. Py_DECREF(member);
  14348. member = __Pyx_PyInt_From_unsigned_int(s.ms_depth); if (unlikely(!member)) goto bad;
  14349. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_depth, member) < 0)) goto bad;
  14350. Py_DECREF(member);
  14351. member = __Pyx_PyInt_FromSize_t(s.ms_branch_pages); if (unlikely(!member)) goto bad;
  14352. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_branch_pages, member) < 0)) goto bad;
  14353. Py_DECREF(member);
  14354. member = __Pyx_PyInt_FromSize_t(s.ms_leaf_pages); if (unlikely(!member)) goto bad;
  14355. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_leaf_pages, member) < 0)) goto bad;
  14356. Py_DECREF(member);
  14357. member = __Pyx_PyInt_FromSize_t(s.ms_overflow_pages); if (unlikely(!member)) goto bad;
  14358. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_overflow_pages, member) < 0)) goto bad;
  14359. Py_DECREF(member);
  14360. member = __Pyx_PyInt_FromSize_t(s.ms_entries); if (unlikely(!member)) goto bad;
  14361. if (unlikely(PyDict_SetItem(res, __pyx_n_s_ms_entries, member) < 0)) goto bad;
  14362. Py_DECREF(member);
  14363. return res;
  14364. bad:
  14365. Py_XDECREF(member);
  14366. Py_DECREF(res);
  14367. return NULL;
  14368. }
  14369. /* CIntFromPy */
  14370. static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
  14371. const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
  14372. const int is_unsigned = neg_one > const_zero;
  14373. #if PY_MAJOR_VERSION < 3
  14374. if (likely(PyInt_Check(x))) {
  14375. if (sizeof(size_t) < sizeof(long)) {
  14376. __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
  14377. } else {
  14378. long val = PyInt_AS_LONG(x);
  14379. if (is_unsigned && unlikely(val < 0)) {
  14380. goto raise_neg_overflow;
  14381. }
  14382. return (size_t) val;
  14383. }
  14384. } else
  14385. #endif
  14386. if (likely(PyLong_Check(x))) {
  14387. if (is_unsigned) {
  14388. #if CYTHON_USE_PYLONG_INTERNALS
  14389. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14390. switch (Py_SIZE(x)) {
  14391. case 0: return (size_t) 0;
  14392. case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
  14393. case 2:
  14394. if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
  14395. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14396. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14397. } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
  14398. return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14399. }
  14400. }
  14401. break;
  14402. case 3:
  14403. if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
  14404. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14405. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14406. } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
  14407. return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14408. }
  14409. }
  14410. break;
  14411. case 4:
  14412. if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
  14413. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14414. __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])))
  14415. } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
  14416. 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]));
  14417. }
  14418. }
  14419. break;
  14420. }
  14421. #endif
  14422. #if CYTHON_COMPILING_IN_CPYTHON
  14423. if (unlikely(Py_SIZE(x) < 0)) {
  14424. goto raise_neg_overflow;
  14425. }
  14426. #else
  14427. {
  14428. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14429. if (unlikely(result < 0))
  14430. return (size_t) -1;
  14431. if (unlikely(result == 1))
  14432. goto raise_neg_overflow;
  14433. }
  14434. #endif
  14435. if (sizeof(size_t) <= sizeof(unsigned long)) {
  14436. __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
  14437. #ifdef HAVE_LONG_LONG
  14438. } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
  14439. __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14440. #endif
  14441. }
  14442. } else {
  14443. #if CYTHON_USE_PYLONG_INTERNALS
  14444. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14445. switch (Py_SIZE(x)) {
  14446. case 0: return (size_t) 0;
  14447. case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
  14448. case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0])
  14449. case -2:
  14450. if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
  14451. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14452. __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14453. } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14454. return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14455. }
  14456. }
  14457. break;
  14458. case 2:
  14459. if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
  14460. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14461. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14462. } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14463. return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14464. }
  14465. }
  14466. break;
  14467. case -3:
  14468. if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14469. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14470. __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14471. } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14472. return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14473. }
  14474. }
  14475. break;
  14476. case 3:
  14477. if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
  14478. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14479. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14480. } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14481. return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14482. }
  14483. }
  14484. break;
  14485. case -4:
  14486. if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14487. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14488. __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])))
  14489. } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
  14490. 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])));
  14491. }
  14492. }
  14493. break;
  14494. case 4:
  14495. if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
  14496. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14497. __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])))
  14498. } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
  14499. 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])));
  14500. }
  14501. }
  14502. break;
  14503. }
  14504. #endif
  14505. if (sizeof(size_t) <= sizeof(long)) {
  14506. __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
  14507. #ifdef HAVE_LONG_LONG
  14508. } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
  14509. __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
  14510. #endif
  14511. }
  14512. }
  14513. {
  14514. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14515. PyErr_SetString(PyExc_RuntimeError,
  14516. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14517. #else
  14518. size_t val;
  14519. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14520. #if PY_MAJOR_VERSION < 3
  14521. if (likely(v) && !PyLong_Check(v)) {
  14522. PyObject *tmp = v;
  14523. v = PyNumber_Long(tmp);
  14524. Py_DECREF(tmp);
  14525. }
  14526. #endif
  14527. if (likely(v)) {
  14528. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14529. unsigned char *bytes = (unsigned char *)&val;
  14530. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14531. bytes, sizeof(val),
  14532. is_little, !is_unsigned);
  14533. Py_DECREF(v);
  14534. if (likely(!ret))
  14535. return val;
  14536. }
  14537. #endif
  14538. return (size_t) -1;
  14539. }
  14540. } else {
  14541. size_t val;
  14542. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14543. if (!tmp) return (size_t) -1;
  14544. val = __Pyx_PyInt_As_size_t(tmp);
  14545. Py_DECREF(tmp);
  14546. return val;
  14547. }
  14548. raise_overflow:
  14549. PyErr_SetString(PyExc_OverflowError,
  14550. "value too large to convert to size_t");
  14551. return (size_t) -1;
  14552. raise_neg_overflow:
  14553. PyErr_SetString(PyExc_OverflowError,
  14554. "can't convert negative value to size_t");
  14555. return (size_t) -1;
  14556. }
  14557. /* CIntFromPy */
  14558. static CYTHON_INLINE MDB_dbi __Pyx_PyInt_As_MDB_dbi(PyObject *x) {
  14559. const MDB_dbi neg_one = (MDB_dbi) -1, const_zero = (MDB_dbi) 0;
  14560. const int is_unsigned = neg_one > const_zero;
  14561. #if PY_MAJOR_VERSION < 3
  14562. if (likely(PyInt_Check(x))) {
  14563. if (sizeof(MDB_dbi) < sizeof(long)) {
  14564. __PYX_VERIFY_RETURN_INT(MDB_dbi, long, PyInt_AS_LONG(x))
  14565. } else {
  14566. long val = PyInt_AS_LONG(x);
  14567. if (is_unsigned && unlikely(val < 0)) {
  14568. goto raise_neg_overflow;
  14569. }
  14570. return (MDB_dbi) val;
  14571. }
  14572. } else
  14573. #endif
  14574. if (likely(PyLong_Check(x))) {
  14575. if (is_unsigned) {
  14576. #if CYTHON_USE_PYLONG_INTERNALS
  14577. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14578. switch (Py_SIZE(x)) {
  14579. case 0: return (MDB_dbi) 0;
  14580. case 1: __PYX_VERIFY_RETURN_INT(MDB_dbi, digit, digits[0])
  14581. case 2:
  14582. if (8 * sizeof(MDB_dbi) > 1 * PyLong_SHIFT) {
  14583. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14584. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14585. } else if (8 * sizeof(MDB_dbi) >= 2 * PyLong_SHIFT) {
  14586. return (MDB_dbi) (((((MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0]));
  14587. }
  14588. }
  14589. break;
  14590. case 3:
  14591. if (8 * sizeof(MDB_dbi) > 2 * PyLong_SHIFT) {
  14592. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14593. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14594. } else if (8 * sizeof(MDB_dbi) >= 3 * PyLong_SHIFT) {
  14595. return (MDB_dbi) (((((((MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0]));
  14596. }
  14597. }
  14598. break;
  14599. case 4:
  14600. if (8 * sizeof(MDB_dbi) > 3 * PyLong_SHIFT) {
  14601. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14602. __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])))
  14603. } else if (8 * sizeof(MDB_dbi) >= 4 * PyLong_SHIFT) {
  14604. 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]));
  14605. }
  14606. }
  14607. break;
  14608. }
  14609. #endif
  14610. #if CYTHON_COMPILING_IN_CPYTHON
  14611. if (unlikely(Py_SIZE(x) < 0)) {
  14612. goto raise_neg_overflow;
  14613. }
  14614. #else
  14615. {
  14616. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14617. if (unlikely(result < 0))
  14618. return (MDB_dbi) -1;
  14619. if (unlikely(result == 1))
  14620. goto raise_neg_overflow;
  14621. }
  14622. #endif
  14623. if (sizeof(MDB_dbi) <= sizeof(unsigned long)) {
  14624. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, unsigned long, PyLong_AsUnsignedLong(x))
  14625. #ifdef HAVE_LONG_LONG
  14626. } else if (sizeof(MDB_dbi) <= sizeof(unsigned PY_LONG_LONG)) {
  14627. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14628. #endif
  14629. }
  14630. } else {
  14631. #if CYTHON_USE_PYLONG_INTERNALS
  14632. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14633. switch (Py_SIZE(x)) {
  14634. case 0: return (MDB_dbi) 0;
  14635. case -1: __PYX_VERIFY_RETURN_INT(MDB_dbi, sdigit, (sdigit) (-(sdigit)digits[0]))
  14636. case 1: __PYX_VERIFY_RETURN_INT(MDB_dbi, digit, +digits[0])
  14637. case -2:
  14638. if (8 * sizeof(MDB_dbi) - 1 > 1 * PyLong_SHIFT) {
  14639. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14640. __PYX_VERIFY_RETURN_INT(MDB_dbi, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14641. } else if (8 * sizeof(MDB_dbi) - 1 > 2 * PyLong_SHIFT) {
  14642. return (MDB_dbi) (((MDB_dbi)-1)*(((((MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14643. }
  14644. }
  14645. break;
  14646. case 2:
  14647. if (8 * sizeof(MDB_dbi) > 1 * PyLong_SHIFT) {
  14648. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14649. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14650. } else if (8 * sizeof(MDB_dbi) - 1 > 2 * PyLong_SHIFT) {
  14651. return (MDB_dbi) ((((((MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14652. }
  14653. }
  14654. break;
  14655. case -3:
  14656. if (8 * sizeof(MDB_dbi) - 1 > 2 * PyLong_SHIFT) {
  14657. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14658. __PYX_VERIFY_RETURN_INT(MDB_dbi, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14659. } else if (8 * sizeof(MDB_dbi) - 1 > 3 * PyLong_SHIFT) {
  14660. return (MDB_dbi) (((MDB_dbi)-1)*(((((((MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14661. }
  14662. }
  14663. break;
  14664. case 3:
  14665. if (8 * sizeof(MDB_dbi) > 2 * PyLong_SHIFT) {
  14666. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14667. __PYX_VERIFY_RETURN_INT(MDB_dbi, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14668. } else if (8 * sizeof(MDB_dbi) - 1 > 3 * PyLong_SHIFT) {
  14669. return (MDB_dbi) ((((((((MDB_dbi)digits[2]) << PyLong_SHIFT) | (MDB_dbi)digits[1]) << PyLong_SHIFT) | (MDB_dbi)digits[0])));
  14670. }
  14671. }
  14672. break;
  14673. case -4:
  14674. if (8 * sizeof(MDB_dbi) - 1 > 3 * PyLong_SHIFT) {
  14675. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14676. __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])))
  14677. } else if (8 * sizeof(MDB_dbi) - 1 > 4 * PyLong_SHIFT) {
  14678. 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])));
  14679. }
  14680. }
  14681. break;
  14682. case 4:
  14683. if (8 * sizeof(MDB_dbi) > 3 * PyLong_SHIFT) {
  14684. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14685. __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])))
  14686. } else if (8 * sizeof(MDB_dbi) - 1 > 4 * PyLong_SHIFT) {
  14687. 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])));
  14688. }
  14689. }
  14690. break;
  14691. }
  14692. #endif
  14693. if (sizeof(MDB_dbi) <= sizeof(long)) {
  14694. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, long, PyLong_AsLong(x))
  14695. #ifdef HAVE_LONG_LONG
  14696. } else if (sizeof(MDB_dbi) <= sizeof(PY_LONG_LONG)) {
  14697. __PYX_VERIFY_RETURN_INT_EXC(MDB_dbi, PY_LONG_LONG, PyLong_AsLongLong(x))
  14698. #endif
  14699. }
  14700. }
  14701. {
  14702. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14703. PyErr_SetString(PyExc_RuntimeError,
  14704. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14705. #else
  14706. MDB_dbi val;
  14707. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14708. #if PY_MAJOR_VERSION < 3
  14709. if (likely(v) && !PyLong_Check(v)) {
  14710. PyObject *tmp = v;
  14711. v = PyNumber_Long(tmp);
  14712. Py_DECREF(tmp);
  14713. }
  14714. #endif
  14715. if (likely(v)) {
  14716. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14717. unsigned char *bytes = (unsigned char *)&val;
  14718. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14719. bytes, sizeof(val),
  14720. is_little, !is_unsigned);
  14721. Py_DECREF(v);
  14722. if (likely(!ret))
  14723. return val;
  14724. }
  14725. #endif
  14726. return (MDB_dbi) -1;
  14727. }
  14728. } else {
  14729. MDB_dbi val;
  14730. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14731. if (!tmp) return (MDB_dbi) -1;
  14732. val = __Pyx_PyInt_As_MDB_dbi(tmp);
  14733. Py_DECREF(tmp);
  14734. return val;
  14735. }
  14736. raise_overflow:
  14737. PyErr_SetString(PyExc_OverflowError,
  14738. "value too large to convert to MDB_dbi");
  14739. return (MDB_dbi) -1;
  14740. raise_neg_overflow:
  14741. PyErr_SetString(PyExc_OverflowError,
  14742. "can't convert negative value to MDB_dbi");
  14743. return (MDB_dbi) -1;
  14744. }
  14745. /* CIntFromPy */
  14746. static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) {
  14747. const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
  14748. const int is_unsigned = neg_one > const_zero;
  14749. #if PY_MAJOR_VERSION < 3
  14750. if (likely(PyInt_Check(x))) {
  14751. if (sizeof(unsigned int) < sizeof(long)) {
  14752. __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x))
  14753. } else {
  14754. long val = PyInt_AS_LONG(x);
  14755. if (is_unsigned && unlikely(val < 0)) {
  14756. goto raise_neg_overflow;
  14757. }
  14758. return (unsigned int) val;
  14759. }
  14760. } else
  14761. #endif
  14762. if (likely(PyLong_Check(x))) {
  14763. if (is_unsigned) {
  14764. #if CYTHON_USE_PYLONG_INTERNALS
  14765. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14766. switch (Py_SIZE(x)) {
  14767. case 0: return (unsigned int) 0;
  14768. case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0])
  14769. case 2:
  14770. if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
  14771. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14772. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14773. } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) {
  14774. return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
  14775. }
  14776. }
  14777. break;
  14778. case 3:
  14779. if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
  14780. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14781. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14782. } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) {
  14783. return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
  14784. }
  14785. }
  14786. break;
  14787. case 4:
  14788. if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
  14789. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14790. __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])))
  14791. } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) {
  14792. 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]));
  14793. }
  14794. }
  14795. break;
  14796. }
  14797. #endif
  14798. #if CYTHON_COMPILING_IN_CPYTHON
  14799. if (unlikely(Py_SIZE(x) < 0)) {
  14800. goto raise_neg_overflow;
  14801. }
  14802. #else
  14803. {
  14804. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14805. if (unlikely(result < 0))
  14806. return (unsigned int) -1;
  14807. if (unlikely(result == 1))
  14808. goto raise_neg_overflow;
  14809. }
  14810. #endif
  14811. if (sizeof(unsigned int) <= sizeof(unsigned long)) {
  14812. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x))
  14813. #ifdef HAVE_LONG_LONG
  14814. } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
  14815. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14816. #endif
  14817. }
  14818. } else {
  14819. #if CYTHON_USE_PYLONG_INTERNALS
  14820. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14821. switch (Py_SIZE(x)) {
  14822. case 0: return (unsigned int) 0;
  14823. case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0]))
  14824. case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0])
  14825. case -2:
  14826. if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) {
  14827. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14828. __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14829. } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
  14830. return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14831. }
  14832. }
  14833. break;
  14834. case 2:
  14835. if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
  14836. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14837. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14838. } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
  14839. return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14840. }
  14841. }
  14842. break;
  14843. case -3:
  14844. if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
  14845. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14846. __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14847. } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
  14848. return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14849. }
  14850. }
  14851. break;
  14852. case 3:
  14853. if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
  14854. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14855. __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14856. } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
  14857. return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
  14858. }
  14859. }
  14860. break;
  14861. case -4:
  14862. if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
  14863. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14864. __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])))
  14865. } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
  14866. 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])));
  14867. }
  14868. }
  14869. break;
  14870. case 4:
  14871. if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
  14872. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14873. __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])))
  14874. } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
  14875. 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])));
  14876. }
  14877. }
  14878. break;
  14879. }
  14880. #endif
  14881. if (sizeof(unsigned int) <= sizeof(long)) {
  14882. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x))
  14883. #ifdef HAVE_LONG_LONG
  14884. } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
  14885. __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x))
  14886. #endif
  14887. }
  14888. }
  14889. {
  14890. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14891. PyErr_SetString(PyExc_RuntimeError,
  14892. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14893. #else
  14894. unsigned int val;
  14895. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14896. #if PY_MAJOR_VERSION < 3
  14897. if (likely(v) && !PyLong_Check(v)) {
  14898. PyObject *tmp = v;
  14899. v = PyNumber_Long(tmp);
  14900. Py_DECREF(tmp);
  14901. }
  14902. #endif
  14903. if (likely(v)) {
  14904. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14905. unsigned char *bytes = (unsigned char *)&val;
  14906. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14907. bytes, sizeof(val),
  14908. is_little, !is_unsigned);
  14909. Py_DECREF(v);
  14910. if (likely(!ret))
  14911. return val;
  14912. }
  14913. #endif
  14914. return (unsigned int) -1;
  14915. }
  14916. } else {
  14917. unsigned int val;
  14918. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14919. if (!tmp) return (unsigned int) -1;
  14920. val = __Pyx_PyInt_As_unsigned_int(tmp);
  14921. Py_DECREF(tmp);
  14922. return val;
  14923. }
  14924. raise_overflow:
  14925. PyErr_SetString(PyExc_OverflowError,
  14926. "value too large to convert to unsigned int");
  14927. return (unsigned int) -1;
  14928. raise_neg_overflow:
  14929. PyErr_SetString(PyExc_OverflowError,
  14930. "can't convert negative value to unsigned int");
  14931. return (unsigned int) -1;
  14932. }
  14933. /* CIntFromPy */
  14934. static CYTHON_INLINE mode_t __Pyx_PyInt_As_mode_t(PyObject *x) {
  14935. const mode_t neg_one = (mode_t) -1, const_zero = (mode_t) 0;
  14936. const int is_unsigned = neg_one > const_zero;
  14937. #if PY_MAJOR_VERSION < 3
  14938. if (likely(PyInt_Check(x))) {
  14939. if (sizeof(mode_t) < sizeof(long)) {
  14940. __PYX_VERIFY_RETURN_INT(mode_t, long, PyInt_AS_LONG(x))
  14941. } else {
  14942. long val = PyInt_AS_LONG(x);
  14943. if (is_unsigned && unlikely(val < 0)) {
  14944. goto raise_neg_overflow;
  14945. }
  14946. return (mode_t) val;
  14947. }
  14948. } else
  14949. #endif
  14950. if (likely(PyLong_Check(x))) {
  14951. if (is_unsigned) {
  14952. #if CYTHON_USE_PYLONG_INTERNALS
  14953. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14954. switch (Py_SIZE(x)) {
  14955. case 0: return (mode_t) 0;
  14956. case 1: __PYX_VERIFY_RETURN_INT(mode_t, digit, digits[0])
  14957. case 2:
  14958. if (8 * sizeof(mode_t) > 1 * PyLong_SHIFT) {
  14959. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14960. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14961. } else if (8 * sizeof(mode_t) >= 2 * PyLong_SHIFT) {
  14962. return (mode_t) (((((mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0]));
  14963. }
  14964. }
  14965. break;
  14966. case 3:
  14967. if (8 * sizeof(mode_t) > 2 * PyLong_SHIFT) {
  14968. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14969. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14970. } else if (8 * sizeof(mode_t) >= 3 * PyLong_SHIFT) {
  14971. return (mode_t) (((((((mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0]));
  14972. }
  14973. }
  14974. break;
  14975. case 4:
  14976. if (8 * sizeof(mode_t) > 3 * PyLong_SHIFT) {
  14977. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14978. __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])))
  14979. } else if (8 * sizeof(mode_t) >= 4 * PyLong_SHIFT) {
  14980. 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]));
  14981. }
  14982. }
  14983. break;
  14984. }
  14985. #endif
  14986. #if CYTHON_COMPILING_IN_CPYTHON
  14987. if (unlikely(Py_SIZE(x) < 0)) {
  14988. goto raise_neg_overflow;
  14989. }
  14990. #else
  14991. {
  14992. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14993. if (unlikely(result < 0))
  14994. return (mode_t) -1;
  14995. if (unlikely(result == 1))
  14996. goto raise_neg_overflow;
  14997. }
  14998. #endif
  14999. if (sizeof(mode_t) <= sizeof(unsigned long)) {
  15000. __PYX_VERIFY_RETURN_INT_EXC(mode_t, unsigned long, PyLong_AsUnsignedLong(x))
  15001. #ifdef HAVE_LONG_LONG
  15002. } else if (sizeof(mode_t) <= sizeof(unsigned PY_LONG_LONG)) {
  15003. __PYX_VERIFY_RETURN_INT_EXC(mode_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  15004. #endif
  15005. }
  15006. } else {
  15007. #if CYTHON_USE_PYLONG_INTERNALS
  15008. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15009. switch (Py_SIZE(x)) {
  15010. case 0: return (mode_t) 0;
  15011. case -1: __PYX_VERIFY_RETURN_INT(mode_t, sdigit, (sdigit) (-(sdigit)digits[0]))
  15012. case 1: __PYX_VERIFY_RETURN_INT(mode_t, digit, +digits[0])
  15013. case -2:
  15014. if (8 * sizeof(mode_t) - 1 > 1 * PyLong_SHIFT) {
  15015. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15016. __PYX_VERIFY_RETURN_INT(mode_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15017. } else if (8 * sizeof(mode_t) - 1 > 2 * PyLong_SHIFT) {
  15018. return (mode_t) (((mode_t)-1)*(((((mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  15019. }
  15020. }
  15021. break;
  15022. case 2:
  15023. if (8 * sizeof(mode_t) > 1 * PyLong_SHIFT) {
  15024. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15025. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15026. } else if (8 * sizeof(mode_t) - 1 > 2 * PyLong_SHIFT) {
  15027. return (mode_t) ((((((mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  15028. }
  15029. }
  15030. break;
  15031. case -3:
  15032. if (8 * sizeof(mode_t) - 1 > 2 * PyLong_SHIFT) {
  15033. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15034. __PYX_VERIFY_RETURN_INT(mode_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15035. } else if (8 * sizeof(mode_t) - 1 > 3 * PyLong_SHIFT) {
  15036. return (mode_t) (((mode_t)-1)*(((((((mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  15037. }
  15038. }
  15039. break;
  15040. case 3:
  15041. if (8 * sizeof(mode_t) > 2 * PyLong_SHIFT) {
  15042. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15043. __PYX_VERIFY_RETURN_INT(mode_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15044. } else if (8 * sizeof(mode_t) - 1 > 3 * PyLong_SHIFT) {
  15045. return (mode_t) ((((((((mode_t)digits[2]) << PyLong_SHIFT) | (mode_t)digits[1]) << PyLong_SHIFT) | (mode_t)digits[0])));
  15046. }
  15047. }
  15048. break;
  15049. case -4:
  15050. if (8 * sizeof(mode_t) - 1 > 3 * PyLong_SHIFT) {
  15051. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15052. __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])))
  15053. } else if (8 * sizeof(mode_t) - 1 > 4 * PyLong_SHIFT) {
  15054. 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])));
  15055. }
  15056. }
  15057. break;
  15058. case 4:
  15059. if (8 * sizeof(mode_t) > 3 * PyLong_SHIFT) {
  15060. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15061. __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])))
  15062. } else if (8 * sizeof(mode_t) - 1 > 4 * PyLong_SHIFT) {
  15063. 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])));
  15064. }
  15065. }
  15066. break;
  15067. }
  15068. #endif
  15069. if (sizeof(mode_t) <= sizeof(long)) {
  15070. __PYX_VERIFY_RETURN_INT_EXC(mode_t, long, PyLong_AsLong(x))
  15071. #ifdef HAVE_LONG_LONG
  15072. } else if (sizeof(mode_t) <= sizeof(PY_LONG_LONG)) {
  15073. __PYX_VERIFY_RETURN_INT_EXC(mode_t, PY_LONG_LONG, PyLong_AsLongLong(x))
  15074. #endif
  15075. }
  15076. }
  15077. {
  15078. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  15079. PyErr_SetString(PyExc_RuntimeError,
  15080. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  15081. #else
  15082. mode_t val;
  15083. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  15084. #if PY_MAJOR_VERSION < 3
  15085. if (likely(v) && !PyLong_Check(v)) {
  15086. PyObject *tmp = v;
  15087. v = PyNumber_Long(tmp);
  15088. Py_DECREF(tmp);
  15089. }
  15090. #endif
  15091. if (likely(v)) {
  15092. int one = 1; int is_little = (int)*(unsigned char *)&one;
  15093. unsigned char *bytes = (unsigned char *)&val;
  15094. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  15095. bytes, sizeof(val),
  15096. is_little, !is_unsigned);
  15097. Py_DECREF(v);
  15098. if (likely(!ret))
  15099. return val;
  15100. }
  15101. #endif
  15102. return (mode_t) -1;
  15103. }
  15104. } else {
  15105. mode_t val;
  15106. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  15107. if (!tmp) return (mode_t) -1;
  15108. val = __Pyx_PyInt_As_mode_t(tmp);
  15109. Py_DECREF(tmp);
  15110. return val;
  15111. }
  15112. raise_overflow:
  15113. PyErr_SetString(PyExc_OverflowError,
  15114. "value too large to convert to mode_t");
  15115. return (mode_t) -1;
  15116. raise_neg_overflow:
  15117. PyErr_SetString(PyExc_OverflowError,
  15118. "can't convert negative value to mode_t");
  15119. return (mode_t) -1;
  15120. }
  15121. /* CIntFromPy */
  15122. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  15123. const int neg_one = (int) -1, const_zero = (int) 0;
  15124. const int is_unsigned = neg_one > const_zero;
  15125. #if PY_MAJOR_VERSION < 3
  15126. if (likely(PyInt_Check(x))) {
  15127. if (sizeof(int) < sizeof(long)) {
  15128. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  15129. } else {
  15130. long val = PyInt_AS_LONG(x);
  15131. if (is_unsigned && unlikely(val < 0)) {
  15132. goto raise_neg_overflow;
  15133. }
  15134. return (int) val;
  15135. }
  15136. } else
  15137. #endif
  15138. if (likely(PyLong_Check(x))) {
  15139. if (is_unsigned) {
  15140. #if CYTHON_USE_PYLONG_INTERNALS
  15141. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15142. switch (Py_SIZE(x)) {
  15143. case 0: return (int) 0;
  15144. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  15145. case 2:
  15146. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  15147. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15148. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15149. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  15150. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  15151. }
  15152. }
  15153. break;
  15154. case 3:
  15155. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  15156. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15157. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15158. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  15159. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  15160. }
  15161. }
  15162. break;
  15163. case 4:
  15164. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  15165. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15166. __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])))
  15167. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  15168. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  15169. }
  15170. }
  15171. break;
  15172. }
  15173. #endif
  15174. #if CYTHON_COMPILING_IN_CPYTHON
  15175. if (unlikely(Py_SIZE(x) < 0)) {
  15176. goto raise_neg_overflow;
  15177. }
  15178. #else
  15179. {
  15180. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  15181. if (unlikely(result < 0))
  15182. return (int) -1;
  15183. if (unlikely(result == 1))
  15184. goto raise_neg_overflow;
  15185. }
  15186. #endif
  15187. if (sizeof(int) <= sizeof(unsigned long)) {
  15188. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  15189. #ifdef HAVE_LONG_LONG
  15190. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  15191. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  15192. #endif
  15193. }
  15194. } else {
  15195. #if CYTHON_USE_PYLONG_INTERNALS
  15196. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15197. switch (Py_SIZE(x)) {
  15198. case 0: return (int) 0;
  15199. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  15200. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  15201. case -2:
  15202. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  15203. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15204. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15205. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  15206. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15207. }
  15208. }
  15209. break;
  15210. case 2:
  15211. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  15212. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15213. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15214. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  15215. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15216. }
  15217. }
  15218. break;
  15219. case -3:
  15220. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  15221. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15222. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15223. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  15224. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15225. }
  15226. }
  15227. break;
  15228. case 3:
  15229. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  15230. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15231. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15232. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  15233. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15234. }
  15235. }
  15236. break;
  15237. case -4:
  15238. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  15239. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15240. __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])))
  15241. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  15242. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15243. }
  15244. }
  15245. break;
  15246. case 4:
  15247. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  15248. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15249. __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])))
  15250. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  15251. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  15252. }
  15253. }
  15254. break;
  15255. }
  15256. #endif
  15257. if (sizeof(int) <= sizeof(long)) {
  15258. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  15259. #ifdef HAVE_LONG_LONG
  15260. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  15261. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  15262. #endif
  15263. }
  15264. }
  15265. {
  15266. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  15267. PyErr_SetString(PyExc_RuntimeError,
  15268. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  15269. #else
  15270. int val;
  15271. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  15272. #if PY_MAJOR_VERSION < 3
  15273. if (likely(v) && !PyLong_Check(v)) {
  15274. PyObject *tmp = v;
  15275. v = PyNumber_Long(tmp);
  15276. Py_DECREF(tmp);
  15277. }
  15278. #endif
  15279. if (likely(v)) {
  15280. int one = 1; int is_little = (int)*(unsigned char *)&one;
  15281. unsigned char *bytes = (unsigned char *)&val;
  15282. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  15283. bytes, sizeof(val),
  15284. is_little, !is_unsigned);
  15285. Py_DECREF(v);
  15286. if (likely(!ret))
  15287. return val;
  15288. }
  15289. #endif
  15290. return (int) -1;
  15291. }
  15292. } else {
  15293. int val;
  15294. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  15295. if (!tmp) return (int) -1;
  15296. val = __Pyx_PyInt_As_int(tmp);
  15297. Py_DECREF(tmp);
  15298. return val;
  15299. }
  15300. raise_overflow:
  15301. PyErr_SetString(PyExc_OverflowError,
  15302. "value too large to convert to int");
  15303. return (int) -1;
  15304. raise_neg_overflow:
  15305. PyErr_SetString(PyExc_OverflowError,
  15306. "can't convert negative value to int");
  15307. return (int) -1;
  15308. }
  15309. /* CIntFromPy */
  15310. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  15311. const long neg_one = (long) -1, const_zero = (long) 0;
  15312. const int is_unsigned = neg_one > const_zero;
  15313. #if PY_MAJOR_VERSION < 3
  15314. if (likely(PyInt_Check(x))) {
  15315. if (sizeof(long) < sizeof(long)) {
  15316. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  15317. } else {
  15318. long val = PyInt_AS_LONG(x);
  15319. if (is_unsigned && unlikely(val < 0)) {
  15320. goto raise_neg_overflow;
  15321. }
  15322. return (long) val;
  15323. }
  15324. } else
  15325. #endif
  15326. if (likely(PyLong_Check(x))) {
  15327. if (is_unsigned) {
  15328. #if CYTHON_USE_PYLONG_INTERNALS
  15329. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15330. switch (Py_SIZE(x)) {
  15331. case 0: return (long) 0;
  15332. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  15333. case 2:
  15334. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  15335. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15336. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15337. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  15338. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  15339. }
  15340. }
  15341. break;
  15342. case 3:
  15343. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  15344. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15345. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15346. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  15347. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  15348. }
  15349. }
  15350. break;
  15351. case 4:
  15352. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  15353. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15354. __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])))
  15355. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  15356. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  15357. }
  15358. }
  15359. break;
  15360. }
  15361. #endif
  15362. #if CYTHON_COMPILING_IN_CPYTHON
  15363. if (unlikely(Py_SIZE(x) < 0)) {
  15364. goto raise_neg_overflow;
  15365. }
  15366. #else
  15367. {
  15368. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  15369. if (unlikely(result < 0))
  15370. return (long) -1;
  15371. if (unlikely(result == 1))
  15372. goto raise_neg_overflow;
  15373. }
  15374. #endif
  15375. if (sizeof(long) <= sizeof(unsigned long)) {
  15376. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  15377. #ifdef HAVE_LONG_LONG
  15378. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  15379. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  15380. #endif
  15381. }
  15382. } else {
  15383. #if CYTHON_USE_PYLONG_INTERNALS
  15384. const digit* digits = ((PyLongObject*)x)->ob_digit;
  15385. switch (Py_SIZE(x)) {
  15386. case 0: return (long) 0;
  15387. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  15388. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  15389. case -2:
  15390. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  15391. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15392. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15393. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  15394. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15395. }
  15396. }
  15397. break;
  15398. case 2:
  15399. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  15400. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  15401. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15402. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  15403. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15404. }
  15405. }
  15406. break;
  15407. case -3:
  15408. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  15409. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15410. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15411. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  15412. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15413. }
  15414. }
  15415. break;
  15416. case 3:
  15417. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  15418. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  15419. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  15420. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  15421. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15422. }
  15423. }
  15424. break;
  15425. case -4:
  15426. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  15427. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15428. __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])))
  15429. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  15430. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15431. }
  15432. }
  15433. break;
  15434. case 4:
  15435. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  15436. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  15437. __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])))
  15438. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  15439. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  15440. }
  15441. }
  15442. break;
  15443. }
  15444. #endif
  15445. if (sizeof(long) <= sizeof(long)) {
  15446. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  15447. #ifdef HAVE_LONG_LONG
  15448. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  15449. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  15450. #endif
  15451. }
  15452. }
  15453. {
  15454. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  15455. PyErr_SetString(PyExc_RuntimeError,
  15456. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  15457. #else
  15458. long val;
  15459. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  15460. #if PY_MAJOR_VERSION < 3
  15461. if (likely(v) && !PyLong_Check(v)) {
  15462. PyObject *tmp = v;
  15463. v = PyNumber_Long(tmp);
  15464. Py_DECREF(tmp);
  15465. }
  15466. #endif
  15467. if (likely(v)) {
  15468. int one = 1; int is_little = (int)*(unsigned char *)&one;
  15469. unsigned char *bytes = (unsigned char *)&val;
  15470. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  15471. bytes, sizeof(val),
  15472. is_little, !is_unsigned);
  15473. Py_DECREF(v);
  15474. if (likely(!ret))
  15475. return val;
  15476. }
  15477. #endif
  15478. return (long) -1;
  15479. }
  15480. } else {
  15481. long val;
  15482. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  15483. if (!tmp) return (long) -1;
  15484. val = __Pyx_PyInt_As_long(tmp);
  15485. Py_DECREF(tmp);
  15486. return val;
  15487. }
  15488. raise_overflow:
  15489. PyErr_SetString(PyExc_OverflowError,
  15490. "value too large to convert to long");
  15491. return (long) -1;
  15492. raise_neg_overflow:
  15493. PyErr_SetString(PyExc_OverflowError,
  15494. "can't convert negative value to long");
  15495. return (long) -1;
  15496. }
  15497. /* FetchCommonType */
  15498. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
  15499. PyObject* fake_module;
  15500. PyTypeObject* cached_type = NULL;
  15501. fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
  15502. if (!fake_module) return NULL;
  15503. Py_INCREF(fake_module);
  15504. cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
  15505. if (cached_type) {
  15506. if (!PyType_Check((PyObject*)cached_type)) {
  15507. PyErr_Format(PyExc_TypeError,
  15508. "Shared Cython type %.200s is not a type object",
  15509. type->tp_name);
  15510. goto bad;
  15511. }
  15512. if (cached_type->tp_basicsize != type->tp_basicsize) {
  15513. PyErr_Format(PyExc_TypeError,
  15514. "Shared Cython type %.200s has the wrong size, try recompiling",
  15515. type->tp_name);
  15516. goto bad;
  15517. }
  15518. } else {
  15519. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
  15520. PyErr_Clear();
  15521. if (PyType_Ready(type) < 0) goto bad;
  15522. if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
  15523. goto bad;
  15524. Py_INCREF(type);
  15525. cached_type = type;
  15526. }
  15527. done:
  15528. Py_DECREF(fake_module);
  15529. return cached_type;
  15530. bad:
  15531. Py_XDECREF(cached_type);
  15532. cached_type = NULL;
  15533. goto done;
  15534. }
  15535. /* PyObjectCallMethod1 */
  15536. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
  15537. PyObject *result = NULL;
  15538. #if CYTHON_UNPACK_METHODS
  15539. if (likely(PyMethod_Check(method))) {
  15540. PyObject *self = PyMethod_GET_SELF(method);
  15541. if (likely(self)) {
  15542. PyObject *args;
  15543. PyObject *function = PyMethod_GET_FUNCTION(method);
  15544. #if CYTHON_FAST_PYCALL
  15545. if (PyFunction_Check(function)) {
  15546. PyObject *args[2] = {self, arg};
  15547. result = __Pyx_PyFunction_FastCall(function, args, 2);
  15548. goto done;
  15549. }
  15550. #endif
  15551. #if CYTHON_FAST_PYCCALL
  15552. if (__Pyx_PyFastCFunction_Check(function)) {
  15553. PyObject *args[2] = {self, arg};
  15554. result = __Pyx_PyCFunction_FastCall(function, args, 2);
  15555. goto done;
  15556. }
  15557. #endif
  15558. args = PyTuple_New(2);
  15559. if (unlikely(!args)) goto done;
  15560. Py_INCREF(self);
  15561. PyTuple_SET_ITEM(args, 0, self);
  15562. Py_INCREF(arg);
  15563. PyTuple_SET_ITEM(args, 1, arg);
  15564. Py_INCREF(function);
  15565. result = __Pyx_PyObject_Call(function, args, NULL);
  15566. Py_DECREF(args);
  15567. Py_DECREF(function);
  15568. return result;
  15569. }
  15570. }
  15571. #endif
  15572. result = __Pyx_PyObject_CallOneArg(method, arg);
  15573. goto done;
  15574. done:
  15575. return result;
  15576. }
  15577. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
  15578. PyObject *method, *result;
  15579. method = __Pyx_PyObject_GetAttrStr(obj, method_name);
  15580. if (unlikely(!method)) return NULL;
  15581. result = __Pyx__PyObject_CallMethod1(method, arg);
  15582. Py_DECREF(method);
  15583. return result;
  15584. }
  15585. /* CoroutineBase */
  15586. #include <structmember.h>
  15587. #include <frameobject.h>
  15588. #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
  15589. static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
  15590. PyObject *et, *ev, *tb;
  15591. PyObject *value = NULL;
  15592. __Pyx_ErrFetch(&et, &ev, &tb);
  15593. if (!et) {
  15594. Py_XDECREF(tb);
  15595. Py_XDECREF(ev);
  15596. Py_INCREF(Py_None);
  15597. *pvalue = Py_None;
  15598. return 0;
  15599. }
  15600. if (likely(et == PyExc_StopIteration)) {
  15601. if (!ev) {
  15602. Py_INCREF(Py_None);
  15603. value = Py_None;
  15604. }
  15605. #if PY_VERSION_HEX >= 0x030300A0
  15606. else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
  15607. value = ((PyStopIterationObject *)ev)->value;
  15608. Py_INCREF(value);
  15609. Py_DECREF(ev);
  15610. }
  15611. #endif
  15612. else if (unlikely(PyTuple_Check(ev))) {
  15613. if (PyTuple_GET_SIZE(ev) >= 1) {
  15614. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  15615. value = PyTuple_GET_ITEM(ev, 0);
  15616. Py_INCREF(value);
  15617. #else
  15618. value = PySequence_ITEM(ev, 0);
  15619. #endif
  15620. } else {
  15621. Py_INCREF(Py_None);
  15622. value = Py_None;
  15623. }
  15624. Py_DECREF(ev);
  15625. }
  15626. else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
  15627. value = ev;
  15628. }
  15629. if (likely(value)) {
  15630. Py_XDECREF(tb);
  15631. Py_DECREF(et);
  15632. *pvalue = value;
  15633. return 0;
  15634. }
  15635. } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
  15636. __Pyx_ErrRestore(et, ev, tb);
  15637. return -1;
  15638. }
  15639. PyErr_NormalizeException(&et, &ev, &tb);
  15640. if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
  15641. __Pyx_ErrRestore(et, ev, tb);
  15642. return -1;
  15643. }
  15644. Py_XDECREF(tb);
  15645. Py_DECREF(et);
  15646. #if PY_VERSION_HEX >= 0x030300A0
  15647. value = ((PyStopIterationObject *)ev)->value;
  15648. Py_INCREF(value);
  15649. Py_DECREF(ev);
  15650. #else
  15651. {
  15652. PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
  15653. Py_DECREF(ev);
  15654. if (likely(args)) {
  15655. value = PySequence_GetItem(args, 0);
  15656. Py_DECREF(args);
  15657. }
  15658. if (unlikely(!value)) {
  15659. __Pyx_ErrRestore(NULL, NULL, NULL);
  15660. Py_INCREF(Py_None);
  15661. value = Py_None;
  15662. }
  15663. }
  15664. #endif
  15665. *pvalue = value;
  15666. return 0;
  15667. }
  15668. static CYTHON_INLINE
  15669. void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
  15670. PyObject *exc_type = self->exc_type;
  15671. PyObject *exc_value = self->exc_value;
  15672. PyObject *exc_traceback = self->exc_traceback;
  15673. self->exc_type = NULL;
  15674. self->exc_value = NULL;
  15675. self->exc_traceback = NULL;
  15676. Py_XDECREF(exc_type);
  15677. Py_XDECREF(exc_value);
  15678. Py_XDECREF(exc_traceback);
  15679. }
  15680. #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
  15681. static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
  15682. const char *msg;
  15683. if (0) {
  15684. #ifdef __Pyx_Coroutine_USED
  15685. } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
  15686. msg = "coroutine already executing";
  15687. #endif
  15688. #ifdef __Pyx_AsyncGen_USED
  15689. } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
  15690. msg = "async generator already executing";
  15691. #endif
  15692. } else {
  15693. msg = "generator already executing";
  15694. }
  15695. PyErr_SetString(PyExc_ValueError, msg);
  15696. }
  15697. #define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
  15698. static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
  15699. const char *msg;
  15700. if (0) {
  15701. #ifdef __Pyx_Coroutine_USED
  15702. } else if (__Pyx_Coroutine_Check(gen)) {
  15703. msg = "can't send non-None value to a just-started coroutine";
  15704. #endif
  15705. #ifdef __Pyx_AsyncGen_USED
  15706. } else if (__Pyx_AsyncGen_CheckExact(gen)) {
  15707. msg = "can't send non-None value to a just-started async generator";
  15708. #endif
  15709. } else {
  15710. msg = "can't send non-None value to a just-started generator";
  15711. }
  15712. PyErr_SetString(PyExc_TypeError, msg);
  15713. }
  15714. #define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
  15715. static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
  15716. #ifdef __Pyx_Coroutine_USED
  15717. if (!closing && __Pyx_Coroutine_Check(gen)) {
  15718. PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
  15719. } else
  15720. #endif
  15721. if (value) {
  15722. #ifdef __Pyx_AsyncGen_USED
  15723. if (__Pyx_AsyncGen_CheckExact(gen))
  15724. PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
  15725. else
  15726. #endif
  15727. PyErr_SetNone(PyExc_StopIteration);
  15728. }
  15729. }
  15730. static
  15731. PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
  15732. __Pyx_PyThreadState_declare
  15733. PyThreadState *tstate;
  15734. PyObject *retval;
  15735. assert(!self->is_running);
  15736. if (unlikely(self->resume_label == 0)) {
  15737. if (unlikely(value && value != Py_None)) {
  15738. return __Pyx_Coroutine_NotStartedError((PyObject*)self);
  15739. }
  15740. }
  15741. if (unlikely(self->resume_label == -1)) {
  15742. return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
  15743. }
  15744. #if CYTHON_FAST_THREAD_STATE
  15745. __Pyx_PyThreadState_assign
  15746. tstate = __pyx_tstate;
  15747. #else
  15748. tstate = __Pyx_PyThreadState_Current;
  15749. #endif
  15750. if (self->exc_type) {
  15751. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  15752. #else
  15753. if (self->exc_traceback) {
  15754. PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
  15755. PyFrameObject *f = tb->tb_frame;
  15756. Py_XINCREF(tstate->frame);
  15757. assert(f->f_back == NULL);
  15758. f->f_back = tstate->frame;
  15759. }
  15760. #endif
  15761. __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
  15762. &self->exc_traceback);
  15763. } else {
  15764. __Pyx_Coroutine_ExceptionClear(self);
  15765. __Pyx_ExceptionSave(&self->exc_type, &self->exc_value, &self->exc_traceback);
  15766. }
  15767. self->is_running = 1;
  15768. retval = self->body((PyObject *) self, tstate, value);
  15769. self->is_running = 0;
  15770. return retval;
  15771. }
  15772. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self) {
  15773. if (likely(self->exc_traceback)) {
  15774. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  15775. #else
  15776. PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
  15777. PyFrameObject *f = tb->tb_frame;
  15778. Py_CLEAR(f->f_back);
  15779. #endif
  15780. }
  15781. }
  15782. static CYTHON_INLINE
  15783. PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
  15784. if (unlikely(!retval)) {
  15785. __Pyx_PyThreadState_declare
  15786. __Pyx_PyThreadState_assign
  15787. if (!__Pyx_PyErr_Occurred()) {
  15788. PyObject *exc = PyExc_StopIteration;
  15789. #ifdef __Pyx_AsyncGen_USED
  15790. if (__Pyx_AsyncGen_CheckExact(gen))
  15791. exc = __Pyx_PyExc_StopAsyncIteration;
  15792. #endif
  15793. __Pyx_PyErr_SetNone(exc);
  15794. }
  15795. }
  15796. return retval;
  15797. }
  15798. static CYTHON_INLINE
  15799. PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
  15800. PyObject *ret;
  15801. PyObject *val = NULL;
  15802. __Pyx_Coroutine_Undelegate(gen);
  15803. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
  15804. ret = __Pyx_Coroutine_SendEx(gen, val, 0);
  15805. Py_XDECREF(val);
  15806. return ret;
  15807. }
  15808. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
  15809. PyObject *retval;
  15810. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  15811. PyObject *yf = gen->yieldfrom;
  15812. if (unlikely(gen->is_running))
  15813. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15814. if (yf) {
  15815. PyObject *ret;
  15816. gen->is_running = 1;
  15817. #ifdef __Pyx_Generator_USED
  15818. if (__Pyx_Generator_CheckExact(yf)) {
  15819. ret = __Pyx_Coroutine_Send(yf, value);
  15820. } else
  15821. #endif
  15822. #ifdef __Pyx_Coroutine_USED
  15823. if (__Pyx_Coroutine_Check(yf)) {
  15824. ret = __Pyx_Coroutine_Send(yf, value);
  15825. } else
  15826. #endif
  15827. #ifdef __Pyx_AsyncGen_USED
  15828. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  15829. ret = __Pyx_async_gen_asend_send(yf, value);
  15830. } else
  15831. #endif
  15832. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
  15833. if (PyGen_CheckExact(yf)) {
  15834. ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  15835. } else
  15836. #endif
  15837. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
  15838. if (PyCoro_CheckExact(yf)) {
  15839. ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  15840. } else
  15841. #endif
  15842. {
  15843. if (value == Py_None)
  15844. ret = Py_TYPE(yf)->tp_iternext(yf);
  15845. else
  15846. ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
  15847. }
  15848. gen->is_running = 0;
  15849. if (likely(ret)) {
  15850. return ret;
  15851. }
  15852. retval = __Pyx_Coroutine_FinishDelegation(gen);
  15853. } else {
  15854. retval = __Pyx_Coroutine_SendEx(gen, value, 0);
  15855. }
  15856. return __Pyx_Coroutine_MethodReturn(self, retval);
  15857. }
  15858. static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
  15859. PyObject *retval = NULL;
  15860. int err = 0;
  15861. #ifdef __Pyx_Generator_USED
  15862. if (__Pyx_Generator_CheckExact(yf)) {
  15863. retval = __Pyx_Coroutine_Close(yf);
  15864. if (!retval)
  15865. return -1;
  15866. } else
  15867. #endif
  15868. #ifdef __Pyx_Coroutine_USED
  15869. if (__Pyx_Coroutine_Check(yf)) {
  15870. retval = __Pyx_Coroutine_Close(yf);
  15871. if (!retval)
  15872. return -1;
  15873. } else
  15874. if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  15875. retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
  15876. if (!retval)
  15877. return -1;
  15878. } else
  15879. #endif
  15880. #ifdef __Pyx_AsyncGen_USED
  15881. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  15882. retval = __Pyx_async_gen_asend_close(yf, NULL);
  15883. } else
  15884. if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
  15885. retval = __Pyx_async_gen_athrow_close(yf, NULL);
  15886. } else
  15887. #endif
  15888. {
  15889. PyObject *meth;
  15890. gen->is_running = 1;
  15891. meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
  15892. if (unlikely(!meth)) {
  15893. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
  15894. PyErr_WriteUnraisable(yf);
  15895. }
  15896. PyErr_Clear();
  15897. } else {
  15898. retval = PyObject_CallFunction(meth, NULL);
  15899. Py_DECREF(meth);
  15900. if (!retval)
  15901. err = -1;
  15902. }
  15903. gen->is_running = 0;
  15904. }
  15905. Py_XDECREF(retval);
  15906. return err;
  15907. }
  15908. static PyObject *__Pyx_Generator_Next(PyObject *self) {
  15909. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  15910. PyObject *yf = gen->yieldfrom;
  15911. if (unlikely(gen->is_running))
  15912. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15913. if (yf) {
  15914. PyObject *ret;
  15915. gen->is_running = 1;
  15916. #ifdef __Pyx_Generator_USED
  15917. if (__Pyx_Generator_CheckExact(yf)) {
  15918. ret = __Pyx_Generator_Next(yf);
  15919. } else
  15920. #endif
  15921. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
  15922. if (PyGen_CheckExact(yf)) {
  15923. ret = _PyGen_Send((PyGenObject*)yf, NULL);
  15924. } else
  15925. #endif
  15926. #ifdef __Pyx_Coroutine_USED
  15927. if (__Pyx_Coroutine_Check(yf)) {
  15928. ret = __Pyx_Coroutine_Send(yf, Py_None);
  15929. } else
  15930. #endif
  15931. ret = Py_TYPE(yf)->tp_iternext(yf);
  15932. gen->is_running = 0;
  15933. if (likely(ret)) {
  15934. return ret;
  15935. }
  15936. return __Pyx_Coroutine_FinishDelegation(gen);
  15937. }
  15938. return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
  15939. }
  15940. static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
  15941. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15942. PyObject *retval, *raised_exception;
  15943. PyObject *yf = gen->yieldfrom;
  15944. int err = 0;
  15945. if (unlikely(gen->is_running))
  15946. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15947. if (yf) {
  15948. Py_INCREF(yf);
  15949. err = __Pyx_Coroutine_CloseIter(gen, yf);
  15950. __Pyx_Coroutine_Undelegate(gen);
  15951. Py_DECREF(yf);
  15952. }
  15953. if (err == 0)
  15954. PyErr_SetNone(PyExc_GeneratorExit);
  15955. retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
  15956. if (unlikely(retval)) {
  15957. const char *msg;
  15958. Py_DECREF(retval);
  15959. if ((0)) {
  15960. #ifdef __Pyx_Coroutine_USED
  15961. } else if (__Pyx_Coroutine_Check(self)) {
  15962. msg = "coroutine ignored GeneratorExit";
  15963. #endif
  15964. #ifdef __Pyx_AsyncGen_USED
  15965. } else if (__Pyx_AsyncGen_CheckExact(self)) {
  15966. #if PY_VERSION_HEX < 0x03060000
  15967. msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
  15968. #else
  15969. msg = "async generator ignored GeneratorExit";
  15970. #endif
  15971. #endif
  15972. } else {
  15973. msg = "generator ignored GeneratorExit";
  15974. }
  15975. PyErr_SetString(PyExc_RuntimeError, msg);
  15976. return NULL;
  15977. }
  15978. raised_exception = PyErr_Occurred();
  15979. if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
  15980. if (raised_exception) PyErr_Clear();
  15981. Py_INCREF(Py_None);
  15982. return Py_None;
  15983. }
  15984. return NULL;
  15985. }
  15986. static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
  15987. PyObject *args, int close_on_genexit) {
  15988. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15989. PyObject *yf = gen->yieldfrom;
  15990. if (unlikely(gen->is_running))
  15991. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15992. if (yf) {
  15993. PyObject *ret;
  15994. Py_INCREF(yf);
  15995. if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
  15996. int err = __Pyx_Coroutine_CloseIter(gen, yf);
  15997. Py_DECREF(yf);
  15998. __Pyx_Coroutine_Undelegate(gen);
  15999. if (err < 0)
  16000. return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
  16001. goto throw_here;
  16002. }
  16003. gen->is_running = 1;
  16004. if (0
  16005. #ifdef __Pyx_Generator_USED
  16006. || __Pyx_Generator_CheckExact(yf)
  16007. #endif
  16008. #ifdef __Pyx_Coroutine_USED
  16009. || __Pyx_Coroutine_Check(yf)
  16010. #endif
  16011. ) {
  16012. ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
  16013. #ifdef __Pyx_Coroutine_USED
  16014. } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  16015. ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
  16016. #endif
  16017. } else {
  16018. PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
  16019. if (unlikely(!meth)) {
  16020. Py_DECREF(yf);
  16021. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
  16022. gen->is_running = 0;
  16023. return NULL;
  16024. }
  16025. PyErr_Clear();
  16026. __Pyx_Coroutine_Undelegate(gen);
  16027. gen->is_running = 0;
  16028. goto throw_here;
  16029. }
  16030. if (likely(args)) {
  16031. ret = PyObject_CallObject(meth, args);
  16032. } else {
  16033. ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
  16034. }
  16035. Py_DECREF(meth);
  16036. }
  16037. gen->is_running = 0;
  16038. Py_DECREF(yf);
  16039. if (!ret) {
  16040. ret = __Pyx_Coroutine_FinishDelegation(gen);
  16041. }
  16042. return __Pyx_Coroutine_MethodReturn(self, ret);
  16043. }
  16044. throw_here:
  16045. __Pyx_Raise(typ, val, tb, NULL);
  16046. return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
  16047. }
  16048. static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
  16049. PyObject *typ;
  16050. PyObject *val = NULL;
  16051. PyObject *tb = NULL;
  16052. if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
  16053. return NULL;
  16054. return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
  16055. }
  16056. static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
  16057. Py_VISIT(gen->closure);
  16058. Py_VISIT(gen->classobj);
  16059. Py_VISIT(gen->yieldfrom);
  16060. Py_VISIT(gen->exc_type);
  16061. Py_VISIT(gen->exc_value);
  16062. Py_VISIT(gen->exc_traceback);
  16063. return 0;
  16064. }
  16065. static int __Pyx_Coroutine_clear(PyObject *self) {
  16066. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  16067. Py_CLEAR(gen->closure);
  16068. Py_CLEAR(gen->classobj);
  16069. Py_CLEAR(gen->yieldfrom);
  16070. Py_CLEAR(gen->exc_type);
  16071. Py_CLEAR(gen->exc_value);
  16072. Py_CLEAR(gen->exc_traceback);
  16073. #ifdef __Pyx_AsyncGen_USED
  16074. if (__Pyx_AsyncGen_CheckExact(self)) {
  16075. Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
  16076. }
  16077. #endif
  16078. Py_CLEAR(gen->gi_code);
  16079. Py_CLEAR(gen->gi_name);
  16080. Py_CLEAR(gen->gi_qualname);
  16081. Py_CLEAR(gen->gi_modulename);
  16082. return 0;
  16083. }
  16084. static void __Pyx_Coroutine_dealloc(PyObject *self) {
  16085. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  16086. PyObject_GC_UnTrack(gen);
  16087. if (gen->gi_weakreflist != NULL)
  16088. PyObject_ClearWeakRefs(self);
  16089. if (gen->resume_label >= 0) {
  16090. PyObject_GC_Track(self);
  16091. #if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
  16092. if (PyObject_CallFinalizerFromDealloc(self))
  16093. #else
  16094. Py_TYPE(gen)->tp_del(self);
  16095. if (self->ob_refcnt > 0)
  16096. #endif
  16097. {
  16098. return;
  16099. }
  16100. PyObject_GC_UnTrack(self);
  16101. }
  16102. #ifdef __Pyx_AsyncGen_USED
  16103. if (__Pyx_AsyncGen_CheckExact(self)) {
  16104. /* We have to handle this case for asynchronous generators
  16105. right here, because this code has to be between UNTRACK
  16106. and GC_Del. */
  16107. Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
  16108. }
  16109. #endif
  16110. __Pyx_Coroutine_clear(self);
  16111. PyObject_GC_Del(gen);
  16112. }
  16113. static void __Pyx_Coroutine_del(PyObject *self) {
  16114. PyObject *error_type, *error_value, *error_traceback;
  16115. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  16116. __Pyx_PyThreadState_declare
  16117. if (gen->resume_label < 0) {
  16118. return;
  16119. }
  16120. #if !CYTHON_USE_TP_FINALIZE
  16121. assert(self->ob_refcnt == 0);
  16122. self->ob_refcnt = 1;
  16123. #endif
  16124. __Pyx_PyThreadState_assign
  16125. __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
  16126. #ifdef __Pyx_AsyncGen_USED
  16127. if (__Pyx_AsyncGen_CheckExact(self)) {
  16128. __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
  16129. PyObject *finalizer = agen->ag_finalizer;
  16130. if (finalizer && !agen->ag_closed) {
  16131. PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
  16132. if (unlikely(!res)) {
  16133. PyErr_WriteUnraisable(self);
  16134. } else {
  16135. Py_DECREF(res);
  16136. }
  16137. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  16138. return;
  16139. }
  16140. }
  16141. #endif
  16142. if (unlikely(gen->resume_label == 0 && !error_value)) {
  16143. #ifdef __Pyx_Coroutine_USED
  16144. #ifdef __Pyx_Generator_USED
  16145. if (!__Pyx_Generator_CheckExact(self))
  16146. #endif
  16147. {
  16148. PyObject_GC_UnTrack(self);
  16149. #if PY_MAJOR_VERSION >= 3 || defined(PyErr_WarnFormat)
  16150. if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
  16151. PyErr_WriteUnraisable(self);
  16152. #else
  16153. {PyObject *msg;
  16154. char *cmsg;
  16155. #if CYTHON_COMPILING_IN_PYPY
  16156. msg = NULL;
  16157. cmsg = (char*) "coroutine was never awaited";
  16158. #else
  16159. char *cname;
  16160. PyObject *qualname;
  16161. qualname = gen->gi_qualname;
  16162. cname = PyString_AS_STRING(qualname);
  16163. msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
  16164. if (unlikely(!msg)) {
  16165. PyErr_Clear();
  16166. cmsg = (char*) "coroutine was never awaited";
  16167. } else {
  16168. cmsg = PyString_AS_STRING(msg);
  16169. }
  16170. #endif
  16171. if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
  16172. PyErr_WriteUnraisable(self);
  16173. Py_XDECREF(msg);}
  16174. #endif
  16175. PyObject_GC_Track(self);
  16176. }
  16177. #endif
  16178. } else {
  16179. PyObject *res = __Pyx_Coroutine_Close(self);
  16180. if (unlikely(!res)) {
  16181. if (PyErr_Occurred())
  16182. PyErr_WriteUnraisable(self);
  16183. } else {
  16184. Py_DECREF(res);
  16185. }
  16186. }
  16187. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  16188. #if !CYTHON_USE_TP_FINALIZE
  16189. assert(self->ob_refcnt > 0);
  16190. if (--self->ob_refcnt == 0) {
  16191. return;
  16192. }
  16193. {
  16194. Py_ssize_t refcnt = self->ob_refcnt;
  16195. _Py_NewReference(self);
  16196. self->ob_refcnt = refcnt;
  16197. }
  16198. #if CYTHON_COMPILING_IN_CPYTHON
  16199. assert(PyType_IS_GC(self->ob_type) &&
  16200. _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
  16201. _Py_DEC_REFTOTAL;
  16202. #endif
  16203. #ifdef COUNT_ALLOCS
  16204. --Py_TYPE(self)->tp_frees;
  16205. --Py_TYPE(self)->tp_allocs;
  16206. #endif
  16207. #endif
  16208. }
  16209. static PyObject *
  16210. __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
  16211. {
  16212. PyObject *name = self->gi_name;
  16213. if (unlikely(!name)) name = Py_None;
  16214. Py_INCREF(name);
  16215. return name;
  16216. }
  16217. static int
  16218. __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value)
  16219. {
  16220. PyObject *tmp;
  16221. #if PY_MAJOR_VERSION >= 3
  16222. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  16223. #else
  16224. if (unlikely(value == NULL || !PyString_Check(value))) {
  16225. #endif
  16226. PyErr_SetString(PyExc_TypeError,
  16227. "__name__ must be set to a string object");
  16228. return -1;
  16229. }
  16230. tmp = self->gi_name;
  16231. Py_INCREF(value);
  16232. self->gi_name = value;
  16233. Py_XDECREF(tmp);
  16234. return 0;
  16235. }
  16236. static PyObject *
  16237. __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
  16238. {
  16239. PyObject *name = self->gi_qualname;
  16240. if (unlikely(!name)) name = Py_None;
  16241. Py_INCREF(name);
  16242. return name;
  16243. }
  16244. static int
  16245. __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value)
  16246. {
  16247. PyObject *tmp;
  16248. #if PY_MAJOR_VERSION >= 3
  16249. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  16250. #else
  16251. if (unlikely(value == NULL || !PyString_Check(value))) {
  16252. #endif
  16253. PyErr_SetString(PyExc_TypeError,
  16254. "__qualname__ must be set to a string object");
  16255. return -1;
  16256. }
  16257. tmp = self->gi_qualname;
  16258. Py_INCREF(value);
  16259. self->gi_qualname = value;
  16260. Py_XDECREF(tmp);
  16261. return 0;
  16262. }
  16263. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  16264. PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  16265. PyObject *name, PyObject *qualname, PyObject *module_name) {
  16266. __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
  16267. if (unlikely(!gen))
  16268. return NULL;
  16269. return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
  16270. }
  16271. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  16272. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  16273. PyObject *name, PyObject *qualname, PyObject *module_name) {
  16274. gen->body = body;
  16275. gen->closure = closure;
  16276. Py_XINCREF(closure);
  16277. gen->is_running = 0;
  16278. gen->resume_label = 0;
  16279. gen->classobj = NULL;
  16280. gen->yieldfrom = NULL;
  16281. gen->exc_type = NULL;
  16282. gen->exc_value = NULL;
  16283. gen->exc_traceback = NULL;
  16284. gen->gi_weakreflist = NULL;
  16285. Py_XINCREF(qualname);
  16286. gen->gi_qualname = qualname;
  16287. Py_XINCREF(name);
  16288. gen->gi_name = name;
  16289. Py_XINCREF(module_name);
  16290. gen->gi_modulename = module_name;
  16291. Py_XINCREF(code);
  16292. gen->gi_code = code;
  16293. PyObject_GC_Track(gen);
  16294. return gen;
  16295. }
  16296. /* PatchModuleWithCoroutine */
  16297. static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
  16298. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  16299. int result;
  16300. PyObject *globals, *result_obj;
  16301. globals = PyDict_New(); if (unlikely(!globals)) goto ignore;
  16302. result = PyDict_SetItemString(globals, "_cython_coroutine_type",
  16303. #ifdef __Pyx_Coroutine_USED
  16304. (PyObject*)__pyx_CoroutineType);
  16305. #else
  16306. Py_None);
  16307. #endif
  16308. if (unlikely(result < 0)) goto ignore;
  16309. result = PyDict_SetItemString(globals, "_cython_generator_type",
  16310. #ifdef __Pyx_Generator_USED
  16311. (PyObject*)__pyx_GeneratorType);
  16312. #else
  16313. Py_None);
  16314. #endif
  16315. if (unlikely(result < 0)) goto ignore;
  16316. if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
  16317. if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
  16318. result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
  16319. if (unlikely(!result_obj)) goto ignore;
  16320. Py_DECREF(result_obj);
  16321. Py_DECREF(globals);
  16322. return module;
  16323. ignore:
  16324. Py_XDECREF(globals);
  16325. PyErr_WriteUnraisable(module);
  16326. if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
  16327. Py_DECREF(module);
  16328. module = NULL;
  16329. }
  16330. #else
  16331. py_code++;
  16332. #endif
  16333. return module;
  16334. }
  16335. /* PatchGeneratorABC */
  16336. #ifndef CYTHON_REGISTER_ABCS
  16337. #define CYTHON_REGISTER_ABCS 1
  16338. #endif
  16339. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  16340. static PyObject* __Pyx_patch_abc_module(PyObject *module);
  16341. static PyObject* __Pyx_patch_abc_module(PyObject *module) {
  16342. module = __Pyx_Coroutine_patch_module(
  16343. module, ""
  16344. "if _cython_generator_type is not None:\n"
  16345. " try: Generator = _module.Generator\n"
  16346. " except AttributeError: pass\n"
  16347. " else: Generator.register(_cython_generator_type)\n"
  16348. "if _cython_coroutine_type is not None:\n"
  16349. " try: Coroutine = _module.Coroutine\n"
  16350. " except AttributeError: pass\n"
  16351. " else: Coroutine.register(_cython_coroutine_type)\n"
  16352. );
  16353. return module;
  16354. }
  16355. #endif
  16356. static int __Pyx_patch_abc(void) {
  16357. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  16358. static int abc_patched = 0;
  16359. if (CYTHON_REGISTER_ABCS && !abc_patched) {
  16360. PyObject *module;
  16361. module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
  16362. if (!module) {
  16363. PyErr_WriteUnraisable(NULL);
  16364. if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
  16365. ((PY_MAJOR_VERSION >= 3) ?
  16366. "Cython module failed to register with collections.abc module" :
  16367. "Cython module failed to register with collections module"), 1) < 0)) {
  16368. return -1;
  16369. }
  16370. } else {
  16371. module = __Pyx_patch_abc_module(module);
  16372. abc_patched = 1;
  16373. if (unlikely(!module))
  16374. return -1;
  16375. Py_DECREF(module);
  16376. }
  16377. module = PyImport_ImportModule("backports_abc");
  16378. if (module) {
  16379. module = __Pyx_patch_abc_module(module);
  16380. Py_XDECREF(module);
  16381. }
  16382. if (!module) {
  16383. PyErr_Clear();
  16384. }
  16385. }
  16386. #else
  16387. if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
  16388. #endif
  16389. return 0;
  16390. }
  16391. /* Generator */
  16392. static PyMethodDef __pyx_Generator_methods[] = {
  16393. {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
  16394. (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
  16395. {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
  16396. (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
  16397. {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS,
  16398. (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
  16399. {0, 0, 0, 0}
  16400. };
  16401. static PyMemberDef __pyx_Generator_memberlist[] = {
  16402. {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
  16403. {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
  16404. (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
  16405. {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
  16406. {0, 0, 0, 0, 0}
  16407. };
  16408. static PyGetSetDef __pyx_Generator_getsets[] = {
  16409. {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
  16410. (char*) PyDoc_STR("name of the generator"), 0},
  16411. {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
  16412. (char*) PyDoc_STR("qualified name of the generator"), 0},
  16413. {0, 0, 0, 0, 0}
  16414. };
  16415. static PyTypeObject __pyx_GeneratorType_type = {
  16416. PyVarObject_HEAD_INIT(0, 0)
  16417. "generator",
  16418. sizeof(__pyx_CoroutineObject),
  16419. 0,
  16420. (destructor) __Pyx_Coroutine_dealloc,
  16421. 0,
  16422. 0,
  16423. 0,
  16424. 0,
  16425. 0,
  16426. 0,
  16427. 0,
  16428. 0,
  16429. 0,
  16430. 0,
  16431. 0,
  16432. 0,
  16433. 0,
  16434. 0,
  16435. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
  16436. 0,
  16437. (traverseproc) __Pyx_Coroutine_traverse,
  16438. 0,
  16439. 0,
  16440. offsetof(__pyx_CoroutineObject, gi_weakreflist),
  16441. 0,
  16442. (iternextfunc) __Pyx_Generator_Next,
  16443. __pyx_Generator_methods,
  16444. __pyx_Generator_memberlist,
  16445. __pyx_Generator_getsets,
  16446. 0,
  16447. 0,
  16448. 0,
  16449. 0,
  16450. 0,
  16451. 0,
  16452. 0,
  16453. 0,
  16454. 0,
  16455. 0,
  16456. 0,
  16457. 0,
  16458. 0,
  16459. 0,
  16460. 0,
  16461. #if CYTHON_USE_TP_FINALIZE
  16462. 0,
  16463. #else
  16464. __Pyx_Coroutine_del,
  16465. #endif
  16466. 0,
  16467. #if CYTHON_USE_TP_FINALIZE
  16468. __Pyx_Coroutine_del,
  16469. #elif PY_VERSION_HEX >= 0x030400a1
  16470. 0,
  16471. #endif
  16472. };
  16473. static int __pyx_Generator_init(void) {
  16474. __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  16475. __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
  16476. __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
  16477. if (unlikely(!__pyx_GeneratorType)) {
  16478. return -1;
  16479. }
  16480. return 0;
  16481. }
  16482. /* CheckBinaryVersion */
  16483. static int __Pyx_check_binary_version(void) {
  16484. char ctversion[4], rtversion[4];
  16485. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  16486. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  16487. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  16488. char message[200];
  16489. PyOS_snprintf(message, sizeof(message),
  16490. "compiletime version %s of module '%.100s' "
  16491. "does not match runtime version %s",
  16492. ctversion, __Pyx_MODULE_NAME, rtversion);
  16493. return PyErr_WarnEx(NULL, message, 1);
  16494. }
  16495. return 0;
  16496. }
  16497. /* VoidPtrExport */
  16498. static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
  16499. PyObject *d;
  16500. PyObject *cobj = 0;
  16501. d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
  16502. Py_XINCREF(d);
  16503. if (!d) {
  16504. d = PyDict_New();
  16505. if (!d)
  16506. goto bad;
  16507. if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
  16508. goto bad;
  16509. }
  16510. #if PY_VERSION_HEX >= 0x02070000
  16511. cobj = PyCapsule_New(p, sig, 0);
  16512. #else
  16513. cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
  16514. #endif
  16515. if (!cobj)
  16516. goto bad;
  16517. if (PyDict_SetItem(d, name, cobj) < 0)
  16518. goto bad;
  16519. Py_DECREF(cobj);
  16520. Py_DECREF(d);
  16521. return 0;
  16522. bad:
  16523. Py_XDECREF(cobj);
  16524. Py_XDECREF(d);
  16525. return -1;
  16526. }
  16527. /* FunctionExport */
  16528. static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
  16529. PyObject *d = 0;
  16530. PyObject *cobj = 0;
  16531. union {
  16532. void (*fp)(void);
  16533. void *p;
  16534. } tmp;
  16535. d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
  16536. if (!d) {
  16537. PyErr_Clear();
  16538. d = PyDict_New();
  16539. if (!d)
  16540. goto bad;
  16541. Py_INCREF(d);
  16542. if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
  16543. goto bad;
  16544. }
  16545. tmp.fp = f;
  16546. #if PY_VERSION_HEX >= 0x02070000
  16547. cobj = PyCapsule_New(tmp.p, sig, 0);
  16548. #else
  16549. cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
  16550. #endif
  16551. if (!cobj)
  16552. goto bad;
  16553. if (PyDict_SetItemString(d, name, cobj) < 0)
  16554. goto bad;
  16555. Py_DECREF(cobj);
  16556. Py_DECREF(d);
  16557. return 0;
  16558. bad:
  16559. Py_XDECREF(cobj);
  16560. Py_XDECREF(d);
  16561. return -1;
  16562. }
  16563. /* InitStrings */
  16564. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  16565. while (t->p) {
  16566. #if PY_MAJOR_VERSION < 3
  16567. if (t->is_unicode) {
  16568. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  16569. } else if (t->intern) {
  16570. *t->p = PyString_InternFromString(t->s);
  16571. } else {
  16572. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  16573. }
  16574. #else
  16575. if (t->is_unicode | t->is_str) {
  16576. if (t->intern) {
  16577. *t->p = PyUnicode_InternFromString(t->s);
  16578. } else if (t->encoding) {
  16579. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  16580. } else {
  16581. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  16582. }
  16583. } else {
  16584. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  16585. }
  16586. #endif
  16587. if (!*t->p)
  16588. return -1;
  16589. if (PyObject_Hash(*t->p) == -1)
  16590. return -1;
  16591. ++t;
  16592. }
  16593. return 0;
  16594. }
  16595. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  16596. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  16597. }
  16598. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  16599. Py_ssize_t ignore;
  16600. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  16601. }
  16602. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  16603. #if !CYTHON_PEP393_ENABLED
  16604. static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  16605. char* defenc_c;
  16606. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  16607. if (!defenc) return NULL;
  16608. defenc_c = PyBytes_AS_STRING(defenc);
  16609. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16610. {
  16611. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  16612. char* c;
  16613. for (c = defenc_c; c < end; c++) {
  16614. if ((unsigned char) (*c) >= 128) {
  16615. PyUnicode_AsASCIIString(o);
  16616. return NULL;
  16617. }
  16618. }
  16619. }
  16620. #endif
  16621. *length = PyBytes_GET_SIZE(defenc);
  16622. return defenc_c;
  16623. }
  16624. #else
  16625. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  16626. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  16627. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16628. if (likely(PyUnicode_IS_ASCII(o))) {
  16629. *length = PyUnicode_GET_LENGTH(o);
  16630. return PyUnicode_AsUTF8(o);
  16631. } else {
  16632. PyUnicode_AsASCIIString(o);
  16633. return NULL;
  16634. }
  16635. #else
  16636. return PyUnicode_AsUTF8AndSize(o, length);
  16637. #endif
  16638. }
  16639. #endif
  16640. #endif
  16641. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  16642. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  16643. if (
  16644. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16645. __Pyx_sys_getdefaultencoding_not_ascii &&
  16646. #endif
  16647. PyUnicode_Check(o)) {
  16648. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  16649. } else
  16650. #endif
  16651. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  16652. if (PyByteArray_Check(o)) {
  16653. *length = PyByteArray_GET_SIZE(o);
  16654. return PyByteArray_AS_STRING(o);
  16655. } else
  16656. #endif
  16657. {
  16658. char* result;
  16659. int r = PyBytes_AsStringAndSize(o, &result, length);
  16660. if (unlikely(r < 0)) {
  16661. return NULL;
  16662. } else {
  16663. return result;
  16664. }
  16665. }
  16666. }
  16667. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  16668. int is_true = x == Py_True;
  16669. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  16670. else return PyObject_IsTrue(x);
  16671. }
  16672. static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
  16673. #if PY_MAJOR_VERSION >= 3
  16674. if (PyLong_Check(result)) {
  16675. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  16676. "__int__ returned non-int (type %.200s). "
  16677. "The ability to return an instance of a strict subclass of int "
  16678. "is deprecated, and may be removed in a future version of Python.",
  16679. Py_TYPE(result)->tp_name)) {
  16680. Py_DECREF(result);
  16681. return NULL;
  16682. }
  16683. return result;
  16684. }
  16685. #endif
  16686. PyErr_Format(PyExc_TypeError,
  16687. "__%.4s__ returned non-%.4s (type %.200s)",
  16688. type_name, type_name, Py_TYPE(result)->tp_name);
  16689. Py_DECREF(result);
  16690. return NULL;
  16691. }
  16692. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  16693. #if CYTHON_USE_TYPE_SLOTS
  16694. PyNumberMethods *m;
  16695. #endif
  16696. const char *name = NULL;
  16697. PyObject *res = NULL;
  16698. #if PY_MAJOR_VERSION < 3
  16699. if (likely(PyInt_Check(x) || PyLong_Check(x)))
  16700. #else
  16701. if (likely(PyLong_Check(x)))
  16702. #endif
  16703. return __Pyx_NewRef(x);
  16704. #if CYTHON_USE_TYPE_SLOTS
  16705. m = Py_TYPE(x)->tp_as_number;
  16706. #if PY_MAJOR_VERSION < 3
  16707. if (m && m->nb_int) {
  16708. name = "int";
  16709. res = m->nb_int(x);
  16710. }
  16711. else if (m && m->nb_long) {
  16712. name = "long";
  16713. res = m->nb_long(x);
  16714. }
  16715. #else
  16716. if (likely(m && m->nb_int)) {
  16717. name = "int";
  16718. res = m->nb_int(x);
  16719. }
  16720. #endif
  16721. #else
  16722. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  16723. res = PyNumber_Int(x);
  16724. }
  16725. #endif
  16726. if (likely(res)) {
  16727. #if PY_MAJOR_VERSION < 3
  16728. if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
  16729. #else
  16730. if (unlikely(!PyLong_CheckExact(res))) {
  16731. #endif
  16732. return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
  16733. }
  16734. }
  16735. else if (!PyErr_Occurred()) {
  16736. PyErr_SetString(PyExc_TypeError,
  16737. "an integer is required");
  16738. }
  16739. return res;
  16740. }
  16741. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  16742. Py_ssize_t ival;
  16743. PyObject *x;
  16744. #if PY_MAJOR_VERSION < 3
  16745. if (likely(PyInt_CheckExact(b))) {
  16746. if (sizeof(Py_ssize_t) >= sizeof(long))
  16747. return PyInt_AS_LONG(b);
  16748. else
  16749. return PyInt_AsSsize_t(x);
  16750. }
  16751. #endif
  16752. if (likely(PyLong_CheckExact(b))) {
  16753. #if CYTHON_USE_PYLONG_INTERNALS
  16754. const digit* digits = ((PyLongObject*)b)->ob_digit;
  16755. const Py_ssize_t size = Py_SIZE(b);
  16756. if (likely(__Pyx_sst_abs(size) <= 1)) {
  16757. ival = likely(size) ? digits[0] : 0;
  16758. if (size == -1) ival = -ival;
  16759. return ival;
  16760. } else {
  16761. switch (size) {
  16762. case 2:
  16763. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  16764. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16765. }
  16766. break;
  16767. case -2:
  16768. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  16769. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16770. }
  16771. break;
  16772. case 3:
  16773. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  16774. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16775. }
  16776. break;
  16777. case -3:
  16778. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  16779. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16780. }
  16781. break;
  16782. case 4:
  16783. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  16784. 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]));
  16785. }
  16786. break;
  16787. case -4:
  16788. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  16789. 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]));
  16790. }
  16791. break;
  16792. }
  16793. }
  16794. #endif
  16795. return PyLong_AsSsize_t(b);
  16796. }
  16797. x = PyNumber_Index(b);
  16798. if (!x) return -1;
  16799. ival = PyInt_AsSsize_t(x);
  16800. Py_DECREF(x);
  16801. return ival;
  16802. }
  16803. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  16804. return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
  16805. }
  16806. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  16807. return PyInt_FromSize_t(ival);
  16808. }
  16809. #endif /* Py_PYTHON_H */