Skip to content
Newer
Older
100644 138 lines (108 sloc) 3.71 KB
9e9eb0c abstracting out record storage for btree
unknown authored Jan 31, 2009
1 // rec.h
b96e4b2 @kreuter Add license headers to .cpp & .h files that lacked them. MINOR
kreuter authored Feb 9, 2010
2 /*
3 * Copyright (C) 2010 10gen Inc.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License, version 3,
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
9e9eb0c abstracting out record storage for btree
unknown authored Jan 31, 2009
18
8f373bf @dwight fix vc proj file
dwight authored Feb 3, 2009
19 /* TODO for _RECSTORE
20
21 _ support > 2GB data per file
22 _ multiple files, not just indexes.dat
c02272c @dwight for new recstore, have a separate datafile for each index
dwight authored Mar 13, 2009
23 _ lazier writes? (may be done?)
8f373bf @dwight fix vc proj file
dwight authored Feb 3, 2009
24 _ configurable cache size
fac2ee6 @dwight mamke getCollectionNames() in the shell prettier
dwight authored Feb 3, 2009
25 _ fix on abnormal terminations to be able to restart some
8f373bf @dwight fix vc proj file
dwight authored Feb 3, 2009
26 */
27
9e9eb0c abstracting out record storage for btree
unknown authored Jan 31, 2009
28 #pragma once
29
30 #include "reci.h"
8ac01ac @dwight remove reccache (mostly)
dwight authored May 17, 2010
31 //#include "reccache.h"
9e9eb0c abstracting out record storage for btree
unknown authored Jan 31, 2009
32
33 namespace mongo {
34
94f125e @dwight new pagewriter
dwight authored Feb 6, 2009
35 /* --------------------------------------------------------------------------
36 A RecStoreInterface for the normal mongo mem mapped file (MongoDataFile)
37 storage
b8447bf inmemrecstore beginnings
unknown authored Jan 31, 2009
38 */
39
0678ced @dwight intermediate buildindex commit
dwight authored Sep 24, 2009
40 NamespaceDetails* nsdetails_notinline(const char *ns);
41
9e9eb0c abstracting out record storage for btree
unknown authored Jan 31, 2009
42 class MongoMemMapped_RecStore : public RecStoreInterface {
43 public:
850c918 @dwight make recstoreinterface nonvirtual so it's slightly faster
dwight authored Apr 10, 2010
44 VIRT char* get(DiskLoc d, unsigned len) { return d.rec()->data; }
9e9eb0c abstracting out record storage for btree
unknown authored Jan 31, 2009
45
850c918 @dwight make recstoreinterface nonvirtual so it's slightly faster
dwight authored Apr 10, 2010
46 VIRT DiskLoc insert(const char *ns, const void *obuf, int len, bool god) {
9e9eb0c abstracting out record storage for btree
unknown authored Jan 31, 2009
47 return theDataFileMgr.insert(ns, obuf, len, god);
48 }
d1ba9df @dwight datastore work
dwight authored Feb 2, 2009
49
850c918 @dwight make recstoreinterface nonvirtual so it's slightly faster
dwight authored Apr 10, 2010
50 VIRT void deleteRecord(const char *ns, DiskLoc d) {
0678ced @dwight intermediate buildindex commit
dwight authored Sep 24, 2009
51 theDataFileMgr._deleteRecord(nsdetails_notinline(ns), ns, d.rec(), d);
52 }
53
850c918 @dwight make recstoreinterface nonvirtual so it's slightly faster
dwight authored Apr 10, 2010
54 VIRT void modified(DiskLoc d) { }
7165d73 @dwight implemented dropIndexes for alt rec store
dwight authored Mar 17, 2009
55
850c918 @dwight make recstoreinterface nonvirtual so it's slightly faster
dwight authored Apr 10, 2010
56 VIRT void drop(const char *ns) {
7165d73 @dwight implemented dropIndexes for alt rec store
dwight authored Mar 17, 2009
57 dropNS(ns);
58 }
64ed02b @dwight recstore: closeFiles() support
dwight authored Mar 24, 2009
59
850c918 @dwight make recstoreinterface nonvirtual so it's slightly faster
dwight authored Apr 10, 2010
60 VIRT void rename(const char *fromNs, const char *toNs) {
5dcdc3a @astaple fast collection renaming within a database
astaple authored Jul 29, 2009
61 renameNamespace( fromNs, toNs );
62 }
63
64ed02b @dwight recstore: closeFiles() support
dwight authored Mar 24, 2009
64 /* close datafiles associated with the db specified. */
850c918 @dwight make recstoreinterface nonvirtual so it's slightly faster
dwight authored Apr 10, 2010
65 VIRT void closeFiles(string dbname, string path) {
64ed02b @dwight recstore: closeFiles() support
dwight authored Mar 24, 2009
66 /* as this is only used for indexes so far, and we are in the same
67 PDFiles as the nonindex data, we just rely on them having been closed
68 at the same time. one day this may need to change.
69 */
70 }
71
9e9eb0c abstracting out record storage for btree
unknown authored Jan 31, 2009
72 };
73
94f125e @dwight new pagewriter
dwight authored Feb 6, 2009
74 /* An in memory RecStoreInterface implementation ----------------------------
b8447bf inmemrecstore beginnings
unknown authored Feb 1, 2009
75 */
76
c88389e @dwight checkpoint: beginnings of cleaning up the recstore interface
dwight authored Mar 20, 2009
77 #if 0
b8447bf inmemrecstore beginnings
unknown authored Feb 1, 2009
78 class InMem_RecStore : public RecStoreInterface {
4e79d2b @astaple name enums to make old compiler happy (thx kristina)
astaple authored Apr 6, 2009
79 enum InmemfileValue { INMEMFILE = 0x70000000 };
b8447bf inmemrecstore beginnings
unknown authored Feb 1, 2009
80 public:
81 static char* get(DiskLoc d, unsigned len) {
82 assert( d.a() == INMEMFILE );
5e5765f recstore
dwight authored Feb 1, 2009
83 #ifdef __LP64__
0ab8149 @erh uassert/massert take error code SERVER-112
erh authored Dec 28, 2009
84 massert( 10372 , "64 bit not done", false);
bf14747 fix to compile
dwight authored Jan 31, 2009
85 return 0;
5e5765f recstore
dwight authored Feb 1, 2009
86 #else
87 return (char *) d.getOfs();
88 #endif
b8447bf inmemrecstore beginnings
unknown authored Feb 1, 2009
89 }
90
91 static DiskLoc insert(const char *ns, const void *obuf, int len, bool god) {
394405a 64-bit linux compile
yellow authored Feb 1, 2009
92 #ifdef __LP64__
93 assert( 0 );
94 throw -1;
95 #else
b8447bf inmemrecstore beginnings
unknown authored Feb 1, 2009
96 char *p = (char *) malloc(len);
97 assert( p );
98 memcpy(p, obuf, len);
99 int b = (int) p;
100 assert( b > 0 );
101 return DiskLoc(INMEMFILE, b);
394405a 64-bit linux compile
yellow authored Feb 1, 2009
102 #endif
b8447bf inmemrecstore beginnings
unknown authored Feb 1, 2009
103 }
d1ba9df @dwight datastore work
dwight authored Feb 2, 2009
104
105 static void modified(DiskLoc d) { }
7165d73 @dwight implemented dropIndexes for alt rec store
dwight authored Mar 17, 2009
106
107 static void drop(const char *ns) {
108 log() << "warning: drop() not yet implemented for InMem_RecStore" << endl;
109 }
5dcdc3a @astaple fast collection renaming within a database
astaple authored Jul 29, 2009
110
111 virtual void rename(const char *fromNs, const char *toNs) {
0ab8149 @erh uassert/massert take error code SERVER-112
erh authored Dec 28, 2009
112 massert( 10373 , "rename not yet implemented for InMem_RecStore", false );
5dcdc3a @astaple fast collection renaming within a database
astaple authored Jul 29, 2009
113 }
b8447bf inmemrecstore beginnings
unknown authored Feb 1, 2009
114 };
c88389e @dwight checkpoint: beginnings of cleaning up the recstore interface
dwight authored Mar 20, 2009
115 #endif
b8447bf inmemrecstore beginnings
unknown authored Feb 1, 2009
116
c02272c @dwight for new recstore, have a separate datafile for each index
dwight authored Mar 13, 2009
117 /* Glue btree to RecStoreInterface: ---------------------------- */
b8447bf inmemrecstore beginnings
unknown authored Feb 1, 2009
118
850c918 @dwight make recstoreinterface nonvirtual so it's slightly faster
dwight authored Apr 10, 2010
119 typedef MongoMemMapped_RecStore StoreToUse;
120
121 extern StoreToUse *btreeStore;
9e9eb0c abstracting out record storage for btree
unknown authored Jan 31, 2009
122
123 const int BucketSize = 8192;
124
125 inline BtreeBucket* DiskLoc::btree() const {
126 assert( fileNo != -1 );
c88389e @dwight checkpoint: beginnings of cleaning up the recstore interface
dwight authored Mar 20, 2009
127 return (BtreeBucket*) btreeStore->get(*this, BucketSize);
9e9eb0c abstracting out record storage for btree
unknown authored Jan 31, 2009
128 }
129
d1ba9df @dwight datastore work
dwight authored Feb 2, 2009
130 inline BtreeBucket* DiskLoc::btreemod() const {
131 assert( fileNo != -1 );
c88389e @dwight checkpoint: beginnings of cleaning up the recstore interface
dwight authored Mar 20, 2009
132 BtreeBucket *b = (BtreeBucket*) btreeStore->get(*this, BucketSize);
133 btreeStore->modified(*this);
d1ba9df @dwight datastore work
dwight authored Feb 2, 2009
134 return b;
135 }
136
9e9eb0c abstracting out record storage for btree
unknown authored Jan 31, 2009
137 }
Something went wrong with that request. Please try again.