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, std::shared_ptr< WriterOptions > writerOptions=nullptr, const ValidateLevel &validate_level=ValidateLevel::no_validate)
 Initialize the VerticesBuilder. More...
 
void Clear ()
 Clear the vertices in this VerciesBuilder.
 
void SetWriterOptions (std::shared_ptr< WriterOptions > writer_options)
 Set the writerOptions. More...
 
std::shared_ptr< WriterOptionsGetWriterOptions ()
 Set the writerOptions. More...
 
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, std::shared_ptr< WriterOptions > writer_options, 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< VertexInfo > &vertex_info, const std::string &prefix, IdType start_vertex_index=0, const ValidateLevel &validate_level=ValidateLevel::no_validate)
 
static Result< std::shared_ptr< VerticesBuilder > > Make (const std::shared_ptr< GraphInfo > &graph_info, const std::string &type, std::shared_ptr< WriterOptions > writer_options, IdType start_vertex_index=0, const ValidateLevel &validate_level=ValidateLevel::no_validate)
 Construct a VertexBuilder from graph info and vertex type. More...
 
static Result< std::shared_ptr< VerticesBuilder > > Make (const std::shared_ptr< GraphInfo > &graph_info, const std::string &type, IdType start_vertex_index=0, const ValidateLevel &validate_level=ValidateLevel::no_validate)
 

Detailed Description

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

Definition at line 224 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,
std::shared_ptr< WriterOptions writerOptions = nullptr,
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.
writerOptionsThe writerOptions provides configuration options for different file format writers.
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 239 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 328 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 359 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 352 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 304 of file vertices_builder.h.

◆ GetWriterOptions()

std::shared_ptr<WriterOptions> graphar::builder::VerticesBuilder::GetWriterOptions ( )
inline

Set the writerOptions.

Parameters
writerOptionsThe writerOptions provides configuration options for different file format writers.

Definition at line 283 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 &  type,
std::shared_ptr< WriterOptions writer_options,
IdType  start_vertex_index = 0,
const ValidateLevel &  validate_level = ValidateLevel::no_validate 
)
inlinestatic

Construct a VertexBuilder from graph info and vertex type.

Parameters
graph_infoThe graph info that describes the graph.
typeThe type of the vertex.
start_vertex_indexThe start index of the vertices collection.
writerOptionsThe writerOptions provides configuration options for different file format writers.
validate_levelThe global validate level for the builder, default is no_validate.

Definition at line 416 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,
std::shared_ptr< WriterOptions writer_options,
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.
writerOptionsThe writerOptions provides configuration options for different file format writers.
validate_levelThe global validate level for the builder, default is no_validate.

Definition at line 387 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 292 of file vertices_builder.h.

◆ SetWriterOptions()

void graphar::builder::VerticesBuilder::SetWriterOptions ( std::shared_ptr< WriterOptions writer_options)
inline

Set the writerOptions.

Returns
The writerOptions provides configuration options for different file format writers.

Definition at line 273 of file vertices_builder.h.


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