Functions

Split :: Represents splitted keysets

used internally for kdbSet() More...

Functions

SplitelektraSplitNew (void)
void elektraSplitDel (Split *keysets)
void elektraSplitResize (Split *split)
ssize_t elektraSplitAppend (Split *split, Backend *backend, Key *parentKey, int syncbits)
ssize_t elektraSplitSearchBackend (Split *split, Backend *backend, Key *parent)
int elektraSplitSearchRoot (Split *split, Key *parentKey)
int elektraSplitBuildup (Split *split, KDB *kdb, Key *parentKey)
int elektraSplitDivide (Split *split, KDB *handle, KeySet *ks)
int elektraSplitAppoint (Split *split, KDB *handle, KeySet *ks)
int elektraSplitGet (Split *split, KDB *handle)
int elektraSplitMerge (Split *split, KeySet *dest)
int elektraSplitSync (Split *split)
int elektraSplitPrepare (Split *split)

Detailed Description

used internally for kdbSet()

Splits up a keyset into multiple keysets where each of them will passed to the correct kdbSet().


Function Documentation

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.

Parameters:
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
Return values:
-1 if no split is found
Returns:
the size of split - 1
int elektraSplitAppoint ( Split split,
KDB handle,
KeySet ks 
)

Appoints all keys from ks to yet unsynced splits.

Precondition:
elektraSplitBuildup() need to be executed before.
Parameters:
split the split object to work with
handle to determine to which backend a key belongs
ks the keyset to appoint to split
Returns:
1 on success
-1 if no backend was found for a key
int elektraSplitBuildup ( Split split,
KDB kdb,
Key parentKey 
)

Walks through the trie and adds all backends below parentKey.

Sets syncbits to 2 if it is a default or root backend (which needs splitting).

Precondition:
split needs to be empty, directly after creation with elektraSplitNew().
there needs to be a valid defaultBackend but its ok not to have a trie inside KDB.
parentKey must be a valid key! (could be implemented more generally, but that would require splitting up of keysets of the same backend)
Parameters:
split the split object to work with
kdb the handle to get information about backends
parentKey the information below which key the backends are from interest
Returns:
always 1
void elektraSplitDel ( Split keysets  ) 

Delete a split object.

Will free all allocated resources of a splitted keyset.

Parameters:
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.

It does not check if there were removed keys, see elektraSplitRemove() for the next step.

It does not create new backends, this has to be done by buildup before.

Precondition:
elektraSplitBuildup() need to be executed before.
Parameters:
split the split object to work with
handle to get information where the individual keys belong
ks the keyset to divide
Returns:
0 if there were no sync bits
1 if there were sync bits
-1 if no backend was found for a key
int elektraSplitGet ( Split split,
KDB handle 
)

Does some work after getting of backends is finished.

Precondition:
elektraSplitAppoint() needs to be executed before.
  • check if keys are in correct backend
  • remove syncbits
  • update usersize and systemsize
Parameters:
split the split object to work with
handle the handle to preprocess the keys
Returns:
1 on success
-1 if no backend was found for a key
int elektraSplitMerge ( Split split,
KeySet dest 
)

Merges together all parts of split into dest.

Parameters:
split the split object to work with
dest the destination keyset where all keysets are appended.
Returns:
1 on success
Split* elektraSplitNew ( void   ) 

Allocates a new split object.

Initially the size is APPROXIMATE_NR_OF_BACKENDS.

Returns:
a fresh allocated split object
See also:
elektraSplitDel()
int 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.

Parameters:
split the split object to work with
Return values:
0 on success
void elektraSplitResize ( Split split  ) 

Doubles the size of how many parts of keysets can be appended.

Parameters:
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.

Warning:
If no parent Key is given, the default/root backends won't be searched.
Parameters:
split the split object to work with
backend the backend to search for
parent the key to check for domains in default/root backends.
Returns:
pos of backend if it already exist
-1 if it does not exist
int elektraSplitSearchRoot ( Split split,
Key parentKey 
)
Returns:
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 splitted keysets
Parameters:
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.

Only this function can really decide if sync is needed or not.

Precondition:
split needs to be processed with elektraSplitDivide() before.
Returns:
0 if kdbSet() is not needed
1 if kdbSet() is needed
Precondition:
user/system was splitted before.
Parameters:
split the split object to work with