summaryrefslogtreecommitdiff
path: root/db/storage.h
diff options
context:
space:
mode:
Diffstat (limited to 'db/storage.h')
-rw-r--r--db/storage.h175
1 files changed, 104 insertions, 71 deletions
diff --git a/db/storage.h b/db/storage.h
index 5e4f43f77f3..f53a732b2e6 100644
--- a/db/storage.h
+++ b/db/storage.h
@@ -1,15 +1,15 @@
/**
* Copyright (C) 2008 10gen Inc.
-*
+*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
-*
+*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
-*
+*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -32,78 +32,111 @@ class BSONObj;
class PhysicalDataFile;
class DiskLoc {
- int fileNo; /* this will be volume, file #, etc. */
- int ofs;
+ int fileNo; /* this will be volume, file #, etc. */
+ int ofs;
public:
- enum { NullOfs = -1, MaxFiles=4000 };
- int a() const { return fileNo; }
- DiskLoc(int a, int b) : fileNo(a), ofs(b) {
- assert(ofs!=0);
- }
- DiskLoc() { fileNo = -1; ofs = NullOfs; }
-
- DiskLoc(const DiskLoc& l) { fileNo=l.fileNo; ofs=l.ofs; }
-
- bool questionable() {
- return ofs < -1 ||
- fileNo < -1 ||
- fileNo > 20;
- }
-
- bool isNull() const { return ofs == NullOfs; }
- void Null() { fileNo = -1; ofs = NullOfs; }
- void setInvalid() { fileNo = -2; }
- void assertOk() { assert(!isNull()); }
-
- string toString() const {
- if( isNull() )
- return "null";
- stringstream ss;
- ss << hex << fileNo << ':' << ofs;
- return ss.str();
- }
-
- int& GETOFS() { return ofs; }
- int getOfs() const { return ofs; }
- void set(int a, int b) { fileNo=a; ofs=b; }
- void setOfs(int _fileNo, int _ofs) {
- fileNo = _fileNo;
- ofs = _ofs;
- }
-
- void inc(int amt) {
- assert( !isNull() );
- ofs += amt;
- }
-
- bool sameFile(DiskLoc b) { return fileNo == b.fileNo; }
-
- bool operator==(const DiskLoc& b) const { return fileNo==b.fileNo && ofs == b.ofs; }
- bool operator!=(const DiskLoc& b) const { return !(*this==b); }
- const DiskLoc& operator=(const DiskLoc& b) {
- fileNo=b.fileNo; ofs = b.ofs;
- assert(ofs!=0);
- return *this;
- }
- int compare(const DiskLoc& b) const {
- int x = fileNo - b.fileNo;
- if( x )
- return x;
+ enum { NullOfs = -1, MaxFiles=4000 };
+ int a() const {
+ return fileNo;
+ }
+ DiskLoc(int a, int b) : fileNo(a), ofs(b) {
+ assert(ofs!=0);
+ }
+ DiskLoc() {
+ fileNo = -1;
+ ofs = NullOfs;
+ }
+
+ DiskLoc(const DiskLoc& l) {
+ fileNo=l.fileNo;
+ ofs=l.ofs;
+ }
+
+ bool questionable() {
+ return ofs < -1 ||
+ fileNo < -1 ||
+ fileNo > 20;
+ }
+
+ bool isNull() const {
+ return ofs == NullOfs;
+ }
+ void Null() {
+ fileNo = -1;
+ ofs = NullOfs;
+ }
+ void setInvalid() {
+ fileNo = -2;
+ }
+ void assertOk() {
+ assert(!isNull());
+ }
+
+ string toString() const {
+ if ( isNull() )
+ return "null";
+ stringstream ss;
+ ss << hex << fileNo << ':' << ofs;
+ return ss.str();
+ }
+
+ int& GETOFS() {
+ return ofs;
+ }
+ int getOfs() const {
+ return ofs;
+ }
+ void set(int a, int b) {
+ fileNo=a;
+ ofs=b;
+ }
+ void setOfs(int _fileNo, int _ofs) {
+ fileNo = _fileNo;
+ ofs = _ofs;
+ }
+
+ void inc(int amt) {
+ assert( !isNull() );
+ ofs += amt;
+ }
+
+ bool sameFile(DiskLoc b) {
+ return fileNo == b.fileNo;
+ }
+
+ bool operator==(const DiskLoc& b) const {
+ return fileNo==b.fileNo && ofs == b.ofs;
+ }
+ bool operator!=(const DiskLoc& b) const {
+ return !(*this==b);
+ }
+ const DiskLoc& operator=(const DiskLoc& b) {
+ fileNo=b.fileNo;
+ ofs = b.ofs;
+ assert(ofs!=0);
+ return *this;
+ }
+ int compare(const DiskLoc& b) const {
+ int x = fileNo - b.fileNo;
+ if ( x )
+ return x;
return ofs - b.ofs;
- }
- bool operator<(const DiskLoc& b) const { return compare(b) < 0; }
-
- /* get the "thing" associated with this disk location.
- it is assumed the object is what it is -- you must asure that:
- think of this as an unchecked type cast.
+ }
+ bool operator<(const DiskLoc& b) const {
+ return compare(b) < 0;
+ }
+
+ /* get the "thing" associated with this disk location.
+ it is assumed the object is what it is -- you must asure that:
+ think of this as an unchecked type cast.
*/
- BSONObj obj() const;
- Record* rec() const;
- DeletedRecord* drec() const;
- Extent* ext() const;
- BtreeBucket* btree() const;
+ BSONObj obj() const;
+ Record* rec() const;
+ DeletedRecord* drec() const;
+ Extent* ext() const;
+ BtreeBucket* btree() const;
- PhysicalDataFile& pdf() const;
+ PhysicalDataFile& pdf() const;
};
#pragma pack(pop)