XRootD
Loading...
Searching...
No Matches
XrdEcObjCfg.hh
Go to the documentation of this file.
1/*
2 * XrdEcObjCfg.hh
3 *
4 * Created on: Nov 25, 2019
5 * Author: simonm
6 */
7
8#ifndef SRC_XRDEC_XRDECOBJCFG_HH_
9#define SRC_XRDEC_XRDECOBJCFG_HH_
10
12
13#include <isa-l/crc.h>
14
15#include <cstdlib>
16#include <string>
17#include <vector>
18#include <sstream>
19#include <iomanip>
20
21namespace XrdEc
22{
23 //---------------------------------------------------------------------------
25 //---------------------------------------------------------------------------
26 inline static uint32_t isal_crc32(uint32_t crc, void const *buf, size_t len)
27 {
28 const unsigned char* buffer = reinterpret_cast<const unsigned char*>( buf );
29 return crc32_gzip_refl( crc, buffer, len );
30 }
31
32 static const std::string ObjStr = "obj";
33 struct ObjCfg
34 {
35 ObjCfg() = delete;
36
37 ObjCfg( const std::string &obj, uint8_t nbdata, uint8_t nbparity, uint64_t chunksize, bool usecrc32c, bool nomtfile = false ) :
38 obj( obj ),
41 nbdata( nbdata ),
47 {
48 digest = usecrc32c ? crc32c : isal_crc32;
49 }
50
51 ObjCfg( const ObjCfg &objcfg ) : obj( objcfg.obj ),
52 nbchunks( objcfg.nbchunks ),
53 nbparity( objcfg.nbparity ),
54 nbdata( objcfg.nbdata ),
55 datasize( objcfg.datasize ),
56 chunksize( objcfg.chunksize ),
57 paritysize( objcfg.paritysize ),
58 blksize( objcfg.blksize ),
59 plgr( objcfg.plgr ),
60 digest( objcfg.digest ),
61 nomtfile( objcfg.nomtfile )
62 {
63 }
64
65 inline std::string GetDataUrl( size_t i ) const
66 {
67 std::string url = plgr[i] + '/' + obj;
68 if( !dtacgi.empty() ) url += '?' + dtacgi[i];
69 return url;
70 }
71
72 inline std::string GetMetadataUrl( size_t i ) const
73 {
74 std::string url = plgr[i] + '/' + obj + ".mt";
75 if( !mdtacgi.empty() ) url += '?' + mdtacgi[i];
76 return url;
77 }
78
79 inline std::string GetFileName( size_t blknb, size_t strpnb ) const
80 {
81 return ObjStr + '.' + std::to_string( blknb ) + '.' + std::to_string( strpnb );
82 }
83
84 const std::string obj;
85 const uint8_t nbchunks; // number of chunks in block
86 const uint8_t nbparity; // number of chunks in parity
87 const uint8_t nbdata; // number of chunks in data
88 const uint64_t datasize; // size of the data in the block
89 const uint64_t chunksize; // size of single chunk (nbchunks * chunksize = blksize)
90 const uint64_t paritysize; // size of the parity in the block
91 const uint64_t blksize; // the whole block size (data + parity) in MB
92 std::vector<std::string> plgr;
93 std::vector<std::string> dtacgi;
94 std::vector<std::string> mdtacgi;
95
96 uint32_t (*digest)(uint32_t, void const*, size_t);
97
99 };
100}
101
102
103#endif /* SRC_XRDEC_XRDECOBJCFG_HH_ */
uint32_t crc32c(uint32_t crc, void const *buf, size_t len)
static const std::string ObjStr
static uint32_t isal_crc32(uint32_t crc, void const *buf, size_t len)
ISAL crc32 implementation.
std::string GetDataUrl(size_t i) const
ObjCfg()=delete
std::vector< std::string > mdtacgi
const uint64_t blksize
const std::string obj
std::vector< std::string > plgr
const uint8_t nbdata
std::string GetMetadataUrl(size_t i) const
const uint64_t paritysize
std::string GetFileName(size_t blknb, size_t strpnb) const
const uint8_t nbchunks
const uint8_t nbparity
ObjCfg(const std::string &obj, uint8_t nbdata, uint8_t nbparity, uint64_t chunksize, bool usecrc32c, bool nomtfile=false)
uint32_t(* digest)(uint32_t, void const *, size_t)
const uint64_t chunksize
ObjCfg(const ObjCfg &objcfg)
const uint64_t datasize
std::vector< std::string > dtacgi