This is an automated email from the ASF dual-hosted git repository.

weibin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-graphar.git


The following commit(s) were added to refs/heads/main by this push:
     new 712b204d feat!(c++): Refactor code structure to consolidate include 
and src into a single src directory (#533)
712b204d is described below

commit 712b204df2aa625d233302a27bc83bd8affd2229
Author: Weibin Zeng <[email protected]>
AuthorDate: Wed Jul 10 10:10:51 2024 +0800

    feat!(c++): Refactor code structure to consolidate include and src into a 
single src directory (#533)
    
    Reason for this PR
    Our current project structure separates header files and source files into 
include and src directories, respectively. This approach, while beneficial in 
some contexts, adds complexity and overhead for smaller projects, and not fits 
to protobuf generated code. To simplify the structure and enhance 
maintainability, we need to consolidate all code into a single src directory.
    
    What changes are included in this PR?
    Here are some notable changes:
    
    Consolidate the header and source code into single src directory.
    Add subdirectory to classify the arrow and high-level related code.
    Add api headers to let users to easily to include the function of c++ 
library.
    Are these changes tested?
    Yes
    
    Are there any user-facing changes?
    BREAKING CHANGE:
    
    -the header path and header name may change, like:
    -graphar/arrow_chunk_reader.h to graphar/arrow/chunk_reader.h
    -graphar/arrow_chunk_writer.h to graphar/arrow/chunk_writer.h
    -The copy way writer function has been moved from arrow_chunk_writer.h to 
chunk_info_writer.h
    
    ---------
    
    Signed-off-by: acezen <[email protected]>
---
 cpp/CMakeLists.txt                                 |  13 +-
 cpp/benchmarks/arrow_chunk_reader_benchmark.cc     |   4 +-
 cpp/benchmarks/benchmark_util.h                    |   3 +-
 cpp/benchmarks/graph_info_benchmark.cc             |   2 +-
 cpp/examples/bfs_father_example.cc                 |   7 +-
 cpp/examples/bfs_pull_example.cc                   |   6 +-
 cpp/examples/bfs_push_example.cc                   |   6 +-
 cpp/examples/bfs_stream_example.cc                 |   6 +-
 cpp/examples/bgl_example.cc                        |   8 +-
 cpp/examples/cc_push_example.cc                    |   6 +-
 cpp/examples/cc_stream_example.cc                  |   6 +-
 cpp/examples/construct_info_example.cc             |   2 +-
 cpp/examples/high_level_reader_example.cc          |   2 +-
 cpp/examples/high_level_writer_example.cc          |   4 +-
 cpp/examples/low_level_reader_example.cc           |   3 +-
 cpp/examples/mid_level_reader_example.cc           |   4 +-
 cpp/examples/mid_level_writer_example.cc           |   3 +-
 cpp/examples/pagerank_example.cc                   |   6 +-
 cpp/examples/snap_dataset_to_graphar.cc            |   4 +-
 cpp/include/graphar/util/adj_list_type.h           |  91 ----------
 cpp/include/graphar/util/file_type.h               |  53 ------
 .../graphar/api/arrow_reader.h}                    |  14 +-
 .../graphar/api/arrow_writer.h}                    |  13 +-
 .../graphar/api/high_level_reader.h}               |  13 +-
 .../graphar/api/high_level_writer.h}               |  14 +-
 .../graphar/api.h => src/graphar/api/info.h}       |  20 +--
 .../graphar/api/meta_reader.h}                     |  13 +-
 .../graphar/api/meta_writer.h}                     |  13 +-
 .../arrow/chunk_reader.cc}                         |  19 ++-
 .../graphar/arrow/chunk_reader.h}                  |   2 +-
 .../arrow/chunk_writer.cc}                         |  63 +------
 .../graphar/arrow/chunk_writer.h}                  |  61 +------
 cpp/src/{ => graphar}/chunk_info_reader.cc         |  13 +-
 .../reader => src/graphar}/chunk_info_reader.h     |   0
 cpp/src/graphar/chunk_info_writer.cc               | 186 +++++++++++++++++++++
 cpp/src/graphar/chunk_info_writer.h                | 176 +++++++++++++++++++
 .../util => src/graphar}/convert_to_arrow_type.h   |   2 +-
 cpp/src/{ => graphar}/expression.cc                |   4 +-
 .../graphar/util => src/graphar}/expression.h      |   0
 cpp/src/{ => graphar}/filesystem.cc                |   4 +-
 .../graphar/util => src/graphar}/filesystem.h      |  10 +-
 cpp/{include => src}/graphar/fwd.h                 |   4 +-
 .../graphar/util => src/graphar}/general_params.h  |   0
 cpp/src/{ => graphar}/graph_info.cc                |  12 +-
 cpp/{include => src}/graphar/graph_info.h          |   0
 cpp/src/{ => graphar/high-level}/edges_builder.cc  |   8 +-
 .../graphar/high-level}/edges_builder.h            |   4 +-
 .../high-level/graph_reader.cc}                    |   6 +-
 .../graphar/high-level/graph_reader.h}             |  10 +-
 .../{ => graphar/high-level}/vertices_builder.cc   |   4 +-
 .../graphar/high-level}/vertices_builder.h         |   4 +-
 cpp/{include/graphar/util => src/graphar}/macros.h |   0
 cpp/src/{ => graphar}/reader_util.cc               |   8 +-
 .../graphar/util => src/graphar}/reader_util.h     |   0
 cpp/{include/graphar/util => src/graphar}/result.h |   2 +-
 cpp/{include/graphar/util => src/graphar}/status.h |   2 +-
 cpp/src/{data_type.cc => graphar/types.cc}         |   3 +-
 .../util/data_type.h => src/graphar/types.h}       |  86 +++++++++-
 cpp/src/{ => graphar}/util.cc                      |   2 +-
 cpp/{include/graphar/util => src/graphar}/util.h   |   2 +-
 cpp/src/{ => graphar}/version_parser.cc            |   3 +-
 .../graphar/util => src/graphar}/version_parser.h  |   2 +-
 .../graphar/util => src/graphar}/writer_util.h     |   2 +-
 cpp/src/{ => graphar}/yaml.cc                      |   4 +-
 cpp/{include/graphar/util => src/graphar}/yaml.h   |   2 +-
 cpp/test/test_arrow_chunk_reader.cc                |   7 +-
 cpp/test/test_arrow_chunk_writer.cc                |   6 +-
 cpp/test/test_builder.cc                           |   5 +-
 cpp/test/test_chunk_info_reader.cc                 |   4 +-
 cpp/test/test_graph.cc                             |   3 +-
 cpp/test/test_info.cc                              |   7 +-
 71 files changed, 592 insertions(+), 489 deletions(-)

diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 2742c19f..c0d39d3a 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -205,11 +205,15 @@ macro(get_target_location var target)
   endif()
 endmacro()
 
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
+include_directories(src)
+
 # 
------------------------------------------------------------------------------
 # generate graphar library
 # 
------------------------------------------------------------------------------
 macro(build_graphar)
