import simpledb.server.SimpleDB; import simpledb.tx.Transaction; import simpledb.record.*; public class RecordMgrTest { public static void main(String[] args) throws Exception { SimpleDB.init("testdb"); Transaction tx = new Transaction(); Schema sch = new Schema(); sch.addIntField("A"); sch.addStringField("B", 9); TableInfo ti = new TableInfo("junk", sch); RecordFile rf = new RecordFile(ti, tx); for (int i=0; i<500; i++) { rf.insert(); int n = (int) Math.round(Math.random() * 200); rf.setInt("A", n); rf.setString("B", "test"+n); } int count = 0; rf.beforeFirst(); while (rf.next()) { if (rf.getInt("A") < 10) { count++; System.out.println(rf.getString("B")); rf.delete(); } } System.out.println(count + " values under 10 were deleted"); rf.close(); tx.commit(); } }