XRootD
Loading...
Searching...
No Matches
XrdEc::RedundancyProvider Class Reference

#include <XrdEcRedundancyProvider.hh>

+ Collaboration diagram for XrdEc::RedundancyProvider:

Public Member Functions

 RedundancyProvider (const ObjCfg &objcfg)
 
void compute (stripes_t &stripes)
 

Detailed Description

The redundancy provider class offers automatic parity computing and data recovery. Depending on configuration it will use erasure coding or replication.

Definition at line 41 of file XrdEcRedundancyProvider.hh.

Constructor & Destructor Documentation

◆ RedundancyProvider()

XrdEc::RedundancyProvider::RedundancyProvider ( const ObjCfg & objcfg)

Constructor. Stripe parameters (number of data and parity blocks) are constant per ErasureEncoding object.

Definition at line 150 of file XrdEcRedundancyProvider.cc.

150 :
151 objcfg( objcfg ),
152 encode_matrix( objcfg.nbchunks * objcfg.nbdata )
153{
154 // k = data
155 // m = data + parity
156 gf_gen_cauchy1_matrix( encode_matrix.data(), static_cast<int>( objcfg.nbchunks ), static_cast<int>( objcfg.nbdata ) );
157}
const uint8_t nbdata
const uint8_t nbchunks

References XrdEc::ObjCfg::nbchunks, and XrdEc::ObjCfg::nbdata.

Member Function Documentation

◆ compute()

void XrdEc::RedundancyProvider::compute ( stripes_t & stripes)

Compute all missing data and parity blocks in the the stripe. Stripe size has to equal nData+nParity. Blocks can be arbitrary size, but size has to be equal within a stripe. Function will throw on incorrect input.

Parameters
stripesnData+nParity blocks, missing (empty) blocks will be computed if possible.

Definition at line 228 of file XrdEcRedundancyProvider.cc.

229{
230 /* throws if stripe is not recoverable */
231 std::string pattern = getErrorPattern( stripes );
232
233 /* nothing to do if there are no parity blocks. */
234 if ( !objcfg.nbparity ) return;
235
236 /* in case of a single data block use replication */
237 if ( objcfg.nbdata == 1 )
238 return replication( stripes );
239
240 /* normal operation: erasure coding */
241 CodingTable& dd = getCodingTable(pattern);
242
243 unsigned char* inbuf[objcfg.nbdata];
244 for( uint8_t i = 0; i < objcfg.nbdata; i++ )
245 inbuf[i] = reinterpret_cast<unsigned char*>( stripes[dd.blockIndices[i]].buffer );
246
247 std::vector<unsigned char> memory( dd.nErrors * objcfg.chunksize );
248
249 unsigned char* outbuf[dd.nErrors];
250 for (int i = 0; i < dd.nErrors; i++)
251 {
252 outbuf[i] = &memory[i * objcfg.chunksize];
253 }
254
255 ec_encode_data(
256 static_cast<int>( objcfg.chunksize ), // Length of each block of data (vector) of source or destination data.
257 static_cast<int>( objcfg.nbdata ), // The number of vector sources in the generator matrix for coding.
258 dd.nErrors, // The number of output vectors to concurrently encode/decode.
259 dd.table.data(), // Pointer to array of input tables
260 inbuf, // Array of pointers to source input buffers
261 outbuf // Array of pointers to coded output buffers
262 );
263
264 int e = 0;
265 for (size_t i = 0; i < objcfg.nbchunks; i++)
266 {
267 if( pattern[i] )
268 {
269 memcpy( stripes[i].buffer, outbuf[e], objcfg.chunksize );
270 e++;
271 }
272 }
273}
const uint8_t nbparity
const uint64_t chunksize

References XrdEc::ObjCfg::chunksize, XrdEc::ObjCfg::nbchunks, XrdEc::ObjCfg::nbdata, and XrdEc::ObjCfg::nbparity.

Referenced by XrdEc::WrtBuff::Encode().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: