public override IdSet GetIdSet( TableExpression te ) { if ( Lhs is ExpName && Rhs.IsConstant() ) { ExpName e = (ExpName)Lhs; if ( e.ColName == "Id" ) // select ... from t where id in ( .... ) { return Rhs.ListIdSet(); } IndexFile ix = te.FindIndex( e.ColIx ); if ( ix != null ) // select ... from t where indexedcol in ( .... ) { return new Lookup( ix, Rhs ); // For each value in the Rhs list, lookup it's ids, and return them in the IdSet. } } return null; }
public override IdSet GetIdSet( TableExpression te ) { if ( Operator <= Token.Equal && Right.IsConstant() && Left is ExpName ) { ExpName e = ((ExpName)Left); if ( e.ColName == "Id" && Operator == Token.Equal ) return new SingleId( Right ); IndexFile ix = te.FindIndex( e.ColIx ); if ( ix != null ) return new IndexFrom( ix, Right, Operator ); } else if ( Operator <= Token.Equal && Left.IsConstant() && Right is ExpName ) { ExpName e = ((ExpName)Right); if ( e.ColName == "Id" && Operator == Token.Equal ) return new SingleId( Left ); IndexFile ix = te.FindIndex( e.ColIx ); if ( ix != null ) return new IndexFrom( ix, Left, TokenInfo.Reflect( Operator ) ); } else if ( Operator == Token.And ) { var left = Left.GetIdSet( te ); if ( left != null ) return left; var right = Right.GetIdSet( te ); if ( right != null ) return right; } return null; }