Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Unify the name:utils -> util and the namespace of GraphAr::util #225

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions cpp/include/gar/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ limitations under the License.
#include <vector>

#include "gar/reader/arrow_chunk_reader.h"
#include "gar/utils/reader_utils.h"
#include "gar/utils/utils.h"
#include "gar/util/reader_util.h"
#include "gar/util/util.h"

// forward declarations
namespace arrow {
Expand Down Expand Up @@ -651,7 +651,7 @@ class EdgesCollection<AdjListType::ordered_by_source> {
: edge_info_(edge_info), prefix_(prefix) {
GAR_ASSIGN_OR_RAISE_ERROR(
auto vertex_chunk_num,
utils::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
util::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
std::vector<IdType> edge_chunk_nums(vertex_chunk_num, 0);
if (vertex_chunk_end == std::numeric_limits<int64_t>::max()) {
vertex_chunk_end = vertex_chunk_num;
Expand All @@ -662,7 +662,7 @@ class EdgesCollection<AdjListType::ordered_by_source> {
for (IdType i = 0; i < vertex_chunk_num; ++i) {
GAR_ASSIGN_OR_RAISE_ERROR(
edge_chunk_nums[i],
utils::GetEdgeChunkNum(prefix, edge_info, adj_list_type_, i));
util::GetEdgeChunkNum(prefix, edge_info, adj_list_type_, i));
if (i < vertex_chunk_begin) {
chunk_begin_ += edge_chunk_nums[i];
chunk_end_ += edge_chunk_nums[i];
Expand All @@ -671,7 +671,7 @@ class EdgesCollection<AdjListType::ordered_by_source> {
chunk_end_ += edge_chunk_nums[i];
GAR_ASSIGN_OR_RAISE_ERROR(
auto chunk_edge_num_,
utils::GetEdgeNum(prefix, edge_info, adj_list_type_, i));
util::GetEdgeNum(prefix, edge_info, adj_list_type_, i));
edge_num_ += chunk_edge_num_;
}
}
Expand Down Expand Up @@ -708,8 +708,8 @@ class EdgesCollection<AdjListType::ordered_by_source> {
* @return The new constructed iterator.
*/
EdgeIter find_src(IdType id, const EdgeIter& from) {
auto result = utils::GetAdjListOffsetOfVertex(edge_info_, prefix_,
adj_list_type_, id);
auto result =
util::GetAdjListOffsetOfVertex(edge_info_, prefix_, adj_list_type_, id);
if (!result.status().ok()) {
return this->end();
}
Expand Down Expand Up @@ -804,7 +804,7 @@ class EdgesCollection<AdjListType::ordered_by_dest> {
: edge_info_(edge_info), prefix_(prefix) {
GAR_ASSIGN_OR_RAISE_ERROR(
auto vertex_chunk_num,
utils::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
util::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
std::vector<IdType> edge_chunk_nums(vertex_chunk_num, 0);
if (vertex_chunk_end == std::numeric_limits<int64_t>::max()) {
vertex_chunk_end = vertex_chunk_num;
Expand All @@ -815,7 +815,7 @@ class EdgesCollection<AdjListType::ordered_by_dest> {
for (IdType i = 0; i < vertex_chunk_num; ++i) {
GAR_ASSIGN_OR_RAISE_ERROR(
edge_chunk_nums[i],
utils::GetEdgeChunkNum(prefix, edge_info, adj_list_type_, i));
util::GetEdgeChunkNum(prefix, edge_info, adj_list_type_, i));
if (i < vertex_chunk_begin) {
chunk_begin_ += edge_chunk_nums[i];
chunk_end_ += edge_chunk_nums[i];
Expand All @@ -824,7 +824,7 @@ class EdgesCollection<AdjListType::ordered_by_dest> {
chunk_end_ += edge_chunk_nums[i];
GAR_ASSIGN_OR_RAISE_ERROR(
auto chunk_edge_num_,
utils::GetEdgeNum(prefix, edge_info, adj_list_type_, i));
util::GetEdgeNum(prefix, edge_info, adj_list_type_, i));
edge_num_ += chunk_edge_num_;
}
}
Expand Down Expand Up @@ -882,8 +882,8 @@ class EdgesCollection<AdjListType::ordered_by_dest> {
* @return The new constructed iterator.
*/
EdgeIter find_dst(IdType id, const EdgeIter& from) {
auto result = utils::GetAdjListOffsetOfVertex(edge_info_, prefix_,
adj_list_type_, id);
auto result =
util::GetAdjListOffsetOfVertex(edge_info_, prefix_, adj_list_type_, id);
if (!result.status().ok()) {
return this->end();
}
Expand Down Expand Up @@ -957,7 +957,7 @@ class EdgesCollection<AdjListType::unordered_by_source> {
: edge_info_(edge_info), prefix_(prefix) {
GAR_ASSIGN_OR_RAISE_ERROR(
auto vertex_chunk_num,
utils::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
util::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
std::vector<IdType> edge_chunk_nums(vertex_chunk_num, 0);
if (vertex_chunk_end == std::numeric_limits<int64_t>::max()) {
vertex_chunk_end = vertex_chunk_num;
Expand All @@ -968,7 +968,7 @@ class EdgesCollection<AdjListType::unordered_by_source> {
for (IdType i = 0; i < vertex_chunk_num; ++i) {
GAR_ASSIGN_OR_RAISE_ERROR(
edge_chunk_nums[i],
utils::GetEdgeChunkNum(prefix, edge_info, adj_list_type_, i));
util::GetEdgeChunkNum(prefix, edge_info, adj_list_type_, i));
if (i < vertex_chunk_begin) {
chunk_begin_ += edge_chunk_nums[i];
chunk_end_ += edge_chunk_nums[i];
Expand All @@ -977,7 +977,7 @@ class EdgesCollection<AdjListType::unordered_by_source> {
chunk_end_ += edge_chunk_nums[i];
GAR_ASSIGN_OR_RAISE_ERROR(
auto chunk_edge_num_,
utils::GetEdgeNum(prefix, edge_info, adj_list_type_, i));
util::GetEdgeNum(prefix, edge_info, adj_list_type_, i));
edge_num_ += chunk_edge_num_;
}
}
Expand Down Expand Up @@ -1083,7 +1083,7 @@ class EdgesCollection<AdjListType::unordered_by_dest> {
: edge_info_(edge_info), prefix_(prefix) {
GAR_ASSIGN_OR_RAISE_ERROR(
auto vertex_chunk_num,
utils::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
util::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
std::vector<IdType> edge_chunk_nums(vertex_chunk_num, 0);
if (vertex_chunk_end == std::numeric_limits<int64_t>::max()) {
vertex_chunk_end = vertex_chunk_num;
Expand All @@ -1094,7 +1094,7 @@ class EdgesCollection<AdjListType::unordered_by_dest> {
for (IdType i = 0; i < vertex_chunk_num; ++i) {
GAR_ASSIGN_OR_RAISE_ERROR(
edge_chunk_nums[i],
utils::GetEdgeChunkNum(prefix, edge_info, adj_list_type_, i));
util::GetEdgeChunkNum(prefix, edge_info, adj_list_type_, i));
if (i < vertex_chunk_begin) {
chunk_begin_ += edge_chunk_nums[i];
chunk_end_ += edge_chunk_nums[i];
Expand All @@ -1103,7 +1103,7 @@ class EdgesCollection<AdjListType::unordered_by_dest> {
chunk_end_ += edge_chunk_nums[i];
GAR_ASSIGN_OR_RAISE_ERROR(
auto chunk_edge_num_,
utils::GetEdgeNum(prefix, edge_info, adj_list_type_, i));
util::GetEdgeNum(prefix, edge_info, adj_list_type_, i));
edge_num_ += chunk_edge_num_;
}
}
Expand Down
16 changes: 8 additions & 8 deletions cpp/include/gar/graph_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ limitations under the License.
#include <unordered_set>
#include <vector>

#include "utils/adj_list_type.h"
#include "utils/data_type.h"
#include "utils/file_type.h"
#include "utils/result.h"
#include "utils/status.h"
#include "utils/utils.h"
#include "utils/version_parser.h"
#include "utils/yaml.h"
#include "util/adj_list_type.h"
#include "util/data_type.h"
#include "util/file_type.h"
#include "util/result.h"
#include "util/status.h"
#include "util/util.h"
#include "util/version_parser.h"
#include "util/yaml.h"

namespace GAR_NAMESPACE_INTERNAL {

Expand Down
68 changes: 32 additions & 36 deletions cpp/include/gar/reader/arrow_chunk_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ limitations under the License.
#include <vector>

#include "gar/graph_info.h"
#include "gar/utils/data_type.h"
#include "gar/utils/filesystem.h"
#include "gar/utils/result.h"
#include "gar/utils/status.h"
#include "gar/utils/utils.h"
#include "gar/util/data_type.h"
#include "gar/util/filesystem.h"
#include "gar/util/result.h"
#include "gar/util/status.h"
#include "gar/util/util.h"

// forward declaration
namespace arrow {
Expand All @@ -52,7 +52,7 @@ class VertexPropertyArrowChunkReader {
const PropertyGroup& property_group,
const std::string& prefix,
IdType chunk_index = 0,
const utils::FilterOptions& options = {})
const util::FilterOptions& options = {})
: vertex_info_(vertex_info),
property_group_(property_group),
chunk_index_(chunk_index),
Expand All @@ -64,9 +64,9 @@ class VertexPropertyArrowChunkReader {
vertex_info.GetPathPrefix(property_group));
std::string base_dir = prefix_ + pg_path_prefix;
GAR_ASSIGN_OR_RAISE_ERROR(chunk_num_,
utils::GetVertexChunkNum(prefix_, vertex_info));
util::GetVertexChunkNum(prefix_, vertex_info));
GAR_ASSIGN_OR_RAISE_ERROR(vertex_num_,
utils::GetVertexNum(prefix_, vertex_info_));
util::GetVertexNum(prefix_, vertex_info_));
}

/**
Expand Down Expand Up @@ -135,15 +135,15 @@ class VertexPropertyArrowChunkReader {
*
* @param filter Predicate expression to filter rows.
*/
void Filter(utils::Filter filter = nullptr);
void Filter(util::Filter filter = nullptr);

/**
* @brief Apply the projection to the table to be read. No parameter call
* Select() will clear the projection.
*
* @param column_names The name of columns to be selected.
*/
void Select(utils::ColumnNames column_names = std::nullopt);
void Select(util::ColumnNames column_names = std::nullopt);

private:
VertexInfo vertex_info_;
Expand All @@ -154,7 +154,7 @@ class VertexPropertyArrowChunkReader {
IdType chunk_num_;
IdType vertex_num_;
std::shared_ptr<arrow::Table> chunk_table_;
utils::FilterOptions filter_options_;
util::FilterOptions filter_options_;
std::shared_ptr<FileSystem> fs_;
};

Expand Down Expand Up @@ -188,10 +188,10 @@ class AdjListArrowChunkReader {
base_dir_ = prefix_ + adj_list_path_prefix;
GAR_ASSIGN_OR_RAISE_ERROR(
vertex_chunk_num_,
utils::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
util::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
GAR_ASSIGN_OR_RAISE_ERROR(
chunk_num_, utils::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
chunk_num_, util::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
}

/**
Expand Down Expand Up @@ -276,9 +276,8 @@ class AdjListArrowChunkReader {
}
chunk_index_ = 0;
GAR_ASSIGN_OR_RAISE_ERROR(
chunk_num_,
utils::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
chunk_num_, util::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
}
seek_offset_ = chunk_index_ * edge_info_.GetChunkSize();
chunk_table_.reset();
Expand All @@ -296,9 +295,8 @@ class AdjListArrowChunkReader {
if (vertex_chunk_index_ != vertex_chunk_index) {
vertex_chunk_index_ = vertex_chunk_index;
GAR_ASSIGN_OR_RAISE_ERROR(
chunk_num_,
utils::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
chunk_num_, util::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
chunk_table_.reset();
}
if (chunk_index_ != chunk_index) {
Expand Down Expand Up @@ -353,7 +351,7 @@ class AdjListOffsetArrowChunkReader {
adj_list_type == AdjListType::ordered_by_dest) {
GAR_ASSIGN_OR_RAISE_ERROR(
vertex_chunk_num_,
utils::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
util::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
vertex_chunk_size_ = adj_list_type == AdjListType::ordered_by_source
? edge_info_.GetSrcChunkSize()
: edge_info_.GetDstChunkSize();
Expand Down Expand Up @@ -453,7 +451,7 @@ class AdjListPropertyArrowChunkReader {
AdjListType adj_list_type,
const std::string prefix,
IdType vertex_chunk_index = 0,
const utils::FilterOptions& options = {})
const util::FilterOptions& options = {})
: edge_info_(edge_info),
property_group_(property_group),
adj_list_type_(adj_list_type),
Expand All @@ -470,10 +468,10 @@ class AdjListPropertyArrowChunkReader {
base_dir_ = prefix_ + pg_path_prefix;
GAR_ASSIGN_OR_RAISE_ERROR(
vertex_chunk_num_,
utils::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
util::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
GAR_ASSIGN_OR_RAISE_ERROR(
chunk_num_, utils::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
chunk_num_, util::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
}

/**
Expand Down Expand Up @@ -558,9 +556,8 @@ class AdjListPropertyArrowChunkReader {
}
chunk_index_ = 0;
GAR_ASSIGN_OR_RAISE_ERROR(
chunk_num_,
utils::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
chunk_num_, util::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
}
seek_offset_ = chunk_index_ * edge_info_.GetChunkSize();
chunk_table_.reset();
Expand All @@ -578,9 +575,8 @@ class AdjListPropertyArrowChunkReader {
if (vertex_chunk_index_ != vertex_chunk_index) {
vertex_chunk_index_ = vertex_chunk_index;
GAR_ASSIGN_OR_RAISE_ERROR(
chunk_num_,
utils::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
chunk_num_, util::GetEdgeChunkNum(prefix_, edge_info_, adj_list_type_,
vertex_chunk_index_));
chunk_table_.reset();
}
if (chunk_index_ != chunk_index) {
Expand All @@ -597,15 +593,15 @@ class AdjListPropertyArrowChunkReader {
*
* @param filter Predicate expression to filter rows.
*/
void Filter(utils::Filter filter = nullptr);
void Filter(util::Filter filter = nullptr);

/**
* @brief Apply the projection to the table to be read. No parameter call
* Select() will clear the projection.
*
* @param column_names The name of columns to be selected.
*/
void Select(utils::ColumnNames column_names = std::nullopt);
void Select(util::ColumnNames column_names = std::nullopt);

private:
EdgeInfo edge_info_;
Expand All @@ -615,7 +611,7 @@ class AdjListPropertyArrowChunkReader {
IdType vertex_chunk_index_, chunk_index_;
IdType seek_offset_;
std::shared_ptr<arrow::Table> chunk_table_;
utils::FilterOptions filter_options_;
util::FilterOptions filter_options_;
IdType vertex_chunk_num_, chunk_num_;
std::string base_dir_;
std::shared_ptr<FileSystem> fs_;
Expand All @@ -632,7 +628,7 @@ static inline Result<VertexPropertyArrowChunkReader>
ConstructVertexPropertyArrowChunkReader(
const GraphInfo& graph_info, const std::string& label,
const PropertyGroup& property_group,
const utils::FilterOptions& options = {}) noexcept {
const util::FilterOptions& options = {}) noexcept {
VertexInfo vertex_info;
GAR_ASSIGN_OR_RAISE(vertex_info, graph_info.GetVertexInfo(label));
if (!vertex_info.ContainPropertyGroup(property_group)) {
Expand Down Expand Up @@ -712,7 +708,7 @@ ConstructAdjListPropertyArrowChunkReader(
const GraphInfo& graph_info, const std::string& src_label,
const std::string& edge_label, const std::string& dst_label,
const PropertyGroup& property_group, AdjListType adj_list_type,
const utils::FilterOptions& options = {}) noexcept {
const util::FilterOptions& options = {}) noexcept {
EdgeInfo edge_info;
GAR_ASSIGN_OR_RAISE(edge_info,
graph_info.GetEdgeInfo(src_label, edge_label, dst_label));
Expand Down
Loading