Hi all,
I am new to Hashtables, so at the moment, not fully familiar with them.
I have been experimenting with a search engine spider written in c#. It uses
hashtables to hold the catalog.
Now, if I have a large site, or I want to scan many websites, then the
hashtables would get very large. I am looking at writing them to disk and
reading them, though am not sure how this would work.
Now, I have found this on the net (vb code, I can convert, so no need to
worry about that)
Private Sub cmdSave_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdSave.Click
'Save the hashtable
If File.Exists(App lication.Startu pPath & "\data.dat" ) = True Then
File.Delete(App lication.Startu pPath & "\data.dat" )
Dim fs As New FileStream(Appl ication.Startup Path & "\data.dat" ,
FileMode.Create New)
Dim bf As New
Runtime.Seriali zation.Formatte rs.Binary.Binar yFormatter()
bf.Serialize(fs , HashTest)
fs.Close()
End Sub
Private Sub cmdLoad_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLoad.Click
If File.Exists(App lication.Startu pPath & "\data.dat" ) = False Then
Exit Sub
Dim fs As New FileStream(Appl ication.Startup Path & "\data.dat" ,
FileMode.Open)
Dim bf As New
Runtime.Seriali zation.Formatte rs.Binary.Binar yFormatter()
HashTest = bf.Deserialize( fs)
fs.Close()
cmdIterate_Clic k(Nothing, Nothing)
End Sub
which looks like it might be suitable... but, my question is then,
1. Can I incrementally add to the hashtable file so that I don't run out of
memory when scanning for files to catalog
2. When reading it back off disk, do I have to read the whole lot into
memory in order to search through it?
If I can't do either of these, then what would you suggest?
The way I want to use it is somewhat like a sql database, where I can
quickly select the records I need.
--
Best regards,
Dave Colliver.
~~
http://www.FOCUSPortals.com - Local franchises available
I am new to Hashtables, so at the moment, not fully familiar with them.
I have been experimenting with a search engine spider written in c#. It uses
hashtables to hold the catalog.
Now, if I have a large site, or I want to scan many websites, then the
hashtables would get very large. I am looking at writing them to disk and
reading them, though am not sure how this would work.
Now, I have found this on the net (vb code, I can convert, so no need to
worry about that)
Private Sub cmdSave_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdSave.Click
'Save the hashtable
If File.Exists(App lication.Startu pPath & "\data.dat" ) = True Then
File.Delete(App lication.Startu pPath & "\data.dat" )
Dim fs As New FileStream(Appl ication.Startup Path & "\data.dat" ,
FileMode.Create New)
Dim bf As New
Runtime.Seriali zation.Formatte rs.Binary.Binar yFormatter()
bf.Serialize(fs , HashTest)
fs.Close()
End Sub
Private Sub cmdLoad_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLoad.Click
If File.Exists(App lication.Startu pPath & "\data.dat" ) = False Then
Exit Sub
Dim fs As New FileStream(Appl ication.Startup Path & "\data.dat" ,
FileMode.Open)
Dim bf As New
Runtime.Seriali zation.Formatte rs.Binary.Binar yFormatter()
HashTest = bf.Deserialize( fs)
fs.Close()
cmdIterate_Clic k(Nothing, Nothing)
End Sub
which looks like it might be suitable... but, my question is then,
1. Can I incrementally add to the hashtable file so that I don't run out of
memory when scanning for files to catalog
2. When reading it back off disk, do I have to read the whole lot into
memory in order to search through it?
If I can't do either of these, then what would you suggest?
The way I want to use it is somewhat like a sql database, where I can
quickly select the records I need.
--
Best regards,
Dave Colliver.
~~
http://www.FOCUSPortals.com - Local franchises available
Comment