The local database can store an integer with each expired object that can
be used to group objects together based on age or other factors. Update
the lbs snapshot utility to place objects into segments based on this
value.
-bool LocalDb::IsOldObject(const string &checksum, int64_t size, double *age)
+bool LocalDb::IsOldObject(const string &checksum, int64_t size, double *age,
+ int *group)
{
int rc;
sqlite3_stmt *stmt;
bool found = false;
{
int rc;
sqlite3_stmt *stmt;
bool found = false;
- stmt = Prepare("select segmentid, object, timestamp from block_index "
- "where checksum = ? and size = ?");
+ stmt = Prepare("select segmentid, object, timestamp, expired "
+ "from block_index where checksum = ? and size = ?");
sqlite3_bind_text(stmt, 1, checksum.c_str(), checksum.size(),
SQLITE_TRANSIENT);
sqlite3_bind_int64(stmt, 2, size);
sqlite3_bind_text(stmt, 1, checksum.c_str(), checksum.size(),
SQLITE_TRANSIENT);
sqlite3_bind_int64(stmt, 2, size);
} else if (rc == SQLITE_ROW) {
found = true;
*age = sqlite3_column_double(stmt, 2);
} else if (rc == SQLITE_ROW) {
found = true;
*age = sqlite3_column_double(stmt, 2);
+ *group = sqlite3_column_int(stmt, 3);
} else {
fprintf(stderr, "Could not execute SELECT statement!\n");
ReportError(rc);
} else {
fprintf(stderr, "Could not execute SELECT statement!\n");
ReportError(rc);
void StoreObject(const ObjectReference& ref,
const std::string &checksum, int64_t size, double age);
ObjectReference FindObject(const std::string &checksum, int64_t size);
void StoreObject(const ObjectReference& ref,
const std::string &checksum, int64_t size, double age);
ObjectReference FindObject(const std::string &checksum, int64_t size);
- bool IsOldObject(const std::string &checksum, int64_t size, double *age);
+ bool IsOldObject(const std::string &checksum, int64_t size, double *age,
+ int *group);
bool IsAvailable(const ObjectReference &ref);
void UseObject(const ObjectReference& ref);
bool IsAvailable(const ObjectReference &ref);
void UseObject(const ObjectReference& ref);
// Store a copy of the object if one does not yet exist
if (ref.get_segment().size() == 0) {
LbsObject *o = new LbsObject;
// Store a copy of the object if one does not yet exist
if (ref.get_segment().size() == 0) {
LbsObject *o = new LbsObject;
/* We might still have seen this checksum before, if the object
* was stored at some time in the past, but we have decided to
/* We might still have seen this checksum before, if the object
* was stored at some time in the past, but we have decided to
* Additionally, keep track of the age of the data by looking
* up the age of the block which was expired and using that
* instead of the current time. */
* Additionally, keep track of the age of the data by looking
* up the age of the block which was expired and using that
* instead of the current time. */
- if (db->IsOldObject(block_csum, bytes, &block_age)) {
- o->set_group("compacted");
+ if (db->IsOldObject(block_csum, bytes,
+ &block_age, &object_group)) {
+ if (object_group == 0) {
+ o->set_group("data");
+ } else {
+ char group[32];
+ sprintf(group, "compacted-%d", object_group);
+ o->set_group(group);
+ }
if (status == NULL)
status = "partial";
} else {
if (status == NULL)
status = "partial";
} else {