Public Member Functions | Protected Member Functions | Friends | List of all members
ibis::fileManager::roFile Class Reference

This class manages content of a whole (read-only) file. More...

#include <fileManager.h>

Inheritance diagram for ibis::fileManager::roFile:
ibis::fileManager::storage

Public Member Functions

virtual void beginUse ()
 Start using a file. Increments the active reference.
 
int disconnectFile ()
 Disconnect the storage object from the file. More...
 
virtual void endUse ()
 Stop using a file. Decrement the active reference count.
 
virtual bool isFileMap () const
 Is the storage a file map ?
 
virtual void printStatus (std::ostream &out) const
 Print information about the storage object to the specified output stream. More...
 
void read (const char *file)
 
- Public Member Functions inherited from ibis::fileManager::storage
char * begin ()
 Starting address of the storage object.
 
const char * begin () const
 Starting address of the storage object.
 
size_t bytes () const
 Return the number of bytes contained in the object.
 
void copy (const storage &rhs)
 Copy function. Make an in-meory copy following the copy-and-swap idiom.
 
bool empty () const
 Is the storage object empty?
 
const char * end () const
 Ending address of the storage object.
 
void enlarge (size_t nelm=0)
 Enlarge the current storage object. More...
 
const char * filename () const
 Pointer to the file name supporting this storage object. More...
 
unsigned inUse () const
 Number of current accesses to this object.
 
storageoperator= (const storage &rhs)
 Assignment operator. More...
 
char operator[] (size_t i) const
 Unchecked index operator. Returns the character at position i.
 
unsigned pastUse () const
 Number of past accesses to this object.
 
off_t read (const char *fname, const off_t begin, const off_t end)
 Read a part of a file. More...
 
off_t read (const int fdes, const off_t begin, const off_t end)
 Read part of a open file [begin, end). Return the number of bytes read.
 
size_t size () const
 Return the size (bytes) of the object.
 
 storage ()
 Constructor. Allocate no real storage.
 
 storage (size_t n)
 Constructor. More...
 
 storage (const char *fname, const off_t begin, const off_t end)
 Constructor. Read part of a file from [begin, end).
 
 storage (const int fdes, const off_t begin, const off_t end)
 Constructor. Read part of a open file, from [begin, end). The file.
 
 storage (const char *begin, const char *end)
 Copy constructor. Copy the values between begin and end [begin, end).
 
 storage (char *addr, size_t num)
 Wrap user provided memory into a storage object. More...
 
 storage (const storage &rhs)
 Copy constructor. Make an in-memory copy.
 
void swap (storage &rhs) throw ()
 Swap the content of the storage objects. More...
 
void write (const char *file) const
 

Protected Member Functions

virtual void clear ()
 Freeing the storage allocated. More...
 
void doRead (const char *file)
 Read the content of a file into memory.
 
void doRead (const char *file, off_t b, off_t e)
 Read a portion of a file into memory. More...
 
void printBody (std::ostream &out) const
 
virtual void * release ()
 Release the control of the memory to the caller as a raw pointer. More...
 
 roFile ()
 Constructor.
 
float score () const
 The function assigns a score to a file. More...
 

Friends

class ibis::fileManager
 

Additional Inherited Members

- Protected Attributes inherited from ibis::fileManager::storage
char * m_begin
 Beginning of the storage.
 
char * m_end
 End of the storage.
 
unsigned nacc
 Number of accesses in the past.
 
char * name
 Name of the file. NULL (0) if no file is involved.
 
ibis::util::sharedInt32 nref
 Number of (active) references to this storage.
 

Detailed Description

This class manages content of a whole (read-only) file.

It inherits the basic information stored in fileManager::storage and is intended to process read-only files.

Note
This class intends to hold a piece of memory managed by ibis::fileManager. If an object of this type is acquired through ibis::fileManager::getFile, the ownership of the object belongs to the file manager, therefore the caller should not delete the object.

Member Function Documentation

void ibis::fileManager::roFile::clear ( )
protectedvirtual

Freeing the storage allocated.

It will only proceed if there is no active reference to it.

Reimplemented from ibis::fileManager::storage.

int ibis::fileManager::roFile::disconnectFile ( )

Disconnect the storage object from the file.

This can only be done for a file whose content has been read into memory, not for a mapped file.

It returns 0 or a positive value to indicate success, otherwise it returns a negative number to indicate error.

References ibis::fileManager::instance(), and ibis::fileManager::unrecordFile().

void ibis::fileManager::roFile::doRead ( const char *  file,
off_t  b,
off_t  e 
)
protected

Read a portion of a file into memory.

Do NOT record the name of the file. This is different from the one that read the whole file which automatically records the name of the file.

References ibis::fileManager::instance(), ibis::util::read(), ibis::fileManager::recordPages(), and UnixOpen.

void ibis::fileManager::roFile::printStatus ( std::ostream &  out) const
virtual

Print information about the storage object to the specified output stream.

Reimplemented from ibis::fileManager::storage.

Referenced by ibis::fileManager::getFile(), and ibis::fileManager::tryGetFile().

virtual void* ibis::fileManager::roFile::release ( )
inlineprotectedvirtual

Release the control of the memory to the caller as a raw pointer.

The caller is to take control of memory and responsible for freeing it after use.

It can only proceed if there is no other accesses to this object.

Reimplemented from ibis::fileManager::storage.

float ibis::fileManager::roFile::score ( ) const
inlineprotected

The function assigns a score to a file.

It is used by ibis::fileManager::unload to determine what files to remove. Files with the smallest scores are the target for removal.

References ibis::fileManager::storage::nacc, and ibis::fileManager::storage::size().


The documentation for this class was generated from the following files:

Make It A Bit Faster
Contact us
Disclaimers
FastBit source code
FastBit mailing list archive