Util
util ¶
Utility functions for the BI SDK.
bi_sdk.util.DictObject ¶
Bases: MutableMapping, dict
Recursively represent a dict and any nested dicts as objects while also still behaving like a dict.
Source: http://stackoverflow.com/a/6573827/194311
It inherits from dict so that isinstance checks will identify it as a dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj |
dict
|
A dictionary-like object |
None
|
recursive |
bool
|
Whether to recursively convert inner dicts. (Default: True) |
True
|
bi_sdk.util.calculate_lambda ¶
Calculates lambda value which is the highest number that can be multiplied by n and still be less than or equal to the value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value |
int
|
the value to be inserted or searched |
required |
n |
int
|
n value, calculated by calculate_n |
required |
Returns:
| Type | Description |
|---|---|
int
|
lambda (int) |
bi_sdk.util.calculate_mu ¶
Calculates mu value which is the remaining of value minus lambda times n
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value |
int
|
the value to be inserted or searched |
required |
n |
int
|
n value, calculated by calculate_n |
required |
value_lambda |
int
|
lambda value, calculated by calculate_lambda |
required |
Returns:
| Type | Description |
|---|---|
int
|
mu (int) |
bi_sdk.util.calculate_n ¶
bi_sdk.util.get_lambda_and_mu ¶
Calculates lambda and mu for a value. It is used on range search to calculate the value's position in the matrix index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema |
Schema
|
schema of the record |
required |
label |
string
|
label to which the value belongs |
required |
value |
int
|
value to be calculated |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
a tuple (int, int) with lambda and mu values |
bi_sdk.util.parse_mathematical_operations ¶
Parses the input value in case of range search. The input value contains the operation and the values to be used in the search.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_value |
int
|
the input value with operation and values to be searched |
required |
Returns:
| Name | Type | Description |
|---|---|---|
operation |
str
|
the operation to be used in the search |
value |
int
|
the first value to be used in the search |
value2 |
int
|
the second value to be used in the search |
bi_sdk.util.prepare_values_and_operation ¶
Range search allows for some operations. = exact match ~ search between two values
search values greater than the input value = search values greater than or equal to the input value < search values less than the input value <= search values less than or equal to the input value For each operation there is a different treatment. This function prepares the values in the right order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema |
Schema
|
schema of the record |
required |
label |
str
|
label to which the value belongs |
required |
input_value |
int
|
the input value with operation and values to be searched |
required |
Returns:
| Name | Type | Description |
|---|---|---|
value1 |
int
|
the minimum value for the search or None |
value2 |
int
|
the maximum value for the search or None |