Commits

Bożydar Sobczak committed 0cfeabf

Fix: NeedList generator crashes for huge files

Comments (0)

Files changed (3)

Rdc.Wrapper.Test/NeedListGeneratorTest.cs

         [TestFixtureSetUp]
         public void Initi()
         {
+
             using (Stream file = File.Create("source.txt"))
             {
-                TestDataGenerators.WriteNumbers(file, 100000);
+                new RandomStream(1024*1024*1024, 1).CopyTo(file);
             }
 
             using (Stream file = File.Create("seed.txt"))
             {
-                TestDataGenerators.WriteNumbers(file, 100000,
-                                                (lineNumber, line) =>
-                                                    {
-                                                        if (lineNumber == 5)
-                                                        {
-                                                            return "Coconut is stupid";
-                                                        }
-                                                        return line;
-                                                    });
+                new RandomlyModifiedStream(new RandomStream(1024*1024*1024, 1), 0.001, 1).CopyTo(file);
             }
         }
 
                 using (var generator = new SigGenerator(_signatureRepository))
                 {
                     seedSignatureInfos = generator.GenerateSignatures(file);
-                }                
+                }
             }
             using (Stream file = File.OpenRead("source.txt"))
             {

Rdc.Wrapper/NeedListGenerator.cs

         private readonly ISignatureRepository _sourceSignatureRepository;
 
         private readonly IRdcLibrary _rdcLibrary;
-        private const int ComparatorBufferSize = 1000000;
-        private const int InputBufferSize = 8 * 1024;
+        private const int ComparatorBufferSize = 0x4000000;
+        private const int InputBufferSize = 0x100000;
 
         public NeedListGenerator(ISignatureRepository seedSignatureRepository, ISignatureRepository sourceSignatureRepository)
         {

Rdc.Wrapper/RdcComInterop.cs

     internal interface IRdcComparator
     {
         [PreserveSig]
-        HRESULT Process([In, MarshalAs(UnmanagedType.U1)] bool endOfInput, [In, Out, MarshalAs(UnmanagedType.U1)] ref bool endOfOutput, [In, Out] ref RdcBufferPointer inputBuffer,
-            //              [In] IntPtr outputBuffer, out RdcError errorCode);
+        HRESULT Process([In, MarshalAs(UnmanagedType.Bool)] bool endOfInput, [In, Out, MarshalAs(UnmanagedType.Bool)] ref bool endOfOutput, [In, Out] ref RdcBufferPointer inputBuffer,
             [In, Out] ref RdcNeedPointer outputBuffer, out RdcError errorCode);
     }