30 using std::istringstream;
54 BESUncompressManager3::BESUncompressManager3()
72 BESUncompressManager3::UCIter i;
73 i = _uncompress_list.find(name);
74 if (i == _uncompress_list.end()) {
75 _uncompress_list[name] = method;
91 BESUncompressManager3::UCIter i;
92 i = _uncompress_list.find(name);
93 if (i != _uncompress_list.end()) {
133 BESDEBUG(
"uncompress2",
"uncompress - src: " << src << endl );
136 string::size_type dot = src.rfind(
".");
137 if (dot == string::npos) {
138 BESDEBUG(
"uncompress2",
"uncompress - no file extension" << endl );
142 string ext = src.substr(dot + 1, src.length() - dot);
148 BESDEBUG(
"uncompress2",
"uncompress - not compressed " << endl );
157 BESDEBUG(
"uncompress2",
"uncompress - is cached? " << src << endl );
161 BESDEBUG(
"uncompress",
"uncompress - cached hit: " << cfile << endl );
168 BESDEBUG(
"uncompress",
"uncompress - caching " << cfile << endl );
190 BESDEBUG(
"uncompress",
"uncompress - cached hit: " << cfile << endl );
198 BESDEBUG(
"uncompress",
"caught exception, unlocking cache and re-throw." << endl );
215 strm <<
BESIndent::LMarg <<
"BESUncompressManager3::dump - (" << (
void *)
this <<
")" << endl;
217 if (_uncompress_list.size()) {
220 BESUncompressManager3::UCIter i = _uncompress_list.begin();
221 BESUncompressManager3::UCIter ie = _uncompress_list.end();
222 for (; i != ie; i++) {
236 if (_instance == 0) {
virtual void exclusive_to_shared_lock(int fd)
Transfer from an exclusive lock to a shared lock.
static void uncompress(const string &src, int fd)
uncompress a file with the .gz file extension
virtual bool cache_too_big(unsigned long long current_size) const
look at the cache size; is it too large? Look at the cache size and see if it is too big...
static BESUncompressManager3 * TheManager()
void(* p_bes_uncompress)(const string &src, int fd)
Implementation of a caching mechanism for compressed data.
static ostream & LMarg(ostream &strm)
virtual unsigned long long update_cache_info(const string &target)
Update the cache info file to include 'target'.
virtual bool create_and_lock(const string &target, int &fd)
Create a file in the cache and lock it for write access.
List of all registered decompression methods.
virtual void dump(ostream &strm) const
dumps information about this object
virtual p_bes_uncompress find_method(const string &name)
returns the uncompression method specified
virtual bool get_read_lock(const string &target, int &fd)
Get a read-only lock on the file if it exists.
string get_cache_file_name(const string &src)
Build the name of file that will holds the uncompressed data from 'src' in the cache.
virtual void update_and_purge(const string &new_file)
Purge files from the cache.
static void uncompress(const string &src, int dest_fd)
uncompress a file with the .gz file extension
virtual bool add_method(const string &name, p_bes_uncompress method)
create_and_lock a uncompress method to the list
virtual bool uncompress(const string &src, string &target, BESCache3 *cache)
If the file 'src' should be uncompressed, do so and return a new file name on the value-result param ...
virtual void unlock_cache()
Unlock the cache info file.
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
static void uncompress(const string &src, int fd)
uncompress a file with the .bz2 file extension