~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to src/mongo/db/diskloc.h

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#pragma once
24
24
 
25
 
#include "jsobj.h"
 
25
#include "mongo/db/jsobj.h"
 
26
#include "mongo/platform/cstdint.h"
 
27
#include "mongo/platform/unordered_set.h"
26
28
 
27
29
namespace mongo {
28
30
 
40
42
        (such as adding a virtual function)
41
43
     */
42
44
    class DiskLoc {
43
 
        int _a;     // this will be volume, file #, etsc. but is a logical value could be anything depending on storage engine
 
45
        int _a;     // this will be volume, file #, etc. but is a logical value could be anything depending on storage engine
44
46
        int ofs;
45
47
 
46
48
    public:
48
50
        enum SentinelValues {
49
51
            /* note NullOfs is different. todo clean up.  see refs to NullOfs in code - use is valid but outside DiskLoc context so confusing as-is. */
50
52
            NullOfs = -1,
51
 
            MaxFiles=16000 // thus a limit of about 32TB of data per db
 
53
 
 
54
            // Caps the number of files that may be allocated in a database, allowing about 32TB of
 
55
            // data per db.  Note that the DiskLoc and DiskLoc56Bit types supports more files than
 
56
            // this value, as does the data storage format.
 
57
            MaxFiles=16000
52
58
        };
53
59
 
54
60
        DiskLoc(int a, int Ofs) : _a(a), ofs(Ofs) { }
80
86
            if ( isNull() )
81
87
                return "null";
82
88
            stringstream ss;
83
 
            ss << hex << _a << ':' << ofs;
 
89
            ss << _a << ':' << hex << ofs;
84
90
            return ss.str();
85
91
        }
86
92
 
127
133
        }
128
134
 
129
135
        /**
 
136
         * Hash value for this disk location.  The hash implementation may be modified, and its
 
137
         * behavior may differ across platforms.  Hash values should not be persisted.
 
138
         */
 
139
        struct Hasher {
 
140
            size_t operator()( DiskLoc loc ) const;
 
141
        };
 
142
 
 
143
        /**
130
144
         * Marks this disk loc for writing
131
145
         * @returns a non const reference to this disk loc
132
146
         * This function explicitly signals we are writing and casts away const
154
168
    };
155
169
#pragma pack()
156
170
 
157
 
    const DiskLoc minDiskLoc(0, 1);
158
 
    const DiskLoc maxDiskLoc(0x7fffffff, 0x7fffffff);
 
171
    inline size_t DiskLoc::Hasher::operator()( DiskLoc loc ) const {
 
172
        // Older tr1 implementations do not support hashing 64 bit integers.  This implementation
 
173
        // delegates to hashing 32 bit integers.
 
174
        return
 
175
            unordered_set<uint32_t>::hasher()( loc.a() ) ^
 
176
            unordered_set<uint32_t>::hasher()( loc.getOfs() );
 
177
    }
 
178
 
 
179
    inline std::ostream& operator<<( std::ostream &stream, const DiskLoc &loc ) {
 
180
        return stream << loc.toString();
 
181
    }
 
182
 
 
183
    // Minimum allowed DiskLoc.  No Record may begin at this location because file and extent
 
184
    // headers must precede Records in a file.
 
185
    const DiskLoc minDiskLoc(0, 0);
 
186
 
 
187
    // Maximum allowed DiskLoc.  Note that only three bytes are used to represent the file number
 
188
    // for consistency with the v1 index DiskLoc storage format, which uses only 7 bytes total.
 
189
    // No Record may begin at this location because the minimum size of a Record is larger than one
 
190
    // byte.
 
191
    const DiskLoc maxDiskLoc(0x00ffffff, 0x7fffffff);
159
192
 
160
193
} // namespace mongo