FlashGraph-ng
A new frontier in large-scale graph analysis and data mining
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
one_val_matrix_store.h
1 #ifndef __ONE_VAL_MATRIX_STORE_H__
2 #define __ONE_VAL_MATRIX_STORE_H__
3 
4 /*
5  * Copyright 2014 Open Connectome Project (http://openconnecto.me)
6  * Written by Da Zheng (zhengda1936@gmail.com)
7  *
8  * This file is part of FlashMatrix.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 
23 #include "virtual_matrix_store.h"
24 #include "NUMA_mapper.h"
25 
26 namespace fm
27 {
28 
29 namespace detail
30 {
31 
32 class one_val_matrix_store: public virtual_matrix_store
33 {
34  scalar_variable::ptr val;
35  matrix_layout_t layout;
36  std::vector<raw_data_array> portion_bufs;
37  int num_nodes;
38  std::shared_ptr<NUMA_mapper> mapper;
39 public:
40  one_val_matrix_store(scalar_variable::ptr val, size_t nrow, size_t ncol,
41  matrix_layout_t layout, int num_nodes);
42 
43  virtual std::string get_name() const {
44  return (boost::format("one_val_mat(%1%,%2%)") % get_num_rows()
45  % get_num_cols()).str();
46  }
47  virtual matrix_store::const_ptr materialize(bool in_mem,
48  int num_nodes) const;
49  virtual std::shared_ptr<const vec_store> get_col_vec(off_t idx) const;
50  virtual std::shared_ptr<const vec_store> get_row_vec(off_t idx) const;
51  virtual matrix_store::const_ptr get_cols(const std::vector<off_t> &idxs) const;
52  virtual matrix_store::const_ptr get_rows(const std::vector<off_t> &idxs) const;
53 
54  virtual std::pair<size_t, size_t> get_portion_size() const;
55 
56  using virtual_matrix_store::get_portion;
57  virtual std::shared_ptr<const local_matrix_store> get_portion(
58  size_t start_row, size_t start_col, size_t num_rows,
59  size_t num_cols) const;
60  virtual async_cres_t get_portion_async(
61  size_t start_row, size_t start_col, size_t num_rows,
62  size_t num_cols, std::shared_ptr<portion_compute> compute) const {
63  return async_cres_t(true,
64  get_portion(start_row, start_col, num_rows, num_cols));
65  }
66  virtual std::shared_ptr<const local_matrix_store> get_portion(
67  size_t id) const;
68 
69  virtual matrix_store::const_ptr transpose() const;
70 
71  virtual matrix_layout_t store_layout() const {
72  return layout;
73  }
74  virtual int get_num_nodes() const {
75  return num_nodes;
76  }
77 
78  virtual std::unordered_map<size_t, size_t> get_underlying_mats() const {
79  return std::unordered_map<size_t, size_t>();
80  }
81 };
82 
83 }
84 
85 }
86 
87 #endif