Segment Collection

A Segment Collection manages a collection of segments virtually arranged in a continuous linear space. More...

Data Structures

struct  segcol_funcs
 Struct that holds the function pointers for an implementation of segcol_t. More...

Typedefs

typedef struct segcol segcol_t
 Opaque type for segment collection ADT.
typedef struct segcol_iter segcol_iter_t
 Opaque type for segment collection iterator.

Functions

int segcol_free (segcol_t *segcol)
 Frees the resources of a segcol_t.
int segcol_append (segcol_t *segcol, segment_t *seg)
 Appends a segment to the segcol_t.
int segcol_insert (segcol_t *segcol, off_t offset, segment_t *seg)
 Inserts a segment into the segcol_t.
int segcol_delete (segcol_t *segcol, segcol_t **deleted, off_t offset, off_t length)
 Deletes a logical range from the segcol_t.
int segcol_find (segcol_t *segcol, segcol_iter_t **iter, off_t offset)
 Finds the segment that contains a given logical offset.
int segcol_get_size (segcol_t *segcol, off_t *size)
 Gets the size of the data contained in a segcol_t.

Iterator functions



int segcol_iter_new (segcol_t *segcol, segcol_iter_t **iter)
 Gets a new (forward) iterator for a segcol_t.
int segcol_iter_next (segcol_iter_t *iter)
 Moves the segcol_iter_t to the next element.
int segcol_iter_is_valid (segcol_iter_t *iter, int *valid)
 Whether the iter points to a valid element.
int segcol_iter_get_segment (segcol_iter_t *iter, segment_t **seg)
 Gets the segment pointed to by a segcol_iter_t.
int segcol_iter_get_mapping (segcol_iter_t *iter, off_t *mapping)
 Gets the mapping (logical offset) of the segment pointed to by a segcol_iter_t.
int segcol_iter_free (segcol_iter_t *iter)
 Frees a segcol_iter_t.

Internal functions



int segcol_create_impl (segcol_t **segcol, void *impl, struct segcol_funcs *funcs)
 Creates a segcol_t using a specific implementation.
void * segcol_get_impl (segcol_t *segcol)
 Gets the implementation of a segcol_t.
void * segcol_iter_get_impl (segcol_iter_t *iter)
 Gets the implementation of a segcol_t.

Constructors



int segcol_list_new (segcol_t **segcol)
 Creates a new segcol_t using a linked list implementation.

Detailed Description

A Segment Collection manages a collection of segments virtually arranged in a continuous linear space.

There may be many implementations of the Segment Collection ADT, each with its own performance characteristics. To create a Segment Collection one must use the constructor functions defined in each implementation (eg segcol_list_new()).

A note on error codes: all functions return EINVAL when an invalid range is specified (eg an offset is outside the limits of the virtual space of a Segment Collection).


Function Documentation

int segcol_append ( segcol_t segcol,
segment_t seg 
)

Appends a segment to the segcol_t.

After the invocation of this function the segcol_t is responsible for the memory handling of the specified segment. The segment should not be further manipulated by the user.

Parameters:
segcol the segcol_t to append to
seg the segment to append
Returns:
the operation error code

Definition at line 127 of file segcol.c.

References segment_get_size().

Referenced by bless_buffer_save(), segcol_add_copy(), segcol_store_in_file(), and segcol_store_in_memory().

Here is the call graph for this function:

Here is the caller graph for this function:

int segcol_create_impl ( segcol_t **  segcol,
void *  impl,
struct segcol_funcs funcs 
)

Creates a segcol_t using a specific implementation.

Parameters:
[out] segcol the created segcol_t
impl the implementation private data
funcs function pointers to the implementations' functions
Returns:
the operation status code

Definition at line 60 of file segcol.c.

Referenced by segcol_list_new().

Here is the caller graph for this function:

int segcol_delete ( segcol_t segcol,
segcol_t **  deleted,
off_t  offset,
off_t  length 
)

Deletes a logical range from the segcol_t.

Parameters:
segcol the segcol_t to delete from
[out] deleted if it is not NULL, on return it will point to a new segcol_t containing the deleted segments
offset the logical offset to start deleting at
length the length of the range to delete
Returns:
the operation error code

Definition at line 189 of file segcol.c.

Referenced by segcol_add_copy(), segcol_store_in_file(), and segcol_store_in_memory().

Here is the caller graph for this function:

int segcol_find ( segcol_t segcol,
segcol_iter_t **  iter,
off_t  offset 
)

Finds the segment that contains a given logical offset.

Parameters:
segcol the segcol_t to search in
[out] iter a segcol_iter_t pointing to the found segment
offset the offset to search for
Returns:
the operation error code

Definition at line 210 of file segcol.c.

Referenced by find_seg_entry(), and segcol_foreach().

