#include <time.h>
#include <uuid/uuid.h>
+#include <list>
+#include <set>
#include <string>
#include <iostream>
#include "tarstore.h"
+using std::list;
+using std::set;
using std::string;
+list<string> TarSegmentStore::norefs;
+
Tarfile::Tarfile(const string &path, const string &segment)
: size(0),
segment_name(segment)
static const size_t SEGMENT_SIZE = 4 * 1024 * 1024;
string TarSegmentStore::write_object(const char *data, size_t len, const
- std::string &group)
+ std::string &group,
+ const std::list<std::string> &refs)
{
struct segment_info *segment;
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<string>::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)
fprintf(stderr, "Closing segment group %s (%s)\n",
group.c_str(), segment->name.c_str());
+ string reflist;
+ for (set<string>::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;
}
+
+string TarSegmentStore::object_reference_to_segment(const string &object)
+{
+ return object;
+}