Ñò c‹lLc@ séddklZddkZddklZddkTddkTddklZlZl Z ddk l Z l Z l Z ddklZddklZd d d d d ddddddg Zd„Zd efd„ƒYZd„Zeidjo d„Znd„Zd efd„ƒYZd efd„ƒYZdefd„ƒYZd„d„Zdefd „ƒYZdefd!„ƒYZd"„Ze ƒd#„Z!defd$„ƒYZ"defd%„ƒYZ#d&efd'„ƒYZ$dS((iÿÿÿÿ(tdivisionN(tAddOn(t*(tsortedtsett frozenset(tMintMaxtExtreme(tdecorate(t InstanceTypetOrderingt BitmapIndext TreeBuildert split_rangestto_bitst from_bitst RangeIndext TypeIndext TruthIndext PointerIndextbitmap_index_typecC s>g}x1|D])}t||ƒi|ƒ|i|ƒq WdS(N(R trequirestappend(tobtseqtitemstkey((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pytdefine_orderings cB s)eZdZd„Zd„Zd„ZRS(s+Track inter-expression ordering constraintscC stƒ|_dS(N(Rt constraints(tselftownertexpr((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyt__init__-scC st|ƒ}|i}||jodSxDt|ƒD]6}||jodS||jo|i|ƒq4q4W|i|ƒdS(N(RRtlisttremovetadd(Rtguardstctcstoldc((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR0s      cC sR|iptSx<|iD]-}x$|D]}||joPq&q&WtSqWtSdS(N(RtTruetFalse(RtexprsR&te((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyt can_precede<s    (t__name__t __module__t__doc__R!RR-(((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR *s  cC s)d}x|D]}|d|>O}q W|S(sAReturn a bitset encoding the numbers contained in sequence `ints`ii((tintstbti((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyRSs s2.4cC sFd}x9|D]1}|djot|ƒ}n|d|>O}q W|S(sAReturn a bitset encoding the numbers contained in sequence `ints`iii(tlong(R1R2R3((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR[s cc shd}x[|oSx$|d@p|dL}|d7}qW|d@o |Vn|dL}|d7}q WdS(s3Yield the (ascending) numbers contained in bitset niiiiN((tnR2((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyRds     cB sDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(s>Template methods for the Chambers&Chen dispatch tree algorithmcC sÃ||f}||jo ||S|p|i||ƒ}nw|i||ƒ\}}t|ƒt|ƒjpt‚|djo|i|||ƒ}n|i||||ƒ}|||<|S(N(t build_leaft best_exprtlentAssertionErrortNonetbuildt build_node(RtcasesR+tmemoRtnodetbesttrest((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR;s      cC s t‚dS(N(tNotImplementedError(RR R=tremaining_exprsR>((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR<‘scC s t‚dS(N(RB(RR=R>((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR6”scC s t‚dS(s4Return (seedcount,totalcases) selectivity statisticsN(RB(Rt expressionR=((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyt selectivity—scC sdS(Ni((RR RC((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pytcost›scC s{d}d}t|ƒ}ti|ƒ}t|ƒ}g}x|o|iƒ} t|| ƒi|ƒp|i| ƒq<n|i | |ƒ\} } | || jo!|| =|i |ƒg}q<n| | } |djp | |jo#| | }}|i | |ƒ} q<| |jo4|i | |ƒ}|| jo| |}} qNq<q<W|dj o ||=n|t |ƒfS(N( R:R"tdicttfromkeysR8tpopR R-RREtextendRFR(RR=R+R7t best_spreadtto_dot remainingt active_casestskippedR tbranchest total_casestspreadt best_costRF((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR7¥s:           ( R.R/R0R;R<R6RERFR7(((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR |s     cB s–eZdZdZefZeeƒd„Zd„Z d„Z d„Z d„Z d„Z d„Zd „Zd „Zd „Zed „Zd „ZRS(sCIndex that computes selectivity and handles basic caching w/bitmapsicG s tf|S(N(R (targs((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyt addon_keyÕscC s6|tjot||ƒ}ntt|ƒi|ƒS(N(R Rtsupert__new__(tclstengineR ((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyRWÙs cC s8h|_h|_|_h|_g|_h|_dS(N(textratnullt all_seedst criteria_bitst case_seedstcriteria_seeds(RRYR ((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR!Þs    cC sÇ||ijo|i|}n.|ii|dƒ|i|ƒ}|i|<|i}|t|ƒjo|i|ƒn|i|ƒ|||Isc C s6g}h}|}xˆ|iƒD][\\}}\}} |o(|tjo|djo| oPn|||Bƒ||node and `ranges` is a sorted list of ``((lo,hi),node)`` tuples expressing non-inclusive ranges. `dont_cares` and `seedmap` should be the return values from a bitmap index's ``seed_bits()`` method. `node(bits)` should return the value to be used as a node in the output; the default is to just return a bitmap of cases. iÿÿÿÿi(t iteritemsRRRRIRt isinstanceR( t dont_carestbitmapR?trangestexacttcurrenttvaltdRoRptlowtnew((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyRIs> *     #cB seZdZd„ZRS(sIndex for pointer equalitycC syt|iƒ}d|i|<|io(|i||ƒ|id|ƒ|iS|id|ƒ|i||ƒ|iSdS(Ni(tidtrefRZRzRyRwR:(RReRn((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyRaus  (R.R/R0Ra(((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyRrscB seZdZd„ZRS(s)Index for simple boolean expression testscC sVt|tƒo|itjpt‚|i|i|ƒ|i|i | ƒ|iS(N(R„tValuetvalueR)R9RyRz(RRe((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyRa…s'(R.R/R0Ra(((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR‚scC sTt|tƒo |i}n4d|tfd„ƒY}|idd!ttf}|S(NttmpcB seZRS((R.R/(((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR’siiÿÿÿÿ(R„ttypet__mro__tobjectR (RXtmroR’((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyt_get_mroŒs  cC st||ƒ‚dS(sCGet the BitmapIndex subclass to use for the given engine and `expr`N(RB(RYR ((s7/usr/lib/python2.6/site-packages/peak/rules/indexing.pyR•scB s)eZdZd„Zd„Zd„ZRS(s3Index for istype(), Class(), and Classes() criteriac C sD||ijodSt|ƒ}|i||ƒ|i}|i}|i}xñt|ƒD]ã}||jo|i|ƒn|i|t|t ƒƒt|ƒ}||jot ƒ||s:      )  R_)  R>