Package com.reve.reed.solomon.shard
Class Shard
java.lang.Object
com.reve.reed.solomon.shard.ShardMetadata
com.reve.reed.solomon.shard.Shard
A slice is a fully independent unit that can be decoded in decoder side.
-
Method Summary
Modifier and TypeMethodDescriptionvoidexpandIfRequired(int len) Expand the length of each byte array ofdatato the required value if the length is not enough.static voidfreeInstance(Shard shard) byte[][]getData()static Shardboolean[]booleanDecide if there are enough presence shard to decode this slice.booleanintmergeData(byte[] output, int index) Get all the data shards value into one single output array.voidreset()Reset all the values so that the instance can become reusable again.voidsetMegaShard(boolean megaShard) voidsetPresence(int index) Set the presence of given index to true.voidsetSubSlices(ArrayList<Shard> subSlices) voidsplitData(byte[] data, int index, int length) Split the given byte array into shards.toString()Methods inherited from class com.reve.reed.solomon.shard.ShardMetadata
getDataShardCount, getLossPercentage, getPaddingLen, getParityShardCount, getShardLen, getSliceSequence, getStartSequence, getTotalShardsCount, getTotalSlices, setDataShardCount, setLossPercentage, setPaddingLen, setParityShardCount, setShardLen, setSliceSequence, setStartSequence, setTotalSlices
-
Method Details
-
getInstance
-
freeInstance
-
getSubSlices
-
setSubSlices
-
isMegaShard
public boolean isMegaShard() -
setMegaShard
public void setMegaShard(boolean megaShard) -
reset
public void reset()Reset all the values so that the instance can become reusable again.- Overrides:
resetin classShardMetadata
-
splitData
public void splitData(byte[] data, int index, int length) Split the given byte array into shards.- Parameters:
data- byte array to be encoded.index- starting index of the byte array.length- total length of bytes to be encoded. It is possible that all of this length were not fitted into this slice, in that case return value will be the length that were actually fitted into this slice.
-
expandIfRequired
public void expandIfRequired(int len) Expand the length of each byte array ofdatato the required value if the length is not enough.- Parameters:
len- Required length of each byte of this shard.
-
mergeData
public int mergeData(byte[] output, int index) Get all the data shards value into one single output array.- Parameters:
output- byte array where all the data shards will be copied.index- starting index of the output byte array- Returns:
- the length of the output byte array after copying all data.
-
isDecodable
public boolean isDecodable()Decide if there are enough presence shard to decode this slice.- Returns:
- true, if this
Shardcan be decoded, otherwise, return false.
-
getData
public byte[][] getData() -
getPresence
public boolean[] getPresence() -
setPresence
public void setPresence(int index) Set the presence of given index to true.- Parameters:
index- index ofpresencewhich need to be set true.
-
toString
-