The reason why nullptr is used is that this is how BplusTreeScanner::open is set (right boundary is unbounded).
The problem is that the source code does not allow nullptr to be passed down but instead defaults to passing its internal rightvalue.data() (in the aforementioned example), which causes BplusTreeScanner::open to fail.
Proposed Modification:
Add flags for left_null_ and right_null_, and modify the parameter logic in index_->create_scanner accordingly. This should not affect the original logic.
I'm currently looking to perform an equality search on a multi-column index.
For an equality search using the IndexScanPhysicalOperator, a Value object corresponding to the required value must be provided.
Before initializing the Value object, I need to concatenate the data from multiple columns. However, this concatenated data will not be in a typical format that the Value object can handle and thus needs to be stored in the form of a character array.
The problem is that the inherent presence of null bytes (0s) in the concatenated character array is almost inevitable, and since the Value implementation decides whether to truncate copying the array based on the presence of null bytes, it’s impossible to concatenate the data in the same format as when it was inserted into the index.
In addition, find_index_by_field needs to be modified to support multi-field index search.
Proposed Modification
Add a new initialization function that will first replace null bytes (0s) with a non-null value (perhaps 1 or another non-zero number) to address the truncation issue. After the copy is completed, it will then revert the null bytes to their original state (thus maintaining consistency with the data format used when inserted into the index).
It is important to note that the safety of this initialization function depends on the users, as it relies on the length parameter (len) provided to determine how much of the character array to read. If you have other solutions, you might consider submitting a PR to fix this workaround.
find_index_by_field is modified to find index.multi_fields(), which is consistent with the case of single-column index.
问题背景:
select * from index_lab where id > 99997;
问题在于源码中没有能够将nullptr传递下去而是默认传递其内部的rightvalue.data()(在上述例子的情况下),导致BplusTreeScanner::open失败
修改思路:
添加
left_null_
和right_null_
的标识量,修改index_->create_scanner的传参逻辑即可,不影响原来的逻辑。Background:
select * from index_lab where id > 99997;
The problem is that the source code does not allow nullptr to be passed down but instead defaults to passing its internal rightvalue.data() (in the aforementioned example), which causes BplusTreeScanner::open to fail.
Proposed Modification:
Add flags for
left_null_
andright_null_
, and modify the parameter logic in index_->create_scanner accordingly. This should not affect the original logic.