acezen commented on code in PR #610:
URL: https://github.com/apache/incubator-graphar/pull/610#discussion_r1741630442


##########
cpp/src/graphar/arrow/chunk_writer.cc:
##########
@@ -287,9 +307,104 @@ Status VertexPropertyWriter::WriteTable(
     GAR_RETURN_NOT_OK(WriteTable(table_with_index, property_group,
                                  start_chunk_index, validate_level));
   }
+  auto labels = vertex_info_->GetLabels();
+  if(!labels.empty()){
+    GAR_ASSIGN_OR_RAISE(auto label_table, GetLabelTable(input_table, labels))
+    GAR_RETURN_NOT_OK(WriteLabelTable(label_table, 
+                                 start_chunk_index, FileType::PARQUET, 
validate_level));
+  };
+  
   return Status::OK();
 }
 
+
+// Helper function to split a string by a delimiter
+std::vector<std::string> SplitString(const std::string& str, char delimiter) {
+    std::vector<std::string> tokens;
+    std::string token;
+    std::istringstream tokenStream(str);
+    while (std::getline(tokenStream, token, delimiter)) {
+        tokens.push_back(token);
+    }
+    return tokens;
+}
+
+Status VertexPropertyWriter::WriteLabelTable(
+    const std::shared_ptr<arrow::Table>& input_table, 
+    IdType start_chunk_index,
+    FileType file_type,
+    ValidateLevel validate_level) const {
+  auto schema = input_table->schema();
+  int indice = schema->GetFieldIndex(GeneralParams::kVertexIndexCol);
+  IdType chunk_size = vertex_info_->GetChunkSize();
+  int64_t length = input_table->num_rows();
+  IdType chunk_index = start_chunk_index;
+  for (int64_t offset = 0; offset < length;
+       offset += chunk_size, chunk_index++) {
+    auto in_chunk = input_table->Slice(offset, chunk_size);
+    GAR_RETURN_NOT_OK(WriteLabelChunk(in_chunk,
+                                chunk_index, file_type, validate_level));
+  }
+  return Status::OK();
+}
+
+Result<std::shared_ptr<arrow::Table>> VertexPropertyWriter::GetLabelTable(
+    const std::shared_ptr<arrow::Table>& input_table, 
+    const std::vector<std::string>& labels) const {
+          // Find the :LABEL column index
+    auto label_col_idx = input_table->schema()->GetFieldIndex(":LABEL");

Review Comment:
   I suggest put the ":LABEL" to `GeneralParams`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to