Krieg
asked on
Searching with Assembly code embedded
Hi Guys,
I have a problem regarding the text file searching.
I have a 2 text files. The first one is 12MB in size, and the second one is 132MB.
It's a list of words with sample sentences. Somewhat like a dictionary.
My problem is the speed... I am already using the stream just to speed up the searching but still frustating. It's Master-Detail relationship for this two text files.
For example, the user type in the word "GO", then you will going to search the word "GO" from the first text file, then once it finds it, it will look for it's relationship on the second text file.
Does anybody has an assembly code for fast searching for the textfile.
I have a problem regarding the text file searching.
I have a 2 text files. The first one is 12MB in size, and the second one is 132MB.
It's a list of words with sample sentences. Somewhat like a dictionary.
My problem is the speed... I am already using the stream just to speed up the searching but still frustating. It's Master-Detail relationship for this two text files.
For example, the user type in the word "GO", then you will going to search the word "GO" from the first text file, then once it finds it, it will look for it's relationship on the second text file.
Does anybody has an assembly code for fast searching for the textfile.
ASKER
Hi meikl,
I Actually copied the code, but there's an error with "TMemoryMappedFileStream". I tried putting "dsstream" in
the USES but my machine don't have any dsStream.dcu.
Sorry, I forgot to tell you... I am using Delphi 5.
Is this code applicable with this format?
Your code below: (from the site you gave me)
procedure TForm1.Button3Click(Sender : TObject);
var
sl : TstringList;
P : PChar;
i,l : Integer;
begin
P := Nil;
if Opendialog1.Execute then
begin
try
sl := TstringList.Create;
mmf := TMemoryMappedFileStream.Cr eate(OPend ialog1.Fil ename,'',f mOpenReadW rite);
l := length(edit1.text);
P := PChar(edit1.text);
i := 0;
repeat
i := BinPosEx(P,PChar(mmf.memor y),i+1,mmf .size,l,mm f.size);
if i > 0 then sl.Add(inttostr(i));
until i = 0;
Listbox1.Items.Assign(sl);
finally
mmf.Free;
sl.free;
end;
end;
end;
I Actually copied the code, but there's an error with "TMemoryMappedFileStream".
the USES but my machine don't have any dsStream.dcu.
Sorry, I forgot to tell you... I am using Delphi 5.
Is this code applicable with this format?
Your code below: (from the site you gave me)
procedure TForm1.Button3Click(Sender
var
sl : TstringList;
P : PChar;
i,l : Integer;
begin
P := Nil;
if Opendialog1.Execute then
begin
try
sl := TstringList.Create;
mmf := TMemoryMappedFileStream.Cr
l := length(edit1.text);
P := PChar(edit1.text);
i := 0;
repeat
i := BinPosEx(P,PChar(mmf.memor
if i > 0 then sl.Add(inttostr(i));
until i = 0;
Listbox1.Items.Assign(sl);
finally
mmf.Free;
sl.free;
end;
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
YES!!! Thanks for the solution meikl :-)
By the way, do you a site that has a good freeware components for Delphi?
By the way, do you a site that has a good freeware components for Delphi?
ASKER
I forgot to ask you meikl, How can i be able to get the value in text or string? using your code since it's only a cardinal result
example:
aaa
bbb
ccc
result to be displayed is -> "bbb"
example:
aaa
bbb
ccc
result to be displayed is -> "bbb"
sorry for delay
>By the way, do you a site that has a good freeware components for Delphi?
www.torry.net
you may find various
>using your code since it's only a cardinal result
the cardinal points to first letter of the found word,
you can seek in the stream to this position,
copy at this the length of the word into a buffer, for example
hope this helps a bit, just ask for further advice on this
meikl ;-)
>By the way, do you a site that has a good freeware components for Delphi?
www.torry.net
you may find various
>using your code since it's only a cardinal result
the cardinal points to first letter of the found word,
you can seek in the stream to this position,
copy at this the length of the word into a buffer, for example
hope this helps a bit, just ask for further advice on this
meikl ;-)
https://www.experts-exchange.com/questions/10169234/Searching-large-text-files.html
meikl ;-)