-    file(GLOB_RECURSE CORE_SRC_FILES "src/*.cc" 
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/mini-yaml/yaml/*.cpp)
+
+    file(GLOB_RECURSE CORE_SRC_FILES "src/graphar/*.cc" 
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/mini-yaml/yaml/*.cpp)
     add_library(graphar SHARED ${CORE_SRC_FILES})
     install_graphar_target(graphar)
     target_compile_features(graphar PRIVATE cxx_std_17)
@@ -266,7 +270,7 @@ endif()
 # 
------------------------------------------------------------------------------
 # Install
 # 
------------------------------------------------------------------------------
-install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/graphar
+install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/graphar
         DESTINATION include
         FILES_MATCHING
         PATTERN "*.h"
@@ -350,14 +354,15 @@ if (BUILD_BENCHMARKS)
     add_benchmark(arrow_chunk_reader_benchmark SRCS 
benchmarks/arrow_chunk_reader_benchmark.cc)
     add_benchmark(graph_info_benchmark SRCS benchmarks/graph_info_benchmark.cc)
 endif()
+
 # 
------------------------------------------------------------------------------
 # Format code & cpplint
 # 
------------------------------------------------------------------------------
-file(GLOB_RECURSE FILES_NEED_FORMAT "include/graphar/*.h" "src/*.cc"
+file(GLOB_RECURSE FILES_NEED_FORMAT "src/graphar/*.h" "src/graphar/*.cc"
                                     "test/*.h" "test/*.cc"
                                     "examples/*.h" "examples/*.cc"
                                     "benchmarks/*.h" "benchmarks/*.cc")
-file(GLOB_RECURSE FILES_NEED_LINT "include/graphar/*.h" "src/*.cc"
+file(GLOB_RECURSE FILES_NEED_LINT "src/graphar/*.h" "src/graphar/*.cc"
                                   "test/*.h" "test/*.cc"
                                   "examples/*.h" "examples/*.cc"
                                   "benchmarks/*.h" "benchmarks/*.cc")
diff --git a/cpp/benchmarks/arrow_chunk_reader_benchmark.cc 
b/cpp/benchmarks/arrow_chunk_reader_benchmark.cc
index db241ef7..833224a0 100644
--- a/cpp/benchmarks/arrow_chunk_reader_benchmark.cc
+++ b/cpp/benchmarks/arrow_chunk_reader_benchmark.cc
@@ -20,9 +20,7 @@
 #include "benchmark/benchmark.h"
 
 #include "./benchmark_util.h"
-#include "graphar/graph_info.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/util/adj_list_type.h"
+#include "graphar/api/arrow_reader.h"
 
 namespace graphar {
 
diff --git a/cpp/benchmarks/benchmark_util.h b/cpp/benchmarks/benchmark_util.h
index b68cd0fa..19cd4737 100644
--- a/cpp/benchmarks/benchmark_util.h
+++ b/cpp/benchmarks/benchmark_util.h
@@ -25,8 +25,7 @@
 
 #include "benchmark/benchmark.h"
 
-#include "graphar/graph_info.h"
-#include "graphar/util/status.h"
+#include "graphar/api/info.h"
 
 namespace graphar {
 
diff --git a/cpp/benchmarks/graph_info_benchmark.cc 
b/cpp/benchmarks/graph_info_benchmark.cc
index c193b0c6..efc3c752 100644
--- a/cpp/benchmarks/graph_info_benchmark.cc
+++ b/cpp/benchmarks/graph_info_benchmark.cc
@@ -20,7 +20,7 @@
 #include "benchmark/benchmark.h"
 
 #include "./benchmark_util.h"
-#include "graphar/graph_info.h"
+#include "graphar/api/info.h"
 
 namespace graphar {
 
diff --git a/cpp/examples/bfs_father_example.cc 
b/cpp/examples/bfs_father_example.cc
index 730bf76f..a864fdac 100644
--- a/cpp/examples/bfs_father_example.cc
+++ b/cpp/examples/bfs_father_example.cc
@@ -22,11 +22,8 @@
 #include "arrow/api.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/graph.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/writer/arrow_chunk_writer.h"
-#include "graphar/writer/edges_builder.h"
+#include "graphar/api/high_level_reader.h"
+#include "graphar/api/high_level_writer.h"
 
 int main(int argc, char* argv[]) {
   // read file and construct graph info
diff --git a/cpp/examples/bfs_pull_example.cc b/cpp/examples/bfs_pull_example.cc
index 1078aee3..83856a55 100644
--- a/cpp/examples/bfs_pull_example.cc
+++ b/cpp/examples/bfs_pull_example.cc
@@ -22,10 +22,8 @@
 #include "arrow/api.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/graph.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/writer/arrow_chunk_writer.h"
+#include "graphar/api/arrow_writer.h"
+#include "graphar/api/high_level_reader.h"
 
 int main(int argc, char* argv[]) {
   // read file and construct graph info
diff --git a/cpp/examples/bfs_push_example.cc b/cpp/examples/bfs_push_example.cc
index 7006514f..13c408df 100644
--- a/cpp/examples/bfs_push_example.cc
+++ b/cpp/examples/bfs_push_example.cc
@@ -22,10 +22,8 @@
 #include "arrow/api.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/graph.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/writer/arrow_chunk_writer.h"
+#include "graphar/api/arrow_writer.h"
+#include "graphar/api/high_level_reader.h"
 
 int main(int argc, char* argv[]) {
   // read file and construct graph info
diff --git a/cpp/examples/bfs_stream_example.cc 
b/cpp/examples/bfs_stream_example.cc
index b77fb307..1d04a3f8 100644
--- a/cpp/examples/bfs_stream_example.cc
+++ b/cpp/examples/bfs_stream_example.cc
@@ -22,10 +22,8 @@
 #include "arrow/api.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/graph.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/writer/arrow_chunk_writer.h"
+#include "graphar/api/arrow_writer.h"
+#include "graphar/api/high_level_reader.h"
 
 int main(int argc, char* argv[]) {
   // read file and construct graph info
diff --git a/cpp/examples/bgl_example.cc b/cpp/examples/bgl_example.cc
index c1d60bdd..6b7e6119 100644
--- a/cpp/examples/bgl_example.cc
+++ b/cpp/examples/bgl_example.cc
@@ -26,11 +26,9 @@
 #include "arrow/api.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/graph.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/writer/arrow_chunk_writer.h"
-#include "graphar/writer/vertices_builder.h"
+#include "graphar/api/arrow_writer.h"
+#include "graphar/api/high_level_reader.h"
+#include "graphar/api/high_level_writer.h"
 
 int main(int argc, char* argv[]) {
   // read file and construct graph info
diff --git a/cpp/examples/cc_push_example.cc b/cpp/examples/cc_push_example.cc
index aee56689..e9d03a2a 100644
--- a/cpp/examples/cc_push_example.cc
+++ b/cpp/examples/cc_push_example.cc
@@ -23,10 +23,8 @@
 #include "arrow/api.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/graph.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/writer/arrow_chunk_writer.h"
+#include "graphar/api/arrow_writer.h"
+#include "graphar/api/high_level_reader.h"
 
 int main(int argc, char* argv[]) {
   // read file and construct graph info
diff --git a/cpp/examples/cc_stream_example.cc 
b/cpp/examples/cc_stream_example.cc
index 23b97222..4425e244 100644
--- a/cpp/examples/cc_stream_example.cc
+++ b/cpp/examples/cc_stream_example.cc
@@ -23,10 +23,8 @@
 #include "arrow/api.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/graph.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/writer/arrow_chunk_writer.h"
+#include "graphar/api/arrow_writer.h"
+#include "graphar/api/high_level_reader.h"
 
 int main(int argc, char* argv[]) {
   // read file and construct graph info
diff --git a/cpp/examples/construct_info_example.cc 
b/cpp/examples/construct_info_example.cc
index 9ef6b4f5..b32f7e44 100644
--- a/cpp/examples/construct_info_example.cc
+++ b/cpp/examples/construct_info_example.cc
@@ -20,7 +20,7 @@
 #include <cassert>
 
 #include "./config.h"
-#include "graphar/api.h"
+#include "graphar/api/info.h"
 
 int main(int argc, char* argv[]) {
   /*------------------construct vertex info------------------*/
diff --git a/cpp/examples/high_level_reader_example.cc 
b/cpp/examples/high_level_reader_example.cc
index a25e2298..a8d37f39 100644
--- a/cpp/examples/high_level_reader_example.cc
+++ b/cpp/examples/high_level_reader_example.cc
@@ -23,7 +23,7 @@
 #include "arrow/filesystem/api.h"
 
 #include "./config.h"
-#include "graphar/graph.h"
+#include "graphar/api/high_level_reader.h"
 
 void vertices_collection(
     const std::shared_ptr<graphar::GraphInfo>& graph_info) {
diff --git a/cpp/examples/high_level_writer_example.cc 
b/cpp/examples/high_level_writer_example.cc
index a6f25aff..bead37a0 100644
--- a/cpp/examples/high_level_writer_example.cc
+++ b/cpp/examples/high_level_writer_example.cc
@@ -23,9 +23,7 @@
 #include "arrow/filesystem/api.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/writer/edges_builder.h"
-#include "graphar/writer/vertices_builder.h"
+#include "graphar/api/high_level_writer.h"
 
 void vertices_builder() {
   // construct vertices builder
diff --git a/cpp/examples/low_level_reader_example.cc 
b/cpp/examples/low_level_reader_example.cc
index c195639d..7f0768de 100644
--- a/cpp/examples/low_level_reader_example.cc
+++ b/cpp/examples/low_level_reader_example.cc
@@ -23,8 +23,7 @@
 #include "arrow/filesystem/api.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/reader/chunk_info_reader.h"
+#include "graphar/api/meta_reader.h"
 
 void vertex_property_chunk_info_reader(
     const std::shared_ptr<graphar::GraphInfo>& graph_info) {
diff --git a/cpp/examples/mid_level_reader_example.cc 
b/cpp/examples/mid_level_reader_example.cc
index 98456a33..ee0d8f44 100644
--- a/cpp/examples/mid_level_reader_example.cc
+++ b/cpp/examples/mid_level_reader_example.cc
@@ -23,9 +23,7 @@
 #include "arrow/filesystem/api.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/util/expression.h"
+#include "graphar/api/arrow_reader.h"
 
 void vertex_property_chunk_reader(
     const std::shared_ptr<graphar::GraphInfo>& graph_info) {
diff --git a/cpp/examples/mid_level_writer_example.cc 
b/cpp/examples/mid_level_writer_example.cc
index 7fe81a35..d6d7b6b4 100644
--- a/cpp/examples/mid_level_writer_example.cc
+++ b/cpp/examples/mid_level_writer_example.cc
@@ -24,8 +24,7 @@
 #include "arrow/result.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/writer/arrow_chunk_writer.h"
+#include "graphar/api/arrow_writer.h"
 
 arrow::Result<std::shared_ptr<arrow::Table>> generate_vertex_table() {
   // property "id"
diff --git a/cpp/examples/pagerank_example.cc b/cpp/examples/pagerank_example.cc
index 1fceb1f4..272498bf 100644
--- a/cpp/examples/pagerank_example.cc
+++ b/cpp/examples/pagerank_example.cc
@@ -23,10 +23,8 @@
 #include "arrow/filesystem/api.h"
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/graph.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/writer/arrow_chunk_writer.h"
+#include "graphar/api/high_level_reader.h"
+#include "graphar/api/high_level_writer.h"
 
 int main(int argc, char* argv[]) {
   // read file and construct graph info
diff --git a/cpp/examples/snap_dataset_to_graphar.cc 
b/cpp/examples/snap_dataset_to_graphar.cc
index c26583da..17da2818 100644
--- a/cpp/examples/snap_dataset_to_graphar.cc
+++ b/cpp/examples/snap_dataset_to_graphar.cc
@@ -21,9 +21,7 @@
 #include <iostream>
 
 #include "./config.h"
-#include "graphar/api.h"
-#include "graphar/writer/edges_builder.h"
-#include "graphar/writer/vertices_builder.h"
+#include "graphar/api/high_level_writer.h"
 
 // using facebook_combined.txt from SNAP dataset
 // available at https://snap.stanford.edu/data/ego-Facebook.html
diff --git a/cpp/include/graphar/util/adj_list_type.h 
b/cpp/include/graphar/util/adj_list_type.h
deleted file mode 100644
index 0da04dd0..00000000
--- a/cpp/include/graphar/util/adj_list_type.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#pragma once
-
-#include <map>
-#include <string>
-#include <utility>
-
-#include "graphar/util/macros.h"
-
-namespace graphar {
-
-/** Adj list type enumeration for adjacency list of graph. */
-enum class AdjListType : std::uint8_t {
-  /// collection of edges by source, but unordered, can represent COO format
-  unordered_by_source = 0b00000001,
-  /// collection of edges by destination, but unordered, can represent COO
-  /// format
-  unordered_by_dest = 0b00000010,
-  /// collection of edges by source, ordered by source, can represent CSR 
format
-  ordered_by_source = 0b00000100,
-  /// collection of edges by destination, ordered by destination, can represent
-  /// CSC format
-  ordered_by_dest = 0b00001000,
-};
-
-constexpr AdjListType operator|(AdjListType lhs, AdjListType rhs) {
-  return static_cast<AdjListType>(
-      static_cast<std::underlying_type_t<AdjListType>>(lhs) |
-      static_cast<std::underlying_type_t<AdjListType>>(rhs));
-}
-
-constexpr AdjListType operator&(AdjListType lhs, AdjListType rhs) {
-  return static_cast<AdjListType>(
-      static_cast<std::underlying_type_t<AdjListType>>(lhs) &
-      static_cast<std::underlying_type_t<AdjListType>>(rhs));
-}
-
-static inline const char* AdjListTypeToString(AdjListType adj_list_type) {
-  static const std::map<AdjListType, const char*> adj_list2string{
-      {AdjListType::unordered_by_source, "unordered_by_source"},
-      {AdjListType::unordered_by_dest, "unordered_by_dest"},
-      {AdjListType::ordered_by_source, "ordered_by_source"},
-      {AdjListType::ordered_by_dest, "ordered_by_dest"}};
-  return adj_list2string.at(adj_list_type);
-}
-
-static inline AdjListType OrderedAlignedToAdjListType(
-    bool ordered, const std::string& aligned) {
-  if (ordered) {
-    return aligned == "src" ? AdjListType::ordered_by_source
-                            : AdjListType::ordered_by_dest;
-  }
-  return aligned == "src" ? AdjListType::unordered_by_source
-                          : AdjListType::unordered_by_dest;
-}
-
-static inline std::pair<bool, std::string> AdjListTypeToOrderedAligned(
-    AdjListType adj_list_type) {
-  switch (adj_list_type) {
-  case AdjListType::unordered_by_source:
-    return std::make_pair(false, "src");
-  case AdjListType::unordered_by_dest:
-    return std::make_pair(false, "dst");
-  case AdjListType::ordered_by_source:
-    return std::make_pair(true, "src");
-  case AdjListType::ordered_by_dest:
-    return std::make_pair(true, "dst");
-  default:
-    return std::make_pair(false, "dst");
-  }
-}
-
-}  // namespace graphar
diff --git a/cpp/include/graphar/util/file_type.h 
b/cpp/include/graphar/util/file_type.h
deleted file mode 100644
index 7fc218ed..00000000
--- a/cpp/include/graphar/util/file_type.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#pragma once
-
-#include <map>
-#include <stdexcept>
-#include <string>
-
-#include "graphar/fwd.h"
-#include "graphar/util/macros.h"
-
-namespace graphar {
-
-static inline FileType StringToFileType(const std::string& str) {
-  static const std::map<std::string, FileType> str2file_type{
-      {"csv", FileType::CSV},
-      {"json", FileType::JSON},
-      {"parquet", FileType::PARQUET},
-      {"orc", FileType::ORC}};
-  try {
-    return str2file_type.at(str.c_str());
-  } catch (const std::exception& e) {
-    throw std::runtime_error("KeyError: " + str);
-  }
-}
-
-static inline const char* FileTypeToString(FileType file_type) {
-  static const std::map<FileType, const char*> file_type2string{
-      {FileType::CSV, "csv"},
-      {FileType::JSON, "json"},
-      {FileType::PARQUET, "parquet"},
-      {FileType::ORC, "orc"}};
-  return file_type2string.at(file_type);
-}
-
-}  // namespace graphar
diff --git a/cpp/include/graphar/util/general_params.h 
b/cpp/src/graphar/api/arrow_reader.h
similarity index 67%
copy from cpp/include/graphar/util/general_params.h
copy to cpp/src/graphar/api/arrow_reader.h
index 55db90fb..685572a3 100644
--- a/cpp/include/graphar/util/general_params.h
+++ b/cpp/src/graphar/api/arrow_reader.h
@@ -19,14 +19,6 @@
 
 #pragma once
 
-namespace graphar {
-
-struct GeneralParams {
-  static constexpr const char* kVertexIndexCol = "_graphArVertexIndex";
-  static constexpr const char* kSrcIndexCol = "_graphArSrcIndex";
-  static constexpr const char* kDstIndexCol = "_graphArDstIndex";
-  static constexpr const char* kOffsetCol = "_graphArOffset";
-  static constexpr const char* kPrimaryCol = "_graphArPrimary";
-};
-
-}  // namespace graphar
+#include "graphar/api/info.h"
+#include "graphar/arrow/chunk_reader.h"
+#include "graphar/expression.h"
diff --git a/cpp/include/graphar/util/general_params.h 
b/cpp/src/graphar/api/arrow_writer.h
similarity index 67%
copy from cpp/include/graphar/util/general_params.h
copy to cpp/src/graphar/api/arrow_writer.h
index 55db90fb..e1cebeca 100644
--- a/cpp/include/graphar/util/general_params.h
+++ b/cpp/src/graphar/api/arrow_writer.h
@@ -19,14 +19,5 @@
 
 #pragma once
 
-namespace graphar {
-
-struct GeneralParams {
-  static constexpr const char* kVertexIndexCol = "_graphArVertexIndex";
-  static constexpr const char* kSrcIndexCol = "_graphArSrcIndex";
-  static constexpr const char* kDstIndexCol = "_graphArDstIndex";
-  static constexpr const char* kOffsetCol = "_graphArOffset";
-  static constexpr const char* kPrimaryCol = "_graphArPrimary";
-};
-
-}  // namespace graphar
+#include "graphar/api/info.h"
+#include "graphar/arrow/chunk_writer.h"
diff --git a/cpp/include/graphar/util/general_params.h 
b/cpp/src/graphar/api/high_level_reader.h
similarity index 67%
copy from cpp/include/graphar/util/general_params.h
copy to cpp/src/graphar/api/high_level_reader.h
index 55db90fb..f7e23dc0 100644
--- a/cpp/include/graphar/util/general_params.h
+++ b/cpp/src/graphar/api/high_level_reader.h
@@ -19,14 +19,5 @@
 
 #pragma once
 
-namespace graphar {
-
-struct GeneralParams {
-  static constexpr const char* kVertexIndexCol = "_graphArVertexIndex";
-  static constexpr const char* kSrcIndexCol = "_graphArSrcIndex";
-  static constexpr const char* kDstIndexCol = "_graphArDstIndex";
-  static constexpr const char* kOffsetCol = "_graphArOffset";
-  static constexpr const char* kPrimaryCol = "_graphArPrimary";
-};
-
-}  // namespace graphar
+#include "graphar/api/info.h"
+#include "graphar/high-level/graph_reader.h"
diff --git a/cpp/include/graphar/util/general_params.h 
b/cpp/src/graphar/api/high_level_writer.h
similarity index 67%
copy from cpp/include/graphar/util/general_params.h
copy to cpp/src/graphar/api/high_level_writer.h
index 55db90fb..552f3049 100644
--- a/cpp/include/graphar/util/general_params.h
+++ b/cpp/src/graphar/api/high_level_writer.h
@@ -19,14 +19,6 @@
 
 #pragma once
 
-namespace graphar {
-
-struct GeneralParams {
-  static constexpr const char* kVertexIndexCol = "_graphArVertexIndex";
-  static constexpr const char* kSrcIndexCol = "_graphArSrcIndex";
-  static constexpr const char* kDstIndexCol = "_graphArDstIndex";
-  static constexpr const char* kOffsetCol = "_graphArOffset";
-  static constexpr const char* kPrimaryCol = "_graphArPrimary";
-};
-
-}  // namespace graphar
+#include "graphar/api/info.h"
+#include "graphar/high-level/edges_builder.h"
+#include "graphar/high-level/vertices_builder.h"
diff --git a/cpp/include/graphar/api.h b/cpp/src/graphar/api/info.h
similarity index 68%
rename from cpp/include/graphar/api.h
rename to cpp/src/graphar/api/info.h
index 8a61add6..52281648 100644
--- a/cpp/include/graphar/api.h
+++ b/cpp/src/graphar/api/info.h
@@ -19,15 +19,13 @@
 
 #pragma once
 
+// Infos
+#include "graphar/filesystem.h"
+#include "graphar/general_params.h"
 #include "graphar/graph_info.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/util/data_type.h"
-#include "graphar/util/file_type.h"
-#include "graphar/util/filesystem.h"
-#include "graphar/util/general_params.h"
-#include "graphar/util/macros.h"
-#include "graphar/util/result.h"
-#include "graphar/util/status.h"
-#include "graphar/util/util.h"
-#include "graphar/util/version_parser.h"
-#include "graphar/util/yaml.h"
+#include "graphar/macros.h"
+#include "graphar/result.h"
+#include "graphar/status.h"
+#include "graphar/types.h"
+#include "graphar/version_parser.h"
+#include "graphar/yaml.h"
diff --git a/cpp/include/graphar/util/general_params.h 
b/cpp/src/graphar/api/meta_reader.h
similarity index 67%
copy from cpp/include/graphar/util/general_params.h
copy to cpp/src/graphar/api/meta_reader.h
index 55db90fb..9054a3d8 100644
--- a/cpp/include/graphar/util/general_params.h
+++ b/cpp/src/graphar/api/meta_reader.h
@@ -19,14 +19,5 @@
 
 #pragma once
 
-namespace graphar {
-
-struct GeneralParams {
-  static constexpr const char* kVertexIndexCol = "_graphArVertexIndex";
-  static constexpr const char* kSrcIndexCol = "_graphArSrcIndex";
-  static constexpr const char* kDstIndexCol = "_graphArDstIndex";
-  static constexpr const char* kOffsetCol = "_graphArOffset";
-  static constexpr const char* kPrimaryCol = "_graphArPrimary";
-};
-
-}  // namespace graphar
+#include "graphar/api/info.h"
+#include "graphar/chunk_info_reader.h"
diff --git a/cpp/include/graphar/util/general_params.h 
b/cpp/src/graphar/api/meta_writer.h
similarity index 67%
copy from cpp/include/graphar/util/general_params.h
copy to cpp/src/graphar/api/meta_writer.h
index 55db90fb..bcc8964e 100644
--- a/cpp/include/graphar/util/general_params.h
+++ b/cpp/src/graphar/api/meta_writer.h
@@ -19,14 +19,5 @@
 
 #pragma once
 
-namespace graphar {
-
-struct GeneralParams {
-  static constexpr const char* kVertexIndexCol = "_graphArVertexIndex";
-  static constexpr const char* kSrcIndexCol = "_graphArSrcIndex";
-  static constexpr const char* kDstIndexCol = "_graphArDstIndex";
-  static constexpr const char* kOffsetCol = "_graphArOffset";
-  static constexpr const char* kPrimaryCol = "_graphArPrimary";
-};
-
-}  // namespace graphar
+#include "graphar/api/info.h"
+#include "graphar/chunk_info_writer.h"
diff --git a/cpp/src/arrow_chunk_reader.cc 
b/cpp/src/graphar/arrow/chunk_reader.cc
similarity index 98%
rename from cpp/src/arrow_chunk_reader.cc
rename to cpp/src/graphar/arrow/chunk_reader.cc
index 40a88163..099d451b 100644
--- a/cpp/src/arrow_chunk_reader.cc
+++ b/cpp/src/graphar/arrow/chunk_reader.cc
@@ -17,19 +17,20 @@
  * under the License.
  */
 
+#include <utility>
+
 #include "arrow/api.h"
 #include "arrow/compute/api.h"
 
+#include "graphar/arrow/chunk_reader.h"
+#include "graphar/filesystem.h"
+#include "graphar/general_params.h"
 #include "graphar/graph_info.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/util/data_type.h"
-#include "graphar/util/filesystem.h"
-#include "graphar/util/general_params.h"
-#include "graphar/util/reader_util.h"
-#include "graphar/util/result.h"
-#include "graphar/util/status.h"
-#include "graphar/util/util.h"
+#include "graphar/reader_util.h"
+#include "graphar/result.h"
+#include "graphar/status.h"
+#include "graphar/types.h"
+#include "graphar/util.h"
 
 namespace graphar {
 
diff --git a/cpp/include/graphar/reader/arrow_chunk_reader.h 
b/cpp/src/graphar/arrow/chunk_reader.h
similarity index 99%
rename from cpp/include/graphar/reader/arrow_chunk_reader.h
rename to cpp/src/graphar/arrow/chunk_reader.h
index b0c90516..89818319 100644
--- a/cpp/include/graphar/reader/arrow_chunk_reader.h
+++ b/cpp/src/graphar/arrow/chunk_reader.h
@@ -25,7 +25,7 @@
 #include <vector>
 
 #include "graphar/fwd.h"
-#include "graphar/util/reader_util.h"
+#include "graphar/reader_util.h"
 
 // forward declaration
 namespace arrow {
diff --git a/cpp/src/arrow_chunk_writer.cc 
b/cpp/src/graphar/arrow/chunk_writer.cc
similarity index 93%
rename from cpp/src/arrow_chunk_writer.cc
rename to cpp/src/graphar/arrow/chunk_writer.cc
index b62e496e..419f13bd 100644
--- a/cpp/src/arrow_chunk_writer.cc
+++ b/cpp/src/graphar/arrow/chunk_writer.cc
@@ -18,6 +18,7 @@
  */
 
 #include <iostream>
+#include <utility>
 
 #include "arrow/api.h"
 #include "arrow/compute/api.h"
@@ -32,15 +33,14 @@
 #include "arrow/dataset/plan.h"
 #include "arrow/dataset/scanner.h"
 
+#include "graphar/arrow/chunk_writer.h"
+#include "graphar/filesystem.h"
+#include "graphar/general_params.h"
 #include "graphar/graph_info.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/util/data_type.h"
-#include "graphar/util/filesystem.h"
-#include "graphar/util/general_params.h"
-#include "graphar/util/result.h"
-#include "graphar/util/status.h"
-#include "graphar/util/util.h"
-#include "graphar/writer/arrow_chunk_writer.h"
+#include "graphar/result.h"
+#include "graphar/status.h"
+#include "graphar/types.h"
+#include "graphar/util.h"
 
 namespace graphar {
 // common methods
@@ -206,17 +206,6 @@ Status VertexPropertyWriter::WriteVerticesNum(
   return fs_->WriteValueToFile<IdType>(count, path);
 }
 
-Status VertexPropertyWriter::WriteChunk(
-    const std::string& file_name,
-    const std::shared_ptr<PropertyGroup>& property_group, IdType chunk_index,
-    ValidateLevel validate_level) const {
-  GAR_RETURN_NOT_OK(validate(property_group, chunk_index, validate_level));
-  GAR_ASSIGN_OR_RAISE(auto suffix,
-                      vertex_info_->GetFilePath(property_group, chunk_index));
-  std::string path = prefix_ + suffix;
-  return fs_->CopyFile(file_name, path);
-}
-
 Status VertexPropertyWriter::WriteChunk(
     const std::shared_ptr<arrow::Table>& input_table,
     const std::shared_ptr<PropertyGroup>& property_group, IdType chunk_index,
@@ -590,42 +579,6 @@ Status EdgeChunkWriter::WriteVerticesNum(const IdType& 
count,
   return fs_->WriteValueToFile<IdType>(count, path);
 }
 
-Status EdgeChunkWriter::WriteOffsetChunk(const std::string& file_name,
-                                         IdType vertex_chunk_index,
-                                         ValidateLevel validate_level) const {
-  GAR_RETURN_NOT_OK(validate(vertex_chunk_index, 0, validate_level));
-  GAR_ASSIGN_OR_RAISE(auto suffix, edge_info_->GetAdjListOffsetFilePath(
-                                       vertex_chunk_index, adj_list_type_));
-  std::string path = prefix_ + suffix;
-  return fs_->CopyFile(file_name, path);
-}
-
-Status EdgeChunkWriter::WriteAdjListChunk(const std::string& file_name,
-                                          IdType vertex_chunk_index,
-                                          IdType chunk_index,
-                                          ValidateLevel validate_level) const {
-  GAR_RETURN_NOT_OK(validate(vertex_chunk_index, chunk_index, validate_level));
-  GAR_ASSIGN_OR_RAISE(
-      auto suffix, edge_info_->GetAdjListFilePath(vertex_chunk_index,
-                                                  chunk_index, 
adj_list_type_));
-  std::string path = prefix_ + suffix;
-  return fs_->CopyFile(file_name, path);
-}
-
-Status EdgeChunkWriter::WritePropertyChunk(
-    const std::string& file_name,
-    const std::shared_ptr<PropertyGroup>& property_group,
-    IdType vertex_chunk_index, IdType chunk_index,
-    ValidateLevel validate_level) const {
-  GAR_RETURN_NOT_OK(validate(property_group, vertex_chunk_index, chunk_index,
-                             validate_level));
-  GAR_ASSIGN_OR_RAISE(auto suffix, edge_info_->GetPropertyFilePath(
-                                       property_group, adj_list_type_,
-                                       vertex_chunk_index, chunk_index));
-  std::string path = prefix_ + suffix;
-  return fs_->CopyFile(file_name, path);
-}
-
 Status EdgeChunkWriter::WriteOffsetChunk(
     const std::shared_ptr<arrow::Table>& input_table, IdType 
vertex_chunk_index,
     ValidateLevel validate_level) const {
diff --git a/cpp/include/graphar/writer/arrow_chunk_writer.h 
b/cpp/src/graphar/arrow/chunk_writer.h
similarity index 91%
rename from cpp/include/graphar/writer/arrow_chunk_writer.h
rename to cpp/src/graphar/arrow/chunk_writer.h
index 0a0496bc..bfcde74a 100644
--- a/cpp/include/graphar/writer/arrow_chunk_writer.h
+++ b/cpp/src/graphar/arrow/chunk_writer.h
@@ -24,7 +24,7 @@
 #include <vector>
 
 #include "graphar/fwd.h"
-#include "graphar/util/writer_util.h"
+#include "graphar/writer_util.h"
 
 // forward declaration
 namespace arrow {
@@ -101,20 +101,6 @@ class VertexPropertyWriter {
       const IdType& count,
       ValidateLevel validate_level = ValidateLevel::default_validate) const;
 
-  /**
-   * @brief Copy a file as a vertex property group chunk.
-   *
-   * @param file_name The file to copy.
-   * @param property_group The property group.
-   * @param chunk_index The index of the vertex chunk.
-   * @param validate_level The validate level for this operation,
-   * which is the writer's validate level by default.
-   * @return Status: ok or error.
-   */
-  Status WriteChunk(
-      const std::string& file_name,
-      const std::shared_ptr<PropertyGroup>& property_group, IdType chunk_index,
-      ValidateLevel validate_level = ValidateLevel::default_validate) const;
   /**
    * @brief Validate and write a single property group for a
    * single vertex chunk.
@@ -330,51 +316,6 @@ class EdgeChunkWriter {
       const IdType& count,
       ValidateLevel validate_level = ValidateLevel::default_validate) const;
 
-  /**
-   * @brief Copy a file as a offset chunk.
-   *
-   * @param file_name The file to copy.
-   * @param vertex_chunk_index The index of the vertex chunk.
-   * @param validate_level The validate level for this operation,
-   * which is the writer's validate level by default.
-   * @return Status: ok or error.
-   */
-  Status WriteOffsetChunk(
-      const std::string& file_name, IdType vertex_chunk_index,
-      ValidateLevel validate_level = ValidateLevel::default_validate) const;
-
-  /**
-   * @brief Copy a file as an adj list chunk.
-   *
-   * @param file_name The file to copy.
-   * @param vertex_chunk_index The index of the vertex chunk.
-   * @param chunk_index The index of the edge chunk inside the vertex chunk.
-   * @param validate_level The validate level for this operation,
-   * which is the writer's validate level by default.
-   * @return Status: ok or error.
-   */
-  Status WriteAdjListChunk(
-      const std::string& file_name, IdType vertex_chunk_index,
-      IdType chunk_index,
-      ValidateLevel validate_level = ValidateLevel::default_validate) const;
-
-  /**
-   * @brief Copy a file as an edge property group chunk.
-   *
-   * @param file_name The file to copy.
-   * @param property_group The property group to write.
-   * @param vertex_chunk_index The index of the vertex chunk.
-   * @param chunk_index The index of the edge chunk inside the vertex chunk.
-   * @param validate_level The validate level for this operation,
-   * which is the writer's validate level by default.
-   * @return Status: ok or error.
-   */
-  Status WritePropertyChunk(
-      const std::string& file_name,
-      const std::shared_ptr<PropertyGroup>& property_group,
-      IdType vertex_chunk_index, IdType chunk_index,
-      ValidateLevel validate_level = ValidateLevel::default_validate) const;
-
   /**
    * @brief Validate and write the offset chunk for a vertex chunk.
    *
diff --git a/cpp/src/chunk_info_reader.cc b/cpp/src/graphar/chunk_info_reader.cc
similarity index 98%
rename from cpp/src/chunk_info_reader.cc
rename to cpp/src/graphar/chunk_info_reader.cc
index 13f48dc4..86ba5747 100644
--- a/cpp/src/chunk_info_reader.cc
+++ b/cpp/src/graphar/chunk_info_reader.cc
@@ -18,14 +18,15 @@
  */
 
 #include <iostream>
+#include <utility>
 
+#include "graphar/chunk_info_reader.h"
+#include "graphar/filesystem.h"
 #include "graphar/graph_info.h"
-#include "graphar/reader/chunk_info_reader.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/util/filesystem.h"
-#include "graphar/util/reader_util.h"
-#include "graphar/util/result.h"
-#include "graphar/util/util.h"
+#include "graphar/reader_util.h"
+#include "graphar/result.h"
+#include "graphar/types.h"
+#include "graphar/util.h"
 
 namespace graphar {
 
diff --git a/cpp/include/graphar/reader/chunk_info_reader.h 
b/cpp/src/graphar/chunk_info_reader.h
similarity index 100%
rename from cpp/include/graphar/reader/chunk_info_reader.h
rename to cpp/src/graphar/chunk_info_reader.h
diff --git a/cpp/src/graphar/chunk_info_writer.cc 
b/cpp/src/graphar/chunk_info_writer.cc
new file mode 100644
index 00000000..ba941d55
--- /dev/null
+++ b/cpp/src/graphar/chunk_info_writer.cc
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "graphar/chunk_info_writer.h"
+#include "graphar/filesystem.h"
+#include "graphar/graph_info.h"
+#include "graphar/result.h"
+#include "graphar/types.h"
+#include "graphar/util.h"
+
+namespace graphar {
+
+VertexChunkInfoWriter::VertexChunkInfoWriter(
+    const std::shared_ptr<VertexInfo>& vertex_info, const std::string& prefix,
+    const ValidateLevel& validate_level)
+    : vertex_info_(vertex_info),
+      prefix_(prefix),
+      validate_level_(validate_level) {
+  if (validate_level_ == ValidateLevel::default_validate) {
+    throw std::runtime_error(
+        "default_validate is not allowed to be set as the global validate "
+        "level for VertexPropertyWriter");
+  }
+  GAR_ASSIGN_OR_RAISE_ERROR(fs_, FileSystemFromUriOrPath(prefix, &prefix_));
+}
+
+// Check if the operation of copying a file as a chunk is allowed.
+Status VertexChunkInfoWriter::validate(
+    const std::shared_ptr<PropertyGroup>& property_group, IdType chunk_index,
+    ValidateLevel validate_level) const {
+  // use the writer's validate level
+  if (validate_level == ValidateLevel::default_validate)
+    validate_level = validate_level_;
+  // no validate
+  if (validate_level == ValidateLevel::no_validate)
+    return Status::OK();
+  // weak & strong validate
+  if (!vertex_info_->HasPropertyGroup(property_group)) {
+    return Status::KeyError("The property group", " does not exist in ",
+                            vertex_info_->GetLabel(), " vertex info.");
+  }
+  if (chunk_index < 0) {
+    return Status::IndexError("Negative chunk index ", chunk_index, ".");
+  }
+  return Status::OK();
+}
+
+Status VertexChunkInfoWriter::WriteChunk(
+    const std::string& file_name,
+    const std::shared_ptr<PropertyGroup>& property_group, IdType chunk_index,
+    ValidateLevel validate_level) const {
+  GAR_RETURN_NOT_OK(validate(property_group, chunk_index, validate_level));
+  GAR_ASSIGN_OR_RAISE(auto suffix,
+                      vertex_info_->GetFilePath(property_group, chunk_index));
+  std::string path = prefix_ + suffix;
+  return fs_->CopyFile(file_name, path);
+}
+
+EdgeChunkInfoWriter::EdgeChunkInfoWriter(
+    const std::shared_ptr<EdgeInfo>& edge_info, const std::string& prefix,
+    AdjListType adj_list_type, const ValidateLevel& validate_level)
+    : edge_info_(edge_info),
+      adj_list_type_(adj_list_type),
+      validate_level_(validate_level) {
+  if (validate_level_ == ValidateLevel::default_validate) {
+    throw std::runtime_error(
+        "default_validate is not allowed to be set as the global validate "
+        "level for EdgeChunkWriter");
+  }
+  GAR_ASSIGN_OR_RAISE_ERROR(fs_, FileSystemFromUriOrPath(prefix, &prefix_));
+  chunk_size_ = edge_info_->GetChunkSize();
+  switch (adj_list_type) {
+  case AdjListType::unordered_by_source:
+    vertex_chunk_size_ = edge_info_->GetSrcChunkSize();
+    break;
+  case AdjListType::ordered_by_source:
+    vertex_chunk_size_ = edge_info_->GetSrcChunkSize();
+    break;
+  case AdjListType::unordered_by_dest:
+    vertex_chunk_size_ = edge_info_->GetDstChunkSize();
+    break;
+  case AdjListType::ordered_by_dest:
+    vertex_chunk_size_ = edge_info_->GetDstChunkSize();
+    break;
+  default:
+    vertex_chunk_size_ = edge_info_->GetSrcChunkSize();
+  }
+}
+
+// Check if the operation of writing number or copying a file is allowed.
+Status EdgeChunkInfoWriter::validate(IdType count_or_index1,
+                                     IdType count_or_index2,
+                                     ValidateLevel validate_level) const {
+  // use the writer's validate level
+  if (validate_level == ValidateLevel::default_validate)
+    validate_level = validate_level_;
+  // no validate
+  if (validate_level == ValidateLevel::no_validate)
+    return Status::OK();
+  // weak & strong validate for adj list type
+  if (!edge_info_->HasAdjacentListType(adj_list_type_)) {
+    return Status::KeyError(
+        "Adj list type ", AdjListTypeToString(adj_list_type_),
+        " does not exist in the ", edge_info_->GetEdgeLabel(), " edge info.");
+  }
+  // weak & strong validate for count or index
+  if (count_or_index1 < 0 || count_or_index2 < 0) {
+    return Status::IndexError(
+        "The count or index must be non-negative, but got ", count_or_index1,
+        " and ", count_or_index2, ".");
+  }
+  return Status::OK();
+}
+
+// Check if the operation of copying a file as a property chunk is allowed.
+Status EdgeChunkInfoWriter::validate(
+    const std::shared_ptr<PropertyGroup>& property_group,
+    IdType vertex_chunk_index, IdType chunk_index,
+    ValidateLevel validate_level) const {
+  // use the writer's validate level
+  if (validate_level == ValidateLevel::default_validate)
+    validate_level = validate_level_;
+  // no validate
+  if (validate_level == ValidateLevel::no_validate)
+    return Status::OK();
+  // validate for adj list type & index
+  GAR_RETURN_NOT_OK(validate(vertex_chunk_index, chunk_index, validate_level));
+  // weak & strong validate for property group
+  if (!edge_info_->HasPropertyGroup(property_group)) {
+    return Status::KeyError("Property group", " does not exist in the ",
+                            edge_info_->GetEdgeLabel(), " edge info.");
+  }
+  return Status::OK();
+}
+
+Status EdgeChunkInfoWriter::WriteAdjListChunk(
+    const std::string& file_name, IdType vertex_chunk_index, IdType 
chunk_index,
+    ValidateLevel validate_level) const {
+  GAR_RETURN_NOT_OK(validate(vertex_chunk_index, chunk_index, validate_level));
+  GAR_ASSIGN_OR_RAISE(
+      auto suffix, edge_info_->GetAdjListFilePath(vertex_chunk_index,
+                                                  chunk_index, 
adj_list_type_));
+  std::string path = prefix_ + suffix;
+  return fs_->CopyFile(file_name, path);
+}
+
+Status EdgeChunkInfoWriter::WriteOffsetChunk(
+    const std::string& file_name, IdType vertex_chunk_index,
+    ValidateLevel validate_level) const {
+  GAR_RETURN_NOT_OK(validate(vertex_chunk_index, 0, validate_level));
+  GAR_ASSIGN_OR_RAISE(auto suffix, edge_info_->GetAdjListOffsetFilePath(
+                                       vertex_chunk_index, adj_list_type_));
+  std::string path = prefix_ + suffix;
+  return fs_->CopyFile(file_name, path);
+}
+
+Status EdgeChunkInfoWriter::WritePropertyChunk(
+    const std::string& file_name,
+    const std::shared_ptr<PropertyGroup>& property_group,
+    IdType vertex_chunk_index, IdType chunk_index,
+    ValidateLevel validate_level) const {
+  GAR_RETURN_NOT_OK(validate(property_group, vertex_chunk_index, chunk_index,
+                             validate_level));
+  GAR_ASSIGN_OR_RAISE(auto suffix, edge_info_->GetPropertyFilePath(
+                                       property_group, adj_list_type_,
+                                       vertex_chunk_index, chunk_index));
+  std::string path = prefix_ + suffix;
+  return fs_->CopyFile(file_name, path);
+}
+}  // namespace graphar
diff --git a/cpp/src/graphar/chunk_info_writer.h 
b/cpp/src/graphar/chunk_info_writer.h
new file mode 100644
index 00000000..0086bbd2
--- /dev/null
+++ b/cpp/src/graphar/chunk_info_writer.h
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "graphar/fwd.h"
+#include "graphar/writer_util.h"
+
+namespace graphar {
+
+class VertexChunkInfoWriter {
+ public:
+  /**
+   * @brief Copy a file as a vertex property group chunk.
+   *
+   * @param file_name The file to copy.
+   * @param property_group The property group.
+   * @param chunk_index The index of the vertex chunk.
+   * @param validate_level The validate level for this operation,
+   * which is the writer's validate level by default.
+   * @return Status: ok or error.
+   */
+
+  /**
+   * @brief Initialize the VertexChunkWriter.
+   *
+   * @param vertex_info The vertex info that describes the vertex type.
+   * @param prefix The absolute prefix.
+   */
+  explicit VertexChunkInfoWriter(
+      const std::shared_ptr<VertexInfo>& vertex_info, const std::string& 
prefix,
+      const ValidateLevel& validate_level = ValidateLevel::no_validate);
+
+  Status WriteChunk(
+      const std::string& file_name,
+      const std::shared_ptr<PropertyGroup>& property_group, IdType chunk_index,
+      ValidateLevel validate_level = ValidateLevel::no_validate) const;
+
+ private:
+  /**
+   * @brief Check if the operation of copying a file as a chunk is allowed.
+   *
+   * @param property_group The property group to write.
+   * @param chunk_index The index of the vertex chunk.
+   * @param validate_level The validate level for this operation.
+   * @return Status: ok or error.
+   */
+  Status validate(const std::shared_ptr<PropertyGroup>& property_group,
+                  IdType chunk_index, ValidateLevel validate_level) const;
+
+ private:
+  std::shared_ptr<VertexInfo> vertex_info_;
+  std::string prefix_;
+  std::shared_ptr<FileSystem> fs_;
+  ValidateLevel validate_level_;
+};
+
+class EdgeChunkInfoWriter {
+  /**
+   * @brief Initialize the EdgeChunkWriter.
+   *
+   * @param edge_info The edge info that describes the edge type.
+   * @param prefix The absolute prefix.
+   * @param adj_list_type The adj list type for the edges.
+   * @param validate_level The global validate level for the writer, with no
+   * validate by default. It could be ValidateLevel::no_validate,
+   * ValidateLevel::weak_validate or ValidateLevel::strong_validate, but could
+   * not be ValidateLevel::default_validate.
+   */
+  explicit EdgeChunkInfoWriter(
+      const std::shared_ptr<EdgeInfo>& edge_info, const std::string& prefix,
+      AdjListType adj_list_type,
+      const ValidateLevel& validate_level = ValidateLevel::no_validate);
+
+  /**
+   * @brief Copy a file as an adj list chunk.
+   *
+   * @param file_name The file to copy.
+   * @param vertex_chunk_index The index of the vertex chunk.
+   * @param chunk_index The index of the edge chunk inside the vertex chunk.
+   * @param validate_level The validate level for this operation,
+   * which is the writer's validate level by default.
+   * @return Status: ok or error.
+   */
+  Status WriteAdjListChunk(
+      const std::string& file_name, IdType vertex_chunk_index,
+      IdType chunk_index,
+      ValidateLevel validate_level = ValidateLevel::default_validate) const;
+
+  /**
+   * @brief Copy a file as a offset chunk.
+   *
+   * @param file_name The file to copy.
+   * @param vertex_chunk_index The index of the vertex chunk.
+   * @param validate_level The validate level for this operation,
+   * which is the writer's validate level by default.
+   * @return Status: ok or error.
+   */
+  Status WriteOffsetChunk(
+      const std::string& file_name, IdType vertex_chunk_index,
+      ValidateLevel validate_level = ValidateLevel::default_validate) const;
+
+  /**
+   * @brief Copy a file as an edge property group chunk.
+   *
+   * @param file_name The file to copy.
+   * @param property_group The property group to write.
+   * @param vertex_chunk_index The index of the vertex chunk.
+   * @param chunk_index The index of the edge chunk inside the vertex chunk.
+   * @param validate_level The validate level for this operation,
+   * which is the writer's validate level by default.
+   * @return Status: ok or error.
+   */
+  Status WritePropertyChunk(
+      const std::string& file_name,
+      const std::shared_ptr<PropertyGroup>& property_group,
+      IdType vertex_chunk_index, IdType chunk_index,
+      ValidateLevel validate_level = ValidateLevel::default_validate) const;
+
+ private:
+  /**
+   * @brief Check if the operation of writing number or copying a file is
+   * allowed.
+   *
+   * @param count_or_index1 The first count or index used by the operation.
+   * @param count_or_index2 The second count or index used by the operation.
+   * @param validate_level The validate level for this operation.
+   * @return Status: ok or error.
+   */
+  Status validate(IdType count_or_index1, IdType count_or_index2,
+                  ValidateLevel validate_level) const;
+
+  /**
+   * @brief Check if the operation of copying a file as a property chunk is
+   * allowed.
+   *
+   * @param property_group The property group to write.
+   * @param vertex_chunk_index The index of the vertex chunk.
+   * @param chunk_index The index of the edge chunk inside the vertex chunk.
+   * @param validate_level The validate level for this operation.
+   * @return Status: ok or error.
+   */
+  Status validate(const std::shared_ptr<PropertyGroup>& property_group,
+                  IdType vertex_chunk_index, IdType chunk_index,
+                  ValidateLevel validate_level) const;
+
+ private:
+  std::shared_ptr<EdgeInfo> edge_info_;
+  IdType vertex_chunk_size_;
+  IdType chunk_size_;
+  AdjListType adj_list_type_;
+  std::string prefix_;
+  std::shared_ptr<FileSystem> fs_;
+  ValidateLevel validate_level_;
+};
+}  // namespace graphar
diff --git a/cpp/include/graphar/util/convert_to_arrow_type.h 
b/cpp/src/graphar/convert_to_arrow_type.h
similarity index 99%
rename from cpp/include/graphar/util/convert_to_arrow_type.h
rename to cpp/src/graphar/convert_to_arrow_type.h
index 764801a6..8710ddbb 100644
--- a/cpp/include/graphar/util/convert_to_arrow_type.h
+++ b/cpp/src/graphar/convert_to_arrow_type.h
@@ -25,7 +25,7 @@
 #include "arrow/api.h"
 #include "arrow/type.h"
 
-#include "graphar/util/data_type.h"
+#include "graphar/types.h"
 
 namespace graphar {
 
diff --git a/cpp/src/expression.cc b/cpp/src/graphar/expression.cc
similarity index 97%
rename from cpp/src/expression.cc
rename to cpp/src/graphar/expression.cc
index f5bf89ff..843e9637 100644
--- a/cpp/src/expression.cc
+++ b/cpp/src/graphar/expression.cc
@@ -17,8 +17,8 @@
  * under the License.
  */
 
-#include "graphar/util/expression.h"
-#include "graphar/util/result.h"
+#include "graphar/expression.h"
+#include "graphar/result.h"
 
 namespace graphar {
 
diff --git a/cpp/include/graphar/util/expression.h 
b/cpp/src/graphar/expression.h
similarity index 100%
rename from cpp/include/graphar/util/expression.h
rename to cpp/src/graphar/expression.h
diff --git a/cpp/src/filesystem.cc b/cpp/src/graphar/filesystem.cc
similarity index 99%
rename from cpp/src/filesystem.cc
rename to cpp/src/graphar/filesystem.cc
index 23b9ec0b..03c03e37 100644
--- a/cpp/src/filesystem.cc
+++ b/cpp/src/graphar/filesystem.cc
@@ -27,9 +27,9 @@
 #include "parquet/arrow/writer.h"
 #include "simple-uri-parser/uri_parser.h"
 
+#include "graphar/expression.h"
+#include "graphar/filesystem.h"
 #include "graphar/fwd.h"
-#include "graphar/util/expression.h"
-#include "graphar/util/filesystem.h"
 
 namespace graphar::detail {
 template <typename U, typename T>
diff --git a/cpp/include/graphar/util/filesystem.h 
b/cpp/src/graphar/filesystem.h
similarity index 96%
rename from cpp/include/graphar/util/filesystem.h
rename to cpp/src/graphar/filesystem.h
index 712a90b9..ec11216a 100644
--- a/cpp/include/graphar/util/filesystem.h
+++ b/cpp/src/graphar/filesystem.h
@@ -24,12 +24,12 @@
 #include <string>
 #include <vector>
 
-#include "graphar/util/file_type.h"
-#include "graphar/util/result.h"
-#include "graphar/util/status.h"
-#include "graphar/util/util.h"
+#include "graphar/result.h"
+#include "graphar/status.h"
+#include "graphar/types.h"
+#include "graphar/util.h"
 
-#include "graphar/util/reader_util.h"
+#include "graphar/reader_util.h"
 
 // forward declarations
 namespace arrow {
diff --git a/cpp/include/graphar/fwd.h b/cpp/src/graphar/fwd.h
similarity index 99%
rename from cpp/include/graphar/fwd.h
rename to cpp/src/graphar/fwd.h
index d053a165..027ffa64 100644
--- a/cpp/include/graphar/fwd.h
+++ b/cpp/src/graphar/fwd.h
@@ -27,8 +27,8 @@
 
 #include "result/result.hpp"
 
-#include "graphar/util/macros.h"
-#include "graphar/util/status.h"
+#include "graphar/macros.h"
+#include "graphar/status.h"
 
 namespace graphar {
 
diff --git a/cpp/include/graphar/util/general_params.h 
b/cpp/src/graphar/general_params.h
similarity index 100%
rename from cpp/include/graphar/util/general_params.h
rename to cpp/src/graphar/general_params.h
diff --git a/cpp/src/graph_info.cc b/cpp/src/graphar/graph_info.cc
similarity index 99%
rename from cpp/src/graph_info.cc
rename to cpp/src/graphar/graph_info.cc
index 3bf0c450..702aff32 100644
--- a/cpp/src/graph_info.cc
+++ b/cpp/src/graphar/graph_info.cc
@@ -18,16 +18,16 @@
  */
 
 #include <unordered_set>
+#include <utility>
 
 #include "mini-yaml/yaml/Yaml.hpp"
 
+#include "graphar/filesystem.h"
 #include "graphar/graph_info.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/util/data_type.h"
-#include "graphar/util/filesystem.h"
-#include "graphar/util/result.h"
-#include "graphar/util/version_parser.h"
-#include "graphar/util/yaml.h"
+#include "graphar/result.h"
+#include "graphar/types.h"
+#include "graphar/version_parser.h"
+#include "graphar/yaml.h"
 
 namespace graphar {
 
diff --git a/cpp/include/graphar/graph_info.h b/cpp/src/graphar/graph_info.h
similarity index 100%
rename from cpp/include/graphar/graph_info.h
rename to cpp/src/graphar/graph_info.h
diff --git a/cpp/src/edges_builder.cc 
b/cpp/src/graphar/high-level/edges_builder.cc
similarity index 98%
rename from cpp/src/edges_builder.cc
rename to cpp/src/graphar/high-level/edges_builder.cc
index a64e5266..2be78c79 100644
--- a/cpp/src/edges_builder.cc
+++ b/cpp/src/graphar/high-level/edges_builder.cc
@@ -19,10 +19,10 @@
 
 #include "arrow/api.h"
 
-#include "graphar/util/convert_to_arrow_type.h"
-#include "graphar/util/general_params.h"
-#include "graphar/util/result.h"
-#include "graphar/writer/edges_builder.h"
+#include "graphar/convert_to_arrow_type.h"
+#include "graphar/general_params.h"
+#include "graphar/high-level/edges_builder.h"
+#include "graphar/result.h"
 
 namespace graphar::builder {
 
diff --git a/cpp/include/graphar/writer/edges_builder.h 
b/cpp/src/graphar/high-level/edges_builder.h
similarity index 99%
rename from cpp/include/graphar/writer/edges_builder.h
rename to cpp/src/graphar/high-level/edges_builder.h
index 13940296..70365b5b 100644
--- a/cpp/include/graphar/writer/edges_builder.h
+++ b/cpp/src/graphar/high-level/edges_builder.h
@@ -27,10 +27,10 @@
 #include <utility>
 #include <vector>
 
+#include "graphar/arrow/chunk_writer.h"
 #include "graphar/fwd.h"
 #include "graphar/graph_info.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/writer/arrow_chunk_writer.h"
+#include "graphar/types.h"
 
 namespace arrow {
 class Array;
diff --git a/cpp/src/graph.cc b/cpp/src/graphar/high-level/graph_reader.cc
similarity index 99%
rename from cpp/src/graph.cc
rename to cpp/src/graphar/high-level/graph_reader.cc
index c386815c..b88206f9 100644
--- a/cpp/src/graph.cc
+++ b/cpp/src/graphar/high-level/graph_reader.cc
@@ -17,9 +17,9 @@
  * under the License.
  */
 
-#include "graphar/graph.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/util/convert_to_arrow_type.h"
+#include "graphar/high-level/graph_reader.h"
+#include "graphar/convert_to_arrow_type.h"
+#include "graphar/types.h"
 
 namespace graphar {
 
diff --git a/cpp/include/graphar/graph.h 
b/cpp/src/graphar/high-level/graph_reader.h
similarity index 99%
rename from cpp/include/graphar/graph.h
rename to cpp/src/graphar/high-level/graph_reader.h
index 23f2d75a..cea54213 100644
--- a/cpp/include/graphar/graph.h
+++ b/cpp/src/graphar/high-level/graph_reader.h
@@ -28,12 +28,12 @@
 #include <variant>
 #include <vector>
 
+#include "graphar/arrow/chunk_reader.h"
+#include "graphar/filesystem.h"
 #include "graphar/graph_info.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/util/filesystem.h"
-#include "graphar/util/reader_util.h"
-#include "graphar/util/util.h"
+#include "graphar/reader_util.h"
+#include "graphar/types.h"
+#include "graphar/util.h"
 
 // forward declarations
 namespace arrow {
diff --git a/cpp/src/vertices_builder.cc 
b/cpp/src/graphar/high-level/vertices_builder.cc
similarity index 98%
rename from cpp/src/vertices_builder.cc
rename to cpp/src/graphar/high-level/vertices_builder.cc
index 4e4e7c45..6225549c 100644
--- a/cpp/src/vertices_builder.cc
+++ b/cpp/src/graphar/high-level/vertices_builder.cc
@@ -17,9 +17,9 @@
  * under the License.
  */
 
-#include "graphar/writer/vertices_builder.h"
+#include "graphar/high-level/vertices_builder.h"
+#include "graphar/convert_to_arrow_type.h"
 #include "graphar/graph_info.h"
-#include "graphar/util/convert_to_arrow_type.h"
 
 namespace graphar::builder {
 
diff --git a/cpp/include/graphar/writer/vertices_builder.h 
b/cpp/src/graphar/high-level/vertices_builder.h
similarity index 99%
rename from cpp/include/graphar/writer/vertices_builder.h
rename to cpp/src/graphar/high-level/vertices_builder.h
index 2bb2b37b..9f8f1a84 100644
--- a/cpp/include/graphar/writer/vertices_builder.h
+++ b/cpp/src/graphar/high-level/vertices_builder.h
@@ -26,9 +26,9 @@
 #include <utility>
 #include <vector>
 
+#include "graphar/arrow/chunk_writer.h"
 #include "graphar/graph_info.h"
-#include "graphar/util/result.h"
-#include "graphar/writer/arrow_chunk_writer.h"
+#include "graphar/result.h"
 
 // forward declaration
 namespace arrow {
diff --git a/cpp/include/graphar/util/macros.h b/cpp/src/graphar/macros.h
similarity index 100%
rename from cpp/include/graphar/util/macros.h
rename to cpp/src/graphar/macros.h
diff --git a/cpp/src/reader_util.cc b/cpp/src/graphar/reader_util.cc
similarity index 98%
rename from cpp/src/reader_util.cc
rename to cpp/src/graphar/reader_util.cc
index 3ca51c1c..9e23899d 100644
--- a/cpp/src/reader_util.cc
+++ b/cpp/src/graphar/reader_util.cc
@@ -24,11 +24,11 @@
 #include "arrow/io/api.h"
 #include "parquet/arrow/reader.h"
 
+#include "graphar/expression.h"
+#include "graphar/filesystem.h"
 #include "graphar/graph_info.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/util/expression.h"
-#include "graphar/util/filesystem.h"
-#include "graphar/util/reader_util.h"
+#include "graphar/reader_util.h"
+#include "graphar/types.h"
 
 namespace graphar::util {
 
diff --git a/cpp/include/graphar/util/reader_util.h 
b/cpp/src/graphar/reader_util.h
similarity index 100%
rename from cpp/include/graphar/util/reader_util.h
rename to cpp/src/graphar/reader_util.h
diff --git a/cpp/include/graphar/util/result.h b/cpp/src/graphar/result.h
similarity index 99%
rename from cpp/include/graphar/util/result.h
rename to cpp/src/graphar/result.h
index 535dd698..3d85c3b4 100644
--- a/cpp/include/graphar/util/result.h
+++ b/cpp/src/graphar/result.h
@@ -22,7 +22,7 @@
 #include <utility>
 
 #include "graphar/fwd.h"
-#include "graphar/util/status.h"
+#include "graphar/status.h"
 
 #define GAR_ASSIGN_OR_RAISE_IMPL(result_name, lhs, rexpr)          \
   auto&& result_name = (rexpr);                                    \
diff --git a/cpp/include/graphar/util/status.h b/cpp/src/graphar/status.h
similarity index 99%
rename from cpp/include/graphar/util/status.h
rename to cpp/src/graphar/status.h
index a3383261..fee92da2 100644
--- a/cpp/include/graphar/util/status.h
+++ b/cpp/src/graphar/status.h
@@ -23,7 +23,7 @@
 #include <string>
 #include <utility>
 
-#include "graphar/util/macros.h"
+#include "graphar/macros.h"
 
 #define GAR_RETURN_IF_(condition, status, _) \
   do {                                       \
diff --git a/cpp/src/data_type.cc b/cpp/src/graphar/types.cc
similarity index 99%
rename from cpp/src/data_type.cc
rename to cpp/src/graphar/types.cc
index 7ec8424b..3996ab08 100644
--- a/cpp/src/data_type.cc
+++ b/cpp/src/graphar/types.cc
@@ -17,13 +17,14 @@
  * under the License.
  */
 
+#include <algorithm>
 #include <memory>
 
 #include "arrow/api.h"
 #include "arrow/type.h"
 
 #include "graphar/fwd.h"
-#include "graphar/util/data_type.h"
+#include "graphar/types.h"
 
 namespace graphar {
 
diff --git a/cpp/include/graphar/util/data_type.h b/cpp/src/graphar/types.h
similarity index 56%
rename from cpp/include/graphar/util/data_type.h
rename to cpp/src/graphar/types.h
index 1b803ff3..cb468a20 100644
--- a/cpp/include/graphar/util/data_type.h
+++ b/cpp/src/graphar/types.h
@@ -24,7 +24,8 @@
 #include <string>
 #include <utility>
 
-#include "graphar/util/macros.h"
+#include "graphar/fwd.h"
+#include "graphar/macros.h"
 
 // forward declaration
 namespace arrow {
@@ -158,4 +159,87 @@ class Date {
   c_type value_;
 };
 
+/** Adj list type enumeration for adjacency list of graph. */
+enum class AdjListType : std::uint8_t {
+  /// collection of edges by source, but unordered, can represent COO format
+  unordered_by_source = 0b00000001,
+  /// collection of edges by destination, but unordered, can represent COO
+  /// format
+  unordered_by_dest = 0b00000010,
+  /// collection of edges by source, ordered by source, can represent CSR 
format
+  ordered_by_source = 0b00000100,
+  /// collection of edges by destination, ordered by destination, can represent
+  /// CSC format
+  ordered_by_dest = 0b00001000,
+};
+
+constexpr AdjListType operator|(AdjListType lhs, AdjListType rhs) {
+  return static_cast<AdjListType>(
+      static_cast<std::underlying_type_t<AdjListType>>(lhs) |
+      static_cast<std::underlying_type_t<AdjListType>>(rhs));
+}
+
+constexpr AdjListType operator&(AdjListType lhs, AdjListType rhs) {
+  return static_cast<AdjListType>(
+      static_cast<std::underlying_type_t<AdjListType>>(lhs) &
+      static_cast<std::underlying_type_t<AdjListType>>(rhs));
+}
+
+static inline const char* AdjListTypeToString(AdjListType adj_list_type) {
+  static const std::map<AdjListType, const char*> adj_list2string{
+      {AdjListType::unordered_by_source, "unordered_by_source"},
+      {AdjListType::unordered_by_dest, "unordered_by_dest"},
+      {AdjListType::ordered_by_source, "ordered_by_source"},
+      {AdjListType::ordered_by_dest, "ordered_by_dest"}};
+  return adj_list2string.at(adj_list_type);
+}
+
+static inline AdjListType OrderedAlignedToAdjListType(
+    bool ordered, const std::string& aligned) {
+  if (ordered) {
+    return aligned == "src" ? AdjListType::ordered_by_source
+                            : AdjListType::ordered_by_dest;
+  }
+  return aligned == "src" ? AdjListType::unordered_by_source
+                          : AdjListType::unordered_by_dest;
+}
+
+static inline std::pair<bool, std::string> AdjListTypeToOrderedAligned(
+    AdjListType adj_list_type) {
+  switch (adj_list_type) {
+  case AdjListType::unordered_by_source:
+    return std::make_pair(false, "src");
+  case AdjListType::unordered_by_dest:
+    return std::make_pair(false, "dst");
+  case AdjListType::ordered_by_source:
+    return std::make_pair(true, "src");
+  case AdjListType::ordered_by_dest:
+    return std::make_pair(true, "dst");
+  default:
+    return std::make_pair(false, "dst");
+  }
+}
+
+static inline FileType StringToFileType(const std::string& str) {
+  static const std::map<std::string, FileType> str2file_type{
+      {"csv", FileType::CSV},
+      {"json", FileType::JSON},
+      {"parquet", FileType::PARQUET},
+      {"orc", FileType::ORC}};
+  try {
+    return str2file_type.at(str.c_str());
+  } catch (const std::exception& e) {
+    throw std::runtime_error("KeyError: " + str);
+  }
+}
+
+static inline const char* FileTypeToString(FileType file_type) {
+  static const std::map<FileType, const char*> file_type2string{
+      {FileType::CSV, "csv"},
+      {FileType::JSON, "json"},
+      {FileType::PARQUET, "parquet"},
+      {FileType::ORC, "orc"}};
+  return file_type2string.at(file_type);
+}
+
 }  // namespace graphar
diff --git a/cpp/src/util.cc b/cpp/src/graphar/util.cc
similarity index 99%
rename from cpp/src/util.cc
rename to cpp/src/graphar/util.cc
index 740669b4..e477188d 100644
--- a/cpp/src/util.cc
+++ b/cpp/src/graphar/util.cc
@@ -22,7 +22,7 @@
 
 #include "arrow/api.h"
 
-#include "graphar/util/util.h"
+#include "graphar/util.h"
 
 namespace graphar::util {
 
diff --git a/cpp/include/graphar/util/util.h b/cpp/src/graphar/util.h
similarity index 99%
rename from cpp/include/graphar/util/util.h
rename to cpp/src/graphar/util.h
index 703b2d36..c51a03ae 100644
--- a/cpp/include/graphar/util/util.h
+++ b/cpp/src/graphar/util.h
@@ -25,7 +25,7 @@
 #include <utility>
 #include <vector>
 
-#include "graphar/util/result.h"
+#include "graphar/result.h"
 
 #define REGULAR_SEPARATOR "_"
 
diff --git a/cpp/src/version_parser.cc b/cpp/src/graphar/version_parser.cc
similarity index 98%
rename from cpp/src/version_parser.cc
rename to cpp/src/graphar/version_parser.cc
index 130a4944..43738178 100644
--- a/cpp/src/version_parser.cc
+++ b/cpp/src/graphar/version_parser.cc
@@ -17,11 +17,12 @@
  * under the License.
  */
 
+#include <algorithm>
 #include <iostream>
 #include <regex>  // NOLINT
 #include <string>
 
-#include "graphar/util/version_parser.h"
+#include "graphar/version_parser.h"
 
 namespace graphar {
 
diff --git a/cpp/include/graphar/util/version_parser.h 
b/cpp/src/graphar/version_parser.h
similarity index 99%
rename from cpp/include/graphar/util/version_parser.h
rename to cpp/src/graphar/version_parser.h
index 6f733a9d..ae5d5a6f 100644
--- a/cpp/include/graphar/util/version_parser.h
+++ b/cpp/src/graphar/version_parser.h
@@ -25,7 +25,7 @@
 #include <string>
 #include <vector>
 
-#include "graphar/util/result.h"
+#include "graphar/result.h"
 
 namespace graphar {
 
diff --git a/cpp/include/graphar/util/writer_util.h 
b/cpp/src/graphar/writer_util.h
similarity index 97%
rename from cpp/include/graphar/util/writer_util.h
rename to cpp/src/graphar/writer_util.h
index 55bbd0ff..4f266ffa 100644
--- a/cpp/include/graphar/util/writer_util.h
+++ b/cpp/src/graphar/writer_util.h
@@ -19,7 +19,7 @@
 
 #pragma once
 
-#include "graphar/util/macros.h"
+#include "graphar/macros.h"
 
 namespace graphar {
 
diff --git a/cpp/src/yaml.cc b/cpp/src/graphar/yaml.cc
similarity index 96%
rename from cpp/src/yaml.cc
rename to cpp/src/graphar/yaml.cc
index e20da01c..27922d70 100644
--- a/cpp/src/yaml.cc
+++ b/cpp/src/graphar/yaml.cc
@@ -22,8 +22,8 @@
 
 #include "mini-yaml/yaml/Yaml.hpp"
 
-#include "graphar/util/result.h"
-#include "graphar/util/yaml.h"
+#include "graphar/result.h"
+#include "graphar/yaml.h"
 
 namespace graphar {
 
diff --git a/cpp/include/graphar/util/yaml.h b/cpp/src/graphar/yaml.h
similarity index 98%
rename from cpp/include/graphar/util/yaml.h
rename to cpp/src/graphar/yaml.h
index 54551cac..5684b6ea 100644
--- a/cpp/include/graphar/util/yaml.h
+++ b/cpp/src/graphar/yaml.h
@@ -23,7 +23,7 @@
 #include <memory>
 #include <string>
 
-#include "graphar/util/result.h"
+#include "graphar/result.h"
 
 // forward declaration
 namespace Yaml {
diff --git a/cpp/test/test_arrow_chunk_reader.cc 
b/cpp/test/test_arrow_chunk_reader.cc
index cc5b3e99..a96c9d06 100644
--- a/cpp/test/test_arrow_chunk_reader.cc
+++ b/cpp/test/test_arrow_chunk_reader.cc
@@ -22,12 +22,7 @@
 #include "arrow/api.h"
 
 #include "./util.h"
-#include "graphar/reader/arrow_chunk_reader.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/util/data_type.h"
-#include "graphar/util/expression.h"
-#include "graphar/util/filesystem.h"
-#include "graphar/util/general_params.h"
+#include "graphar/api/arrow_reader.h"
 
 #include <catch2/catch_test_macros.hpp>
 namespace graphar {
diff --git a/cpp/test/test_arrow_chunk_writer.cc 
b/cpp/test/test_arrow_chunk_writer.cc
index 57aa2ea3..682c1a1a 100644
--- a/cpp/test/test_arrow_chunk_writer.cc
+++ b/cpp/test/test_arrow_chunk_writer.cc
@@ -33,11 +33,7 @@
 #include "parquet/arrow/writer.h"
 
 #include "./util.h"
-#include "graphar/graph_info.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/util/general_params.h"
-#include "graphar/util/yaml.h"
-#include "graphar/writer/arrow_chunk_writer.h"
+#include "graphar/api/arrow_writer.h"
 
 #include <catch2/catch_test_macros.hpp>
 
diff --git a/cpp/test/test_builder.cc b/cpp/test/test_builder.cc
index 39e40f95..7fecd9c6 100644
--- a/cpp/test/test_builder.cc
+++ b/cpp/test/test_builder.cc
@@ -34,10 +34,7 @@
 #include "parquet/arrow/writer.h"
 
 #include "./util.h"
-#include "graphar/graph_info.h"
-#include "graphar/util/yaml.h"
-#include "graphar/writer/edges_builder.h"
-#include "graphar/writer/vertices_builder.h"
+#include "graphar/api/high_level_writer.h"
 
 #include <catch2/catch_test_macros.hpp>
 namespace graphar {
diff --git a/cpp/test/test_chunk_info_reader.cc 
b/cpp/test/test_chunk_info_reader.cc
index 98bd09b1..ef7ca33f 100644
--- a/cpp/test/test_chunk_info_reader.cc
+++ b/cpp/test/test_chunk_info_reader.cc
@@ -20,9 +20,7 @@
 #include <cstdlib>
 
 #include "./util.h"
-#include "graphar/graph_info.h"
-#include "graphar/reader/chunk_info_reader.h"
-#include "graphar/util/adj_list_type.h"
+#include "graphar/api/meta_reader.h"
 
 #include <catch2/catch_test_macros.hpp>
 
diff --git a/cpp/test/test_graph.cc b/cpp/test/test_graph.cc
index 03a7470f..f31b573d 100644
--- a/cpp/test/test_graph.cc
+++ b/cpp/test/test_graph.cc
@@ -20,8 +20,7 @@
 #include <iostream>
 
 #include "./util.h"
-#include "graphar/graph.h"
-#include "graphar/util/data_type.h"
+#include "graphar/api/high_level_reader.h"
 
 #include <catch2/catch_test_macros.hpp>
 
diff --git a/cpp/test/test_info.cc b/cpp/test/test_info.cc
index 8a2a9762..3216b8ed 100644
--- a/cpp/test/test_info.cc
+++ b/cpp/test/test_info.cc
@@ -24,12 +24,7 @@
 
 #include "./util.h"
 
-#include "graphar/graph_info.h"
-#include "graphar/util/adj_list_type.h"
-#include "graphar/util/data_type.h"
-#include "graphar/util/file_type.h"
-#include "graphar/util/filesystem.h"
-#include "graphar/util/version_parser.h"
+#include "graphar/api/info.h"
 
 #include <catch2/catch_test_macros.hpp>
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to