XRootD
XrdEcRedundancyProvider.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
5 //------------------------------------------------------------------------------
6 
7 /************************************************************************
8  * KineticIo - a file io interface library to kinetic devices. *
9  * *
10  * This Source Code Form is subject to the terms of the Mozilla *
11  * Public License, v. 2.0. If a copy of the MPL was not *
12  * distributed with this file, You can obtain one at *
13  * https://mozilla.org/MP:/2.0/. *
14  * *
15  * This program is distributed in the hope that it will be useful, *
16  * but is provided AS-IS, WITHOUT ANY WARRANTY; including without *
17  * the implied warranty of MERCHANTABILITY, NON-INFRINGEMENT or *
18  * FITNESS FOR A PARTICULAR PURPOSE. See the Mozilla Public *
19  * License for more details. *
20  ************************************************************************/
21 
22 #ifndef KINETICIO_REDUNDANCYPROVIDER_HH
23 #define KINETICIO_REDUNDANCYPROVIDER_HH
24 
25 #include "XrdEc/XrdEcObjCfg.hh"
26 #include "XrdEc/XrdEcUtilities.hh"
27 
28 #include <memory>
29 #include <vector>
30 #include <string>
31 #include <unordered_map>
32 #include <mutex>
33 
34 namespace XrdEc
35 {
36  //------------------------------------------------------------------------------
40  //------------------------------------------------------------------------------
42  public:
43  //--------------------------------------------------------------------------
50  //--------------------------------------------------------------------------
51  void compute( stripes_t &stripes );
52 
53  //--------------------------------------------------------------------------
57  //--------------------------------------------------------------------------
58  RedundancyProvider( const ObjCfg &objcfg );
59 
60  private:
61  //--------------------------------------------------------------------------
64  //--------------------------------------------------------------------------
65  struct CodingTable {
67  std::vector<unsigned char> table;
69  std::vector<unsigned int> blockIndices;
71  int nErrors;
72  };
73 
74  //--------------------------------------------------------------------------
83  //--------------------------------------------------------------------------
84  std::string getErrorPattern( stripes_t &stripes ) const;
85 
86  //--------------------------------------------------------------------------
93  //--------------------------------------------------------------------------
94  CodingTable& getCodingTable(
95  const std::string& pattern
96  );
97 
98  private:
99 
100  void replication( stripes_t &stripes );
101 
102  ObjCfg objcfg;
103 
105  std::vector<unsigned char> encode_matrix;
107  std::unordered_map<std::string, CodingTable> cache;
109  std::mutex mutex;
110  };
111 
112 };
113 
114 #endif /* ERASURECODING_HH */
RedundancyProvider(const ObjCfg &objcfg)
void compute(stripes_t &stripes)
std::vector< stripe_t > stripes_t
All stripes in a block.