BadgerDB
Main Page
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Friends
Pages
afs
cs.wisc.edu
u
h
a
haiyun
private
cs564-spr17
projects
p2
BufMgr
src
file_iterator.h
1
8
#pragma once
9
10
#include <cassert>
11
#include "file.h"
12
#include "page.h"
13
#include "types.h"
14
15
namespace
badgerdb {
16
23
class
FileIterator
{
24
public
:
28
FileIterator
()
29
: file_(NULL),
30
current_page_number_(
Page
::INVALID_NUMBER) {
31
}
32
39
FileIterator
(
File
* file)
40
: file_(file) {
41
assert(file_ != NULL);
42
const
FileHeader
& header = file_->readHeader();
43
current_page_number_ = header.
first_used_page
;
44
}
45
53
FileIterator
(
File
* file,
PageId
page_number)
54
: file_(file),
55
current_page_number_(page_number) {
56
}
57
61
inline
FileIterator
&
operator++
() {
62
assert(file_ != NULL);
63
const
PageHeader
& header = file_->readPageHeader(current_page_number_);
64
current_page_number_ = header.
next_page_number
;
65
66
return
*
this
;
67
}
68
69
//postfix
70
inline
FileIterator
operator++
(
int
)
71
{
72
FileIterator
tmp = *
this
;
// copy ourselves
73
74
assert(file_ != NULL);
75
const
PageHeader
& header = file_->readPageHeader(current_page_number_);
76
current_page_number_ = header.
next_page_number
;
77
78
return
tmp;
79
}
80
87
inline
bool
operator==
(
const
FileIterator
& rhs)
const
{
88
return
file_->
filename
() == rhs.file_->
filename
() &&
89
current_page_number_ == rhs.current_page_number_;
90
}
91
92
inline
bool
operator!=(
const
FileIterator
& rhs)
const
{
93
return
(file_->
filename
() != rhs.file_->
filename
()) ||
94
(current_page_number_ != rhs.current_page_number_);
95
}
96
103
inline
Page
operator*
()
const
104
{
return
file_->
readPage
(current_page_number_); }
105
106
private
:
110
File
* file_;
111
115
PageId
current_page_number_;
116
};
117
118
}
badgerdb::FileIterator::operator++
FileIterator & operator++()
Definition:
file_iterator.h:61
badgerdb::FileIterator::operator*
Page operator*() const
Definition:
file_iterator.h:103
badgerdb::File::filename
const std::string & filename() const
Definition:
file.h:179
badgerdb::FileHeader
Header metadata for files on disk which contain pages.
Definition:
file.h:24
badgerdb::PageHeader::next_page_number
PageId next_page_number
Definition:
page.h:58
badgerdb::File
Class which represents a file in the filesystem containing database pages.
Definition:
file.h:73
badgerdb::FileIterator::operator==
bool operator==(const FileIterator &rhs) const
Definition:
file_iterator.h:87
badgerdb::PageId
std::uint32_t PageId
Identifier for a page in a file.
Definition:
types.h:15
badgerdb::Page
Class which represents a fixed-size database page containing records.
Definition:
page.h:107
badgerdb::FileIterator
Iterator for iterating over the pages in a file.
Definition:
file_iterator.h:23
badgerdb::FileIterator::FileIterator
FileIterator(File *file, PageId page_number)
Definition:
file_iterator.h:53
badgerdb::File::readPage
Page readPage(const PageId page_number) const
Definition:
file.cpp:149
badgerdb::FileHeader::first_used_page
PageId first_used_page
Definition:
file.h:33
badgerdb::FileIterator::FileIterator
FileIterator()
Definition:
file_iterator.h:28
badgerdb::FileIterator::FileIterator
FileIterator(File *file)
Definition:
file_iterator.h:39
badgerdb::PageHeader
Header metadata in a page.
Definition:
page.h:25
Generated on Fri Feb 10 2017 12:39:55 for BadgerDB by
1.8.6