SOS: Scalable Object Store  4.0.0
 All Classes Functions Variables Typedefs Enumerations Enumerator Groups Pages
Partition Functions

Classes

struct  sos_part_obj_iter_pos_s
 

Typedefs

typedef int(* sos_part_obj_iter_fn_t )(sos_part_t part, sos_obj_t obj, void *arg)
 The callback function called by the sos_part_obj_iter() function. More...
 
typedef struct
sos_part_obj_iter_pos_s
sos_part_obj_iter_pos_t
 

Functions

int sos_part_create (sos_t sos, const char *name, const char *path)
 Create a new partition. More...
 
int sos_part_delete (sos_part_t part)
 Delete a partition. More...
 
int sos_part_move (sos_part_t part, const char *part_path)
 Move a partition. More...
 
sos_part_t sos_part_find (sos_t sos, const char *name)
 Find a partition. More...
 
sos_part_iter_t sos_part_iter_new (sos_t sos)
 Create a partition iterator. More...
 
void sos_part_iter_free (sos_part_iter_t iter)
 Free the memory associated with the Iterator. More...
 
sos_part_t sos_part_first (sos_part_iter_t iter)
 Return the first partition in the container. More...
 
sos_part_t sos_part_next (sos_part_iter_t iter)
 Return the next partition in the container. More...
 
const char * sos_part_name (sos_part_t part)
 Return the partition's name. More...
 
const char * sos_part_path (sos_part_t part)
 Return the partition's path. More...
 
uint32_t sos_part_id (sos_part_t part)
 Return the partition's id. More...
 
sos_part_state_t sos_part_state (sos_part_t part)
 Return the partition's state. More...
 
int sos_part_state_set (sos_part_t part, sos_part_state_t state)
 Set the state of a partition. More...
 
uint32_t sos_part_refcount (sos_part_t part)
 Return the number of references on the partition. More...
 
void sos_part_put (sos_part_t part)
 Drop a reference on a partition. More...
 
int sos_part_stat (sos_part_t part, sos_part_stat_t stat)
 Return size and access data for the partition. More...
 
int64_t sos_part_export (sos_part_t src_part, sos_t dst_sos, int reindex)
 Export the objects in a partition to another container. More...
 
int64_t sos_part_index (sos_part_t src_part)
 
void sos_part_obj_iter_pos_init (sos_part_obj_iter_pos_t pos)
 
int sos_part_obj_iter (sos_part_t part, sos_part_obj_iter_pos_t pos, sos_part_obj_iter_fn_t fn, void *arg)
 Iterate over objects in the partition. More...
 

Detailed Description

Typedef Documentation

typedef int(* sos_part_obj_iter_fn_t)(sos_part_t part, sos_obj_t obj, void *arg)

The callback function called by the sos_part_obj_iter() function.

Called by the sos_part_obj_iter() function for each object in the partition. If the function wishes to cancel iteration, return !0, otherwise, return 0.

Parameters
sosThe container handle
objThe object handle
szThe size of the object
argThe 'arg' passed into sos_part_obj_iter()
Return values
0Continue iterating
!0Stop iterating

Function Documentation

int sos_part_create ( sos_t  sos,
const char *  part_name,
const char *  part_path 
)

Create a new partition.

Parameters
sosThe sos_t container handle
part_nameThe name of the new partition.
part_pathAn optional path to the partition. If null, the container path will be used.
Return values
0Success
EEXISTThe specified partition already exists
EBADFInvalid container handle or other storage error
ENOMEMInsufficient resources
int sos_part_delete ( sos_part_t  part)

Delete a partition.

Deletes the paritition specified by the handle. All object storage associated with the parition will be freed. The parition must be in the OFFLINE state to be deleted.

Parameters
partThe partition handle
Return values
0The parition was deleted
EBUSYThe partition is not offline
int64_t sos_part_export ( sos_part_t  src_part,
sos_t  dst_sos,
int  reindex 
)

Export the objects in a partition to another container.

Export all of the objects in the specified partition to another container. The destination partition in the destination container will be the primary partition in the destination container.

The source partition must not be the primary partition in order to ensure that every object will be exported.

The source container (the container in which src_part is located) cannot be the same as the destination container.

Parameters
src_partThe source partition handle
dst_contThe destination container
reindexSet to 1 to add exported objects to their schema indices
Return values
>=0 The number of objects exported to the destination container
<0An error occured, see errno for more information
sos_part_t sos_part_find ( sos_t  sos,
const char *  name 
)

Find a partition.

Returns the partition handle for the partition with the name specified by the name parameter.

The application should call sos_part_put() when finished with the partition object. Note that calling sos_part_put() too many times can result in destroying the partition.

Parameters
sosThe container handle
nameThe name of the partition
Return values
Partitionhandle
NULLif the partition was not found
sos_part_t sos_part_first ( sos_part_iter_t  iter)

