BlobStorage code review fixes.

This commit is contained in:
Yury Melnichek 2012-09-24 23:02:21 +03:00 committed by Alex Zolotarev
parent 5d851463c1
commit 122429fbf2
4 changed files with 12 additions and 7 deletions

View file

@ -13,7 +13,7 @@
BlobIndexer::BlobIndexer(Writer & writer,
size_t maxUncompressedChunkSize,
function<void (char const *, size_t, string &)> const & compressor) :
CompressorType const & compressor) :
m_writer(writer),
m_maxUncompressedChunkSize(min(int(maxUncompressedChunkSize), (1 << BITS_IN_CHUNK_SIZE) - 1)),
m_compressor(compressor),

View file

@ -9,9 +9,11 @@ class Writer;
class BlobIndexer
{
public:
typedef function<void (char const *, size_t, string &)> CompressorType;
BlobIndexer(Writer & writer,
size_t maxUncompressedChunkSize,
function<void (char const *, size_t, string &)> const & compressor);
CompressorType const & compressor);
~BlobIndexer();
// Add blob and return its id.
@ -24,7 +26,7 @@ private:
Writer & m_writer;
size_t const m_maxUncompressedChunkSize;
function<void (char const *, size_t, string &)> const m_compressor;
CompressorType m_compressor;
static uint32_t const BITS_IN_CHUNK_SIZE = 20;

View file

@ -6,7 +6,8 @@
// nb - number of blobs
// nc - number of chunks
//
// [4| Header = "Blb1"]
// [3| Header = "Blb"]
// [1| logMaxChunkSize]
// [*| Chunk 0 ] [*| Chunk 1 ] ... [*| Chunk nc-1]
// [4| Chunk 1 pos] [4| Chunk 2 pos] ... [4| Pos after the last chunk]
// [4| Blob info 0] [4| Blob info 1] ... [4| Blob info nb-1]
@ -23,7 +24,7 @@
BlobStorage::BlobStorage(Reader const * pReader,
function<void (char const *, size_t, char *, size_t)> decompressor) :
DecompressorType const & decompressor) :
m_pReader(pReader), m_decompressor(decompressor)
{
Init();

View file

@ -14,9 +14,11 @@ class BlobStorage
public:
DECLARE_EXCEPTION(OpenException, RootException);
typedef function<void (char const *, size_t, char *, size_t)> DecompressorType;
// Takes ownership of pReader and deletes it, even if exception is thrown.
BlobStorage(Reader const * pReader,
function<void (char const *, size_t, char *, size_t)> decompressor);
DecompressorType const & decompressor);
~BlobStorage();
// Get blob by its number, starting from 0.
@ -35,7 +37,7 @@ private:
static uint32_t const START_OFFSET = 4;
scoped_ptr<Reader const> m_pReader;
function<void (char const *, size_t, char *, size_t)> m_decompressor;
DecompressorType m_decompressor;
DDVector<uint32_t, PolymorphReader> m_blobInfo;
DDVector<uint32_t, PolymorphReader> m_chunkOffset;