Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

TLMDSearchFileGrep appears to hang searching large files

We regularly deal with files well over 16 meg in size. When we search for files in a directory containing even 1 or 2 files of this size using a single character in the SearchString property the program appears to loop and the Cancel method has no effect. We have no problem when searching for 2 or more characters in StringSearch property.

The problem seems to be with scanning large files (1 meg is ok, 16 meg is not) even if the character should be found near the front.

Is this explainable or possibly a bug?

Environment is Search Pack 2016.5 on C++ Builder Berlin 10.1.  The problem also occurred in earlier versions of both.

Thank you.

Comments

  • 4 Comments sorted by Votes Date Added
  • Hi,

    I can't reproduce this issue. I just generated a file using the following simple algorithm:

    procedure TForm1.Button1Click(Sender: TObject);
    var
      i: Int64;
      s: TFileStream;
      c: AnsiChar;
    begin
      s := TFileStream.Create('big.dat', fmCreate);
      i := 0;
      while i < 40000000 do
      begin
        c := 'X';
        if i = 30000000 then
          c := 'A';
        s.Write(C, 1);
        Inc(i);
      end;
      s.Free;
    end;

    And searched for the 'A' char in this file. The component worked well...
  • edited May 2016 Posts: 15Vote Up0Vote Down
    Thank you for researching this. As a result I did some more testing and should probably restate my original problem description. The problem seems to happen when the character I am searching for iscontained in large files many times, not just once. For example, I searched a directory for files containing the letter "Z" and the program appears to hang on a 16 meg file of about 1076000 lines where the character appears on almost every line. If I search the same directory for the letter "O" the search proceeds quickly and accurately. Due to the nature of our data, the letter "O" occurs infrequently or not at all. The search even finds files of 90 meg size with just one or two "O"s.

    This could probably be illustrated using your program and then searching for files with an "X".

    The leads me to believe that the file search is locating all occurrences of the search string. For my purposes (listing all files containing the search argument at least once) I only need a single hit.

    I can't find any properties to avoid this behavior. Am I misinterpreting how the TLMDSearchFileGrep component works?

    Thank you again.

  • The leads me to believe that the file search is locating all occurrences of the search string. For my purposes (listing all files containing the search argument at least once) I only need a single hit.

    You right. Generally, the component works, but processing too many search results are just too slow internally. Unfortunately, there nothing to do with that.
  • Thank you. Is this something that LMD can fix in the future?
Sign In or Register to comment.