Iterators
TableScan
Provides access to the rows of a table as an operator.
class TableScan: public Iterator { ... };
TableScan::TableScan(Table* table)
{
this->table = table;
this->file = NULL;
}
|
void TableScan::open()
{
file = fopen(table->file(), "r");
this->buffer = new char[BUFFER_SIZE];
this->buffer_start = 0;
this->buffer_end = 0;
}
|
Row* TableScan::next()
{
int more = ensure_buffer_filled(file,
buffer,
&buffer_start,
&buffer_end);
if (!more) {
return NULL;
} else {
return new Row(buffer,
&buffer_start,
&buffer_end);
}
}
|
void TableScan::close()
{
fclose(file);
delete [] buffer;
}
|
|