package Ġorg . vit riv r . cott ont ail . dbms . queries . operators . physical . predicates Ċ Ċ import Ġorg . vit riv r . cott ont ail . core . database . Column Def Ċ import Ġorg . vit riv r . cott ont ail . core . queries . nodes . traits . Trait Ċ import Ġorg . vit riv r . cott ont ail . core . queries . nodes . traits . Trait Type Ċ import Ġorg . vit riv r . cott ont ail . core . queries . planning . cost . Cost Ċ import Ġorg . vit riv r . cott ont ail . core . queries . predicates . Boolean Predicate Ċ import Ġorg . vit riv r . cott ont ail . core . queries . predicates . Comparison Operator Ċ import Ġorg . vit riv r . cott ont ail . core . queries . predicates . Prox imity Predicate Ċ import Ġorg . vit riv r . cott ont ail . dbms . execution . operators . basics . Operator Ċ import Ġorg . vit riv r . cott ont ail . dbms . execution . operators . predicates . Filter On Sub select Operator Ċ import Ġorg . vit riv r . cott ont ail . dbms . queries . context . Query Context Ċ import Ġorg . vit riv r . cott ont ail . dbms . queries . operators . logical . Binary Logical Operator Node Ċ import Ġorg . vit riv r . cott ont ail . dbms . queries . operators . physical . NA ry Physical Operator Node Ċ import Ġorg . vit riv r . cott ont ail . dbms . statistics . select ivity . Na ive Select ivity Calculator Ċ import Ġorg . vit riv r . cott ont ail . dbms . statistics . select ivity . Select ivity Ċ Ċ /** Ċ Ġ* ĠA Ġ[ Binary Logical Operator Node ] Ġthat Ġformal izes Ġfiltering Ġusing Ġsome Ġ[ Boolean Predicate ]. Ċ Ġ* Ċ Ġ* ĠAs Ġopposed Ġto Ġ[ Filter Physical Operator Node ], Ġthe Ġ[ Filter On Sub Select Physical Operator Node ] Ġdepends Ġon Ċ Ġ* Ġthe Ġexecution Ġof Ġone Ġor Ġmany Ġsub - queries . Ċ Ġ* Ċ Ġ* Ġ@ author ĠR alph ĠG asser Ċ Ġ* Ġ@ version Ġ 2 . 2 . 0 Ċ Ġ*/ Ċ class ĠFilter On Sub Select Physical Operator Node ( val Ġpredicate : ĠBoolean Predicate , Ġvar arg Ġinputs : ĠPhysical ) Ġ: ĠNA ry Physical Operator Node (* inputs ) Ġ{ ĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠNODE _ NAME Ġ= Ġ" Filter " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĠThe Ġname Ġof Ġthis Ġ[ Filter On Sub Select Physical Operator Node ]. Ġ*/ ĊĠĠĠ Ġoverride Ġval Ġname : ĠString ĊĠĠĠĠĠĠĠ Ġget () Ġ= ĠNODE _ NAME ĊĊĠĠĠ Ġ/** ĠThe Ġ[ Filter On Sub Select Physical Operator Node ] Ġrequires Ġall Ġ[ Column Def ] s Ġused Ġin Ġthe Ġ[ Prox imity Predicate ]. Ġ*/ ĊĠĠĠ Ġoverride Ġval Ġrequires : ĠList < Column Def <* >> Ġ= Ġthis . predicate . columns . toList () ĊĊĠĠĠ Ġ/** ĠThe Ġ[ Filter On Sub Select Physical Operator Node ] Ġcan Ġonly Ġbe Ġexecuted Ġif Ġit Ġdoesn 't Ġcontain Ġany Ġ[ Comparison Operator . Binary . Match ]. Ġ*/ ĊĠĠĠ Ġoverride Ġval Ġexecutable : ĠBoolean ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġsuper . executable Ġ&& Ġthis . predicate . atom ics . none Ġ{ Ġit . operator Ġis ĠComparison Operator . Binary . Match Ġ} ĊĊĠĠĠ Ġ/** ĠThe Ġestimated Ġoutput Ġsize Ġof Ġthis Ġ[ Filter On Sub Select Physical Operator Node ]. ĠCalcul ated Ġbased Ġon Ġ[ Select ivity ] Ġestimates . Ġ*/ ĊĠĠĠ Ġoverride Ġval Ġoutput Size : ĠLong ĊĠĠĠĠĠĠĠ Ġget () Ġ= ĠNa ive Select ivity Calculator . estimate ( this . predicate , Ġthis . statistics ). invoke ( this . inputs [ 0 ]. output Size ) ĊĊĠĠĠ Ġ/** ĠThe Ġ[ Cost ] Ġof Ġthis Ġ[ Filter On Sub Select Physical Operator Node ]. Ġ*/ ĊĠĠĠ Ġoverride Ġval Ġcost : ĠCost ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġthis . predicate . cost Ġ* Ġ( this . inputs . first OrNull ()?. output Size Ġ?: Ġ 0 ) ĊĊĠĠĠ Ġ/** ĠThe Ġ[ Filter On Sub Select Physical Operator Node ] Ġinherits Ġits Ġtraits Ġfrom Ġits Ġleft Ġmost Ġinput . Ġ*/ ĊĠĠĠ Ġoverride Ġval Ġtraits : ĠMap < Trait Type <* >, ĠTrait > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġsuper . inputs [ 0 ]. traits ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠCreates Ġand Ġreturns Ġa Ġcopy Ġof Ġthis Ġ[ Filter On Sub Select Physical Operator Node ] Ġwithout Ġany Ġchildren Ġor Ġparents . ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ@ return ĠCopy Ġof Ġthis Ġ[ Filter On Sub Select Physical Operator Node ]. ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġoverride Ġfun Ġcopy () Ġ= ĠFilter On Sub Select Physical Operator Node ( predicate Ġ= Ġthis . predicate . copy ()) ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠConverts Ġthis Ġ[ Filter On Sub Select Physical Operator Node ] Ġto Ġa Ġ[ Filter On Sub select Operator ]. ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ@ param Ġctx ĠThe Ġ[ Query Context ] Ġused Ġfor Ġthe Ġconversion Ġ( e . g . Ġlate Ġbinding ). ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġoverride Ġfun Ġto Operator ( ctx : ĠQuery Context ): ĠOperator Ġ{ ĊĠĠĠĠĠĠĠ Ġ/* ĠBind Ġpredicate Ġto Ġcontext . Ġ*/ ĊĠĠĠĠĠĠĠ Ġthis . predicate . bind ( ctx . bindings ) ĊĊĠĠĠĠĠĠĠ Ġ/* ĠGenerate Ġand Ġreturn ĠFilter On Sub select Operator . Ġ*/ ĊĠĠĠĠĠĠĠ Ġreturn ĠFilter On Sub select Operator ( this . inputs [ 0 ]. to Operator ( ctx ), Ġthis . inputs . drop ( 1 ). map Ġ{ Ġit . to Operator ( ctx ) Ġ}, Ġthis . predicate ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĠGenerates Ġand Ġreturns Ġa Ġ[ String ] Ġrepresentation Ġof Ġthis Ġ[ Filter On Sub Select Physical Operator Node ]. Ġ*/ ĊĠĠĠ Ġoverride Ġfun ĠtoString () Ġ= Ġ"${ super . toString ()} [ ${ this . predicate }] " ĊĊĠĠĠ Ġoverride Ġfun Ġequals ( other : ĠAny ?): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( this Ġ=== Ġother ) Ġreturn Ġtrue ĊĠĠĠĠĠĠĠ Ġif Ġ( other Ġ! is ĠFilter On Sub Select Physical Operator Node ) Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġif Ġ( predicate Ġ!= Ġother . predicate ) Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġreturn Ġtrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠhashCode (): ĠInt Ġ= Ġthis . predicate . hashCode () Ċ }