[placeholder] serialization placeholder for domain index scan and text retrieval
This commit is contained in:
		| @ -621,7 +621,8 @@ ObTableParam::ObTableParam(ObIAllocator &allocator) | |||||||
|     rowid_version_(ObURowIDData::INVALID_ROWID_VERSION), |     rowid_version_(ObURowIDData::INVALID_ROWID_VERSION), | ||||||
|     rowid_projector_(allocator), |     rowid_projector_(allocator), | ||||||
|     enable_lob_locator_v2_(false), |     enable_lob_locator_v2_(false), | ||||||
|     is_spatial_index_(false) |     is_spatial_index_(false), | ||||||
|  |     is_fts_index_(false) | ||||||
| { | { | ||||||
|   reset(); |   reset(); | ||||||
| } | } | ||||||
| @ -645,6 +646,7 @@ void ObTableParam::reset() | |||||||
|   main_read_info_.reset(); |   main_read_info_.reset(); | ||||||
|   enable_lob_locator_v2_ = false; |   enable_lob_locator_v2_ = false; | ||||||
|   is_spatial_index_ = false; |   is_spatial_index_ = false; | ||||||
|  |   is_fts_index_ = false; | ||||||
| } | } | ||||||
|  |  | ||||||
| OB_DEF_SERIALIZE(ObTableParam) | OB_DEF_SERIALIZE(ObTableParam) | ||||||
| @ -664,7 +666,8 @@ OB_DEF_SERIALIZE(ObTableParam) | |||||||
|               main_read_info_, |               main_read_info_, | ||||||
|               enable_lob_locator_v2_, |               enable_lob_locator_v2_, | ||||||
|               is_spatial_index_, |               is_spatial_index_, | ||||||
|               group_by_projector_); |               group_by_projector_, | ||||||
|  |               is_fts_index_); | ||||||
|   return ret; |   return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -697,6 +700,9 @@ OB_DEF_DESERIALIZE(ObTableParam) | |||||||
|       LOG_WARN("Fail to deserialize group by projector", K(ret)); |       LOG_WARN("Fail to deserialize group by projector", K(ret)); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |   if (OB_SUCC(ret)) { | ||||||
|  |     LST_DO_CODE(OB_UNIS_DECODE, is_fts_index_); | ||||||
|  |   } | ||||||
|   return ret; |   return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -718,7 +724,8 @@ OB_DEF_SERIALIZE_SIZE(ObTableParam) | |||||||
|               main_read_info_, |               main_read_info_, | ||||||
|               enable_lob_locator_v2_, |               enable_lob_locator_v2_, | ||||||
|               is_spatial_index_, |               is_spatial_index_, | ||||||
|               group_by_projector_); |               group_by_projector_, | ||||||
|  |               is_fts_index_); | ||||||
|   return len; |   return len; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -390,6 +390,7 @@ private: | |||||||
|   // use enable_lob_locator_v2_ to avoid locator type sudden change while table scan is running |   // use enable_lob_locator_v2_ to avoid locator type sudden change while table scan is running | ||||||
|   bool enable_lob_locator_v2_; |   bool enable_lob_locator_v2_; | ||||||
|   bool is_spatial_index_; |   bool is_spatial_index_; | ||||||
|  |   bool is_fts_index_; | ||||||
| }; | }; | ||||||
| } //namespace schema | } //namespace schema | ||||||
| } //namespace share | } //namespace share | ||||||
|  | |||||||
| @ -68,6 +68,7 @@ ob_set_subtarget(ob_sql das | |||||||
|   das/ob_das_spatial_index_lookup_op.cpp |   das/ob_das_spatial_index_lookup_op.cpp | ||||||
|   das/ob_das_retry_ctrl.cpp |   das/ob_das_retry_ctrl.cpp | ||||||
|   das/ob_das_simple_op.cpp |   das/ob_das_simple_op.cpp | ||||||
|  |   das/ob_text_retrieval_op.cpp | ||||||
| ) | ) | ||||||
|  |  | ||||||
| ob_set_subtarget(ob_sql dtl | ob_set_subtarget(ob_sql dtl | ||||||
|  | |||||||
| @ -399,6 +399,16 @@ OB_INLINE ObDuplicateType loc_meta_to_duplicate_type(const ObDASTableLocMeta &lo | |||||||
|   } |   } | ||||||
|   return dup_type; |   return dup_type; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | enum ObTSCIRScanType : uint8_t | ||||||
|  | { | ||||||
|  |   OB_NOT_A_SPEC_SCAN = 0, | ||||||
|  |   OB_IR_DOC_ID_IDX_AGG, | ||||||
|  |   OB_IR_INV_IDX_AGG, | ||||||
|  |   OB_IR_INV_IDX_SCAN, | ||||||
|  |   OB_IR_FWD_IDX_AGG, | ||||||
|  | }; | ||||||
|  |  | ||||||
| }  // namespace sql | }  // namespace sql | ||||||
| }  // namespace oceanbase | }  // namespace oceanbase | ||||||
| #endif /* OBDEV_SRC_SQL_DAS_OB_DAS_DEFINE_H_ */ | #endif /* OBDEV_SRC_SQL_DAS_OB_DAS_DEFINE_H_ */ | ||||||
|  | |||||||
| @ -58,7 +58,8 @@ OB_SERIALIZE_MEMBER(ObDASScanCtDef, | |||||||
|                     external_files_, |                     external_files_, | ||||||
|                     external_file_format_str_, |                     external_file_format_str_, | ||||||
|                     trans_info_expr_, |                     trans_info_expr_, | ||||||
|                     group_by_column_ids_); |                     group_by_column_ids_, | ||||||
|  |                     ir_scan_type_); | ||||||
|  |  | ||||||
| OB_DEF_SERIALIZE(ObDASScanRtDef) | OB_DEF_SERIALIZE(ObDASScanRtDef) | ||||||
| { | { | ||||||
| @ -169,7 +170,8 @@ ObDASScanOp::ObDASScanOp(ObIAllocator &op_alloc) | |||||||
|     scan_rtdef_(nullptr), |     scan_rtdef_(nullptr), | ||||||
|     result_(nullptr), |     result_(nullptr), | ||||||
|     remain_row_cnt_(0), |     remain_row_cnt_(0), | ||||||
|     retry_alloc_(nullptr) |     retry_alloc_(nullptr), | ||||||
|  |     ir_param_(op_alloc) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -739,7 +741,72 @@ OB_SERIALIZE_MEMBER((ObDASScanOp, ObIDASTaskOp), | |||||||
|                     scan_param_.key_ranges_, |                     scan_param_.key_ranges_, | ||||||
|                     scan_ctdef_, |                     scan_ctdef_, | ||||||
|                     scan_rtdef_, |                     scan_rtdef_, | ||||||
|                     scan_param_.ss_key_ranges_); |                     scan_param_.ss_key_ranges_, | ||||||
|  |                     ir_param_); | ||||||
|  |  | ||||||
|  | OB_DEF_SERIALIZE(ObDASIRParam) | ||||||
|  | { | ||||||
|  |   int ret = OB_SUCCESS; | ||||||
|  |   const bool ir_scan = is_ir_scan(); | ||||||
|  |   LST_DO_CODE(OB_UNIS_ENCODE, ir_scan); | ||||||
|  |   if (OB_SUCC(ret) && ir_scan) { | ||||||
|  |     if (OB_ISNULL(ctdef_) || OB_ISNULL(rtdef_)) { | ||||||
|  |       ret = OB_ERR_UNEXPECTED; | ||||||
|  |       LOG_WARN("unexpected nullptr", K(ret)); | ||||||
|  |     } else { | ||||||
|  |       LST_DO_CODE(OB_UNIS_ENCODE, | ||||||
|  |           *ctdef_, | ||||||
|  |           *rtdef_, | ||||||
|  |           ls_id_, | ||||||
|  |           inv_idx_tablet_id_, | ||||||
|  |           doc_id_idx_tablet_id_); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   return ret; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | OB_DEF_DESERIALIZE(ObDASIRParam) | ||||||
|  | { | ||||||
|  |   int ret = OB_SUCCESS; | ||||||
|  |   bool ir_scan = false; | ||||||
|  |   LST_DO_CODE(OB_UNIS_DECODE, ir_scan); | ||||||
|  |   if (OB_SUCC(ret) && ir_scan) { | ||||||
|  |     if (OB_ISNULL(ctdef_ = OB_NEWx(ObDASIRCtDef, &allocator_, allocator_))) { | ||||||
|  |       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|  |       LOG_WARN("failed to allocate memory for ir ctdef", K(ret)); | ||||||
|  |     } else if (OB_ISNULL(rtdef_ = OB_NEWx(ObDASIRRtDef, &allocator_, allocator_))) { | ||||||
|  |       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|  |       LOG_WARN("failed to allocate memory for ir rtdef", K(ret)); | ||||||
|  |     } else { | ||||||
|  |       LST_DO_CODE(OB_UNIS_DECODE, | ||||||
|  |           *ctdef_, | ||||||
|  |           *rtdef_, | ||||||
|  |           ls_id_, | ||||||
|  |           inv_idx_tablet_id_, | ||||||
|  |           doc_id_idx_tablet_id_); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   return ret; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | OB_DEF_SERIALIZE_SIZE(ObDASIRParam) | ||||||
|  | { | ||||||
|  |   int64_t len = 0; | ||||||
|  |   const bool ir_scan = is_ir_scan(); | ||||||
|  |   LST_DO_CODE(OB_UNIS_ADD_LEN, ir_scan); | ||||||
|  |   if (ir_scan) { | ||||||
|  |     if (nullptr != ctdef_ && nullptr != rtdef_) { | ||||||
|  |       LST_DO_CODE(OB_UNIS_ADD_LEN, | ||||||
|  |           *ctdef_, | ||||||
|  |           *rtdef_); | ||||||
|  |     } | ||||||
|  |     LST_DO_CODE(OB_UNIS_ADD_LEN, | ||||||
|  |         ls_id_, | ||||||
|  |         inv_idx_tablet_id_, | ||||||
|  |         doc_id_idx_tablet_id_); | ||||||
|  |   } | ||||||
|  |   return len; | ||||||
|  | } | ||||||
|  |  | ||||||
| ObDASScanResult::ObDASScanResult() | ObDASScanResult::ObDASScanResult() | ||||||
|   : ObIDASTaskResult(), |   : ObIDASTaskResult(), | ||||||
|  | |||||||
| @ -22,6 +22,8 @@ namespace sql | |||||||
| { | { | ||||||
| class ObDASExtraData; | class ObDASExtraData; | ||||||
| class ObLocalIndexLookupOp; | class ObLocalIndexLookupOp; | ||||||
|  | struct ObDASIRCtDef; | ||||||
|  | struct ObDASIRRtDef; | ||||||
|  |  | ||||||
| struct ObDASScanCtDef : ObDASBaseCtDef | struct ObDASScanCtDef : ObDASBaseCtDef | ||||||
| { | { | ||||||
| @ -44,7 +46,8 @@ public: | |||||||
|       external_file_location_(alloc), |       external_file_location_(alloc), | ||||||
|       external_files_(alloc), |       external_files_(alloc), | ||||||
|       external_file_format_str_(alloc), |       external_file_format_str_(alloc), | ||||||
|       trans_info_expr_(nullptr) |       trans_info_expr_(nullptr), | ||||||
|  |       ir_scan_type_(ObTSCIRScanType::OB_NOT_A_SPEC_SCAN) | ||||||
|   { } |   { } | ||||||
|   //in das scan op, column described with column expr |   //in das scan op, column described with column expr | ||||||
|   virtual bool has_expr() const override { return true; } |   virtual bool has_expr() const override { return true; } | ||||||
| @ -77,7 +80,8 @@ public: | |||||||
|                        K_(external_files), |                        K_(external_files), | ||||||
|                        K_(external_file_format_str), |                        K_(external_file_format_str), | ||||||
|                        K_(external_file_location), |                        K_(external_file_location), | ||||||
|                        KPC_(trans_info_expr)); |                        KPC_(trans_info_expr), | ||||||
|  |                        K_(ir_scan_type)); | ||||||
|   common::ObTableID ref_table_id_; |   common::ObTableID ref_table_id_; | ||||||
|   UIntFixedArray access_column_ids_; |   UIntFixedArray access_column_ids_; | ||||||
|   int64_t schema_version_; |   int64_t schema_version_; | ||||||
| @ -97,6 +101,7 @@ public: | |||||||
|   ExternalFileNameArray external_files_; //for external table scan TODO jim.wjh remove |   ExternalFileNameArray external_files_; //for external table scan TODO jim.wjh remove | ||||||
|   ObExternalFileFormat::StringData external_file_format_str_; |   ObExternalFileFormat::StringData external_file_format_str_; | ||||||
|   ObExpr *trans_info_expr_; // transaction information pseudo-column |   ObExpr *trans_info_expr_; // transaction information pseudo-column | ||||||
|  |   ObTSCIRScanType ir_scan_type_; // specify retrieval scan type | ||||||
| }; | }; | ||||||
|  |  | ||||||
| struct ObDASScanRtDef : ObDASBaseRtDef | struct ObDASScanRtDef : ObDASBaseRtDef | ||||||
| @ -168,6 +173,32 @@ private: | |||||||
|   }; |   }; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | struct ObDASIRParam | ||||||
|  | { | ||||||
|  |   OB_UNIS_VERSION(1); | ||||||
|  | public: | ||||||
|  |   ObDASIRParam(ObIAllocator &alloc) | ||||||
|  |     : allocator_(alloc), | ||||||
|  |       ctdef_(nullptr), | ||||||
|  |       rtdef_(nullptr), | ||||||
|  |       ls_id_(OB_INVALID_ID), | ||||||
|  |       inv_idx_tablet_id_(), | ||||||
|  |       fwd_idx_tablet_id_(), | ||||||
|  |       doc_id_idx_tablet_id_() {} | ||||||
|  |   virtual ~ObDASIRParam() {} | ||||||
|  |   inline bool is_ir_scan() const { return false; } // always false on master | ||||||
|  |  | ||||||
|  |   TO_STRING_KV(K_(ls_id), K_(inv_idx_tablet_id), K_(fwd_idx_tablet_id), | ||||||
|  |       K_(doc_id_idx_tablet_id), KP_(ctdef), KP_(rtdef)); | ||||||
|  |   ObIAllocator &allocator_; | ||||||
|  |   ObDASIRCtDef *ctdef_; | ||||||
|  |   ObDASIRRtDef *rtdef_; | ||||||
|  |   share::ObLSID ls_id_; | ||||||
|  |   ObTabletID inv_idx_tablet_id_; | ||||||
|  |   ObTabletID fwd_idx_tablet_id_; | ||||||
|  |   ObTabletID doc_id_idx_tablet_id_; | ||||||
|  | }; | ||||||
|  |  | ||||||
| class ObDASScanOp : public ObIDASTaskOp | class ObDASScanOp : public ObIDASTaskOp | ||||||
| { | { | ||||||
|   friend class DASOpResultIter; |   friend class DASOpResultIter; | ||||||
| @ -253,6 +284,7 @@ protected: | |||||||
|   union { |   union { | ||||||
|     common::ObArenaAllocator retry_alloc_buf_; |     common::ObArenaAllocator retry_alloc_buf_; | ||||||
|   }; |   }; | ||||||
|  |   ObDASIRParam ir_param_; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class ObDASScanResult : public ObIDASTaskResult, public common::ObNewRowIterator | class ObDASScanResult : public ObIDASTaskResult, public common::ObNewRowIterator | ||||||
|  | |||||||
							
								
								
									
										168
									
								
								src/sql/das/ob_text_retrieval_op.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										168
									
								
								src/sql/das/ob_text_retrieval_op.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,168 @@ | |||||||
|  | /** | ||||||
|  |  * Copyright (c) 2024 OceanBase | ||||||
|  |  * OceanBase CE is licensed under Mulan PubL v2. | ||||||
|  |  * You can use this software according to the terms and conditions of the Mulan PubL v2. | ||||||
|  |  * You may obtain a copy of Mulan PubL v2 at: | ||||||
|  |  *          http://license.coscl.org.cn/MulanPubL-2.0 | ||||||
|  |  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||||||
|  |  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||||||
|  |  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||||||
|  |  * See the Mulan PubL v2 for more details. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #define USING_LOG_PREFIX SQL_DAS | ||||||
|  | #include "sql/das/ob_text_retrieval_op.h" | ||||||
|  |  | ||||||
|  | namespace oceanbase | ||||||
|  | { | ||||||
|  | namespace sql | ||||||
|  | { | ||||||
|  |  | ||||||
|  | OB_DEF_SERIALIZE_SIZE(ObDASIRCtDef) | ||||||
|  | { | ||||||
|  |   int64_t len = 0; | ||||||
|  |   LST_DO_CODE(OB_UNIS_ADD_LEN, | ||||||
|  |       inv_idx_scan_ctdef_, | ||||||
|  |       search_text_, | ||||||
|  |       inv_scan_doc_id_col_, | ||||||
|  |       match_filter_, | ||||||
|  |       need_relevance_); | ||||||
|  |   if (need_relevance_) { | ||||||
|  |     if (OB_NOT_NULL(inv_idx_agg_ctdef_) | ||||||
|  |         && OB_NOT_NULL(fwd_idx_scan_ctdef_) | ||||||
|  |         && OB_NOT_NULL(doc_id_idx_whole_agg_ctdef_)) { | ||||||
|  |       LST_DO_CODE(OB_UNIS_ADD_LEN, | ||||||
|  |           relevance_expr_, | ||||||
|  |           relevance_proj_col_, | ||||||
|  |           *inv_idx_agg_ctdef_, | ||||||
|  |           *doc_id_idx_whole_agg_ctdef_, | ||||||
|  |           *fwd_idx_scan_ctdef_); | ||||||
|  |       } | ||||||
|  |   } | ||||||
|  |   return len; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | OB_DEF_SERIALIZE(ObDASIRCtDef) | ||||||
|  | { | ||||||
|  |   int ret = OB_SUCCESS; | ||||||
|  |   LST_DO_CODE(OB_UNIS_ENCODE, | ||||||
|  |       inv_idx_scan_ctdef_, | ||||||
|  |       search_text_, | ||||||
|  |       inv_scan_doc_id_col_, | ||||||
|  |       match_filter_, | ||||||
|  |       need_relevance_); | ||||||
|  |   if (OB_SUCC(ret) && need_relevance_) { | ||||||
|  |     if (OB_ISNULL(inv_idx_agg_ctdef_) | ||||||
|  |         || OB_ISNULL(fwd_idx_scan_ctdef_) | ||||||
|  |         || OB_ISNULL(doc_id_idx_whole_agg_ctdef_)) { | ||||||
|  |       ret = OB_ERR_UNEXPECTED; | ||||||
|  |       LOG_WARN("unexpected", K(ret), KP_(inv_idx_agg_ctdef), KP_(fwd_idx_scan_ctdef), KP_(doc_id_idx_whole_agg_ctdef)); | ||||||
|  |     } else { | ||||||
|  |       LST_DO_CODE(OB_UNIS_ENCODE, | ||||||
|  |           relevance_expr_, | ||||||
|  |           relevance_proj_col_, | ||||||
|  |           *inv_idx_agg_ctdef_, | ||||||
|  |           *doc_id_idx_whole_agg_ctdef_, | ||||||
|  |           *fwd_idx_scan_ctdef_); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   return ret; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | OB_DEF_DESERIALIZE(ObDASIRCtDef) | ||||||
|  | { | ||||||
|  |   int ret = OB_SUCCESS; | ||||||
|  |   need_relevance_ = false; | ||||||
|  |   LST_DO_CODE(OB_UNIS_DECODE, | ||||||
|  |       inv_idx_scan_ctdef_, | ||||||
|  |       search_text_, | ||||||
|  |       inv_scan_doc_id_col_, | ||||||
|  |       match_filter_, | ||||||
|  |       need_relevance_); | ||||||
|  |   if (OB_SUCC(ret) && need_relevance_) { | ||||||
|  |     if (OB_ISNULL(inv_idx_agg_ctdef_ = OB_NEWx(ObDASScanCtDef, &allocator_, allocator_))) { | ||||||
|  |       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|  |       LOG_WARN("failed to allocate memory for ctdef", K(ret)); | ||||||
|  |     } else if (OB_ISNULL(fwd_idx_scan_ctdef_ = OB_NEWx(ObDASScanCtDef, &allocator_, allocator_))) { | ||||||
|  |       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|  |       LOG_WARN("failed to allocate memory for ctdef", K(ret)); | ||||||
|  |     } else if (OB_ISNULL(doc_id_idx_whole_agg_ctdef_ = OB_NEWx(ObDASScanCtDef, &allocator_, allocator_))) { | ||||||
|  |       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|  |       LOG_WARN("failed to allocate memory for ctdef", K(ret)); | ||||||
|  |     } else { | ||||||
|  |       LST_DO_CODE(OB_UNIS_DECODE, | ||||||
|  |           relevance_expr_, | ||||||
|  |           relevance_proj_col_, | ||||||
|  |           *inv_idx_agg_ctdef_, | ||||||
|  |           *doc_id_idx_whole_agg_ctdef_, | ||||||
|  |           *fwd_idx_scan_ctdef_); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   return ret; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | OB_DEF_SERIALIZE_SIZE(ObDASIRRtDef) | ||||||
|  | { | ||||||
|  |   int64_t len = 0; | ||||||
|  |   LST_DO_CODE(OB_UNIS_ADD_LEN, | ||||||
|  |       inv_idx_scan_rtdef_, | ||||||
|  |       need_relevance_); | ||||||
|  |   if (need_relevance_) { | ||||||
|  |     if (OB_NOT_NULL(inv_idx_agg_rtdef_) && OB_NOT_NULL(doc_id_idx_whole_agg_rtdef_) && OB_NOT_NULL(fwd_idx_rtdef_)) { | ||||||
|  |       LST_DO_CODE(OB_UNIS_ADD_LEN, | ||||||
|  |           *inv_idx_agg_rtdef_, | ||||||
|  |           *doc_id_idx_whole_agg_rtdef_, | ||||||
|  |           *fwd_idx_rtdef_); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   return len; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | OB_DEF_SERIALIZE(ObDASIRRtDef) | ||||||
|  | { | ||||||
|  |   int ret = OB_SUCCESS; | ||||||
|  |   LST_DO_CODE(OB_UNIS_ENCODE, | ||||||
|  |       inv_idx_scan_rtdef_, | ||||||
|  |       need_relevance_); | ||||||
|  |   if (OB_SUCC(ret) && need_relevance_) { | ||||||
|  |     if (OB_ISNULL(inv_idx_agg_rtdef_) || OB_ISNULL(doc_id_idx_whole_agg_rtdef_) || OB_ISNULL(fwd_idx_rtdef_)) { | ||||||
|  |       ret = OB_ERR_UNEXPECTED; | ||||||
|  |       LOG_WARN("unexpected null rtdef", K(ret), KP_(inv_idx_agg_rtdef), KP_(fwd_idx_rtdef), KP_(doc_id_idx_whole_agg_rtdef)); | ||||||
|  |     } else { | ||||||
|  |       LST_DO_CODE(OB_UNIS_ENCODE, | ||||||
|  |           *inv_idx_agg_rtdef_, | ||||||
|  |           *doc_id_idx_whole_agg_rtdef_, | ||||||
|  |           *fwd_idx_rtdef_); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   return ret; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | OB_DEF_DESERIALIZE(ObDASIRRtDef) | ||||||
|  | { | ||||||
|  |   int ret = OB_SUCCESS; | ||||||
|  |   LST_DO_CODE(OB_UNIS_DECODE, | ||||||
|  |       inv_idx_scan_rtdef_, | ||||||
|  |       need_relevance_); | ||||||
|  |   if (OB_SUCC(ret) && need_relevance_) { | ||||||
|  |     if (OB_ISNULL(inv_idx_agg_rtdef_ = OB_NEWx(ObDASScanRtDef, &allocator_))) { | ||||||
|  |       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|  |       LOG_WARN("failed to allocate memory for rtdef", K(ret)); | ||||||
|  |     } else if (OB_ISNULL(fwd_idx_rtdef_ = OB_NEWx(ObDASScanRtDef, &allocator_))) { | ||||||
|  |       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|  |       LOG_WARN("failed to allocate memory for rtdef", K(ret)); | ||||||
|  |     } else if (OB_ISNULL(doc_id_idx_whole_agg_rtdef_ = OB_NEWx(ObDASScanRtDef, &allocator_))) { | ||||||
|  |       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|  |       LOG_WARN("failed to allocate memory for rtdef", K(ret)); | ||||||
|  |     } else { | ||||||
|  |       LST_DO_CODE(OB_UNIS_DECODE, | ||||||
|  |           *inv_idx_agg_rtdef_, | ||||||
|  |           *doc_id_idx_whole_agg_rtdef_, | ||||||
|  |           *fwd_idx_rtdef_); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   return ret; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | } // namespace sql | ||||||
|  | } // namespace oceanbase | ||||||
							
								
								
									
										107
									
								
								src/sql/das/ob_text_retrieval_op.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								src/sql/das/ob_text_retrieval_op.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,107 @@ | |||||||
|  | /** | ||||||
|  |  * Copyright (c) 2024 OceanBase | ||||||
|  |  * OceanBase CE is licensed under Mulan PubL v2. | ||||||
|  |  * You can use this software according to the terms and conditions of the Mulan PubL v2. | ||||||
|  |  * You may obtain a copy of Mulan PubL v2 at: | ||||||
|  |  *          http://license.coscl.org.cn/MulanPubL-2.0 | ||||||
|  |  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||||||
|  |  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||||||
|  |  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||||||
|  |  * See the Mulan PubL v2 for more details. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #ifndef OBDEV_SRC_SQL_DAS_OB_TEXT_RETRIEVAL_OP_H_ | ||||||
|  | #define OBDEV_SRC_SQL_DAS_OB_TEXT_RETRIEVAL_OP_H_ | ||||||
|  |  | ||||||
|  | #include "sql/das/ob_das_task.h" | ||||||
|  | #include "sql/das/ob_das_scan_op.h" | ||||||
|  |  | ||||||
|  | namespace oceanbase | ||||||
|  | { | ||||||
|  | namespace sql | ||||||
|  | { | ||||||
|  | static const int64_t OB_MAX_TEXT_RETRIEVAL_TOKEN_CNT = 64; | ||||||
|  |  | ||||||
|  | // Lots of meta data in ctdef / rtdef for inverted index / forward index scan are redundant here | ||||||
|  | //  Should we make constant meta datas shared between iterators ? | ||||||
|  | struct ObDASIRCtDef | ||||||
|  | { | ||||||
|  |   OB_UNIS_VERSION(1); | ||||||
|  | public: | ||||||
|  |   ObDASIRCtDef(common::ObIAllocator &alloc) | ||||||
|  |     : allocator_(alloc), | ||||||
|  |       search_text_(nullptr), | ||||||
|  |       inv_scan_doc_id_col_(nullptr), | ||||||
|  |       relevance_expr_(nullptr), | ||||||
|  |       match_filter_(nullptr), | ||||||
|  |       relevance_proj_col_(nullptr), | ||||||
|  |       inv_idx_scan_ctdef_(alloc), | ||||||
|  |       inv_idx_loc_meta_(alloc), | ||||||
|  |       inv_idx_agg_ctdef_(nullptr), | ||||||
|  |       doc_id_idx_whole_agg_ctdef_(nullptr), | ||||||
|  |       fwd_idx_scan_ctdef_(nullptr), | ||||||
|  |       fwd_idx_loc_meta_(nullptr), | ||||||
|  |       need_relevance_(false) {} | ||||||
|  |   virtual ~ObDASIRCtDef() {} | ||||||
|  |   ObExpr *get_inv_scan_doc_id() const { return inv_scan_doc_id_col_; } | ||||||
|  |   ObExpr *get_relevance_expr() const { return relevance_expr_; } | ||||||
|  |   ObExpr *get_relevance_proj_expr() const { return relevance_proj_col_; } | ||||||
|  |   bool need_proj_relevance_score() const { return nullptr != relevance_proj_col_; } | ||||||
|  |   TO_STRING_KV( | ||||||
|  |       KPC_(search_text), | ||||||
|  |       KPC_(inv_scan_doc_id_col), | ||||||
|  |       KPC_(relevance_expr), | ||||||
|  |       KPC_(match_filter), | ||||||
|  |       KPC_(relevance_proj_col), | ||||||
|  |       K_(inv_idx_scan_ctdef), | ||||||
|  |       K_(inv_idx_loc_meta), | ||||||
|  |       KPC_(inv_idx_agg_ctdef), | ||||||
|  |       KPC_(doc_id_idx_whole_agg_ctdef), | ||||||
|  |       KPC_(fwd_idx_scan_ctdef), | ||||||
|  |       KPC_(fwd_idx_loc_meta), | ||||||
|  |       K_(need_relevance)); | ||||||
|  |  | ||||||
|  |   common::ObIAllocator &allocator_; | ||||||
|  |   ObExpr *search_text_; | ||||||
|  |   ObExpr *inv_scan_doc_id_col_; | ||||||
|  |   ObExpr *relevance_expr_; | ||||||
|  |   ObExpr *match_filter_; | ||||||
|  |   ObExpr *relevance_proj_col_; | ||||||
|  |   ObDASScanCtDef inv_idx_scan_ctdef_; | ||||||
|  |   ObDASTableLocMeta inv_idx_loc_meta_; | ||||||
|  |   ObDASScanCtDef *inv_idx_agg_ctdef_; | ||||||
|  |   ObDASScanCtDef *doc_id_idx_whole_agg_ctdef_; // aggregate on inverted index with whole range | ||||||
|  |   ObDASScanCtDef *fwd_idx_scan_ctdef_; | ||||||
|  |   ObDASTableLocMeta *fwd_idx_loc_meta_; | ||||||
|  |   bool need_relevance_; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | struct ObDASIRRtDef | ||||||
|  | { | ||||||
|  |   OB_UNIS_VERSION(1); | ||||||
|  | public: | ||||||
|  |   ObDASIRRtDef(common::ObIAllocator &alloc) | ||||||
|  |     : allocator_(alloc), | ||||||
|  |       inv_idx_scan_rtdef_(), | ||||||
|  |       inv_idx_agg_rtdef_(nullptr), | ||||||
|  |       doc_id_idx_whole_agg_rtdef_(nullptr), | ||||||
|  |       fwd_idx_rtdef_(nullptr), | ||||||
|  |       eval_ctx_(nullptr), | ||||||
|  |       need_relevance_(false) {} | ||||||
|  |   virtual ~ObDASIRRtDef() {} | ||||||
|  |  | ||||||
|  |   TO_STRING_KV(K_(inv_idx_scan_rtdef), KPC_(inv_idx_agg_rtdef), KPC_(doc_id_idx_whole_agg_rtdef), | ||||||
|  |       KPC_(fwd_idx_rtdef), KPC_(eval_ctx), K_(need_relevance)); | ||||||
|  |   common::ObIAllocator &allocator_; | ||||||
|  |   ObDASScanRtDef inv_idx_scan_rtdef_; | ||||||
|  |   ObDASScanRtDef *inv_idx_agg_rtdef_; | ||||||
|  |   ObDASScanRtDef *doc_id_idx_whole_agg_rtdef_; | ||||||
|  |   ObDASScanRtDef *fwd_idx_rtdef_; | ||||||
|  |   ObEvalCtx *eval_ctx_; | ||||||
|  |   bool need_relevance_; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | } // namespace sql | ||||||
|  | } // namespace oceanbase | ||||||
|  |  | ||||||
|  | #endif | ||||||
| @ -127,6 +127,18 @@ OB_DEF_SERIALIZE(ObTableScanCtDef) | |||||||
|   OB_UNIS_ENCODE(calc_part_id_expr_); |   OB_UNIS_ENCODE(calc_part_id_expr_); | ||||||
|   OB_UNIS_ENCODE(global_index_rowkey_exprs_); |   OB_UNIS_ENCODE(global_index_rowkey_exprs_); | ||||||
|   OB_UNIS_ENCODE(flashback_item_.fq_read_tx_uncommitted_); |   OB_UNIS_ENCODE(flashback_item_.fq_read_tx_uncommitted_); | ||||||
|  |   bool has_aux_lookup = false; | ||||||
|  |   OB_UNIS_ENCODE(has_aux_lookup); | ||||||
|  |   if (OB_SUCC(ret) && has_aux_lookup) { | ||||||
|  |     OB_UNIS_ENCODE(*aux_lookup_ctdef_); | ||||||
|  |     OB_UNIS_ENCODE(*aux_lookup_loc_meta_); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   bool has_text_ir = false; | ||||||
|  |   OB_UNIS_ENCODE(has_text_ir); | ||||||
|  |   if (OB_SUCC(ret) && has_text_ir) { | ||||||
|  |     OB_UNIS_ENCODE(*text_ir_ctdef_); | ||||||
|  |   } | ||||||
|   return ret; |   return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -154,6 +166,17 @@ OB_DEF_SERIALIZE_SIZE(ObTableScanCtDef) | |||||||
|   OB_UNIS_ADD_LEN(calc_part_id_expr_); |   OB_UNIS_ADD_LEN(calc_part_id_expr_); | ||||||
|   OB_UNIS_ADD_LEN(global_index_rowkey_exprs_); |   OB_UNIS_ADD_LEN(global_index_rowkey_exprs_); | ||||||
|   OB_UNIS_ADD_LEN(flashback_item_.fq_read_tx_uncommitted_); |   OB_UNIS_ADD_LEN(flashback_item_.fq_read_tx_uncommitted_); | ||||||
|  |   bool has_aux_lookup = false; | ||||||
|  |   OB_UNIS_ADD_LEN(has_aux_lookup); | ||||||
|  |   if (has_aux_lookup) { | ||||||
|  |     OB_UNIS_ADD_LEN(*aux_lookup_ctdef_); | ||||||
|  |     OB_UNIS_ADD_LEN(*aux_lookup_loc_meta_); | ||||||
|  |   } | ||||||
|  |   bool has_text_ir = false; | ||||||
|  |   OB_UNIS_ADD_LEN(has_text_ir); | ||||||
|  |   if (has_text_ir) { | ||||||
|  |     OB_UNIS_ADD_LEN(*text_ir_ctdef_); | ||||||
|  |   } | ||||||
|   return len; |   return len; | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -198,6 +221,30 @@ OB_DEF_DESERIALIZE(ObTableScanCtDef) | |||||||
|   OB_UNIS_DECODE(calc_part_id_expr_); |   OB_UNIS_DECODE(calc_part_id_expr_); | ||||||
|   OB_UNIS_DECODE(global_index_rowkey_exprs_); |   OB_UNIS_DECODE(global_index_rowkey_exprs_); | ||||||
|   OB_UNIS_DECODE(flashback_item_.fq_read_tx_uncommitted_); |   OB_UNIS_DECODE(flashback_item_.fq_read_tx_uncommitted_); | ||||||
|  |   bool has_aux_lookup = false; | ||||||
|  |   OB_UNIS_DECODE(has_aux_lookup); | ||||||
|  |   if (OB_SUCC(ret) && has_aux_lookup) { | ||||||
|  |     if (OB_ISNULL(aux_lookup_ctdef_ = OB_NEWx(ObDASScanCtDef, &allocator_, allocator_))) { | ||||||
|  |       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|  |       LOG_WARN("failed to allocate memory for aux lookup ctdef", K(ret)); | ||||||
|  |     } else if (OB_ISNULL(aux_lookup_loc_meta_ = OB_NEWx(ObDASTableLocMeta, &allocator_, allocator_))) { | ||||||
|  |       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|  |       LOG_WARN("failed to allocate memory for aux lookup table location meta", K(ret)); | ||||||
|  |     } else { | ||||||
|  |       OB_UNIS_DECODE(*aux_lookup_ctdef_); | ||||||
|  |       OB_UNIS_DECODE(*aux_lookup_loc_meta_); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   bool has_text_ir = false; | ||||||
|  |   OB_UNIS_DECODE(has_text_ir); | ||||||
|  |   if (OB_SUCC(ret) && has_text_ir) { | ||||||
|  |     if (OB_ISNULL(text_ir_ctdef_ = OB_NEWx(ObDASIRCtDef, &allocator_, allocator_))) { | ||||||
|  |       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|  |       LOG_WARN("failed to allocate memory for text ir ctdef", K(ret)); | ||||||
|  |     } else { | ||||||
|  |       OB_UNIS_DECODE(*text_ir_ctdef_); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|   return ret; |   return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -24,6 +24,7 @@ | |||||||
| #include "sql/das/ob_das_ref.h" | #include "sql/das/ob_das_ref.h" | ||||||
| #include "sql/das/ob_data_access_service.h" | #include "sql/das/ob_data_access_service.h" | ||||||
| #include "sql/das/ob_das_scan_op.h" | #include "sql/das/ob_das_scan_op.h" | ||||||
|  | #include "sql/das/ob_text_retrieval_op.h" | ||||||
| #include "sql/engine/basic/ob_pushdown_filter.h" | #include "sql/engine/basic/ob_pushdown_filter.h" | ||||||
| #include "sql/engine/table/ob_index_lookup_op_impl.h" | #include "sql/engine/table/ob_index_lookup_op_impl.h" | ||||||
| namespace oceanbase | namespace oceanbase | ||||||
| @ -139,7 +140,10 @@ public: | |||||||
|       das_dppr_tbl_(nullptr), |       das_dppr_tbl_(nullptr), | ||||||
|       allocator_(allocator), |       allocator_(allocator), | ||||||
|       calc_part_id_expr_(NULL), |       calc_part_id_expr_(NULL), | ||||||
|       global_index_rowkey_exprs_(allocator) |       global_index_rowkey_exprs_(allocator), | ||||||
|  |       aux_lookup_ctdef_(nullptr), | ||||||
|  |       aux_lookup_loc_meta_(nullptr), | ||||||
|  |       text_ir_ctdef_(nullptr) | ||||||
|   { } |   { } | ||||||
|   const ExprFixedArray &get_das_output_exprs() const |   const ExprFixedArray &get_das_output_exprs() const | ||||||
|   { |   { | ||||||
| @ -161,7 +165,10 @@ public: | |||||||
|                KPC_(lookup_loc_meta), |                KPC_(lookup_loc_meta), | ||||||
|                KPC_(das_dppr_tbl), |                KPC_(das_dppr_tbl), | ||||||
|                KPC_(calc_part_id_expr), |                KPC_(calc_part_id_expr), | ||||||
|                K_(global_index_rowkey_exprs)); |                K_(global_index_rowkey_exprs), | ||||||
|  |                KPC_(aux_lookup_ctdef), | ||||||
|  |                KPC_(aux_lookup_loc_meta), | ||||||
|  |                KPC_(text_ir_ctdef)); | ||||||
|   //the query range of index scan/table scan |   //the query range of index scan/table scan | ||||||
|   ObQueryRange pre_query_range_; |   ObQueryRange pre_query_range_; | ||||||
|   FlashBackItem flashback_item_; |   FlashBackItem flashback_item_; | ||||||
| @ -188,6 +195,11 @@ public: | |||||||
|   ObExpr *calc_part_id_expr_; |   ObExpr *calc_part_id_expr_; | ||||||
|   ExprFixedArray global_index_rowkey_exprs_; |   ExprFixedArray global_index_rowkey_exprs_; | ||||||
|   // end for Global Index Lookup |   // end for Global Index Lookup | ||||||
|  |   // domain doc_id aux lookup | ||||||
|  |   ObDASScanCtDef *aux_lookup_ctdef_; | ||||||
|  |   ObDASTableLocMeta *aux_lookup_loc_meta_; | ||||||
|  |   // text retrieval | ||||||
|  |   ObDASIRCtDef *text_ir_ctdef_; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| struct ObTableScanRtDef | struct ObTableScanRtDef | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 saltonz
					saltonz