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

Method insertTuple

src/java/simpledb/storage/HeapPage.java:292–313  ·  view source on GitHub ↗

Adds the specified tuple to the page; the tuple should be updated to reflect that it is now stored on this page. @throws DbException if the page is full (no empty slots) or tupledesc is mismatch. @param t The tuple to add.

(Tuple t)

Source from the content-addressed store, hash-verified

290 * @param t The tuple to add.
291 */
292 public void insertTuple(Tuple t) throws DbException {
293 // some code goes here
294 // not necessary for lab1
295 if(getNumEmptySlots()==0){
296 throw new DbException("slots if empty");
297 }
298 //判断元数据是否正常
299 if(!t.getTupleDesc().equals(this.td)){
300 throw new DbException("insert tuple err");
301 }
302 for(int i=0;i<numSlots;i++){
303 if(tuples[i]!=null){
304 continue;
305 }
306 if(!isSlotUsed(i)){
307 tuples[i] =t;
308 tuples[i].setRecordId(new RecordId(pid,i));
309 markSlotUsed(i,true);
310 return;
311 }
312 }
313 }
314
315 /**
316 * Marks this page as dirty/not dirty and record that transaction

Callers 4

addTupleMethod · 0.95
insertTupleMethod · 0.95
insertTupleMethod · 0.95

Calls 6

getNumEmptySlotsMethod · 0.95
isSlotUsedMethod · 0.95
markSlotUsedMethod · 0.95
equalsMethod · 0.65
getTupleDescMethod · 0.65
setRecordIdMethod · 0.45

Tested by 3

addTupleMethod · 0.76
insertTupleMethod · 0.76