6 #ifndef TURI_SGRAPH_SGRAPH_COMPUTE_VERTEX_BLOCK_HPP 7 #define TURI_SGRAPH_SGRAPH_COMPUTE_VERTEX_BLOCK_HPP 11 #include <core/parallel/mutex.hpp> 12 #include <core/storage/sframe_data/sframe.hpp> 13 #include <core/data/flexible_type/flexible_type.hpp> 26 namespace sgraph_compute {
31 template <
typename SIterableType>
50 void load(
const SIterableType& sf) {
55 void flush(SIterableType& outputsf) {
57 outputsf.get_output_iterator(0));
61 void flush(SIterableType& outputsf,
const std::vector<size_t>& mutated_field_index) {
62 auto out = outputsf.get_output_iterator(0);
63 std::vector<flexible_type> temp(mutated_field_index.size());
65 for (
size_t i = 0; i < mutated_field_index.size(); ++i) {
66 temp[i] = value[mutated_field_index[i]];
115 typename SIterableType::value_type& operator[](
size_t i) {
119 const typename SIterableType::value_type& operator[](
size_t i)
const {
127 void load_impl(
const SIterableType& sf) {
128 if (m_last_index_file != sf.get_index_file() || !m_reader) {
129 m_last_index_file = sf.get_index_file();
130 m_reader = std::move(sf.get_reader());
132 m_vertices.reserve(sf.size());
133 m_reader->read_rows(0, m_reader->size(),
m_vertices);
137 bool m_loaded =
false;
139 bool m_modified =
false;
141 std::string m_last_index_file;
142 std::unique_ptr<typename SIterableType::reader_type> m_reader;
void clear_modified_flag()
void load(const SIterableType &sf)
void load_if_not_loaded(const SIterableType &sf)
void copy(const std::string src, const std::string dest)
std::vector< typename SIterableType::value_type > m_vertices
The loaded data.