Ejemplo n.º 1
0
        public void TestSpecificScenarioHuge()
        {
            int dataBlockCount   = 64;
            int parityBlockCount = 64;
            int dataLength       = 1;



            //Parallel.For(0, 1000, new ParallelOptions() { MaxDegreeOfParallelism = 32 }, (i) =>
            for (int i = 0; i < 100; i++)
            {
                var expectedData = GenerateTestDataHelper.ConvertToUint(GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength));

                var data         = GenerateTestDataHelper.ConvertToUint(GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength));
                var parityData   = ParityGFAlgorithm.GenerateParityData3(gfTable, data, parityBlockCount);
                var combinedData = data.Concat(parityData).ToList();

                var r = new Random(i);

                combinedData.Shuffle(r);
                for (int y = 0; y < parityBlockCount; y++)
                {
                    combinedData[y].Data = null;
                }


                var repairedData = ParityGFAlgorithm.RecoverData3(gfTable, data, parityData, parityBlockCount);

                VerifyData(expectedData, repairedData);
            }
            //);
        }
Ejemplo n.º 2
0
        public void TestSpecificScenario5()
        {
            int dataBlockCount   = 6;
            int parityBlockCount = 6;
            int dataLength       = 1;


            var expectedData = GenerateTestDataHelper.ConvertToUint(GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength));

            var data         = GenerateTestDataHelper.ConvertToUint(GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength));
            var parityData   = ParityGFAlgorithm.GenerateParityData3(gfTable, data, parityBlockCount);
            var combinedData = data.Concat(parityData).ToList();

            combinedData[2].Data  = null;
            combinedData[3].Data  = null;
            combinedData[5].Data  = null;
            combinedData[7].Data  = null;
            combinedData[8].Data  = null;
            combinedData[10].Data = null;


            var repairedData = ParityGFAlgorithm.RecoverData3(gfTable, data, parityData, parityBlockCount);

            VerifyData(expectedData, repairedData);
        }
Ejemplo n.º 3
0
        public void TestSpecificScenario9()
        {
            int dataBlockCount   = 3;
            int parityBlockCount = 3;
            int dataLength       = 1;


            var expectedData = GenerateTestDataHelper.ConvertToUint(GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength));

            var data         = GenerateTestDataHelper.ConvertToUint(GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength));
            var parityData   = ParityGFAlgorithm.GenerateParityData3(gfTable, data, parityBlockCount);
            var combinedData = data.Concat(parityData).ToList();

            combinedData[0].Data = null;
            combinedData[1].Data = null;
            combinedData[2].Data = null;


            //var matrix = ParityGFAlgorithm.CreateParityMatrix(gfTable, expectedData.Count, parityBlockCount);
            //Console.WriteLine($"Matrix: {matrix}");

            var repairedData = ParityGFAlgorithm.RecoverData3(gfTable, data, parityData, parityBlockCount);

            VerifyData(expectedData, repairedData);
        }
Ejemplo n.º 4
0
        public void TestSpecificScenario2()
        {
            //This scenario works if using:
            //var val = Field.pow(baseList[column], row);

            int dataBlockCount   = 5;
            int parityBlockCount = 5;
            int dataLength       = 1;


            var expectedData = GenerateTestDataHelper.ConvertToUint(GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength));

            var data         = GenerateTestDataHelper.ConvertToUint(GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength));
            var parityData   = ParityGFAlgorithm.GenerateParityData3(gfTable, data, parityBlockCount);
            var combinedData = data.Concat(parityData).ToList();

            combinedData[1].Data = null;
            combinedData[2].Data = null;
            combinedData[3].Data = null;
            combinedData[6].Data = null;
            combinedData[7].Data = null;


            //var matrix = ParityGFAlgorithm.CreateParityMatrix2(gfTable, expectedData.Count, parityBlockCount);
            //Console.WriteLine($"Matrix: {matrix}");


            var repairedData = ParityGFAlgorithm.RecoverData3(gfTable, data, parityData, parityBlockCount);


            VerifyData(expectedData, repairedData);
        }
Ejemplo n.º 5
0
        private static void RunRepairTest(GFTable gfTable, int dataBlockCount, int parityBlockCount, int dataLength)
        {
            var expectedData = GenerateTestDataHelper.ConvertToUint(GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength));



            for (int dataBlocksToDeleteCount = 1; dataBlocksToDeleteCount <= parityBlockCount; dataBlocksToDeleteCount++)
            {
                var rowsToDelete = DeleteDataHelper.DetermineAllPermutations(dataBlockCount + parityBlockCount, dataBlocksToDeleteCount);

                //for (int zzz = 0; zzz < rowsToDelete.Count; zzz++)
                Parallel.For(0, rowsToDelete.Count, new ParallelOptions()
                {
                    MaxDegreeOfParallelism = 32
                }, (zzz) =>
                {
                    {
                        var toDelete = rowsToDelete[zzz];

                        var data         = GenerateTestDataHelper.ConvertToUint(GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength));
                        var parityData   = ParityGFAlgorithm.GenerateParityData3(gfTable, data, parityBlockCount);
                        var combinedData = data.Concat(parityData).ToList();

                        foreach (var rowToDelete in toDelete)
                        {
                            combinedData[rowToDelete].Data = null;
                        }

                        var repairedData = ParityGFAlgorithm.RecoverData3(gfTable, data, parityData, parityBlockCount);

                        VerifyData(expectedData, repairedData);
                    }
                }
                             );
            }
        }