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 151 of file XrdEcRedundancyProvider.cc.

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

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 233 of file XrdEcRedundancyProvider.cc.

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

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

Here is the caller graph for this function:

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