Skip to content
Open
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
48 changes: 32 additions & 16 deletions cpp/src/graphar/arrow/chunk_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ VertexPropertyWriter::VertexPropertyWriter(
Status VertexPropertyWriter::validate(const IdType& count,
ValidateLevel validate_level) const {
// use the writer's validate level
if (validate_level == ValidateLevel::default_validate)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::no_validate)
if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
}
// weak & strong validate
if (count < 0) {
return Status::Invalid("The number of vertices is negative.");
Expand All @@ -143,11 +145,13 @@ Status VertexPropertyWriter::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)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::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 ",
Expand Down Expand Up @@ -512,11 +516,13 @@ EdgeChunkWriter::EdgeChunkWriter(const std::shared_ptr<EdgeInfo>& edge_info,
Status EdgeChunkWriter::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)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::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(
Expand All @@ -538,11 +544,13 @@ Status EdgeChunkWriter::validate(
IdType vertex_chunk_index, IdType chunk_index,
ValidateLevel validate_level) const {
// use the writer's validate level
if (validate_level == ValidateLevel::default_validate)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::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
Expand All @@ -558,11 +566,13 @@ Status EdgeChunkWriter::validate(
const std::shared_ptr<arrow::Table>& input_table, IdType vertex_chunk_index,
ValidateLevel validate_level) const {
// use the writer's validate level
if (validate_level == ValidateLevel::default_validate)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::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, 0, validate_level));
// weak validate for the input table
Expand Down Expand Up @@ -613,11 +623,13 @@ Status EdgeChunkWriter::validate(
const std::shared_ptr<arrow::Table>& input_table, IdType vertex_chunk_index,
IdType chunk_index, ValidateLevel validate_level) const {
// use the writer's validate level
if (validate_level == ValidateLevel::default_validate)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::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 validate for the input table
Expand Down Expand Up @@ -666,11 +678,13 @@ Status EdgeChunkWriter::validate(
IdType vertex_chunk_index, IdType chunk_index,
ValidateLevel validate_level) const {
// use the writer's validate level
if (validate_level == ValidateLevel::default_validate)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::no_validate)
if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
}
// validate for property group, adj list type & index
GAR_RETURN_NOT_OK(validate(property_group, vertex_chunk_index, chunk_index,
validate_level));
Expand Down Expand Up @@ -970,12 +984,14 @@ Result<std::shared_ptr<arrow::Table>> EdgeChunkWriter::getOffsetTable(
int64_t global_index = 0;
for (IdType i = begin_index; i < end_index; i++) {
while (true) {
if (array_index >= column->num_chunks())
if (array_index >= column->num_chunks()) {
break;
}
if (index >= ids->length()) {
array_index++;
if (array_index == column->num_chunks())
if (array_index == column->num_chunks()) {
break;
}
ids = std::static_pointer_cast<arrow::Int64Array>(
column->chunk(array_index));
index = 0;
Expand Down
18 changes: 12 additions & 6 deletions cpp/src/graphar/chunk_info_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ 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)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::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 ",
Expand Down Expand Up @@ -108,11 +110,13 @@ 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)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::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(
Expand All @@ -134,11 +138,13 @@ Status EdgeChunkInfoWriter::validate(
IdType vertex_chunk_index, IdType chunk_index,
ValidateLevel validate_level) const {
// use the writer's validate level
if (validate_level == ValidateLevel::default_validate)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::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
Expand Down
15 changes: 10 additions & 5 deletions cpp/src/graphar/high-level/edges_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,24 @@ Status EdgesBuilder::Dump() {
// construct empty edge collections for vertex chunks without edges
IdType num_vertex_chunks =
(num_vertices_ + vertex_chunk_size_ - 1) / vertex_chunk_size_;
for (IdType i = 0; i < num_vertex_chunks; i++)
for (IdType i = 0; i < num_vertex_chunks; i++) {
if (edges_.find(i) == edges_.end()) {
std::vector<Edge> empty_chunk_edges;
edges_[i] = empty_chunk_edges;
}
}
// dump the offsets
if (adj_list_type_ == AdjListType::ordered_by_source ||
adj_list_type_ == AdjListType::ordered_by_dest) {
for (auto& chunk_edges : edges_) {
IdType vertex_chunk_index = chunk_edges.first;
// sort the edges
if (adj_list_type_ == AdjListType::ordered_by_source)
if (adj_list_type_ == AdjListType::ordered_by_source) {
sort(chunk_edges.second.begin(), chunk_edges.second.end(), cmp_src);
if (adj_list_type_ == AdjListType::ordered_by_dest)
}
if (adj_list_type_ == AdjListType::ordered_by_dest) {
sort(chunk_edges.second.begin(), chunk_edges.second.end(), cmp_dst);
}
// construct and write offset chunk
GAR_ASSIGN_OR_RAISE(
auto offset_table,
Expand Down Expand Up @@ -86,11 +89,13 @@ Status EdgesBuilder::Dump() {
Status EdgesBuilder::validate(const Edge& e,
ValidateLevel validate_level) const {
// use the builder's validate level
if (validate_level == ValidateLevel::default_validate)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::no_validate)
if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
}

// weak validate
// can not add new edges after dumping
Expand Down
6 changes: 4 additions & 2 deletions cpp/src/graphar/high-level/vertices_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ namespace graphar::builder {
Status VerticesBuilder::validate(const Vertex& v, IdType index,
ValidateLevel validate_level) const {
// use the builder's validate level
if (validate_level == ValidateLevel::default_validate)
if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
}
// no validate
if (validate_level == ValidateLevel::no_validate)
if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
}

// weak validate
// can not add new vertices after dumping
Expand Down
Loading