This is an automated email from the ASF dual-hosted git repository.
hongze pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 007de4c447 [GLUTEN-10403] Extract the common code from ObjectStore as
a new method lookup (#10404)
007de4c447 is described below
commit 007de4c44794752eb5bf630127c2549addd2ca9b
Author: Jiaan Geng <[email protected]>
AuthorDate: Wed Aug 13 16:27:55 2025 +0800
[GLUTEN-10403] Extract the common code from ObjectStore as a new method
lookup (#10404)
---
cpp/core/utils/ObjectStore.cc | 8 ++++++++
cpp/core/utils/ObjectStore.h | 10 ++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/cpp/core/utils/ObjectStore.cc b/cpp/core/utils/ObjectStore.cc
index 34fe0d842e..05fd584373 100644
--- a/cpp/core/utils/ObjectStore.cc
+++ b/cpp/core/utils/ObjectStore.cc
@@ -36,6 +36,14 @@ gluten::ResourceMap<gluten::ObjectStore*>&
gluten::ObjectStore::stores() {
return stores;
}
+// static
+std::pair<gluten::ObjectStore*, gluten::ResourceHandle>
gluten::ObjectStore::lookup(gluten::ObjectHandle handle) {
+ ResourceHandle storeId = safeCast<ResourceHandle>(handle >>
(sizeof(gluten::ResourceHandle) * 8));
+ ResourceHandle resourceId = safeCast<ResourceHandle>(handle &
std::numeric_limits<ResourceHandle>::max());
+ auto store = stores().lookup(storeId);
+ return {store, resourceId};
+};
+
gluten::ObjectStore::~ObjectStore() {
for (;;) {
if (aliveObjects_.empty()) {
diff --git a/cpp/core/utils/ObjectStore.h b/cpp/core/utils/ObjectStore.h
index 182d659526..24fab4d423 100644
--- a/cpp/core/utils/ObjectStore.h
+++ b/cpp/core/utils/ObjectStore.h
@@ -52,17 +52,13 @@ class ObjectStore {
static std::unique_ptr<ObjectStore> create();
static void release(ObjectHandle handle) {
- ResourceHandle storeId = safeCast<ResourceHandle>(handle >>
(sizeof(ResourceHandle) * 8));
- ResourceHandle resourceId = safeCast<ResourceHandle>(handle &
std::numeric_limits<ResourceHandle>::max());
- auto store = stores().lookup(storeId);
+ auto [store, resourceId] = lookup(handle);
store->releaseInternal(resourceId);
}
template <typename T>
static std::shared_ptr<T> retrieve(ObjectHandle handle) {
- ResourceHandle storeId = safeCast<ResourceHandle>(handle >>
(sizeof(ResourceHandle) * 8));
- ResourceHandle resourceId = safeCast<ResourceHandle>(handle &
std::numeric_limits<ResourceHandle>::max());
- auto store = stores().lookup(storeId);
+ auto [store, resourceId] = lookup(handle);
return store->retrieveInternal<T>(resourceId);
}
@@ -85,6 +81,8 @@ class ObjectStore {
private:
static ResourceMap<ObjectStore*>& stores();
+ static std::pair<ObjectStore*, ResourceHandle> lookup(ObjectHandle handle);
+
struct ObjectDebugInfo {
const std::string_view typeName;
const size_t size;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]