XRootD
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 }
const uint8_t nbdata
Definition: XrdEcObjCfg.hh:87
const uint8_t nbchunks
Definition: XrdEcObjCfg.hh:85

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

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

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: