Project

General

Profile

Actions

Feature #3100

closed

Add Block constructor to create sub-blocks reusing the underlying buffer

Added by Alex Afanasyev over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Category:
Base
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:

Description

To avoid multiple copy operations during processing of NDNLP packets, a Block should allow creation of sub-blocks reusing the underlying buffer.

/** @brief Create a Block from existing block (reusing the underlying buffer), directly
 *         specifying boundaries of the block within the buffer
 *
 *  This overload will automatically detect type and position of the value within the block
 */
Block(const Block& block,
      const Buffer::const_iterator& begin, const Buffer::const_iterator& end,
      bool verifyLength = true);
Actions #1

Updated by Junxiao Shi over 9 years ago

Does this in any way contradict with the copy-on-write semantics of Block?

For example:

  1. create block1 with a full Interest
  2. create block2 that shares the buffer of block1, covering the Name portion of that Interest
  3. modify either block1 or block2 using parse then insert|delete then encode
  4. call parse on the other block

Expected: the other block remain unchanged

Actions #2

Updated by Alex Afanasyev over 9 years ago

It does not conflict.

In fact, the same operation is used as part of internal "Block::parse()" method (not exactly the same way, but almost the same). This feature is merely allowing external usage of the function, with creation of blocks from arbitrary offsets inside the underlying wire buffer.

Actions #3

Updated by Junxiao Shi over 9 years ago

It does not conflict.

To prove this point, test case(s) similar to note-1 steps should be created as part of this issue, in the same commit.

Actions #4

Updated by Junxiao Shi over 9 years ago

  • Status changed from Code review to Closed
  • Start date deleted (08/12/2015)
Actions

Also available in: Atom PDF