Class DecodingValidator
java.lang.Object
org.apache.hadoop.io.erasurecode.rawcoder.DecodingValidator
A utility class to validate decoding.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intprotected int[]voidvalidate(ByteBuffer[] inputs, int[] erasedIndexes, ByteBuffer[] outputs) Validate outputs decoded from inputs, by decoding an input back from the outputs and comparing it with the original one.voidValidate outputs decoded from inputs, by decoding an input back from those outputs and comparing it with the original one.
-
Constructor Details
-
DecodingValidator
-
-
Method Details
-
validate
public void validate(ByteBuffer[] inputs, int[] erasedIndexes, ByteBuffer[] outputs) throws IOException Validate outputs decoded from inputs, by decoding an input back from the outputs and comparing it with the original one. For instance, in RS (6, 3), let (d0, d1, d2, d3, d4, d5) be sources and (p0, p1, p2) be parities, and assume inputs = [d0, null (d1), d2, d3, d4, d5, null (p0), p1, null (p2)]; erasedIndexes = [1, 6]; outputs = [d1, p0]. Then 1. Create new inputs, erasedIndexes and outputs for validation so that the inputs could contain the decoded outputs, and decode them: newInputs = [d1, d2, d3, d4, d5, p0] newErasedIndexes = [0] newOutputs = [d0'] 2. Compare d0 and d0'. The comparison will fail with high probability when the initial outputs are wrong. Note that the input buffers' positions must be the ones where data are read: If the input buffers have been processed by a decoder, the buffers' positions must be reset before being passed into this method. This method does not change outputs and erasedIndexes.- Parameters:
inputs- input buffers used for decoding. The buffers' position are moved to the end after this method.erasedIndexes- indexes of erased units used for decodingoutputs- decoded output buffers, which are ready to be read after the call- Throws:
IOException- raised on errors performing I/O.
-
validate
Validate outputs decoded from inputs, by decoding an input back from those outputs and comparing it with the original one.- Parameters:
inputs- input buffers used for decodingerasedIndexes- indexes of erased units used for decodingoutputs- decoded output buffers- Throws:
IOException- raised on errors performing I/O.
-
getNewValidIndexes
@VisibleForTesting protected int[] getNewValidIndexes() -
getNewErasedIndex
@VisibleForTesting protected int getNewErasedIndex()
-