6 #ifndef TURI_UNITY_SGRAPH_HPP 7 #define TURI_UNITY_SGRAPH_HPP 8 #include <model_server/lib/api/unity_graph_interface.hpp> 9 #include <model_server/lib/api/unity_sframe_interface.hpp> 10 #include <model_server/lib/sgraph_triple_apply_typedefs.hpp> 11 #include <core/storage/sgraph_data/sgraph_constants.hpp> 12 #include <core/storage/sframe_data/dataframe.hpp> 14 #include <core/parallel/mutex.hpp> 20 class lazy_eval_operation_dag;
22 class lazy_eval_future;
27 typedef lazy_eval_operation_dag<sgraph> unity_graph_dag_type;
28 typedef lazy_eval_future<sgraph> sgraph_future;
48 static unity_graph_dag_type*
get_dag();
50 static const char* GRAPH_MAGIC_HEADER;
79 std::shared_ptr<unity_sgraph_base>
clone();
99 const std::vector<flexible_type>& vid_vec = std::vector<flexible_type>(),
131 std::shared_ptr<unity_sframe_base>
get_edges(
const std::vector<flexible_type>& source_vids=std::vector<flexible_type>(),
132 const std::vector<flexible_type>& target_vids=std::vector<flexible_type>(),
134 size_t groupa = 0,
size_t groupb = 0);
154 std::shared_ptr<unity_sframe_base> vertices,
155 const std::string& id_field_name,
size_t group = 0);
170 std::shared_ptr<unity_sgraph_base>
add_edges(
171 std::shared_ptr<unity_sframe_base> edges,
172 const std::string& source_field_name,
173 const std::string& target_field_name,
174 size_t groupa = 0,
size_t groupb = 0);
189 std::vector<std::string>
get_edge_fields(
size_t groupa = 0,
size_t groupb = 0);
201 const std::vector<std::string>& fields,
size_t group=0);
208 std::string field, std::string newfield,
size_t group=0);
215 std::string field,
size_t group=0);
221 std::shared_ptr<unity_sarray_base> column_data, std::string field);
228 const std::vector<std::string>& oldnames,
229 const std::vector<std::string>& newnames);
236 const std::string& field1,
const std::string& field2);
244 const std::vector<std::string>& fields,
245 size_t groupa=0,
size_t groupb=0);
252 std::string field, std::string newfield,
253 size_t groupa=0,
size_t groupb=0);
260 std::string field,
size_t groupa=0,
size_t groupb=0);
266 std::shared_ptr<unity_sarray_base> column_data, std::string field);
273 const std::vector<std::string>& oldnames,
274 const std::vector<std::string>& newnames);
280 std::shared_ptr<unity_sgraph_base>
swap_edge_fields(
const std::string& field1,
const std::string& field2);
283 std::shared_ptr<unity_sgraph_base> lambda_triple_apply(
const std::string& lambda_str,
284 const std::vector<std::string>& mutated_fields);
286 std::shared_ptr<unity_sgraph_base> lambda_triple_apply_native(
288 const std::vector<std::string>& mutated_fields);
290 std::shared_ptr<unity_sgraph_base> lambda_triple_apply_native(
292 const std::vector<std::string>& mutated_fields);
344 bool save_graph(std::string target_dir, std::string format);
355 mutable std::shared_ptr<sgraph_future> m_graph;
359 void fast_validate_add_vertices(
const sframe& vertices,
360 std::string id_field,
363 void fast_validate_add_edges(
const sframe& vertices,
364 std::string src_field,
365 std::string dst_field,
366 size_t groupa,
size_t groupb)
const;
370 std::shared_ptr<unity_sframe_base> get_edges_lazy(
size_t groupa = 0,
size_t groupb = 0);
std::vector< flex_type_enum > get_vertex_field_types(size_t group=0)
std::vector< std::string > get_edge_fields(size_t groupa=0, size_t groupb=0)
sgraph & get_graph() const
The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities.
std::shared_ptr< unity_sgraph_base > add_edges(std::shared_ptr< unity_sframe_base > edges, const std::string &source_field_name, const std::string &target_field_name, size_t groupa=0, size_t groupb=0)
std::shared_ptr< unity_sgraph_base > copy_vertex_field(std::string field, std::string newfield, size_t group=0)
sframe group(sframe sframe_in, std::string key_column)
std::shared_ptr< unity_sgraph_base > swap_vertex_fields(const std::string &field1, const std::string &field2)
bool load_graph(std::string target_dir)
std::shared_ptr< unity_sgraph_base > copy_edge_field(std::string field, std::string newfield, size_t groupa=0, size_t groupb=0)
std::shared_ptr< unity_sgraph_base > add_vertices(std::shared_ptr< unity_sframe_base > vertices, const std::string &id_field_name, size_t group=0)
static unity_graph_dag_type * get_dag()
Gets the lazy evaluation DAG object.
std::vector< flex_type_enum > get_edge_field_types(size_t groupa=0, size_t groupb=0)
void save_reference(oarchive &oarc) const
unity_sgraph(size_t npartitions=SGRAPH_DEFAULT_NUM_PARTITIONS)
Default constructor.
std::shared_ptr< unity_sgraph_base > select_vertex_fields(const std::vector< std::string > &fields, size_t group=0)
std::shared_ptr< unity_sgraph_base > add_edge_field(std::shared_ptr< unity_sarray_base > column_data, std::string field)
std::shared_ptr< unity_sgraph_base > rename_edge_fields(const std::vector< std::string > &oldnames, const std::vector< std::string > &newnames)
std::shared_ptr< unity_sgraph_base > swap_edge_fields(const std::string &field1, const std::string &field2)
std::shared_ptr< unity_sframe_base > get_vertices(const std::vector< flexible_type > &vid_vec=std::vector< flexible_type >(), const options_map_t &field_constraint=options_map_t(), size_t group=0)
bool save_graph(std::string target_dir, std::string format)
std::shared_ptr< unity_sgraph_base > add_vertex_field(std::shared_ptr< unity_sarray_base > column_data, std::string field)
std::shared_ptr< unity_sgraph_base > delete_vertex_field(std::string field, size_t group=0)
void save(oarchive &oarc) const
size_t SGRAPH_DEFAULT_NUM_PARTITIONS
std::shared_ptr< unity_sgraph_base > clone()
unity_sgraph & operator=(const unity_sgraph &)=default
void load(iarchive &iarc)
std::shared_ptr< unity_sgraph_base > delete_edge_field(std::string field, size_t groupa=0, size_t groupb=0)
std::function< void(edge_triple &)> lambda_triple_apply_fn
static unity_graph_dag_type * dag_singleton
Global lazy evaluation DAG object.
std::shared_ptr< unity_sframe_base > get_edges(const std::vector< flexible_type > &source_vids=std::vector< flexible_type >(), const std::vector< flexible_type > &target_vids=std::vector< flexible_type >(), const options_map_t &field_constraint=options_map_t(), size_t groupa=0, size_t groupb=0)
std::map< std::string, flexible_type > options_map_t
virtual ~unity_sgraph()
Destructor.
The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities.
std::vector< std::string > get_vertex_fields(size_t group=0)
std::shared_ptr< unity_sgraph_base > select_edge_fields(const std::vector< std::string > &fields, size_t groupa=0, size_t groupb=0)
std::shared_ptr< unity_sgraph_base > rename_vertex_fields(const std::vector< std::string > &oldnames, const std::vector< std::string > &newnames)