Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: Icechunk driver 5 : * Author: Even Rouault <even dot rouault at spatialys.com> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2026, Even Rouault <even dot rouault at spatialys.com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef ICECHUNKMANIFEST_H 14 : #define ICECHUNKMANIFEST_H 15 : 16 : #include "icechunkdefs.h" 17 : #include "icechunkfile.h" 18 : 19 : #include <map> 20 : #include <string> 21 : #include <memory> 22 : #include <vector> 23 : 24 : namespace gdal::icechunk 25 : { 26 : class IcechunkSnapshot; 27 : 28 : /************************************************************************/ 29 : /* IcechunkManifest */ 30 : /************************************************************************/ 31 : 32 : /** Instance of https://icechunk.io/en/stable/reference/spec/#manifestfileinfo 33 : * 34 : * It is thread-safe. 35 : */ 36 10836 : class IcechunkManifest final : public IcechunkFile 37 : { 38 : public: 39 : IcechunkManifest(); 40 : ~IcechunkManifest() override; 41 : 42 : struct ChunkRef 43 : { 44 : ChunkIdx idx{}; 45 : 46 : std::vector<uint8_t> inlineContent{}; 47 : 48 : // offset and length only apply to chunkId or location not empty 49 : uint64_t offset = 0; 50 : uint64_t length = 0; 51 : 52 : // In-repository chunk 53 : std::string chunkId{}; 54 : 55 : // Virtual reference 56 : std::string location{}; 57 : 58 : uint32_t checksumLastModified = 0; 59 : std::string checksumEtag{}; 60 : }; 61 : 62 : struct ArrayManifest 63 : { 64 : ObjectId8 nodeId{}; 65 : 66 : // Sorted by increasing ChunkRef::idx 67 : std::vector<ChunkRef> chunkRefs{}; 68 : }; 69 : 70 : static std::unique_ptr<IcechunkManifest> Open(const char *pszFilename); 71 : 72 : const ChunkRef *GetChunkRef(const ObjectId8 &nodeId, 73 : const ChunkIdx &idx) const; 74 : 75 : std::string GetChunkFilename(const std::string &chunkId) const; 76 : 77 3603 : inline uint32_t GetChunkRefsCount() const 78 : { 79 3603 : return m_chunkRefsCount; 80 : } 81 : 82 : private: 83 : // Sorted by increasing ArrayManifest::nodeId 84 : std::vector<ArrayManifest> m_arrayManifests{}; 85 : 86 : // count(m_arrayManifests[].chunkRefs[]) 87 : uint32_t m_chunkRefsCount = 0; 88 : }; 89 : 90 : } // namespace gdal::icechunk 91 : 92 : #endif