本文整理汇总了C++中Scan::getNext方法的典型用法代码示例。如果您正苦于以下问题:C++ Scan::getNext方法的具体用法?C++ Scan::getNext怎么用?C++ Scan::getNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scan
的用法示例。
在下文中一共展示了Scan::getNext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
//-------------------------------------------------------------
// test
//-------------------------------------------------------------
Status test(int t)
{
char outfile[10];
int Rarray[] = { 0, 1, 0, 3, 4, 4, 4 };
int Sarray[] = { 1, 0, 2, 2, 2, 3, 0 };
int R = Rarray[t-1];
int S = Sarray[t-1];
Status s;
sprintf(outfile,"test%d", t);
// Perform sort-merge on R and S
sortMerge sm(files[R],NUM_COLS,attrType,attrSize,JOIN_COL,files[S],NUM_COLS,attrType,attrSize,JOIN_COL,outfile,SORTPGNUM,Ascending,s);
if (s != OK)
{
cout << "Test " << t << " -- sortMerge failed" << endl;
return s;
}
// Write merged results to stdout
HeapFile* outf = new HeapFile (outfile,s);
if (s != OK)
{
cout << "Test " << t << " -- result file not created " << endl;
return s;
}
Scan* scan = outf->openScan(s);
assert(s == OK);
int len;
RID rid;
char rec[sizeof(struct _rec)*2];
cout << endl;
cout << "------------ Test " << t << " ---------------" << endl;
for (s = scan->getNext(rid, rec, len); s == OK; s = scan->getNext(rid, rec, len))
{
cout << (*((struct _rec*)&rec)).key << "\t" << (*((struct _rec*)&rec[8])).key << endl;
}
cout << "-------- Test " << t << " completed --------" << endl;
delete scan;
s=outf->deleteFile();
if(s!=OK) MINIBASE_CHAIN_ERROR(JOINS,s);
delete outf;
return s;
}
示例2: test2
//-------------------------------------------------------------
// test2
//-------------------------------------------------------------
void test2()
{
struct R1 {
char key [32];
} rec;
AttrType attrType[] = { attrString };
short attrSize[] = { 32 };
// Create unsorted data file "test2.in"
Status s;
RID rid;
HeapFile f("test2.in",s);
assert(s == OK);
for (int i=0; i<NUM_RECORDS; i++)
{
strcpy(rec.key, data2[i]);
s = f.insertRecord((char*)&rec,REC_LEN2,rid);
assert(s == OK);
}
// Sort "test2.in" into "test2.out"
keySize = attrSize[0];
sortOrder = Ascending;
Sort sort("test2.in","test2.out",1,attrType,attrSize,0,Ascending,SORTPGNUM,s);
f.deleteFile();
if (s != OK)
{
minibase_errors.show_errors();
minibase_errors.clear_errors();
return;
}
// check if "test2.out" is sorted correctly
HeapFile f2("test2.out",s);
if (s != OK)
{
cout << "Test2 -- OOPS! test2.out not created\n";
return;
}
Scan* scan = f2.openScan(s);
assert(s == OK);
int len;
int count = 0;
for (s = scan->getNext(rid, (char *) &rec, len);
(s == OK) && (count < NUM_RECORDS);
s = scan->getNext(rid, (char *) &rec, len))
{
if (strcmp(rec.key,data2[count]) != 0)
{
cout << "Test2 -- OOPS! test2.out not sorted\n";
s = FAIL;
}
count++;
}
if (count != NUM_RECORDS)
cout << "Test2 -- OOPS! Sorting Failed\n";
else
cout << "Test2 -- Sorting OK\n";
f2.deleteFile();
}