Package ganeti :: Module query :: Class _FilterHints
[hide private]
[frames] | no frames]

Class _FilterHints

source code


Class for filter analytics.

When filters are used, the user of the Query class usually doesn't know exactly which items will be necessary for building the result. It therefore has to prepare and compute the input data for potentially returning everything.

There are two ways to optimize this. The first, and simpler, is to assign each field a group of data, so that the caller can determine which computations are necessary depending on the data groups requested. The list of referenced groups must also be computed for fields referenced in the filter.

The second is restricting the items based on a primary key. The primary key is usually a unique name (e.g. a node name). This class extracts all referenced names from a filter. If it encounters any filter condition which disallows such a list to be determined (e.g. a non-equality filter), all names will be requested.

The end-effect is that any operation other than qlang.OP_OR and qlang.OP_EQUAL will make the query more expensive.

Instance Methods [hide private]
 
__init__(self, namefield)
Initializes this class.
source code
list
RequestedNames(self)
Returns all requested values.
source code
 
ReferencedData(self)
Returns all kinds of data referenced by the filter.
source code
 
_NeedAllNames(self)
Changes internal state to request all names.
source code
 
NoteLogicOp(self, op)
Called when handling a logic operation.
source code
 
NoteUnaryOp(self, op, datakind)
Called when handling an unary operation.
source code
 
NoteBinaryOp(self, op, datakind, name, value)
Called when handling a binary operation.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
  _allnames
Whether all names need to be requested (e.g.
  _names
Which names to request
  _datakinds
Data kinds referenced by the filter (used by Query.RequestedData)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, namefield)
(Constructor)

source code 

Initializes this class.

Parameters:
  • namefield (string) - Field caller is interested in
Overrides: object.__init__

RequestedNames(self)

source code 

Returns all requested values.

Returns None if list of values can't be determined (e.g. encountered non-equality operators).

Returns: list

NoteLogicOp(self, op)

source code 

Called when handling a logic operation.

Parameters:
  • op (string) - Operator

NoteUnaryOp(self, op, datakind)

source code 

Called when handling an unary operation.

Parameters:
  • op (string) - Operator

NoteBinaryOp(self, op, datakind, name, value)

source code 

Called when handling a binary operation.

Parameters:
  • op (string) - Operator
  • name (string) - Left-hand side of operator (field name)
  • value - Right-hand side of operator

Instance Variable Details [hide private]

_allnames

Whether all names need to be requested (e.g. if a non-equality operator has been used)