Seismic Drive Client API
SDGenericDataset.h
Go to the documentation of this file.
1 // ============================================================================
2 // Copyright 2017-2024, Schlumberger
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 // ============================================================================
16 
17 #pragma once
18 
19 #include "DLL_EXPORT.h"
20 #include "HttpContext.h"
21 #include "Params.h"
22 #include "SDDatasetDisposition.h"
23 #include "SDManager.h"
24 
25 #include <memory>
26 #include <unordered_map>
27 #include <vector>
28 
29 namespace seismicdrive
30 {
31  /*******************************************************************************/
41  {
42  public:
43  /*******************************************************************************/
51 
52  /*******************************************************************************/
60 
61  /*******************************************************************************/
69 
70  /*******************************************************************************/
77 
78  /*******************************************************************************/
86 
87  /*******************************************************************************/
94 
95  /*******************************************************************************/
102  std::string getName() const;
103 
104  /*******************************************************************************/
111  long long getSize() const;
112 
113  /*******************************************************************************/
121  void setName(const std::string &objname);
122 
123  /*******************************************************************************/
131  void setSize(long long objsize);
132 
133  private:
134 #ifdef _MSC_VER
135  #pragma warning(push)
136  #pragma warning(disable : 4251)
137 #endif
138 
139  class Impl;
140 
141  std::unique_ptr<Impl> _impl;
142 
143 #ifdef _MSC_VER
144  #pragma warning(pop)
145 #endif
146  };
147 
148  /*******************************************************************************/
157  {
158  public:
159  /*******************************************************************************/
167 
168  /*******************************************************************************/
176 
177  /*******************************************************************************/
185 
186  /*******************************************************************************/
193 
194  /*******************************************************************************/
202 
203  /*******************************************************************************/
210 
211  /*******************************************************************************/
220  bool hasNext();
221 
222  /*******************************************************************************/
233 
234  private:
235  friend class SDGenericDataset;
236  friend class SDGenericDatasetTest;
237 
238 #ifdef _MSC_VER
239  #pragma warning(push)
240  #pragma warning(disable : 4251)
241 #endif
242 
243  class Impl;
244 
245  std::unique_ptr<Impl> _impl;
246 
247 #ifdef _MSC_VER
248  #pragma warning(pop)
249 #endif
250  };
251 
252  /*******************************************************************************/
261  class DLL_PUBLIC SDGenericDataset
262  {
263  public:
264  /*******************************************************************************/
272  SDGenericDataset(SDManager *sdmanager, const std::string &sdfilename, const bool log = false);
273 
274  /*******************************************************************************/
283  SDGenericDataset(SDManager *sdmanager, const std::string &sdfilename, const std::string &filetype, const bool log = false);
284 
285  /*******************************************************************************/
291  ~SDGenericDataset();
292 
293  /*******************************************************************************/
300  SDGenericDataset(SDGenericDataset &&rhs) noexcept;
301 
302  /*******************************************************************************/
308  SDGenericDataset &operator=(SDGenericDataset &&rhs) noexcept;
309 
310  /*******************************************************************************/
318 
319  /*******************************************************************************/
325  SDGenericDataset &operator=(const SDGenericDataset &rhs);
326 
327  /*******************************************************************************/
342  void open(const SDDatasetDisposition disposition);
343 
344  /*******************************************************************************/
452  void open(const SDDatasetDisposition disposition, const std::string &legaltag);
453 
454  /*******************************************************************************/
486  void open(const SDDatasetDisposition disposition, const std::string &legaltag, const std::string &wid);
487 
488  /*******************************************************************************/
576  void open(SDDatasetDisposition disposition, const std::unordered_map<std::string, std::string> &args);
577 
578  /*******************************************************************************/
593  void open(const dataset::ParamsOpen& params);
594 
595  /*******************************************************************************/
614  void close();
615 
616  /*******************************************************************************/
622  std::string getGcsUrl() const;
623 
624  /*******************************************************************************/
631  std::string getStorageUrl() const;
632 
633  /*******************************************************************************/
640  std::string getType() const;
641 
642  /*******************************************************************************/
649  std::string getLegalTag() const;
650 
651  /*******************************************************************************/
660  bool blockExists(int blocknum) const;
661 
662  /*******************************************************************************/
671  bool blockExists(const std::string &
672  ) const;
673 
674  /*******************************************************************************/
685  void writeBlock(int blocknum, const char *data, std::size_t len, bool check_and_overwrite = false);
686 
687  /*******************************************************************************/
700  void readBlock(int blocknum, char *data, size_t offset, size_t numBytes);
701 
702  /*******************************************************************************/
713  void readBlock(int blocknum, char *data, size_t &len);
714 
715  /*******************************************************************************/
727  void readBlock(int blocknum, char **data, size_t &len);
728 
729  /*******************************************************************************/
740  void writeBlock(const std::string &blockName, const char *data, std::size_t len, bool check_and_overwrite = false);
741 
742  /*******************************************************************************/
755  void readBlock(const std::string &blockName, char *data, size_t offset, size_t numBytes);
756 
757  /*******************************************************************************/
768  void readBlock(const std::string &blockName, char *data, size_t &len);
769 
770  /*******************************************************************************/
782  void readBlock(const std::string &blockName, char **data, size_t &len);
783 
784  /*******************************************************************************/
794  long long getBlockSize(int blocknum);
795 
796  /*******************************************************************************/
806  long long getBlockSize(const std::string &blockName);
807 
808  /*******************************************************************************/
814  std::vector<long long> getBlocksSize(const std::vector<std::string> &blockNames);
815 
816  /*******************************************************************************/
825  std::vector<long long> getBlockSizes(const std::vector<std::string> &blockNames);
826 
827  /*******************************************************************************/
836  void deleteBlock(const std::string &blockName);
837 
838  /*******************************************************************************/
848  void deleteBlock(const std::string &blockName, bool skipMetadataUpdate);
849 
850  /*******************************************************************************/
857  uint64_t getBlockNum();
858 
859  /*******************************************************************************/
866  uint64_t getSize();
867 
868  /*******************************************************************************/
876  void setBlockNum(uint64_t blockNum);
877 
878  /*******************************************************************************/
887  void setSize(uint64_t size);
888 
889  /*******************************************************************************/
896  bool checkReadAccess() const;
897 
898  /*******************************************************************************/
905  bool checkWriteAccess() const;
906 
907  /*******************************************************************************/
914  bool checkDeleteAccess() const;
915 
916  /*******************************************************************************/
925  void setMetaData(const std::string &metadata) const;
926 
927  /*******************************************************************************/
934  std::string getMetaData() const;
935 
936  /*******************************************************************************/
943  std::string getFileMetaData() const;
944 
945  /*******************************************************************************/
963  void setSeismicMeta(const std::string &seismicmeta);
964 
965  /*******************************************************************************/
980  std::string getSeismicMeta() const;
981 
982  /*******************************************************************************/
999  std::string getCTag();
1000 
1001  /*******************************************************************************/
1008  std::string getConsistencyID();
1009 
1010  /*******************************************************************************/
1017  int getConsistencyCounter();
1018 
1019  /*******************************************************************************/
1060  bool checkCTag();
1061 
1062 
1063  /*******************************************************************************/
1069  void refreshDatsetMetadata();
1070 
1071  /*******************************************************************************/
1090  void refreshDatasetMetadata();
1091 
1092  /*******************************************************************************/
1099  SDGenericDatasetBasicObjectIterator getIterator() const;
1100 
1101  /*******************************************************************************/
1110  SDGenericDatasetBasicObjectIterator getIterator(bool recursive) const;
1111 
1112  /*******************************************************************************/
1118  void flush();
1119 
1120  /*******************************************************************************/
1126  bool exist() const;
1127 
1128  /*******************************************************************************/
1135  bool exists() const;
1136 
1137  /*******************************************************************************/
1144  std::string getSerializedReadOnlyAccessor() const;
1145 
1146  /*******************************************************************************/
1155  void upload(const std::string &filepath, const std::string &legaltag = "") const;
1156 
1157  /*******************************************************************************/
1187  void setTags(const std::vector<std::string> &tags) const;
1188 
1189  /*******************************************************************************/
1204  std::vector<std::string> getTags() const;
1205 
1206  /*******************************************************************************/
1221  std::string getCreatedDate() const;
1222 
1223  /*******************************************************************************/
1238  std::string getStatus() const;
1239 
1240  /*******************************************************************************/
1259  void setHttpContext(const HttpContext *context = nullptr);
1260 
1261  /*******************************************************************************/
1284  void setHttpContext(const HttpContext *context, HttpConnectionLink link);
1285 
1286  /*******************************************************************************/
1309  void setExponentialRetryBackoffPolicy(const ExponentialRetryBackoffPolicy *policy, HttpConnectionLink link = HttpConnectionLink::ANY);
1310 
1311  /*******************************************************************************/
1333  std::string getSerializedContext();
1334 
1335  /*******************************************************************************/
1351  void setReadonlyMode(bool readonly);
1352 
1353  /*******************************************************************************/
1368  bool getReadonlyMode() const;
1369 
1370  /*******************************************************************************/
1379  std::vector<std::string> getHosts();
1380 
1381  /*******************************************************************************
1382  * @brief Update the StorageTier of a dataset
1383  *
1384  * This method can be used to update all of a dataset's blobs to an available storage tier
1385  *
1386  * usage example:
1387  * - SDManager sdmanager;
1388  * - SDGenericDataset dataset(&manager, path);
1389  *
1390  * - dataset.open(SDDatasetDisposition::READ_ONLY);
1391  * - dataset.updateStorageTier(StorageTier::COOL);
1392  * - dataset.close();
1393  *
1394  * @param storageTier is the storage tier the dataset to change to
1395  *
1396  * @return A bool value representing the completion of storage tier change operation.
1397  ******************************************************************************/
1398  bool updateStorageTier(const std::string &storageTier) const;
1399 
1400  /*******************************************************************************/
1407  bool setStorageTier(const std::string &tier);
1408 
1409  /*******************************************************************************/
1416  std::string getStorageTier();
1417 
1418  private:
1419 #ifdef _MSC_VER
1420  #pragma warning(push)
1421  #pragma warning(disable : 4251)
1422 #endif
1423 
1424  class Impl;
1425 
1426  std::unique_ptr<Impl> _impl;
1427 
1428 #ifdef _MSC_VER
1429  #pragma warning(pop)
1430 #endif
1431 
1432  friend class SDGenericDatasetTest;
1433  };
1434 }
This class holds generic dataset object info.
Definition: SDGenericDataset.h:40
Defines the underline http connection parameters.
Definition: HttpContext.h:85
SDDatasetDisposition
Defines the different Seismic Drive Dataset Dispositions.
Definition: SDDatasetDisposition.h:29
This class is a generic Dataset class object iterator.
Definition: SDGenericDataset.h:156
Defines the exponential retry backoff policy parameters.
Definition: HttpContext.h:67
HttpConnectionLink
Defines the sdapi connection links.
Definition: HttpContext.h:31
Definition: SDManager.h:27
Definition: Constants.h:27
Represents parameters passed to dataset &#39;open&#39; request.
Definition: Params.h:63
This class represents a generic cloud storage dataset.
Definition: SDGenericDataset.h:261