From fe4837b73b23b72fcb9ba787982db5de1130cb49 Mon Sep 17 00:00:00 2001 From: Tao He Date: Thu, 19 Aug 2021 17:38:52 +0800 Subject: [PATCH] Adapt to latest vineyard: the `Create()` API has changed. (#713) * Adapt to latest vineyard: the `Create()` API has changed. Signed-off-by: Tao He --- .../fragment/append_only_arrow_fragment.h | 11 ++++++++++ .../core/fragment/arrow_projected_fragment.h | 11 ++++++++++ .../vertex_map/arrow_projected_vertex_map.h | 21 +++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/analytical_engine/core/fragment/append_only_arrow_fragment.h b/analytical_engine/core/fragment/append_only_arrow_fragment.h index dac5a600c3f8..6dc846273015 100644 --- a/analytical_engine/core/fragment/append_only_arrow_fragment.h +++ b/analytical_engine/core/fragment/append_only_arrow_fragment.h @@ -27,6 +27,7 @@ #include "arrow/util/config.h" #include "grape/grape.h" +#include "vineyard/common/util/version.h" #include "vineyard/graph/fragment/arrow_fragment.h" #include "vineyard/graph/vertex_map/arrow_vertex_map.h" @@ -293,10 +294,20 @@ class AppendOnlyArrowFragment template using vertex_array_t = grape::VertexArray; +#if defined(VINEYARD_VERSION) && defined(VINEYARD_VERSION_MAJOR) +#if VINEYARD_VERSION >= 2007 + static std::unique_ptr Create() __attribute__((used)) { + return std::static_pointer_cast( + std::unique_ptr>{ + new AppendOnlyArrowFragment()}); + } +#endif +#else static std::shared_ptr Create() __attribute__((used)) { return std::static_pointer_cast( std::make_shared>()); } +#endif public: void Construct(const vineyard::ObjectMeta& meta) override { diff --git a/analytical_engine/core/fragment/arrow_projected_fragment.h b/analytical_engine/core/fragment/arrow_projected_fragment.h index 4f872127b813..69424b169ce9 100644 --- a/analytical_engine/core/fragment/arrow_projected_fragment.h +++ b/analytical_engine/core/fragment/arrow_projected_fragment.h @@ -26,6 +26,7 @@ #include "boost/lexical_cast.hpp" #include "vineyard/basic/ds/arrow_utils.h" +#include "vineyard/common/util/version.h" #include "vineyard/graph/fragment/arrow_fragment.h" #include "vineyard/graph/vertex_map/arrow_vertex_map.h" @@ -366,11 +367,21 @@ class ArrowProjectedFragment static constexpr grape::LoadStrategy load_strategy = grape::LoadStrategy::kBothOutIn; +#if defined(VINEYARD_VERSION) && defined(VINEYARD_VERSION_MAJOR) +#if VINEYARD_VERSION >= 2007 + static std::unique_ptr Create() __attribute__((used)) { + return std::static_pointer_cast( + std::unique_ptr>{ + new ArrowProjectedFragment()}); + } +#endif +#else static std::shared_ptr Create() __attribute__((used)) { return std::static_pointer_cast( std::make_shared< ArrowProjectedFragment>()); } +#endif ~ArrowProjectedFragment() {} diff --git a/analytical_engine/core/vertex_map/arrow_projected_vertex_map.h b/analytical_engine/core/vertex_map/arrow_projected_vertex_map.h index 32b697dab5fd..625672f83f17 100644 --- a/analytical_engine/core/vertex_map/arrow_projected_vertex_map.h +++ b/analytical_engine/core/vertex_map/arrow_projected_vertex_map.h @@ -19,6 +19,7 @@ #include #include +#include "vineyard/common/util/version.h" #include "vineyard/graph/fragment/property_graph_types.h" #include "vineyard/graph/vertex_map/arrow_vertex_map.h" @@ -39,10 +40,20 @@ class ArrowProjectedVertexMap using oid_array_t = typename vineyard::ConvertToArrowType::ArrayType; public: +#if defined(VINEYARD_VERSION) && defined(VINEYARD_VERSION_MAJOR) +#if VINEYARD_VERSION >= 2007 + static std::unique_ptr Create() __attribute__((used)) { + return std::static_pointer_cast( + std::unique_ptr>{ + new ArrowProjectedVertexMap()}); + } +#endif +#else static std::shared_ptr Create() __attribute__((used)) { return std::static_pointer_cast( std::make_shared>()); } +#endif static std::shared_ptr> Project( std::shared_ptr> vm, @@ -149,10 +160,20 @@ class ArrowProjectedVertexMap using oid_array_t = arrow::LargeStringArray; public: +#if defined(VINEYARD_VERSION) && defined(VINEYARD_VERSION_MAJOR) +#if VINEYARD_VERSION >= 2007 + static std::unique_ptr Create() __attribute__((used)) { + return std::static_pointer_cast( + std::unique_ptr>{ + new ArrowProjectedVertexMap()}); + } +#endif +#else static std::shared_ptr Create() __attribute__((used)) { return std::static_pointer_cast( std::make_shared>()); } +#endif static std::shared_ptr> Project( std::shared_ptr> vm,