@@ -339,7 +339,7 @@ int BPtree::insert_record(int primary_key, int record_num){
339339 Btreenode n (true );
340340 int q, j, prop_n, prop_k, prop_new, curr_node = root_num;
341341 bool finish = false ;
342- std::stack < int >S;
342+ std::stack < int > S;
343343 // read all the data of node stored in file tree%d.data (%d==curr_node=root_num=file_no);
344344// now n contains all the previously stored data;
345345 read_node (curr_node, n);
@@ -396,9 +396,9 @@ int BPtree::insert_record(int primary_key, int record_num){
396396 // copy remaining values to other node created(new_node);
397397 new_node.copy_last (temp, j);
398398 // return keys[j-1];
399- prop_k = temp.get_key (j);
399+ prop_k = temp.get_key (j); // key to be moved to new root
400400 prop_new = files_till_now;
401- prop_n = curr_node;
401+ prop_n = curr_node; // node that is splitted at first place
402402 // write back the two new nodes created to their respective files;
403403 write_node (files_till_now, new_node);
404404 write_node (curr_node, n);
@@ -413,7 +413,10 @@ int BPtree::insert_record(int primary_key, int record_num){
413413 /* Last element splitted was root
414414 so create new root and assign meta_data */
415415 Btreenode nn (false );
416+ // insert key to new root
416417 nn.push_key (prop_k);
418+ // insert two pointer associated to this key
419+ // for left and right
417420 nn.push_pointer (prop_n);
418421 nn.push_pointer (prop_new);
419422 files_till_now++;
0 commit comments