class documentation

class _FilterCompilerHelper(object):

View In Hierarchy

Converts a query filter to a callable usable for filtering.

Method __call__ Converts a query filter into a callable function.
Method __init__ Initializes this class.
Method _Compile Inner function for converting filters.
Method _HandleBinaryOp Handles binary operators.
Method _HandleLogicOp Handles logic operators.
Method _HandleUnaryOp Handles unary operators.
Method _LookupField Returns a field definition by name.
Constant _EQUALITY_CHECKS Known operators
Constant _LEVELS_MAX Undocumented
Constant _OPS Undocumented
Constant _OPTYPE_BINARY Functions for equality checks depending on field flags.
Constant _OPTYPE_LOGIC Undocumented
Constant _OPTYPE_UNARY Undocumented
Instance Variable _fields Undocumented
Instance Variable _hints Undocumented
Instance Variable _op_handler Undocumented
def __call__(self, hints, qfilter):

Converts a query filter into a callable function.

Parameters
hints:_FilterHints or NoneCallbacks doing analysis on filter
qfilter:listFilter structure
Returns
callableFunction receiving context and item as parameters, returning boolean as to whether item matches filter
def __init__(self, fields):

Initializes this class.

Parameters
fieldsField definitions (return value of _PrepareFieldList)
def _Compile(self, qfilter, level):

Inner function for converting filters.

Calls the correct handler functions for the top-level operator. This function is called recursively (e.g. for logic operators).

def _HandleBinaryOp(self, hints_fn, level, op, op_data, operands):

Handles binary operators.

Parameters
hints_fn:callableCallback doing some analysis on the filter
level:integerCurrent depth
op:stringOperator
op_dataFunctions implementing operators
operands:listList of operands
def _HandleLogicOp(self, hints_fn, level, op, op_fn, operands):

Handles logic operators.

Parameters
hints_fn:callableCallback doing some analysis on the filter
level:integerCurrent depth
op:stringOperator
op_fn:callableFunction implementing operator
operands:listList of operands
def _HandleUnaryOp(self, hints_fn, level, op, op_fn, operands):

Handles unary operators.

Parameters
hints_fn:callableCallback doing some analysis on the filter
level:integerCurrent depth
op:stringOperator
op_fn:callableFunction implementing operator
operands:listList of operands
def _LookupField(self, name):

Returns a field definition by name.

_EQUALITY_CHECKS =

Known operators

Operator as key (qlang.OP_*), value a tuple of operator group (_OPTYPE_*) and a group-specific value:

  • _OPTYPE_LOGIC: Callable taking any number of arguments; used by _HandleLogicOp
  • _OPTYPE_UNARY: Always None; details handled by _HandleUnaryOp
  • _OPTYPE_BINARY: Callable taking exactly two parameters, the left- and right-hand side of the operator, used by _HandleBinaryOp
Value
[(QFF_HOSTNAME,
  (lambda lhs, rhs: utils.MatchNameComponent(rhs, [lhs], case_sensitive=False)),
  None),
 (QFF_SPLIT_TIMESTAMP,
  _MakeSplitTimestampComparison(operator.eq),
  _PrepareSplitTimestamp),
 (None, operator.eq, None)]
_LEVELS_MAX: int =

Undocumented

Value
10
_OPTYPE_BINARY =

Functions for equality checks depending on field flags.

List of tuples containing flags and a callable receiving the left- and right-hand side of the operator. The flags are an OR-ed value of QFF_* (e.g. QFF_HOSTNAME or QFF_SPLIT_TIMESTAMP).

Order matters. The first item with flags will be used. Flags are checked using binary AND.

_OPTYPE_LOGIC =

Undocumented

_OPTYPE_UNARY =

Undocumented

_fields =

Undocumented

_hints =

Undocumented

_op_handler =

Undocumented