From b24e1e6e7f0586cb74e7b55c748c79f49f8d1354 Mon Sep 17 00:00:00 2001 From: Jimmy Lu Date: Mon, 28 Oct 2024 07:06:39 -0700 Subject: [PATCH] Add fb_regex_match_any (#11273) Summary: X-link: https://github.com/facebookexternal/presto-facebook/pull/3019 Pull Request resolved: https://github.com/facebookincubator/velox/pull/11273 Reviewed By: kevinwilfong Differential Revision: D64356475 fbshipit-source-id: 6c5bac796f7b628ebb4d73356106ca5edc5ce345 --- velox/vector/BaseVector.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/velox/vector/BaseVector.h b/velox/vector/BaseVector.h index 18f5725d4e76..ec9ce0a0d883 100644 --- a/velox/vector/BaseVector.h +++ b/velox/vector/BaseVector.h @@ -145,6 +145,28 @@ class BaseVector { return static_cast(this); } + template + T* asChecked() { + auto* casted = as(); + VELOX_CHECK_NOT_NULL( + casted, + "Wrong type cast expected {}, but got {}", + typeid(T).name(), + typeid(*this).name()); + return casted; + } + + template + const T* asChecked() const { + auto* casted = as(); + VELOX_CHECK_NOT_NULL( + casted, + "Wrong type cast expected {}, but got {}", + typeid(T).name(), + typeid(*this).name()); + return casted; + } + template const FlatVector* asFlatVector() const { return dynamic_cast*>(this);