From 08147fb0bc1d09610b05f3f7d54eda88ef5776ec Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Fri, 11 May 2007 10:37:29 -0700 Subject: [PATCH] Remove checksums and reference tracking; I think they are not needed. --- store.cc | 41 ++--------------------------------------- store.h | 14 +------------- 2 files changed, 3 insertions(+), 52 deletions(-) diff --git a/store.cc b/store.cc index 0533630..ce91e55 100644 --- a/store.cc +++ b/store.cc @@ -26,8 +26,6 @@ using std::list; using std::set; using std::string; -list TarSegmentStore::norefs; - Tarfile::Tarfile(const string &path, const string &segment) : size(0), segment_name(segment) @@ -39,9 +37,6 @@ Tarfile::Tarfile(const string &path, const string &segment) Tarfile::~Tarfile() { - string checksum_list = checksums.str(); - internal_write_object(segment_name + "/checksums", - checksum_list.data(), checksum_list.size()); tar_append_eof(t); if (tar_close(t) != 0) @@ -55,13 +50,6 @@ void Tarfile::write_object(int id, const char *data, size_t len) string path = segment_name + "/" + buf; internal_write_object(path, data, len); - - // Compute a checksum for the data block, which will be stored at the end - // of the TAR file. - SHA1Checksum hash; - hash.process(data, len); - sprintf(buf, "%08x", id); - checksums << buf << " " << hash.checksum_str() << "\n"; } void Tarfile::internal_write_object(const string &path, @@ -106,8 +94,7 @@ void Tarfile::internal_write_object(const string &path, static const size_t SEGMENT_SIZE = 4 * 1024 * 1024; string TarSegmentStore::write_object(const char *data, size_t len, const - std::string &group, - const std::list &refs) + std::string &group) { struct segment_info *segment; @@ -137,12 +124,6 @@ string TarSegmentStore::write_object(const char *data, size_t len, const string full_name = segment->name + "/" + id_buf; - // Store any dependencies this object has on other segments, so they can be - // written when the segment is closed. - for (list::const_iterator i = refs.begin(); i != refs.end(); ++i) { - segment->refs.insert(*i); - } - // If this segment meets or exceeds the size target, close it so that // future objects will go into a new segment. if (segment->file->size_estimate() >= SEGMENT_SIZE) @@ -163,14 +144,6 @@ void TarSegmentStore::close_segment(const string &group) fprintf(stderr, "Closing segment group %s (%s)\n", group.c_str(), segment->name.c_str()); - string reflist; - for (set::iterator i = segment->refs.begin(); - i != segment->refs.end(); ++i) { - reflist += *i + "\n"; - } - segment->file->internal_write_object(segment->name + "/references", - reflist.data(), reflist.size()); - delete segment->file; segments.erase(segments.find(group)); delete segment; @@ -190,22 +163,12 @@ LbsObject::~LbsObject() { } -void LbsObject::add_reference(const LbsObject *o) -{ - refs.insert(o->get_name()); -} - void LbsObject::write(TarSegmentStore *store) { assert(data != NULL); assert(!written); - list reflist; - for (set::iterator i = refs.begin(); i != refs.end(); ++i) { - reflist.push_back(*i); - } - - name = store->write_object(data, data_len, group, reflist); + name = store->write_object(data, data_len, group); written = true; data = NULL; diff --git a/store.h b/store.h index 6fec763..a9d6365 100644 --- a/store.h +++ b/store.h @@ -59,7 +59,6 @@ public: private: size_t size; std::string segment_name; - std::ostringstream checksums; TAR *t; }; @@ -74,8 +73,7 @@ public: // used to control object placement; objects with different group // parameters are kept in separate segments. std::string write_object(const char *data, size_t len, - const std::string &group = "", - const std::list &refs = norefs); + const std::string &group = ""); // Ensure all segments have been fully written. void sync(); @@ -91,10 +89,6 @@ private: std::string path; std::map segments; - // An empty list which can be used as an argument to write_object to - // indicate that this object depends on no others. - static std::list norefs; - // Ensure that all segments in the given group have been fully written. void close_segment(const std::string &group); @@ -132,12 +126,6 @@ public: // segment. Until that time, its name cannot be determined. std::string get_name() const { return name; } - // Logically, one object may reference other objects (such as a metadata - // listing referncing actual file data blocks). Such references should be - // noted explicitly. It may eventually be used to build up a tree of - // checksums for later verifying integrity. - void add_reference(const LbsObject *o); - private: std::string group; const char *data; -- 2.20.1