Message 42

Re: 15-721: Assignment 2 questions

X-Added: With Flames (bblib $Revision: 1.4 $)
Return-path: <spapadim+@cs.cmu.edu>
X-Andrew-Authenticated-as: 0;andrew.cmu.edu;Network-Mail
Received: from po0.andrew.cmu.edu via trymail for bb+academic.cs.15-721@andrew.cmu.edu
          ID </afs/andrew.cmu.edu/usr0/bb/Mailbox/cviI6yq00UdYNYhE4S>;
          Tue,  2 Oct 2001 00:25:34 -0400 (EDT)
Received: from mx2.andrew.cmu.edu (MX2.ANDREW.CMU.EDU [128.2.10.112])
        by po0.andrew.cmu.edu (8.9.3/8.9.3) with ESMTP id AAA25777
        for <bb+academic.cs.15-721@ams.andrew.cmu.edu>; Tue, 2 Oct 2001 00:25:34 -0400 (EDT)
Received: from iluvatar.dhs.org (pool-151-201-19-40.pitt.east.verizon.net [151.201.19.40])
        by mx2.andrew.cmu.edu (8.12.0.Beta16/8.12.0.Beta16) with ESMTP id f924PWtx019296
        for <bb+academic.cs.15-721@andrew.cmu.edu>; Tue, 2 Oct 2001 00:25:32 -0400
Received: from cs.cmu.edu (iluvatar.hobbiton.cmu.edu [192.168.0.2])
        by iluvatar.dhs.org (Postfix) with ESMTP
        id AFD1420527; Tue,  2 Oct 2001 00:25:32 -0400 (EDT)
Message-ID: <3BB941BC.3000806@cs.cmu.edu>
Date: Tue, 02 Oct 2001 00:25:32 -0400
From: Spiros Papadimitriou <spapadim+@cs.cmu.edu>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.3) Gecko/20010808
X-Accept-Language: en-us
MIME-Version: 1.0
To: Bartosz Przydatek <bartosz@cs.cmu.edu>
Cc: Yan Karklin <yan+@cs.cmu.edu>, Francisco Pereira <fpereira+@cs.cmu.edu>,
        bb+academic.cs.15-721@andrew.cmu.edu
Subject: Re: 15-721: Assignment 2 questions
References: <Pine.LNX.3.95L.1011001205330.27210Y-100000@ux10.sp.cs.cmu.edu>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

 > * In the constructor
 >   HeapFile::HeapFile( const char *name, Status& returnStatus ),
 >   to create a new heapfile, do we use
 >   DB::add_file_entry(const char* fname, PageId start_page_num), right?
 >   If so, what is the meaning of the start_page_num?

 From the Minibase documentation:
  The DB class also provides a `file naming service,' which is used by
  higher-level code to create logical `files of pages.'  This service is
  implemented using records consisting of file names and their header page
  IDs. There are functions to insert, look up, and delete file entries.
The `header page' is simply a page ID that you know what to do with
(eg: the head or root node of your directory..).

 > * The destructor Heapfile::~HeapFile() removes the heapfile permanently
 >   ( using deleteFile(), which in turn calls
 >     DB::delete_file_entry(const char* fname)? )
 >   only if the created file was temporary, right?

Yes, that is right (otherwise deleteFile() has to be called explicitly).

 > * What should be returned by HFPage::nextRecord (RID curRid, RID& 
nextRid)
 >   if curRid.pageNo != curPage ? (FAIL or DONE?)

Hmm...  The logical answer is FAIL, since these functions are meant to be
used as in
   Status s;  RID i;
   for (s = firstRecord(i);  s == OK;  s = nextRecord(i, i)) { ... }
so assuming the user (or a bug in your HFPage code) does not do something
bad this should not happen.  Practically, both DONE and FAIL (or != OK in
general) signify end-of-iteration.  Conceptually, I guess the obvious is
DONE for normal end, FAIL for end due to an error...

Spiros