Skip to content

Commit

Permalink
Add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
lixueclaire committed Jun 12, 2023
1 parent 20c40b0 commit 6ac637a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cpp/include/gar/utils/writer_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ enum class ValidateLevel : char {
/// and the size of the table passed to the writer/builder are valid.
weak_validate = 2,
/// Strong validation: except for the weak validation, also check if the
/// schema (including each property name and data type) of the table passed to
/// the writer/builder is consistent with that defined in the info.
/// schema (including each property name and data type) of the intput data
/// passed to the writer/builder is consistent with that defined in the info.
strong_validate = 3
};

Expand Down
35 changes: 35 additions & 0 deletions cpp/include/gar/writer/arrow_chunk_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ namespace GAR_NAMESPACE_INTERNAL {
/**
* @brief The writer for vertex property group chunks.
*
* Notes: For each writing operation, a validate_level could be set, which will
* be used to validate the data before writing. The validate_level could be:
*
* ValidateLevel::default_validate: to use the validate_level of the writer,
* which set through the constructor or the SetValidateLevel method;
*
* ValidateLevel::no_validate: without validation;
*
* ValidateLevel::weak_validate: to validate if the vertex count or vertex chunk
* index is non-negative, the property group exists and the size of input_table
* is not larger than the vertex chunk size;
*
* ValidateLevel::strong_validate: besides weak_validate, also validate the
* schema of input_table is consistent with that of property group; for writing
* operations without input_table, such as writing vertices number or copying
* file, the strong_validate is same as weak_validate.
*
*/
class VertexPropertyWriter {
public:
Expand Down Expand Up @@ -219,6 +236,24 @@ class VertexPropertyWriter {
/**
* @brief The writer for edge (adj list, offset and property group) chunks.
*
* Notes: For each writing operation, a validate_level could be set, which will
* be used to validate the data before writing. The validate_level could be:
*
* ValidateLevel::default_validate: to use the validate_level of the writer,
* which set through the constructor or the SetValidateLevel method;
*
* ValidateLevel::no_validate: without validation;
*
* ValidateLevel::weak_validate: to validate if the vertex/edge count or
* vertex/edge chunk index is non-negative, the adj_list type is valid, the
* property group exists and the size of input_table is not larger than the
* chunk size;
*
* ValidateLevel::strong_validate: besides weak_validate, also validate the
* schema of input_table is consistent with that of property group; for writing
* operations without input_table, such as writing vertices/edges number or
* copying file, the strong_validate is same as weak_validate.
*
*/
class EdgeChunkWriter {
public:
Expand Down
13 changes: 13 additions & 0 deletions cpp/include/gar/writer/edges_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ class EdgesBuilder {
/**
* @brief Add an edge to the collection.
*
* The validate_level for this operation could be:
*
* ValidateLevel::default_validate: to use the validate_level of the builder,
* which set through the constructor or the SetValidateLevel method;
*
* ValidateLevel::no_validate: without validation;
*
* ValidateLevel::weak_validate: to validate if the adj_list type is valid,
* and the data in builder is not saved;
*
* ValidateLevel::strong_validate: besides weak_validate, also validate the
* schema of the edge is consistent with the info defined.
*
* @param e The edge to add.
* @param validate_level The validate level for this operation,
* which is the builder's validate level by default.
Expand Down
13 changes: 13 additions & 0 deletions cpp/include/gar/writer/vertices_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,19 @@ class VerticesBuilder {
/**
* @brief Add a vertex with the given index.
*
* The validate_level for this operation could be:
*
* ValidateLevel::default_validate: to use the validate_level of the builder,
* which set through the constructor or the SetValidateLevel method;
*
* ValidateLevel::no_validate: without validation;
*
* ValidateLevel::weak_validate: to validate if the start index and the vertex
* index is valid, and the data in builder is not saved;
*
* ValidateLevel::strong_validate: besides weak_validate, also validate the
* schema of the vertex is consistent with the info defined.
*
* @param v The vertex to add.
* @param index The given index, -1 means the next unused index.
* @param validate_level The validate level for this operation,
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow_chunk_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ Status EdgeChunkWriter::validate(
field = schema->field(index);
if (field->type()->id() != arrow::Type::INT64) {
return Status::TypeError(
"the data type for destination column should be INT64, but got " +
"the data type for destination column should be INT64, but got " +
field->type()->name());
}
}
Expand Down

0 comments on commit 6ac637a

Please sign in to comment.