bes  Updated for version 3.20.8
SuperChunk.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of the BES
4 
5 // Copyright (c) 2020 OPeNDAP, Inc.
6 // Author: Nathan Potter<ndp@opendap.org>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 //
22 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
23 
24 #ifndef HYRAX_GIT_SUPERCHUNK_H
25 #define HYRAX_GIT_SUPERCHUNK_H
26 
27 
28 #include <vector>
29 #include <memory>
30 
31 
32 #include "Chunk.h"
33 
34 
35 namespace dmrpp {
36 
37 class DmrppArray;
38 
39 class SuperChunk {
40 private:
41  std::string d_data_url;
42  std::vector<std::shared_ptr<Chunk>> d_chunks;
43  unsigned long long d_offset;
44  unsigned long long d_size;
45  bool d_is_read;
46  char *d_read_buffer;
47 
48  bool is_contiguous(std::shared_ptr<Chunk> candidate_chunk);
49  void map_chunks_to_buffer();
50  void read_aggregate_bytes();
51 
52 public:
53  explicit SuperChunk():
54  d_data_url(""), d_offset(0), d_size(0), d_is_read(false), d_read_buffer(nullptr){}
55 
56  virtual ~SuperChunk(){
57  delete[] d_read_buffer;
58  }
59 
60  virtual bool add_chunk(std::shared_ptr<Chunk> candidate_chunk);
61 
62  virtual std::string get_data_url(){ return d_data_url; }
63  virtual unsigned long long get_size(){ return d_size; }
64  virtual unsigned long long get_offset(){ return d_offset; }
65 
66  virtual void read();
67  virtual bool empty(){ return d_chunks.empty(); }
68 
69 
70  std::vector<std::shared_ptr<Chunk>> get_chunks(){ return d_chunks; }
71 
72  //virtual void read_and_copy(DmrppArray *target_array);
73  //virtual void read_and_copy_unconstrained(DmrppArray *target_array);
74 
75  std::string to_string(bool verbose) const;
76  virtual void dump(std::ostream & strm) const;
77 };
78 
79 }// namespace dmrpp
80 
81 
82 #endif //HYRAX_GIT_SUPERCHUNK_H
virtual void read()
Cause the SuperChunk and all of it's subordinate Chunks to be read.
Definition: SuperChunk.cc:168
virtual bool add_chunk(std::shared_ptr< Chunk > candidate_chunk)
Attempts to add a new Chunk to this SuperChunk.
Definition: SuperChunk.cc:64
std::string to_string(bool verbose) const
Makes a string representation of the SuperChunk.
Definition: SuperChunk.cc:265
virtual void dump(std::ostream &strm) const
Writes the to_string() output to the stream strm.
Definition: SuperChunk.cc:286