


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: DATABASE SYSTEMS; Subject: COMPUTER SCIENCE; University: Texas A&M University; Term: Fall 2008;
Typology: Assignments
1 / 4
This page cannot be seen from the preview
Don't miss anything!



//print file forward System. out .println("FORWARD listing"); rf.beforeFirst(); while (rf.next()) System. out .println(rf.getInt("movidx")+" "+ rf.getInt("yearmade")+" "+rf.getString("title")); //print the file backwards System. out .println("BACKWARD listing"); rf.afterLast(); while (rf.previous()) System. out .println(rf.getInt("movidx")+" "+ rf.getInt("yearmade")+" "+rf.getString("title"));
FORWARD listing 1 2003 Dinosaur Planet 2 2004 Isle of Man TT 2004 3 1997 Character 4 1994 Paula Abduls Get Up 5 2004 The Rise and Fall o 6 1997 Sick 7 1992 8 Man 8 2004 What the #$! Do We 9 1991 Class of Nuke Em Hi 10 2001 Fighter BACKWARD listing 10 2001 Fighter 9 1991 Class of Nuke Em Hi 8 2004 What the #$! Do We 7 1992 8 Man 6 1997 Sick 5 2004 The Rise and Fall o 4 1994 Paula Abduls Get Up 3 1997 Character 2 2004 Isle of Man TT 2004 1 2003 Dinosaur Planet
private boolean atFirstBlock() {//rgw return currentblknum == 0; } public boolean previous() {//rgw while ( true ) { if (rp.previous()) return true ; if (atFirstBlock()) return false ; moveTo(currentblknum - 1); } } public void afterLast() {//rgw moveTo(tx.size(filename) - 1);//move to last block }
private boolean searchBak( int flag) {//rgw if (currentslot < 0) while (next()); currentslot--;
number_hits=0; while (mscan.next()){ lnum = mscan.getInt("mnum"); lyear = mscan.getInt("yearmade"); ltitle = mscan.getString("title"); if (lyear==searchkey)number_hits++; } mscan.close(); tx.commit(); ctm1 = fm.blockreads()-ctm1; ctm2 = fm.blockwrites()-ctm2; System. out .println("Blocks accessed withOUT indexing: " + ctm1 + " " + ctm2+ " Number hits = "+number_hits);//+"\n"