Class: StateResolver

olympe.dc.ranking. StateResolver

A StateResolver comes with the execution of every listDef through the transformers that compose its query in order to discover the last element which is result of the query. It makes possible to run a specific callback when the listDef becomes ready. (eg: a sort algorithm).


new StateResolver(db [, logger])

Parameters:
Name Type Argument Description
db olympe.dc.DBView
logger olympe.logging.Channel <optional>

Methods


checkDeadEnd(index, tag, type [, direction])

Unregister the specified index if it has no child and so could block the execution of the query

Parameters:
Name Type Argument Description
index string
tag string
type string
direction olympe.dc.Direction <optional>
<nullable>

if no specified check for both directions


createBlock()

Creates a new block, child of the current block. (e.g.: used in the union transformer to split the query). Returns the id of the new created block.

Returns:
Type
string

forceSetLast(index)

Set the instance represented by the index to be the last one. It means that it will consider instances related to this instance as the last ones to process in the entire query tree. It is used in the transformer Limit, because we potentially reorder instances (if a sort is set before the limit), then we must restart with the right last instance.

Parameters:
Name Type Description
index string

getCurrentLast()

Returns:

the last index of the current block

Type
string

isReady()

Return true if the resolver is ready

Returns:
Type
boolean

onChildrenReady(callback)

Set the callback to execute when all children are marked as ready. When the children are all ready, it automatically set the current block to their parent (which is the current block at the method call moment).

Parameters:
Name Type Description
callback function

onLast(callback [, blockId])

Set a function to execute when the last instance of the specified block is reached.

Parameters:
Name Type Argument Description
callback function
blockId string <optional>

root block if no specified


register(index, parentIndex [, parentTag] [, type] [, direction])

Register an instance, part of the subscription resulting path.

Parameters:
Name Type Argument Description
index string

of the instance in the subscription

parentIndex string <nullable>

if null, considers this is the root instance of the tree result

parentTag string <optional>

previous instance in the tree result

type string <optional>
direction olympe.dc.Direction <optional>

registerResult(index [, blockId])

Activates the specified block since the specified instance's index is a result instance.

Parameters:
Name Type Argument Description
index string
blockId string <optional>

root block if no specified


setBlockReady( [blockId])

Set the specified block to ready.

Parameters:
Name Type Argument Description
blockId string <optional>

setCurrentBlock(id)

Set the current block to the specified one if exists.

Parameters:
Name Type Description
id string

block id


setReady( [ready])

Set the stateResolver's state to ready

Parameters:
Name Type Argument Default Description
ready boolean <optional>
true

unregister(index)

Unregister an instance when it is removed from the tree result. Activates the current block and set the current block as ready if the instance is marked as the last of the current block.

Parameters:
Name Type Argument Description
index string <nullable>