⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 load.c

📁 linux 下用c++ 开发的一个小型数据库系统
💻 C
字号:
#include <unistd.h>#include <fcntl.h>#include "catalog.h"#include "utility.h"#include <stdlib.h>//// Loads a file of (binary) tuples from a standard file into the relation.// Any indices on the relation are updated appropriately.//// Returns:// 	OK on success// 	an error code otherwise//const Status UT_Load(const string & relation, const string & fileName){  Status status;  RelDesc rd;  AttrDesc *attrs;  int attrCnt,fopen;  int size = 0;  RID rid;  Record myrec ;  char *mydata = NULL ;  if (relation.empty() || fileName.empty() || relation == string(RELCATNAME)      || relation == string(ATTRCATNAME))    return BADCATPARM;  if((fopen=open( fileName.c_str(), O_RDONLY, 0)) < 0)    return UNIXERR;  if((status = relCat->getInfo( relation, rd)) != OK) return status;  if((status = attrCat->getRelInfo( rd.relName, attrCnt, attrs)) != OK) return status;  InsertFileScan* ifs = new InsertFileScan( rd.relName, status);  if (status != OK) return status;  for(int i=0; i<attrCnt; i++) size += attrs[i].attrLen;  mydata = new char[size];  while(read( fopen, mydata, size) == size){    myrec.data = mydata;    myrec.length=size;    if((status=ifs->insertRecord( myrec, rid)) != OK) return status;  }  delete [] mydata;  if(close(fopen)<0) return UNIXERR;  else return OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -