From 722040937d7709a7b976bf57b045dac6d703c893 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Wed, 12 Dec 2007 10:34:46 -0800 Subject: [PATCH] Include sizes in references to blocks in each file's data list. This optimization is aimed at large files that are composed of many blocks--including the size of each block allows a restore program to determine the offset at which each block begins in the output file (by adding up the sizes of the previous block). This may allow for more efficient restores, in which file data is filled in as blocks are encountered, instead of having to find the blocks in the order they appear in the data list. A future change might be to only include the sizes when necessary--files which are composed of a single object do not need a size, nor does the last block of a large file. But for now, simply include the size on all objects. This is part of a recommended format change, but one that is both forward- and backward-compatible. --- localdb.cc | 1 + scandir.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/localdb.cc b/localdb.cc index 004391b..17337f0 100644 --- a/localdb.cc +++ b/localdb.cc @@ -258,6 +258,7 @@ ObjectReference LocalDb::FindObject(const string &checksum, int64_t size) } else if (rc == SQLITE_ROW) { ref = ObjectReference(IdToSegment(sqlite3_column_int64(stmt, 0)), (const char *)sqlite3_column_text(stmt, 1)); + ref.set_range(0, size); } else { fprintf(stderr, "Could not execute SELECT statement!\n"); ReportError(rc); diff --git a/scandir.cc b/scandir.cc index f653f43..9727133 100644 --- a/scandir.cc +++ b/scandir.cc @@ -228,6 +228,7 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path, o->write(tss); ref = o->get_ref(); db->StoreObject(ref, block_csum, bytes, block_age); + ref.set_range(0, bytes); delete o; } -- 2.20.1