From 92cb67639862613b7db4a488b994803ba570e727 Mon Sep 17 00:00:00 2001 From: Tao He Date: Mon, 1 Apr 2024 11:57:08 +0800 Subject: [PATCH] Fixes value getters for date/time/timestamp arrays Signed-off-by: Tao He --- modules/basic/ds/arrow_utils.cc | 10 ++++----- .../fragment/arrow_fragment.vineyard-mod | 20 +---------------- modules/graph/fragment/arrow_fragment_impl.h | 22 +++++++++++++++++++ 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/modules/basic/ds/arrow_utils.cc b/modules/basic/ds/arrow_utils.cc index a431cb1b..026f871b 100644 --- a/modules/basic/ds/arrow_utils.cc +++ b/modules/basic/ds/arrow_utils.cc @@ -925,19 +925,19 @@ const void* get_arrow_array_data(std::shared_ptr const& array) { std::dynamic_pointer_cast(array).get()); } else if (array->type()->Equals(arrow::date32())) { return reinterpret_cast( - std::dynamic_pointer_cast(array).get()); + std::dynamic_pointer_cast(array)->raw_values()); } else if (array->type()->Equals(arrow::date64())) { return reinterpret_cast( - std::dynamic_pointer_cast(array).get()); + std::dynamic_pointer_cast(array)->raw_values()); } else if (array->type()->id() == arrow::Type::TIME32) { return reinterpret_cast( - std::dynamic_pointer_cast(array).get()); + std::dynamic_pointer_cast(array)->raw_values()); } else if (array->type()->id() == arrow::Type::TIME64) { return reinterpret_cast( - std::dynamic_pointer_cast(array).get()); + std::dynamic_pointer_cast(array)->raw_values()); } else if (array->type()->id() == arrow::Type::TIMESTAMP) { return reinterpret_cast( - std::dynamic_pointer_cast(array).get()); + std::dynamic_pointer_cast(array)->raw_values()); } else if (array->type()->id() == arrow::Type::LIST) { return reinterpret_cast( std::dynamic_pointer_cast(array).get()); diff --git a/modules/graph/fragment/arrow_fragment.vineyard-mod b/modules/graph/fragment/arrow_fragment.vineyard-mod index 22c03e7a..a6b909d7 100644 --- a/modules/graph/fragment/arrow_fragment.vineyard-mod +++ b/modules/graph/fragment/arrow_fragment.vineyard-mod @@ -141,25 +141,7 @@ class [[vineyard]] ArrowFragment const std::string oid_typename() const override { return oid_type; } - void PostConstruct(const vineyard::ObjectMeta& meta) override { - vid_parser_.Init(fnum_, vertex_label_num_); - this->schema_.FromJSON(schema_json_); - - // init pointers for arrays and tables - initPointers(); - - // init edge numbers - oenum_ = 0; - ienum_ = 0; - for (label_id_t i = 0; i < vertex_label_num_; i++) { - for (auto& v : InnerVertices(i)) { - for (label_id_t j = 0; j < edge_label_num_; j++) { - oenum_ += GetLocalOutDegree(v, j); - ienum_ += GetLocalInDegree(v, j); - } - } - } - } + void PostConstruct(const vineyard::ObjectMeta& meta) override; fid_t fid() const { return fid_; } diff --git a/modules/graph/fragment/arrow_fragment_impl.h b/modules/graph/fragment/arrow_fragment_impl.h index 144c215a..cd9ea477 100644 --- a/modules/graph/fragment/arrow_fragment_impl.h +++ b/modules/graph/fragment/arrow_fragment_impl.h @@ -54,6 +54,28 @@ limitations under the License. namespace vineyard { +template +void ArrowFragment::PostConstruct( + const vineyard::ObjectMeta& meta) { + vid_parser_.Init(fnum_, vertex_label_num_); + this->schema_.FromJSON(schema_json_); + + // init pointers for arrays and tables + initPointers(); + + // init edge numbers + oenum_ = 0; + ienum_ = 0; + for (label_id_t i = 0; i < vertex_label_num_; i++) { + for (auto& v : InnerVertices(i)) { + for (label_id_t j = 0; j < edge_label_num_; j++) { + oenum_ += GetLocalOutDegree(v, j); + ienum_ += GetLocalInDegree(v, j); + } + } + } +} + template void ArrowFragment::PrepareToRunApp( const grape::CommSpec& comm_spec, grape::PrepareConf conf) {