24#ifndef HYRAX_GIT_SUPERCHUNK_H
25#define HYRAX_GIT_SUPERCHUNK_H
46 friend class SuperChunkTest;
50 std::shared_ptr<http::url> d_data_url;
51 std::vector<std::shared_ptr<Chunk>> d_chunks;
52 unsigned long long d_offset = 0;
53 unsigned long long d_size = 0;
54 bool d_is_read =
false;
55 char *d_read_buffer =
nullptr;
57 bool d_uses_fill_value{
false};
59 bool non_contiguous_chunk{
false};
61 bool is_contiguous(std::shared_ptr<Chunk> candidate_chunk);
62 void map_chunks_to_buffer();
63 void map_non_contiguous_chunks_to_buffer();
64 void read_aggregate_bytes();
65 void read_fill_value_chunk();
69 explicit SuperChunk(
const std::string &sc_id,
DmrppArray *parent =
nullptr) :
70 d_id(sc_id), d_parent_array(parent)
73 virtual ~SuperChunk(){
74 delete[] d_read_buffer;
77 virtual std::string id()
const {
return d_id; }
79 virtual bool add_chunk(std::shared_ptr<Chunk> candidate_chunk);
81 std::shared_ptr<http::url> get_data_url() {
return d_data_url; }
82 virtual unsigned long long get_size()
const {
return d_size; }
83 virtual unsigned long long get_offset()
const {
return d_offset; }
89 virtual void read_unconstrained() {
93 virtual void read_unconstrained_dio();
97 virtual void retrieve_data_dio();
102 virtual bool empty()
const {
return d_chunks.empty(); }
104 void set_non_contiguous_chunk_flag(
bool flag) { non_contiguous_chunk = flag; }
105 bool get_non_contiguous_chunk_flag()
const {
return non_contiguous_chunk;}
106 virtual bool add_chunk_non_contiguous(std::shared_ptr<Chunk> candidate_chunk,
unsigned long long &end_pos);
108 std::string
to_string(
bool verbose)
const;
109 virtual void dump(std::ostream & strm)
const;
116struct one_chunk_args {
117 std::thread::id parent_thread_id;
118 std::string parent_super_chunk_id;
119 std::shared_ptr<Chunk> chunk;
123 one_chunk_args(
const std::string &sc_id, std::shared_ptr<Chunk> c,
DmrppArray *a,
const std::vector<unsigned long long> &a_s)
124 : parent_thread_id(std::this_thread::get_id()), parent_super_chunk_id(sc_id), chunk(std::move(c)), array(a), array_shape(a_s) {}
132struct one_chunk_unconstrained_args {
133 std::thread::id parent_thread_id;
134 std::string parent_super_chunk_id;
135 std::shared_ptr<Chunk> chunk;
140 one_chunk_unconstrained_args(
const std::string &sc_id, std::shared_ptr<Chunk> c,
DmrppArray *a,
const std::vector<unsigned long long> &a_s,
141 const std::vector<unsigned long long> &c_s)
142 : parent_thread_id(std::this_thread::get_id()), parent_super_chunk_id(sc_id), chunk(std::move(c)),
143 array(a), array_shape(a_s), chunk_shape(c_s) {}
146void process_chunks_concurrent(
147 const string &super_chunk_id,
148 std::queue<shared_ptr<Chunk>> &chunks,
150 const std::vector<unsigned long long> &shape );
152void process_chunks_unconstrained_concurrent(
153 const string &super_chunk_id,
154 std::queue<std::shared_ptr<Chunk>> &chunks,
155 const std::vector<unsigned long long> &chunk_shape,
157 const std::vector<unsigned long long> &array_shape);
159void process_chunks_unconstrained_concurrent_dio(
160 const string &super_chunk_id,
161 std::queue<std::shared_ptr<Chunk>> &chunks,
162 const std::vector<unsigned long long> &chunk_shape,
164 const std::vector<unsigned long long> &array_shape);
Extend libdap::Array so that a handler can read data using a DMR++ file.
virtual void retrieve_data()
Cause the SuperChunk and all of it's subordinate Chunks to be read.
virtual bool add_chunk(std::shared_ptr< Chunk > candidate_chunk)
Attempts to add a new Chunk to this SuperChunk.
std::string to_string(bool verbose) const
Makes a string representation of the SuperChunk.
virtual void dump(std::ostream &strm) const
Writes the to_string() output to the stream strm.
virtual void process_child_chunks()
Reads the SuperChunk, inflates/de-shuffles the subordinate chunks as required and copies the values i...
virtual void process_child_chunks_unconstrained()
Reads the SuperChunk, inflates/deshuffles the subordinate chunks as required and copies the values in...