susumu.yata
null+****@clear*****
Mon Dec 17 15:10:31 JST 2012
susumu.yata 2012-12-17 15:10:31 +0900 (Mon, 17 Dec 2012) New Revision: c354e6561748d73068f4ef8a54ce91572b18d976 https://github.com/groonga/grnxx/commit/c354e6561748d73068f4ef8a54ce91572b18d976 Log: Implement grnxx::db::BlobVector::defrag(). Modified files: lib/db/blob_vector.cpp lib/db/blob_vector.hpp Modified: lib/db/blob_vector.cpp (+11 -0) =================================================================== --- lib/db/blob_vector.cpp 2012-12-17 13:41:26 +0900 (a0564f8) +++ lib/db/blob_vector.cpp 2012-12-17 15:10:31 +0900 (2287d1e) @@ -129,6 +129,17 @@ void BlobVectorImpl::prepend(uint64_t id, const Blob &value) { } } +void BlobVectorImpl::defrag() { + // TODO: To be more efficient. + table_.scan([this](uint64_t id, BlobVectorCell *cell) -> bool { + if (cell->type() != BLOB_VECTOR_MEDIUM) { + return true; + } + set_value(id, get_value(*cell)); + return true; + }); +} + StringBuilder &BlobVectorImpl::write_to(StringBuilder &builder) const { if (!builder) { return builder; Modified: lib/db/blob_vector.hpp (+6 -0) =================================================================== --- lib/db/blob_vector.hpp 2012-12-17 13:41:26 +0900 (6026f09) +++ lib/db/blob_vector.hpp 2012-12-17 15:10:31 +0900 (e60ee6f) @@ -399,6 +399,8 @@ class BlobVectorImpl { void append(uint64_t id, const Blob &value); void prepend(uint64_t id, const Blob &value); + void defrag(); + uint32_t block_id() const { return block_info_->id(); } @@ -494,6 +496,10 @@ class BlobVector { impl_->prepend(id, value); } + void defrag() { + impl_->defrag(); + } + uint32_t block_id() const { return impl_->block_id(); } -------------- next part -------------- HTML����������������������������... Télécharger