File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,23 +102,30 @@ class IndexSelection {
102102 template <typename T>
103103 Future<std::vector<T>> run_values (const std::string& output_variable) {
104104 auto non_const_ds = dataset_;
105+ std::vector<Future<VariableData<T>>> reads;
106+ reads.reserve (kept_runs_.size ());
105107 std::vector<T> ret;
106108
107109 for (const auto & desc : kept_runs_) {
108110 MDIO_ASSIGN_OR_RETURN (auto ds, non_const_ds.isel (desc));
109111 MDIO_ASSIGN_OR_RETURN (auto var, ds.variables .get <T>(output_variable));
110112 auto fut = var.Read ();
111- MDIO_ASSIGN_OR_RETURN (auto resolution, _resolve_future<T>(fut));
113+ reads.push_back (fut);
114+ if (var.rank () == 1 ) {
115+ break ;
116+ }
117+ }
118+
119+
120+ for (auto & f : reads) {
121+ MDIO_ASSIGN_OR_RETURN (auto resolution, _resolve_future<T>(f));
112122 auto data = std::get<0 >(resolution);
113123 auto data_ptr = std::get<1 >(resolution);
114124 auto offset = std::get<2 >(resolution);
115125 auto n = std::get<3 >(resolution);
116126 std::vector<T> buffer (n);
117127 std::memcpy (buffer.data (), data_ptr + offset, n * sizeof (T));
118128 ret.insert (ret.end (), buffer.begin (), buffer.end ());
119- if (var.rank () == 1 ) {
120- return ret;
121- }
122129 }
123130 return ret;
124131 }
You can’t perform that action at this time.
0 commit comments