Discussion Board
Go to the previous messageGo to the following message
Current Forum: Homework 5 - Part 3
Date: Mon Nov 19 2001 12:16 pm
Author: Liu, Limin Angela <laliu@andrew.cmu.edu>
Subject: Re: Saving and Restoring from disk takes very long

This is how I did it. It's not as straightforward as ObjectInput(Output)Stream.

I output first the number of links I have parsed into the file, then I output the URLs and the indegrees line by line. After that, I output each keyword in a separate line (there are quoted strings that can also be a single keyword), and output the links for this keyword on the next line.

When I read, I use a BufferedReader to read in the file line by line. The first line tells me how many links there are so that I can rebuild my Vector of links with their indegrees (I'm not using graph.) After I build up the Vector of the links, I read in a line of keyword, followed by another line of URLs, and at the same time add them to the Trie (I'm using a Trie.). So when the file is read, the Trie and the Vector are ready for searching. Also, I use a StringTokenizer to parse each line, since I use a space to separate all the strings in one line and add a "\n" at the end of the line when I write.

If you are implementing graph, or hashtable, you probably need to think about how to write them to a file in text format.

Good luck!
Post response

Go to the previous messageGo to the following message
Current Thread Detail:
Saving and Restoring from disk takes v...      Brands, Marc C.      Thu Nov 15 2001 7:25 pm       
Re: Saving and Restoring from disk ...      Liu, Limin Angela      Fri Nov 16 2001 4:45 pm       
Re: Saving and Restoring from di...      Brands, Marc C.      Fri Nov 16 2001 5:30 pm       
Re: Saving and Restoring from di...      Brands, Marc C.      Fri Nov 16 2001 6:21 pm       
Re: Saving and Restoring from disk ...      Bortz, Andrew S.      Fri Nov 16 2001 8:58 pm       
Re: Saving and Restoring from di...      Goodman, Brian J.      Sat Nov 17 2001 1:19 am       
Re: Saving and Restoring from...      Bortz, Andrew S.      Sat Nov 17 2001 1:59 am       
Re: Saving and Restoring f...      Goodman, Brian J.      Sat Nov 17 2001 2:35 am       
Re: Saving and Restorin...      Bortz, Andrew S.      Sat Nov 17 2001 2:42 am       
Re: Saving and Restoring from disk ...      Liu, Limin Angela      Sat Nov 17 2001 3:28 pm       
Re: Saving and Restoring from di...      Batra, Rohan      Mon Nov 19 2001 5:52 am       
Re: Saving and Restoring from...      Liu, Limin Angela      Mon Nov 19 2001 12:16 pm       
Re: Saving and Restoring f...      Batra, Rohan      Mon Nov 19 2001 8:43 pm       
Re: Saving and Restorin...      Liu, Limin Angela      Mon Nov 19 2001 8:54 pm       
Re: Saving and Restoring from di...      White, David      Mon Nov 19 2001 5:16 pm       
Re: Saving and Restoring from...      Liu, Limin Angela      Mon Nov 19 2001 8:01 pm       
Re: Saving and Restoring from...      Liu, Limin Angela      Mon Nov 19 2001 8:18 pm       

Back to previous screen