Apache GraphAr C++ Library
The C++ Library for Apache GraphAr
Public Member Functions | Static Public Member Functions | List of all members
graphar::builder::VerticesBuilder Class Reference

VertexBuilder is designed for building and writing a collection of vertices. More...

#include <vertices_builder.h>

Public Member Functions

 VerticesBuilder (const std::shared_ptr< VertexInfo > &vertex_info, const std::string &prefix, IdType start_vertex_index=0, const ValidateLevel &validate_level=ValidateLevel::no_validate)
 Initialize the VerticesBuilder. More...
 
void Clear ()
 Clear the vertices in this VerciesBuilder.
 
void SetValidateLevel (const ValidateLevel &validate_level)
 Set the validate level. More...
 
ValidateLevel GetValidateLevel () const
 Get the validate level. More...
 
Status AddVertex (Vertex &v, IdType index=-1, ValidateLevel validate_level=ValidateLevel::default_validate)
 Add a vertex with the given index. More...
 
IdType GetNum () const
 Get the current number of vertices in the collection. More...
 
Status Dump ()
 Dump the collection into files. More...
 

Static Public Member Functions

static Result< std::shared_ptr< VerticesBuilder > > Make (const std::shared_ptr< VertexInfo > &vertex_info, const std::string &prefix, IdType start_vertex_index=0, const ValidateLevel &validate_level=ValidateLevel::no_validate)
 Construct a VertexBuilder from vertex info. More...
 
static Result< std::shared_ptr< VerticesBuilder > > Make (const std::shared_ptr< GraphInfo > &graph_info, const std::string &label, IdType start_vertex_index=0, const ValidateLevel &validate_level=ValidateLevel::no_validate)
 Construct a VertexBuilder from graph info and vertex label. More...
 

Detailed Description

VertexBuilder is designed for building and writing a collection of vertices.

Definition at line 130 of file vertices_builder.h.

Constructor & Destructor Documentation

◆ VerticesBuilder()

graphar::builder::VerticesBuilder::VerticesBuilder ( const std::shared_ptr< VertexInfo > &  vertex_info,
const std::string &  prefix,
IdType  start_vertex_index = 0,
const ValidateLevel &  validate_level = ValidateLevel::no_validate 
)
inlineexplicit

Initialize the VerticesBuilder.

Parameters
vertex_infoThe vertex info that describes the vertex type.
prefixThe absolute prefix.
start_vertex_indexThe start index of the vertices collection.
validate_levelThe global validate level for the writer, with no validate by default. It could be ValidateLevel::no_validate, ValidateLevel::weak_validate or ValidateLevel::strong_validate, but could not be ValidateLevel::default_validate.

Definition at line 143 of file vertices_builder.h.

Member Function Documentation

◆ AddVertex()

Status graphar::builder::VerticesBuilder::AddVertex ( Vertex v,
IdType  index = -1,
ValidateLevel  validate_level = ValidateLevel::default_validate 
)
inline

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.

Parameters
vThe vertex to add.
indexThe given index, -1 means the next unused index.
validate_levelThe validate level for this operation, which is the builder's validate level by default.
Returns
Status: ok or Status::Invalid error.

Definition at line 211 of file vertices_builder.h.

◆ Dump()

Status graphar::builder::VerticesBuilder::Dump ( )
inline

Dump the collection into files.

Returns
Status: ok or error.

Definition at line 242 of file vertices_builder.h.

◆ GetNum()

IdType graphar::builder::VerticesBuilder::GetNum ( ) const
inline

Get the current number of vertices in the collection.

Returns
The current number of vertices in the collection.

Definition at line 235 of file vertices_builder.h.

◆ GetValidateLevel()

ValidateLevel graphar::builder::VerticesBuilder::GetValidateLevel ( ) const
inline

Get the validate level.

Returns
The validate level of this writer.

Definition at line 187 of file vertices_builder.h.

◆ Make() [1/2]

static Result<std::shared_ptr<VerticesBuilder> > graphar::builder::VerticesBuilder::Make ( const std::shared_ptr< GraphInfo > &  graph_info,
const std::string &  label,
IdType  start_vertex_index = 0,
const ValidateLevel &  validate_level = ValidateLevel::no_validate 
)
inlinestatic

Construct a VertexBuilder from graph info and vertex label.

Parameters
graph_infoThe graph info that describes the graph.
labelThe label of the vertex.
start_vertex_indexThe start index of the vertices collection.
validate_levelThe global validate level for the builder, default is no_validate.

Definition at line 284 of file vertices_builder.h.

◆ Make() [2/2]

static Result<std::shared_ptr<VerticesBuilder> > graphar::builder::VerticesBuilder::Make ( const std::shared_ptr< VertexInfo > &  vertex_info,
const std::string &  prefix,
IdType  start_vertex_index = 0,
const ValidateLevel &  validate_level = ValidateLevel::no_validate 
)
inlinestatic

Construct a VertexBuilder from vertex info.

Parameters
vertex_infoThe vertex info that describes the vertex type.
prefixThe absolute prefix.
start_vertex_indexThe start index of the vertices collection.
validate_levelThe global validate level for the builder, default is no_validate.

Definition at line 267 of file vertices_builder.h.

◆ SetValidateLevel()

void graphar::builder::VerticesBuilder::SetValidateLevel ( const ValidateLevel &  validate_level)
inline

Set the validate level.

Parameters
validate_levelThe validate level to set.

Definition at line 175 of file vertices_builder.h.


The documentation for this class was generated from the following files: