30 using std::istringstream;
32 #include "BESUncompressManager3.h" 33 #include "BESUncompress3GZ.h" 34 #include "BESUncompress3BZ2.h" 35 #include "BESUncompress3Z.h" 37 #include "BESFileLockingCache.h" 39 #include "BESInternalError.h" 42 #include "TheBESKeys.h" 55 BESUncompressManager3::BESUncompressManager3()
73 BESUncompressManager3::UCIter i;
74 i = _uncompress_list.find(name);
75 if (i == _uncompress_list.end()) {
76 _uncompress_list[name] = method;
92 BESUncompressManager3::UCIter i;
93 i = _uncompress_list.find(name);
94 if (i != _uncompress_list.end()) {
134 BESDEBUG(
"uncompress2",
"BESUncompressManager3::uncompress() - src: " << src << endl );
147 std::ostringstream oss;
148 oss <<
"BESUncompressManager3::" << __func__ <<
"() - ";
149 oss <<
"The supplied Cache object is NULL. Decompression Requires An Operational Cache.";
154 string::size_type dot = src.rfind(
".");
155 if (dot == string::npos) {
156 BESDEBUG(
"uncompress2",
"BESUncompressManager3::uncompress() - no file extension" << endl );
160 string ext = src.substr(dot + 1, src.length() - dot);
166 BESDEBUG(
"uncompress2",
"BESUncompressManager3::uncompress() - not compressed " << endl );
175 BESDEBUG(
"uncompress2",
"BESUncompressManager3::uncompress() - is cached? " << src << endl );
179 BESDEBUG(
"uncompress",
"BESUncompressManager3::uncompress() - cached hit: " << cache_file << endl );
186 BESDEBUG(
"uncompress",
"BESUncompressManager3::uncompress() - caching " << cache_file << endl );
208 BESDEBUG(
"uncompress",
"BESUncompressManager3::uncompress() - cached hit: " << cache_file << endl );
216 BESDEBUG(
"uncompress",
"BESUncompressManager3::uncompress() - caught exception, unlocking cache and re-throw." << endl );
233 strm << BESIndent::LMarg <<
"BESUncompressManager3::dump - (" << (
void *)
this <<
")" << endl;
235 if (_uncompress_list.size()) {
236 strm << BESIndent::LMarg <<
"registered uncompression methods:" << endl;
238 BESUncompressManager3::UCIter i = _uncompress_list.begin();
239 BESUncompressManager3::UCIter ie = _uncompress_list.end();
240 for (; i != ie; i++) {
241 strm << BESIndent::LMarg << (*i).first << endl;
243 BESIndent::UnIndent();
246 strm << BESIndent::LMarg <<
"registered uncompress methods: none" << endl;
248 BESIndent::UnIndent();
252 BESUncompressManager3::TheManager()
254 if (_instance == 0) {
virtual void unlock_cache()
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...
virtual void dump(ostream &strm) const
dumps information about this object
exception thrown if inernal error encountered
virtual bool create_and_lock(const string &target, int &fd)
Create a file in the cache and lock it for write access.
static void uncompress(const string &src, int fd)
uncompress a file with the .gz file extension
virtual bool uncompress(const string &src, string &target, BESFileLockingCache *cache)
If the file 'src' should be uncompressed, do so and return a new file name on the value-result param ...
Implementation of a caching mechanism for compressed data.
List of all registered decompression methods.
virtual p_bes_uncompress find_method(const string &name)
returns the uncompression method specified
virtual string get_cache_file_name(const string &src, bool mangle=true)
virtual bool get_read_lock(const string &target, int &fd)
Get a read-only lock on the file if it exists.
virtual void update_and_purge(const string &new_file)
Purge files from the cache.
virtual unsigned long long update_cache_info(const string &target)
Update the cache info file to include 'target'.
virtual void exclusive_to_shared_lock(int fd)
Transfer from an exclusive lock to a shared lock.
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
static void uncompress(const string &src, int fd)
uncompress a file with the .bz2 file extension