Here is the caller graph for this function:

int segcol_free ( segcol_t segcol  ) 

Frees the resources of a segcol_t.

After the invocation of this function it is an error to use the freed segcol_t.

Parameters:
segcol the segcol_t to free
Returns:
the operation error code

Definition at line 108 of file segcol.c.

Referenced by bless_buffer_free(), bless_buffer_new(), and bless_buffer_save().

Here is the caller graph for this function:

int segcol_get_size ( segcol_t segcol,
off_t *  size 
)

Gets the size of the data contained in a segcol_t.

Parameters:
segcol the segcol to get the size of
[out] size the size of the segcol in bytes
Returns:
the operation error code

Definition at line 311 of file segcol.c.

Referenced by bless_buffer_get_size(), bless_buffer_save(), segcol_add_copy(), segcol_foreach(), segcol_store_in_file(), and segcol_store_in_memory().

Here is the caller graph for this function:

int segcol_insert ( segcol_t segcol,
off_t  offset,
segment_t seg 
)

Inserts a segment into the segcol_t.

After the invocation of this function the segcol_t is responsible for the memory handling of the specified segment. The segment should not be further manipulated by the caller.

Parameters:
segcol the segcol_t to insert into
offset the logical offset at which to insert
seg the segment to insert
Returns:
the operation error code

Definition at line 159 of file segcol.c.

References segment_get_size().

Referenced by segcol_add_copy(), segcol_store_in_file(), and segcol_store_in_memory().

Here is the call graph for this function:

Here is the caller graph for this function:

int segcol_iter_free ( segcol_iter_t iter  ) 

Frees a segcol_iter_t.

It is an error to use a segcol_iter_t after freeing it.

Parameters:
iter the segcol_iter_t to free
Returns:
the operation error code

Definition at line 295 of file segcol.c.

Referenced by create_overlap_graph(), find_seg_entry(), segcol_add_copy(), segcol_foreach(), and write_segcol_rest().

Here is the caller graph for this function:

int segcol_iter_get_mapping ( segcol_iter_t iter,
off_t *  mapping 
)

Gets the mapping (logical offset) of the segment pointed to by a segcol_iter_t.

Parameters:
iter the iter to use
[out] mapping the mapping of the pointed segment or -1 if the iterator is invalid
Returns:
the operation error code

Definition at line 281 of file segcol.c.

Referenced by create_overlap_graph(), get_data_from_iter(), segcol_add_copy(), and write_segcol_rest().

Here is the caller graph for this function:

int segcol_iter_get_segment ( segcol_iter_t iter,
segment_t **  seg 
)

Gets the segment pointed to by a segcol_iter_t.

Parameters:
iter the iter to use
[out] seg the pointed segment or NULL if the iterator is invalid
Returns:
the operation error code

Definition at line 266 of file segcol.c.

Referenced by create_overlap_graph(), get_data_from_iter(), segcol_add_copy(), and write_segcol_rest().

Here is the caller graph for this function:

int segcol_iter_is_valid ( segcol_iter_t iter,
int *  valid 
)

Whether the iter points to a valid element.

Parameters:
iter the segcol_iter_t to check
[out] valid 1 if the segcol_iter_t is valid, 0 otherwise
Returns:
the operation error code

Definition at line 253 of file segcol.c.

Referenced by create_overlap_graph(), find_seg_entry(), segcol_add_copy(), segcol_foreach(), and write_segcol_rest().

Here is the caller graph for this function:

int segcol_iter_new ( segcol_t segcol,
segcol_iter_t **  iter 
)

Gets a new (forward) iterator for a segcol_t.

Parameters:
segcol the segcol_t
[out] iter a forward segcol_iter_t
Returns:
the operation error code

Definition at line 223 of file segcol.c.

Referenced by create_overlap_graph(), segcol_add_copy(), and write_segcol_rest().

Here is the caller graph for this function:

int segcol_iter_next ( segcol_iter_t iter  ) 

Moves the segcol_iter_t to the next element.

Parameters:
iter the segcol_iter_t to move
Returns:
the operation error code

Definition at line 240 of file segcol.c.

Referenced by create_overlap_graph(), segcol_add_copy(), segcol_foreach(), and write_segcol_rest().

Here is the caller graph for this function:

int segcol_list_new ( segcol_t **  segcol  ) 

Creates a new segcol_t using a linked list implementation.

Parameters:
[out] segcol the created segcol_t
Returns:
the operation error code

Definition at line 241 of file segcol_list.c.

References list_free(), list_new, segcol_create_impl(), and segcol_list_clear_cache().

Referenced by bless_buffer_new(), and bless_buffer_save().

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Sun Nov 15 15:28:00 2009 for libbls by  doxygen 1.6.1