-
Type:
Task
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Query Integration
-
Fully Compatible
-
None
-
None
-
None
-
None
-
None
-
None
-
None
We introduce MongoExtensionDPLArrayContainer in order to provide an abstraction for wrapping an extension implemented array that must be transferred into a Host pre-allocated array.
struct MongoExtensionDPLArrayContainer {
MongoExtensionDPLArrayContainerVTable* const vtable;
};
struct MongoExtensionDPLArrayContainerVTable {
void (*destroy)();
size_t (*size)();
/**
* transfer: On success, transfers ownership of the underlying array's elements into
* the target array.
* Callers must first obtain the size of the array in order to pre-allocate the
* target output array.
* Ownership of the pointers within the array elements is transferred to the caller.
* It is an error to provide an incorrectly sized output array.
**/
MongoExtensionStatus* transfer(MongoExtensionDPLArray* array);
};
As an example, let’s consider the case where the Host asks an extension stage’s DPL for its merge pipeline.
First, the Host obtains a MongoExtensionDPLArrayContainer by calling MongoExtensionDistributedPlanLogic::get_merge_pipeline() on the stage’s DPL. The Host is then responsible for pre-allocating the elements (MongoExtensionDistributedPlanLogicArrayElement) buffer in a local instance of a MongoExtensionDPLArray. The Host can then pass a pointer to the MongoExtensionDPLArray over to the extension in a call to MongoExtensionDPLArrayContainer::transfer(), where the extension is responsible for populating the individual array elements with the correct type and value of each array element.
Ownership of the pointers within each array element is transferred to the Host from the extension. This design was chosen to allow us to keep a simple API with a contiguous block of memory to hold the expansion elements, which the Host is fully responsible for allocating and deallocating.
As part of this ticket, add MongoExtensionDPLArrayContainer to the public API, add a host adapter and a sdk adapter with unit tests.
- depends on
-
SERVER-113655 Implement MongoExtensionDPLArray (variant array <LogicalStage,ParseNode>)
-
- Closed
-