vitrio 0.3.1
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
indexed_image_scratch.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2
3#pragma once
4
5#include <vitrio/export.hpp>
6#include <vitrio/image_scratch.hpp>
7#include <vitrio/image_scratch_open_mode.hpp>
8#include <vitrio/platform.hpp>
9
10#include <cstddef>
11#include <limits>
12#include <memory>
13#include <string>
14#include <unordered_map>
15
16namespace vitrio
17{
18
19class executor;
24
55class VITRIO_API indexed_image_scratch final
56 : public image_scratch
57{
58public:
97 const image_location_grouping &locations,
99 executor &tasks,
100 std::shared_ptr<image_scratch_storage> storage,
101 std::size_t run_length,
102 image_scratch_open_mode mode = image_scratch_open_mode::empty
103 );
104
105 ~indexed_image_scratch() override;
106
107 std::shared_ptr<image_scratch_entry>
108 find(const std::string &key) override;
109
110private:
111 using entry_map_type =
112 std::unordered_map<std::string, std::shared_ptr<image_scratch_entry>>;
113
114 VITRIO_STD_MEMBER_INTERFACE
115 entry_map_type m_entries;
116};
117
147VITRIO_API
148std::shared_ptr<image_scratch> create_host_image_scratch(
149 const image_location_grouping &locations,
151 executor &tasks,
152 std::size_t run_length,
153 std::size_t max_size = std::numeric_limits<std::size_t>::max()
154);
155
202VITRIO_API
203std::shared_ptr<image_scratch> create_file_image_scratch(
204 const image_location_grouping &locations,
206 executor &tasks,
207 const file_transfer_pool &transfers,
208 const std::string &path,
209 std::size_t run_length,
210 std::size_t max_size = std::numeric_limits<std::size_t>::max()
211);
212
279VITRIO_API
280std::shared_ptr<image_scratch> create_directory_image_scratch(
281 const image_location_grouping &locations,
283 executor &tasks,
284 const file_transfer_pool &transfers,
285 const std::string &directory,
286 std::size_t run_length,
287 std::size_t budget
288);
289
290} // namespace vitrio
Where a task is handed off to run, now or later.
Definition executor.hpp:26
Threads that carry out the reads and writes of files, each many at once, and hand the computations th...
Definition file_transfer_pool.hpp:30
Groups a list of image locations by file.
Definition image_location_grouping.hpp:31
Interface to serve image_reader given a key.
Definition image_reader_provider.hpp:26
Where a scratch keeps its copies: a block of bytes, in main memory or in a file, which it reads and w...
Definition image_scratch_storage.hpp:41
indexed_image_scratch(const image_location_grouping &locations, image_reader_provider &files, executor &tasks, std::shared_ptr< image_scratch_storage > storage, std::size_t run_length, image_scratch_open_mode mode=image_scratch_open_mode::empty)
Construct a scratch for a grouping of locations.
std::shared_ptr< image_scratch_entry > find(const std::string &key) override
Get what is held of a file, to read it and to add to it.