public class ReedSolomon extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
private CodingLoop |
codingLoop |
private int |
dataShardCount |
private static ByteBufCodingLoop |
LOOP |
private Matrix |
matrix |
private byte[][] |
parityRows
Rows from the matrix for encoding parity, each one as its own
byte array to allow for efficient access while encoding.
|
private int |
parityShardCount |
private int |
totalShardCount |
| 构造器和说明 |
|---|
ReedSolomon(int dataShardCount,
int parityShardCount,
CodingLoop codingLoop)
Initializes a new encoder/decoder, with a chosen coding loop.
|
| 限定符和类型 | 方法和说明 |
|---|---|
private static Matrix |
buildMatrix(int dataShards,
int totalShards)
Create the matrix to use for encoding, given the number of
data shards and the number of total shards.
|
private void |
checkBuffersAndSizes(byte[][] shards,
int offset,
int byteCount)
Checks the consistency of arguments passed to public methods.
|
private void |
checkBuffersAndSizes(io.netty.buffer.ByteBuf[] shards,
int offset,
int byteCount)
Checks the consistency of arguments passed to public methods.
|
static ReedSolomon |
create(int dataShardCount,
int parityShardCount)
Creates a ReedSolomon codec with the default coding loop.
|
void |
decodeMissing(byte[][] shards,
boolean[] shardPresent,
int offset,
int byteCount)
Given a list of shards, some of which contain data, fills in the
ones that don't have data.
|
void |
decodeMissing(io.netty.buffer.ByteBuf[] shards,
boolean[] shardPresent,
int offset,
int byteCount) |
void |
encodeParity(byte[][] shards,
int offset,
int byteCount)
Encodes parity for a set of data shards.
|
void |
encodeParity(io.netty.buffer.ByteBuf[] shards,
int offset,
int byteCount) |
int |
getDataShardCount()
Returns the number of data shards.
|
int |
getParityShardCount()
Returns the number of parity shards.
|
int |
getTotalShardCount()
Returns the total number of shards.
|
boolean |
isParityCorrect(byte[][] shards,
int firstByte,
int byteCount)
Returns true if the parity shards contain the right data.
|
boolean |
isParityCorrect(byte[][] shards,
int firstByte,
int byteCount,
byte[] tempBuffer)
Returns true if the parity shards contain the right data.
|
private static Matrix |
vandermonde(int rows,
int cols)
Create a Vandermonde matrix, which is guaranteed to have the
property that any subset of rows that forms a square matrix
is invertible.
|
private final int dataShardCount
private final int parityShardCount
private final int totalShardCount
private final Matrix matrix
private final CodingLoop codingLoop
private final byte[][] parityRows
private static final ByteBufCodingLoop LOOP
public ReedSolomon(int dataShardCount,
int parityShardCount,
CodingLoop codingLoop)
public static ReedSolomon create(int dataShardCount, int parityShardCount)
public int getDataShardCount()
public int getParityShardCount()
public int getTotalShardCount()
public void encodeParity(byte[][] shards,
int offset,
int byteCount)
shards - An array containing data shards followed by parity shards.
Each shard is a byte array, and they must all be the same
size.offset - The index of the first byte in each shard to encode.byteCount - The number of bytes to encode in each shard.public void encodeParity(io.netty.buffer.ByteBuf[] shards,
int offset,
int byteCount)
public boolean isParityCorrect(byte[][] shards,
int firstByte,
int byteCount)
shards - An array containing data shards followed by parity shards.
Each shard is a byte array, and they must all be the same
size.firstByte - The index of the first byte in each shard to check.byteCount - The number of bytes to check in each shard.public boolean isParityCorrect(byte[][] shards,
int firstByte,
int byteCount,
byte[] tempBuffer)
shards - An array containing data shards followed by parity shards.
Each shard is a byte array, and they must all be the same
size.firstByte - The index of the first byte in each shard to check.byteCount - The number of bytes to check in each shard.tempBuffer - A temporary buffer (the same size as each of the
shards) to use when computing parity.public void decodeMissing(byte[][] shards,
boolean[] shardPresent,
int offset,
int byteCount)
public void decodeMissing(io.netty.buffer.ByteBuf[] shards,
boolean[] shardPresent,
int offset,
int byteCount)
private void checkBuffersAndSizes(io.netty.buffer.ByteBuf[] shards,
int offset,
int byteCount)
private void checkBuffersAndSizes(byte[][] shards,
int offset,
int byteCount)
private static Matrix buildMatrix(int dataShards, int totalShards)
private static Matrix vandermonde(int rows, int cols)
rows - Number of rows in the result.cols - Number of columns in the result.Copyright © 2022. All rights reserved.