Return the first partition in the container.

The application should call sos_part_put() when finished with the partition object. Note that calling sos_part_put() too many times can result in destroying the partition.

Parameters
iterThe partition iterator handle
Returns
The first partition object or NULL if there are no partitions in the container.
uint32_t sos_part_id ( sos_part_t  part)

Return the partition's id.

Returns the parititions unique 32b id. This id is part of an object's sos_obj_ref_t and identifies the partition in which the object is allocated.

Parameters
partThe partition handle
Returns
An integer representing the partition's id
void sos_part_iter_free ( sos_part_iter_t  iter)

Free the memory associated with the Iterator.

Parameters
iterThe iterator handle
sos_part_iter_t sos_part_iter_new ( sos_t  sos)

Create a partition iterator.

A partition iterator is used to iterate through all partitions in the container.

Parameters
sosThe container handle
Returns
A partition iterator handle
int sos_part_move ( sos_part_t  part,
const char *  new_part_path 
)

Move a partition.

Move a partition from it's current storage location to another. Any references to objects in the partition by indices or other objects are preserved by the move.

Parameters
partThe partition handle
pathThe new path for the partition.
Return values
0The parition was deleted
EBUSYThe partition is not offline
EINVALThe destination path is the same as the source path
EEXISTThe destination path already exists
EPERMThe user has insufficient privilege to write to the destination path
const char* sos_part_name ( sos_part_t  part)

Return the partition's name.

Parameters
partThe partition handle
Returns
Pointer to a string containing the name
sos_part_t sos_part_next ( sos_part_iter_t  iter)

Return the next partition in the container.

The application should call sos_part_put() when finished with the partition object. Note that calling sos_part_put() too many times can result in destroying the partition.

Parameters
iterThe partition iterator handle
Returns
The next partition object or NULL if there are no more partitions in the container.
int sos_part_obj_iter ( sos_part_t  part,
sos_part_obj_iter_pos_t  pos,
sos_part_obj_iter_fn_t  fn,
void *  arg 
)

Iterate over objects in the partition.

This function iterates over objects allocated in the partition and calls the specified 'iter_fn' for each object. See the sos_part_obj_iter_fn_t() for the function definition.

If the the pos argument is not NULL, it should be initialized with the sos_obj_iter_pos_init() funuction. The pos argument will updated with the location of the next object in the store when sos_part_obj_iter() returns. This facilitates walking through a portion of the objects at a time, continuing later where the function left off.

The sos_part_obj_iter_fn_t() function indicates that the iteration should stop by returning !0. Otherwise, the sos_part_obj_iter() function will continue until all objects in the ODS have been seen.

Parameters
odsThe ODS handle
posThe object iterator position
iter_fnPointer to the function to call
argA void* argument that the user wants passed to the callback function.
Return values
0All objects were iterated through
!0A callback returned !0
const char* sos_part_path ( sos_part_t  part)

Return the partition's path.

Parameters
partThe partition handle
Returns
Pointer to a string containing the path
void sos_part_put ( sos_part_t  part)

Drop a reference on a partition.

Partitions are reference counted. When the reference count goes to zero, it is destroyed and all of it's storage is released. The sos_part_first(), sos_part_next(), and sos_part_find() functions take a reference on behalf of the application. This reference should be dropped by the application when the application is finished with the partition.

Parameters
partThe partition handle.
uint32_t sos_part_refcount ( sos_part_t  part)

Return the number of references on the partition.

Parameters
partThe partition handle
Return values
An32b integer representing the partition's reference count
int sos_part_stat ( sos_part_t  part,
sos_part_stat_t  stat 
)

Return size and access data for the partition.

Parameters
partThe partition handle
statThe stat buffer
Return values
0Success
EINVALThe partition or stat buffer handles were NULL or the partition is not open, for example, OFFLINE.
sos_part_state_t sos_part_state ( sos_part_t  part)

Return the partition's state.

Parameters
partThe partition handle
Returns
An integer representing the partition's state
int sos_part_state_set ( sos_part_t  part,
sos_part_state_t  new_state 
)

Set the state of a partition.

Partition state transitions are limited by the current state. If the current state is PRIMARY, there are no state changes allowed. The only way to change the state of the PRIMARY partition is to make another partition PRIMARY. When this occurs, the partition is made ACTIVE.

Any partition in the ACTIVE state can be made PRIMARY. Any partition in the ACTIVE state can be made OFFLINE and an OFFLINE partition can be made ACTIVE. Note that when a parition is made OFFLINE, all Keys that refer to objects in that partition are removed from all indices in the container.

Parameters
partThe partition handle
new_stateThe desired state of the partition
Return values
0The state was successfully changed
EINVALThe specified state is invalid given the current state of the partition.