6 #ifndef TURI_SGRAPH_SGRAPH_TRIPLE_APPLY 7 #define TURI_SGRAPH_SGRAPH_TRIPLE_APPLY 9 #include<core/data/flexible_type/flexible_type.hpp> 10 #include<core/storage/sgraph_data/sgraph.hpp> 11 #include<core/storage/sgraph_data/sgraph_compute_vertex_block.hpp> 24 namespace sgraph_compute {
26 typedef std::vector<flexible_type> vertex_data;
27 typedef std::vector<flexible_type> edge_data;
28 typedef sgraph::vertex_partition_address vertex_partition_address;
29 typedef sgraph::edge_partition_address edge_partition_address;
39 vertex_data&
source() {
return *m_source; }
41 const vertex_data&
source()
const {
return *m_source; }
43 vertex_data& target() {
return *m_target; }
45 const vertex_data& target()
const {
return *m_target; }
48 edge_data&
edge() {
return *m_edge; }
50 const edge_data&
edge()
const {
return *m_edge; }
55 if (m_lock_0 && m_lock_1) {
56 if (m_lock_0 == m_lock_1) {
67 if (m_lock_0 && m_lock_1) {
68 if (m_lock_0 == m_lock_1) {
81 m_source(source), m_target(target), m_edge(edge),
82 m_lock_0(lock_0), m_lock_1(lock_1) { }
85 vertex_data* m_source;
86 vertex_data* m_target;
93 typedef std::function<void(edge_scope&)> triple_apply_fn_type;
95 typedef std::function<void(std::vector<edge_scope>&)> batch_triple_apply_fn_type;
121 triple_apply_fn_type apply_fn,
122 const std::vector<std::string>& mutated_vertex_fields,
123 const std::vector<std::string>& mutated_edge_fields = {},
124 bool requires_vertex_id =
true);
132 const std::vector<std::string>& mutated_vertex_fields,
133 const std::vector<std::string>& mutated_edge_fields = {});
149 batch_triple_apply_fn_type batch_apply_fn,
150 const std::vector<std::string>& mutated_vertex_fields,
151 const std::vector<std::string>& mutated_edge_fields = {});
158 triple_apply_fn_type apply_fn,
159 const std::vector<std::string>& mutated_vertex_fields,
160 const std::vector<std::string>& mutated_edge_fields = {});
edge_data & edge()
Provide edge data access.
void lock() const
Acquires a lock on the mutex.
void unlock_vertices()
Unlock both source and target vertices.
void unlock() const
Releases a lock on the mutex.
vertex_data & source()
Provide vertex data access.
void lock_vertices()
Lock both source and target vertices.
void triple_apply(sgraph &g, triple_apply_fn_type apply_fn, const std::vector< std::string > &mutated_vertex_fields, const std::vector< std::string > &mutated_edge_fields={}, bool requires_vertex_id=true)
edge_scope(vertex_data *source, vertex_data *target, edge_data *edge, turi::mutex *lock_0=NULL, turi::mutex *lock_1=NULL)
Do not construct edge_scope directly. Used by triple_apply_impl.
void batch_triple_apply_mock(sgraph &g, triple_apply_fn_type apply_fn, const std::vector< std::string > &mutated_vertex_fields, const std::vector< std::string > &mutated_edge_fields={})