NAME
Genezzo::SpaceMan::SMFile.pm - File Space Management
SYNOPSIS
DESCRIPTION
Maintain a block header for each file with information on space usage. Each file is composed of *extents*, groups of contiguous blocks. The free extent list is composed of a number of blocknumber/extent length pairs, e.g. the row:
FreeExtents 39:12 19:2
indicates that the current file has free space starting at block 39 of 12 contiguous blocks, plus space of 2 contiguous block starting at block 19.
When an object requests space, SMFile tries to find an exact match in the free list. If it cannot, it carves the requested size from a larger free extent.
FUNCTIONS
- currblock
-
return the current active block (insert high water mark) for an object
- firstblock, nextblock
-
iterate over the set of *used* blocks for an object. Ignores unused blocks in last extent
- countblock
-
count of all blocks associated with the object. Includes allocated, *unused* blocks, plus empty blocks (i.e. blocks with no rows).
- hasblock
-
check if block is associated with an object
- freetable
-
return all of an object's blocks to the freelist
- flush
-
write the contents of block zero to disk. Need to handle case of extent lists spread over multiple blocks.
EXPORT
TODO
- support for non-table objects like indexes - done?
- freetable: when last object is freed, need to update _tsfiles as UNUSED
- need to coalesce adjacent free extents
- maintain multiple free lists for performance
- better indexing scheme - maybe a btree
- chain the block header if necessary -- allocate a new block to hold additional free list information, append extent allocation to HEADER row (after 0:1)
- check status everywhere where update rows
- maintain free extents list for each object, so can re-use extents (especially important for updates of large multi-block rows)
AUTHOR
Jeffrey I. Cohen, jcohen@genezzo.com
SEE ALSO
perl(1).
Copyright (c) 2003, 2004 Jeffrey I Cohen. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Address bug reports and comments to: jcohen@genezzo.com