The class encapsulating the insert and delete operators. More...
#include <updates.h>
Static Public Member Functions | |
static void | Insert (const std::string &relation, int attrCnt, const attrInfo attrList[]) |
void badgerdb::Updates::Insert | ( | const std::string & | relation, |
int | attrCnt, | ||
const attrInfo | attrList[] | ||
) | [static] |
The insert operator. Get Attribute information for the relation from attribute catalog. For every indexed attribute create a Index object. Make a record using attrOffset and attrLen values obtained from attribute catalog. Insert that record into the relation file. Add entries corresponding to this new record in every new relation.
Definition at line 22 of file updates.cpp.
{ int i; /*for(i = 0 ; i < attrCnt; i++){ std::cout<<"\nattrList["<<i<<"]"; Helpers::printAttrInfo(&attrList[i]); } std::cout<<"\nRelation: "<<relation; */ RelDesc rd; AttrDesc *attrs; int attrCntReal; std::string s1, s2; relCat->getInfo(relation, rd); // get attribute data attrCat->getRelInfo(rd.relName, attrCntReal, attrs); if(attrCntReal != attrCnt){//checks to make sure correct number of attributes return; } int projToAttrMap[attrCntReal]; for(i = 0; i < attrCntReal; i++){//gets correct order of attributes, s1 = attrList[i].attrName; for(int j = 0; j < attrCntReal; j++){ s2 = attrs[j].attrName; if(s1.compare(s2) == 0){ projToAttrMap[i] =j; break; } } } int length; Datatype type; RecordId insertRecId; for(i = 0; i< attrCntReal; i++){ if(attrs[i].indexed ==1){//if attribute is indexed, create index object(should already be created) Index attrobject(rd.relName, attrs[i].attrOffset, length , type, 1, bufMgr); attrobject.insertEntry(attrList[i].attrValue, insertRecId); } } }