Beispiel #1
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);
        }
Beispiel #2
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);
            }
            //);
        }
Beispiel #3
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);
        }
Beispiel #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);
        }
Beispiel #5
0
        private static void RunRepairTest(int dataBlockCount, int parityBlockCount, int dataLength)
        {
            var expectedData = 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++)
                {
                    var toDelete = rowsToDelete[zzz];

                    var data         = GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength);
                    var parityData   = ParityAlgorithm.GenerateParityData(data, parityBlockCount);
                    var combinedData = data.Concat(parityData).ToList();

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

                    if (dataBlocksToDeleteCount == 2)
                    {
                    }

                    var repairedData = ParityAlgorithm.RecoverData(data, parityData, parityBlockCount);

                    VerifyData(expectedData, repairedData);
                }
            }
        }
Beispiel #6
0
        public void WriteTestFiles()
        {
            var data = GenerateTestDataHelper.GenerateTestData(4, 1);

            for (int i = 0; i < data.Count; i++)
            {
                File.WriteAllBytes($"{i}.txt", new byte[] { data[i].Data[0] });
            }
        }
Beispiel #7
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.GenerateTestData(dataBlockCount, dataLength);

            var data         = GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength);
            var parityData   = ParityAlgorithm.GenerateParityData(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 = ParityAlgorithm.CreateParityMatrix(expectedData, parityBlockCount);

            Console.WriteLine($"Matrix: {matrix}");

            //1 0 0 0 0
            //0 1 0 0 0
            //0 0 1 0 0
            //0 0 0 1 0
            //0 0 0 0 1
            //1 1 1 1 1
            //2 4 16 128 29
            //4 16 29 19 76
            //8 64 205 117 143
            //16 29 76 24 157

            var repairedData = ParityAlgorithm.RecoverData(data, parityData, parityBlockCount);

            //1 0 0 0 0
            //0 0 0 0 1
            //1 1 1 1 1
            //8 64 205 117 143
            //16 29 76 24 157

            VerifyData(expectedData, repairedData);
        }
Beispiel #8
0
        public void TestSpecificScenario()
        {
            //This scenario works if using:
            //var val = Field.pow(baseList[row], column);

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


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

            var data         = GenerateTestDataHelper.GenerateTestData(dataBlockCount, dataLength);
            var parityData   = ParityAlgorithm.GenerateParityData(data, parityBlockCount);
            var combinedData = data.Concat(parityData).ToList();

            combinedData[0].Data = null;
            combinedData[3].Data = null;
            combinedData[4].Data = null;
            combinedData[5].Data = null;


            var matrix = ParityAlgorithm.CreateParityMatrix(expectedData, parityBlockCount);

            Console.WriteLine($"Matrix: {matrix}");
            //1 0 0 0 0
            //0 1 0 0 0
            //0 0 1 0 0
            //0 0 0 1 0
            //0 0 0 0 1
            //1 2 4 8 16
            //1 4 16 64 29
            //1 16 29 205 76
            //1 128 19 117 24
            //1 29 76 143 157

            var repairedData = ParityAlgorithm.RecoverData(data, parityData, parityBlockCount);

            //0 1 0 0 0
            //0 0 1 0 0
            //1 4 16 64 29
            //1 16 29 205 76
            //1 128 19 117 24

            VerifyData(expectedData, repairedData);
        }
Beispiel #9
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);
                    }
                }
                             );
            }
        }