daily pastebin goal
95%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. std::shared_ptr<Chunk> ChunkSequence::getChunkByPosition(uint32_t position) {
  2.     assert(position >= 1);
  3.     std::lock_guard<std::mutex> lk(m_read_write_mtx);
  4.     return _getChunk((position - 1) * m_format.getPayloadLength());
  5. }
  6.  
  7. uint32_t ChunkSequence::getChunkPositionByOffset(uint64_t offset) const {
  8.     return targetChunkIndex(offset, m_format.getPayloadLength());
  9. }
  10.  
  11. ChunkSequence::ChunkSequenceChunkRangeVector ChunkSequence::getChunkRangesVectorCopy() const {
  12.     return m_chunk_range_vec;
  13. }
  14.  
  15. void ChunkSequence::removeChunks() {
  16.     LOGD("ChunkSequence::removeChunks()");
  17.     auto chunk = getChunkByPosition(0);
  18.     if (chunk) {
  19.         auto storage = DataStorage::extension.getDataStorage().getChunkStorage(chunk->getChunkStorageId());
  20.         Resource link;
  21.         link.addRefResource(chunk.get());
  22.         bool is_next_chunk = true;
  23.         while(is_next_chunk) {
  24.             storage->deleteChunk(chunk);
  25.             is_next_chunk = chunk->isNextChunk();
  26.             if (is_next_chunk) {
  27.                 chunk = DataStorage::extension.getDataStorage().getChunk(chunk->getNextChunkPtr().first,
  28.                                                                          chunk->getNextChunkPtr().second);
  29.                 link.addRefResource(chunk.get());
  30.             }
  31.         }
  32.     }
  33.     _createDeletedRevision();
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top