-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
map: Introduce BatchCursor abstraction
The batch API in the kernel is quite tricky to get right. In order to pass the arguments in correctly, especially regarding the "in_batch" and "out_batch" arguments, it requires knowledge of how the batch map iteration is implemented in the kernel. In order to avoid pushing the cognitive overhead onto users of the library, abstract away the details of batch map iteration into an opaque type, BatchCursor. Users are expected to pass in a reference to a BatchCursor and the library will handle allocating the underlying buffer when needed. Specifically, the first time that a batch API is called using the cursor, the underlying buffer will be nil, which signfifies that the "in_batch" (aka "prevKey") should be nil to indicate the starting of a batching operation, and "out_batch" (aka "nextKey") is set to an newly-allocated buffer. Previously, users were expected to carry the "out_batch" reference in order to pass it in as "in_batch" upon the next call to the batching operation. Instead, with this abstraction, the cursor handles it for the user, by using the underlying buffer for both "in_batch" and "out_batch" in subsequent calls. Signed-off-by: Chris Tarazi <chris@isovalent.com> Suggested-by: Lorenz Bauer <lmb@isovalent.com>
- Loading branch information
1 parent
f0d238d
commit d9f8904
Showing
2 changed files
with
48 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters