[FEAT MERGE] Vector Index & Array Type

Co-authored-by: helloamateur <magiccheery@163.com>
Co-authored-by: skylhd <dickylhd@gmail.com>
Co-authored-by: JLY2015 <1623359870@qq.com>
This commit is contained in:
wanghangQ
2024-08-29 07:52:21 +00:00
committed by ob-robot
parent 376ae13422
commit 5cbd86c9e6
443 changed files with 46822 additions and 2893 deletions

View File

@ -0,0 +1,100 @@
/**
* Copyright (c) 2023 OceanBase
* OceanBase 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 COMMON
#include "sql/engine/expr/ob_expr_vec_vector.h"
#include "lib/udt/ob_collection_type.h"
#include "lib/udt/ob_array_type.h"
#include "sql/engine/expr/ob_expr_lob_utils.h"
#include "sql/engine/expr/ob_array_expr_utils.h"
#include "sql/engine/ob_exec_context.h"
namespace oceanbase
{
using namespace common;
namespace sql
{
ObExprVecVector::ObExprVecVector(ObIAllocator &allocator)
: ObFuncExprOperator(allocator, T_FUN_SYS_VEC_VECTOR, N_VEC_VECTOR, MORE_THAN_ZERO, VALID_FOR_GENERATED_COL, NOT_ROW_DIMENSION)
{
need_charset_convert_ = false;
}
int ObExprVecVector::calc_result_typeN(ObExprResType &type,
ObExprResType *types,
int64_t param_num,
ObExprTypeCtx &type_ctx) const
{
int ret = OB_SUCCESS;
ObSQLSessionInfo *session = const_cast<ObSQLSessionInfo *>(type_ctx.get_session());
ObExecContext *exec_ctx = OB_ISNULL(session) ? NULL : session->get_cur_exec_ctx();
ObDataType elem_type;
elem_type.meta_.set_float();
uint16_t subschema_id;
if (OB_ISNULL(exec_ctx)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("exec ctx is null", K(ret));
} else if (OB_FAIL(exec_ctx->get_subschema_id_by_collection_elem_type(ObNestedType::OB_VECTOR_TYPE,
elem_type, subschema_id))) {
LOG_WARN("failed to get collection subschema id", K(ret));
} else {
type.set_collection(subschema_id);
}
return ret;
}
int ObExprVecVector::calc_resultN(ObObj &result,
const ObObj *objs_array,
int64_t param_num,
ObExprCtx &expr_ctx) const
{
return OB_NOT_SUPPORTED;
}
int ObExprVecVector::cg_expr(
ObExprCGCtx &expr_cg_ctx,
const ObRawExpr &raw_expr,
ObExpr &rt_expr) const
{
int ret = OB_SUCCESS;
UNUSED(raw_expr);
UNUSED(expr_cg_ctx);
if (OB_UNLIKELY(rt_expr.arg_cnt_ < 1) || OB_ISNULL(rt_expr.args_)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arguments", K(rt_expr.arg_cnt_), KP(rt_expr.args_), K(rt_expr.type_));
} else {
rt_expr.eval_func_ = generate_vec_vector;
}
return ret;
}
/*static*/ int ObExprVecVector::generate_vec_vector(
const ObExpr &raw_ctx,
ObEvalCtx &eval_ctx,
ObDatum &expr_datum)
{
int ret = OB_SUCCESS;
ObDatum *datum = nullptr;
if (OB_FAIL(raw_ctx.args_[0]->eval(eval_ctx, datum))) {
LOG_WARN("fail to eval arg expr", K(ret), KPC(raw_ctx.args_[0]));
} else if (OB_ISNULL(datum)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get null datum", K(ret), KPC(raw_ctx.args_[0]));
} else {
expr_datum.set_string(datum->get_string());
}
return ret;
}
} // namespace sql
} // namespace oceanbase