private void runEncodeDecode(int dataCount,int parityCount,byte[][] dataShards){
  final int totalCount=dataCount + parityCount;
  final int shardLength=dataShards[0].length;
  assertEquals(dataCount,dataShards.length);
  final int dataLength=dataShards[0].length;
  byte[][] allShards=new byte[totalCount][];
  for (int i=0; i < dataCount; i++) {
    allShards[i]=Arrays.copyOf(dataShards[i],dataLength);
  }
  for (int i=dataCount; i < totalCount; i++) {
    allShards[i]=new byte[dataLength];
  }
  ReedSolomon codec=ReedSolomon.create(dataCount,parityCount);
  codec.encodeParity(allShards,0,dataLength);
  byte[][] testShards=new byte[totalCount][];
  boolean[] shardPresent=new boolean[totalCount];
  for (int i=0; i < totalCount; i++) {
    testShards[i]=Arrays.copyOf(allShards[i],shardLength);
    shardPresent[i]=true;
  }
  for (int numberMissing=0; numberMissing < parityCount + 1; numberMissing++) {
    tryAllSubsetsMissing(codec,allShards,testShards,shardPresent,numberMissing);
  }
}

private void runEncodeDecode ( int dataCount , int parityCount , byte [ ] [ ] dataShards ) { final int totalCount = dataCount + parityCount ; final int shardLength = dataShards [ 0 ] . length ; assertEquals ( dataCount , dataShards . length ) ; final int dataLength = dataShards [ 0 ] . length ; byte [ ] [ ] allShards = new byte [ totalCount ] [ ] ; for ( int i = 0 ; i < dataCount ; i ++ ) { allShards [ i ] = Arrays . copyOf ( dataShards [ i ] , dataLength ) ; } for ( int i = dataCount ; i < totalCount ; i ++ ) { allShards [ i ] = new byte [ dataLength ] ; } ReedSolomon codec = ReedSolomon . create ( dataCount , parityCount ) ; codec . encodeParity ( allShards , 0 , dataLength ) ; byte [ ] [ ] testShards = new byte [ totalCount ] [ ] ; boolean [ ] shardPresent = new boolean [ totalCount ] ; for ( int i = 0 ; i < totalCount ; i ++ ) { testShards [ i ] = Arrays . copyOf ( allShards [ i ] , shardLength ) ; shardPresent [ i ] = true ; } for ( int numberMissing = 0 ; numberMissing < parityCount + 1 ; numberMissing ++ ) { tryAllSubsetsMissing ( codec , allShards , testShards , shardPresent , numberMissing ) ; } }
encodes a set of data shards , and then tries decoding using all possible subsets of the encoded shards . uses 5 + 5 coding , so there must be 5 input data shards .
