This is an automated email from the ASF dual-hosted git repository.
xiaokang 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 95ac39b4 fix(C++): centralize ReadFileToTable error handling and
Improve examples spelling (#866)
95ac39b4 is described below
commit 95ac39b457fa1d72cc550245af1b9201da421d0b
Author: Jason <[email protected]>
AuthorDate: Tue Feb 24 10:43:22 2026 +0800
fix(C++): centralize ReadFileToTable error handling and Improve examples
spelling (#866)
---
cpp/examples/low_level_reader_example.cc | 4 ++--
cpp/examples/mid_level_reader_example.cc | 17 ++++++++---------
cpp/src/graphar/filesystem.cc | 17 +++++++----------
3 files changed, 17 insertions(+), 21 deletions(-)
diff --git a/cpp/examples/low_level_reader_example.cc
b/cpp/examples/low_level_reader_example.cc
index 1ba306cd..e835c078 100644
--- a/cpp/examples/low_level_reader_example.cc
+++ b/cpp/examples/low_level_reader_example.cc
@@ -27,7 +27,7 @@
void vertex_property_chunk_info_reader(
const std::shared_ptr<graphar::GraphInfo>& graph_info) {
- // constuct reader
+ // construct reader
std::string type = "person", property_name = "id";
auto maybe_reader = graphar::VertexPropertyChunkInfoReader::Make(
graph_info, type, property_name);
@@ -112,7 +112,7 @@ void adj_list_property_chunk_info_reader(
maybe_chunk_path = reader->GetChunk();
ASSERT(maybe_chunk_path.status().ok());
chunk_path = maybe_chunk_path.value();
- std::cout << "path of fisrt adj_list property chunk for outgoing edges of "
+ std::cout << "path of first adj_list property chunk for outgoing edges of "
"vertex id 100: "
<< chunk_path << std::endl;
// next chunk
diff --git a/cpp/examples/mid_level_reader_example.cc
b/cpp/examples/mid_level_reader_example.cc
index 1789139d..1299afd8 100644
--- a/cpp/examples/mid_level_reader_example.cc
+++ b/cpp/examples/mid_level_reader_example.cc
@@ -81,10 +81,10 @@ void vertex_property_chunk_reader(
specific_reader->GetChunk(graphar::GetChunkVersion::V1);
ASSERT(!result.has_error());
auto specific_table = specific_result.value();
- std::cout << "rows number of first specificed vertex property chunk: "
+ std::cout << "rows number of first specified vertex property chunk: "
<< specific_table->num_rows() << std::endl;
ASSERT(specific_table->num_columns() == 2);
- std::cout << "schema of first specificed vertex property chunk: " <<
std::endl
+ std::cout << "schema of first specified vertex property chunk: " << std::endl
<< specific_table->schema()->ToString() << std::endl;
index_col =
specific_table->GetColumnByName(graphar::GeneralParams::kVertexIndexCol);
@@ -104,10 +104,10 @@ void vertex_property_chunk_reader(
specific_result = specific_reader->GetChunk(graphar::GetChunkVersion::V2);
ASSERT(!specific_result.has_error());
specific_table = specific_result.value();
- std::cout << "rows number of first specificed vertex property chunk (V2): "
+ std::cout << "rows number of first specified vertex property chunk (V2): "
<< specific_table->num_rows() << std::endl;
ASSERT(specific_table->num_columns() == 2);
- std::cout << "schema of first specificed vertex property chunk (V2): "
+ std::cout << "schema of first specified vertex property chunk (V2): "
<< std::endl
<< specific_table->schema()->ToString() << std::endl;
index_col =
@@ -129,10 +129,10 @@ void vertex_property_chunk_reader(
specific_result = specific_reader->GetChunk(graphar::GetChunkVersion::V1);
ASSERT(!result.has_error());
specific_table = specific_result.value();
- std::cout << "rows number of specificed vertex properties chunk: "
+ std::cout << "rows number of specified vertex properties chunk: "
<< specific_table->num_rows() << std::endl;
ASSERT(specific_table->num_columns() == specific_cols.size() + 1);
- std::cout << "schema of specificed vertex properties chunk: " << std::endl
+ std::cout << "schema of specified vertex properties chunk: " << std::endl
<< specific_table->schema()->ToString() << std::endl;
index_col =
specific_table->GetColumnByName(graphar::GeneralParams::kVertexIndexCol);
@@ -157,11 +157,10 @@ void vertex_property_chunk_reader(
specific_result = specific_reader->GetChunk(graphar::GetChunkVersion::V2);
ASSERT(!specific_result.has_error());
specific_table = specific_result.value();
- std::cout << "rows number of specificed vertex properties chunk (V2): "
+ std::cout << "rows number of specified vertex properties chunk (V2): "
<< specific_table->num_rows() << std::endl;
ASSERT(specific_table->num_columns() == specific_cols.size() + 1);
- std::cout << "schema of specificed vertex properties chunk (V2): "
- << std::endl
+ std::cout << "schema of specified vertex properties chunk (V2): " <<
std::endl
<< specific_table->schema()->ToString() << std::endl;
index_col =
specific_table->GetColumnByName(graphar::GeneralParams::kVertexIndexCol);
diff --git a/cpp/src/graphar/filesystem.cc b/cpp/src/graphar/filesystem.cc
index 93684ceb..83f9b7dc 100644
--- a/cpp/src/graphar/filesystem.cc
+++ b/cpp/src/graphar/filesystem.cc
@@ -123,18 +123,15 @@ Result<std::shared_ptr<arrow::Table>>
FileSystem::ReadFileToTable(
builder.memory_pool(arrow::default_memory_pool());
GAR_RETURN_ON_ARROW_ERROR_AND_ASSIGN(auto reader, builder.Build());
std::shared_ptr<arrow::Table> table;
+ arrow::Status read_status;
if (column_indices.empty()) {
- arrow::Status read_status = reader->ReadTable(&table);
- if (!read_status.ok()) {
- return Status::Invalid("Failed to read table from file: ", path, " - ",
- read_status.ToString());
- }
+ read_status = reader->ReadTable(&table);
} else {
- arrow::Status read_status = reader->ReadTable(column_indices, &table);
- if (!read_status.ok()) {
- return Status::Invalid("Failed to read table from file: ", path, " - ",
- read_status.ToString());
- }
+ read_status = reader->ReadTable(column_indices, &table);
+ }
+ if (!read_status.ok()) {
+ return Status::Invalid("Failed to read table from file: ", path, " - ",
+ read_status.ToString());
}
return table;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]