Class: Veritas::Optimizer::Relation::Operation::Order::OneLimitOperand

Inherits:
Veritas::Optimizer::Relation::Operation::Order show all
Defined in:
lib/veritas/optimizer/relation/operation/order.rb

Overview

Optimize when the operand is a Limit with a limit of 1

Constant Summary

Constants inherited from Veritas::Optimizer

Noop, VERSION

Instance Attribute Summary

Attributes inherited from Unary

#header

Attributes included from Function::Unary

#operand

Attributes inherited from Veritas::Optimizer

#operation

Instance Method Summary collapse

Methods inherited from Unary

#initialize

Methods included from Function::Unary

#initialize

Methods inherited from Veritas::Optimizer

chain, #initialize

Constructor Details

This class inherits a constructor from Veritas::Optimizer::Relation::Operation::Unary

Instance Method Details

#optimizable?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test if the operand is an Limit with a limit of 1

Returns:

  • (Boolean)


42
43
44
45
46
# File 'lib/veritas/optimizer/relation/operation/order.rb', line 42

def optimizable?
  operand = self.operand
  operand.kind_of?(Veritas::Relation::Operation::Limit) &&
  operand.limit == 1
end

#optimizeLimit

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

An Order of a Limit with a limit of 1 is a noop

Returns:



53
54
55
# File 'lib/veritas/optimizer/relation/operation/order.rb', line 53

def optimize
  operand
end