Elektra
0.8.18
|
Interna of splitting functionality. More...
Functions | |
Split * | elektraSplitNew (void) |
Allocates a new split object. More... | |
void | elektraSplitDel (Split *keysets) |
Delete a split object. More... | |
void | elektraSplitRemove (Split *split, size_t where) |
Remove one part of split. More... | |
void | elektraSplitResize (Split *split) |
Doubles the size of how many parts of keysets can be appended. More... | |
ssize_t | elektraSplitAppend (Split *split, Backend *backend, Key *parentKey, int syncbits) |
Increases the size of split and appends a new empty keyset. More... | |
ssize_t | elektraSplitSearchBackend (Split *split, Backend *backend, Key *parent) |
Determines if the backend is already inserted or not. More... | |
int | elektraSplitSearchRoot (Split *split, Key *parentKey) |
int | elektraSplitBuildup (Split *split, KDB *kdb, Key *parentKey) |
Walks through kdb->split and adds all backends below parentKey to split. More... | |
int | elektraSplitDivide (Split *split, KDB *handle, KeySet *ks) |
Splits up the keysets and search for a sync bit in every key. More... | |
void | elektraSplitUpdateFileName (Split *split, KDB *handle, Key *key) |
Update the (configuration) file name for the parent key. More... | |
int | elektraSplitAppoint (Split *split, KDB *handle, KeySet *ks) |
Appoints all keys from ks to yet unsynced splits. More... | |
int | elektraSplitGet (Split *split, Key *warningKey, KDB *handle) |
Does some work after getting of backends is finished. More... | |
int | elektraSplitCheckSize (Split *split) |
Check if any of the split is uninitialized. More... | |
int | elektraSplitUpdateSize (Split *split) |
Also update sizes after kdbSet() to recognize multiple kdbSet() attempts. More... | |
int | elektraSplitMerge (Split *split, KeySet *dest) |
Merges together all parts of split into dest. More... | |
int | elektraSplitSync (Split *split) |
Add sync bits everywhere keys were removed/added. More... | |
void | elektraSplitPrepare (Split *split) |
Prepares for kdbSet() mainloop afterwards. More... | |
Interna of splitting functionality.
ssize_t elektraSplitAppend | ( | Split * | split, |
Backend * | backend, | ||
Key * | parentKey, | ||
int | syncbits | ||
) |
Increases the size of split and appends a new empty keyset.
Initializes the element with the given parameters at size-1 to be used.
Will automatically resize split if needed.
split | the split object to work with |
backend | the backend which should be appended |
parentKey | the parentKey which should be appended |
syncbits | the initial syncstate which should be appended |
-1 | if no split is found |
int elektraSplitAppoint | ( | Split * | split, |
KDB * | handle, | ||
KeySet * | ks | ||
) |
Appoints all keys from ks to yet unsynced splits.
split | the split object to work with |
handle | to determine to which backend a key belongs |
ks | the keyset to appoint to split |
1 | on success |
-1 | if no backend was found for a key |
int elektraSplitBuildup | ( | Split * | split, |
KDB * | kdb, | ||
Key * | parentKey | ||
) |
Walks through kdb->split and adds all backends below parentKey to split.
Sets syncbits to 2 if it is a default or root backend (which needs splitting). The information is copied from kdb->split.
split | will get all backends appended |
kdb | the handle to get information about backends |
parentKey | the information below which key the backends are from interest |
1 | always |
int elektraSplitCheckSize | ( | Split * | split | ) |
Check if any of the split is uninitialized.
split |
-1 | if size is wrong |
1 | if everything is ok |
void elektraSplitDel | ( | Split * | keysets | ) |
Delete a split object.
Will free all allocated resources of a split keyset.
keysets | the split object to work with |
int elektraSplitDivide | ( | Split * | split, |
KDB * | handle, | ||
KeySet * | ks | ||
) |
Splits up the keysets and search for a sync bit in every key.
It does not check if there were removed keys, see elektraSplitSync() for the next step.
It does not create new backends, this has to be done by buildup before.
split | the split object to work with |
handle | to get information where the individual keys belong |
ks | the keyset to divide |
0 | if there were no sync bits |
1 | if there were sync bits |
-1 | if no backend was found for any key |
int elektraSplitGet | ( | Split * | split, |
Key * | warningKey, | ||
KDB * | handle | ||
) |
Does some work after getting of backends is finished.
split | the split object to work with |
warningKey | postcondition violations are reported here |
handle | the handle to preprocess the keys |
1 | on success |
-1 | if no backend was found for a key or split->parents has invalid namespace |
int elektraSplitMerge | ( | Split * | split, |
KeySet * | dest | ||
) |
Merges together all parts of split into dest.
split | the split object to work with |
dest | the destination keyset where all keysets are appended. |
1 | on success |
Split* elektraSplitNew | ( | void | ) |
Allocates a new split object.
Splits up a keyset into multiple keysets where each of them will passed to the correct kdbSet().
Initially the size is 0 and alloc is APPROXIMATE_NR_OF_BACKENDS.
void elektraSplitPrepare | ( | Split * | split | ) |
Prepares for kdbSet() mainloop afterwards.
All splits which do not need sync are removed and a deep copy of the remaining keysets is done.
split | the split object to work with |
void elektraSplitRemove | ( | Split * | split, |
size_t | where | ||
) |
Remove one part of split.
split | the split object to work with |
where | the position to cut away |
void elektraSplitResize | ( | Split * | split | ) |
Doubles the size of how many parts of keysets can be appended.
split | the split object to work with |
ssize_t elektraSplitSearchBackend | ( | Split * | split, |
Backend * | backend, | ||
Key * | parent | ||
) |
Determines if the backend is already inserted or not.
split | the split object to work with |
backend | the backend to search for |
parent | the key to check for domains in default/root backends. |
-1 | if it does not exist |
int elektraSplitSearchRoot | ( | Split * | split, |
Key * | parentKey | ||
) |
1 | if one of the backends in split has all keys below parentKey |
0 | if parentKey == 0 or there are keys below or same than parentKey which do not fit in any of split keysets |
split | the split object to work with |
parentKey | the key which relation is searched for |
int elektraSplitSync | ( | Split * | split | ) |
Add sync bits everywhere keys were removed/added.
Only elektraSplitDivide() together with this function can really decide if sync is needed or not.
0 | if kdbSet() is not needed |
1 | if kdbSet() is needed |
-1 | on wrong keys (also has assert, should not happen) |
-2 | wrong spec state: kdbGet() was not executed before |
-3 | wrong dir state: kdbGet() was not executed before |
-4 | wrong user state: kdbGet() was not executed before |
-5 | wrong system state: kdbGet() was not executed before |
split | the split object to work with |
void elektraSplitUpdateFileName | ( | Split * | split, |
KDB * | handle, | ||
Key * | key | ||
) |
Update the (configuration) file name for the parent key.
split | the split to work with |
handle | the handle to work with |
key | the parentKey that should be updated (name must be correct) |