MCPcopy Create free account
hub / github.com/1345414527/MIT6.830 / readPageData

Method readPageData

src/java/simpledb/storage/LogFile.java:252–290  ·  view source on GitHub ↗
(RandomAccessFile raf)

Source from the content-addressed store, hash-verified

250 }
251
252 Page readPageData(RandomAccessFile raf) throws IOException {
253 PageId pid;
254 Page newPage = null;
255
256 String pageClassName = raf.readUTF();
257 String idClassName = raf.readUTF();
258
259 try {
260 Class<?> idClass = Class.forName(idClassName);
261 Class<?> pageClass = Class.forName(pageClassName);
262
263 Constructor<?>[] idConsts = idClass.getDeclaredConstructors();
264 int numIdArgs = raf.readInt();
265 Object[] idArgs = new Object[numIdArgs];
266 for (int i = 0; i<numIdArgs;i++) {
267 idArgs[i] = raf.readInt();
268 }
269 pid = (PageId)idConsts[0].newInstance(idArgs);
270
271 Constructor<?>[] pageConsts = pageClass.getDeclaredConstructors();
272 int pageSize = raf.readInt();
273
274 byte[] pageData = new byte[pageSize];
275 raf.read(pageData); //read before image
276
277 Object[] pageArgs = new Object[2];
278 pageArgs[0] = pid;
279 pageArgs[1] = pageData;
280
281 newPage = (Page)pageConsts[0].newInstance(pageArgs);
282
283 // Debug.log("READ PAGE OF TYPE " + pageClassName + ", table = " + newPage.getId().getTableId() + ", page = " + newPage.getId().pageno());
284 } catch (ClassNotFoundException | InvocationTargetException | IllegalAccessException | InstantiationException e){
285 e.printStackTrace();
286 throw new IOException();
287 }
288 return newPage;
289
290 }
291
292 /** Write a BEGIN record for the specified transaction
293 @param tid The transaction that is beginning

Callers 4

logTruncateMethod · 0.95
rollbackMethod · 0.95
recoverSearchMethod · 0.95
printMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected