You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
Reformat all code to coding standard
This commit is contained in:
@ -20,7 +20,7 @@
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/** @file
|
||||
/** @file
|
||||
* class OIDServer interface.
|
||||
*/
|
||||
|
||||
@ -40,12 +40,14 @@
|
||||
#define EXPORT
|
||||
#endif
|
||||
|
||||
namespace idbdatafile {
|
||||
namespace idbdatafile
|
||||
{
|
||||
class IDBDataFile;
|
||||
}
|
||||
|
||||
|
||||
namespace BRM {
|
||||
namespace BRM
|
||||
{
|
||||
|
||||
/** @brief The class that manages the Object ID space
|
||||
*
|
||||
@ -55,154 +57,155 @@ namespace BRM {
|
||||
class OIDServer
|
||||
{
|
||||
private:
|
||||
struct FEntry {
|
||||
int begin, end;
|
||||
};
|
||||
struct FEntry
|
||||
{
|
||||
int begin, end;
|
||||
};
|
||||
|
||||
public:
|
||||
/** @brief Default constructor
|
||||
*
|
||||
* @note Throws ios::failure on a file IO error
|
||||
*/
|
||||
EXPORT OIDServer();
|
||||
EXPORT virtual ~OIDServer();
|
||||
/** @brief Default constructor
|
||||
*
|
||||
* @note Throws ios::failure on a file IO error
|
||||
*/
|
||||
EXPORT OIDServer();
|
||||
EXPORT virtual ~OIDServer();
|
||||
|
||||
/** @brief Allocate a contiguous range of Object IDs
|
||||
*
|
||||
* @param num The number of contiguous Object IDs to allocate
|
||||
* @return The first OID allocated on success, -1 on failure
|
||||
*/
|
||||
EXPORT int allocOIDs(int num);
|
||||
/** @brief Allocate a contiguous range of Object IDs
|
||||
*
|
||||
* @param num The number of contiguous Object IDs to allocate
|
||||
* @return The first OID allocated on success, -1 on failure
|
||||
*/
|
||||
EXPORT int allocOIDs(int num);
|
||||
|
||||
|
||||
/** @brief Allocates a single OID for a version buffer file, given its dbroot
|
||||
*
|
||||
* A new requirement in the shared nothing implementation is for version buffer
|
||||
* files to be anchored to a specific dbroot. This association is stored on disk as
|
||||
* an array of uint16s. Version buffer OIDs use 0-999, so the 0th offset in the
|
||||
* array is the dbroot of the OID 0, and so on.
|
||||
*/
|
||||
EXPORT int allocVBOID(uint16_t dbroot);
|
||||
/** @brief Allocates a single OID for a version buffer file, given its dbroot
|
||||
*
|
||||
* A new requirement in the shared nothing implementation is for version buffer
|
||||
* files to be anchored to a specific dbroot. This association is stored on disk as
|
||||
* an array of uint16s. Version buffer OIDs use 0-999, so the 0th offset in the
|
||||
* array is the dbroot of the OID 0, and so on.
|
||||
*/
|
||||
EXPORT int allocVBOID(uint16_t dbroot);
|
||||
|
||||
/** @brief Returns the DBRoot of the given version buffer file.
|
||||
*
|
||||
*/
|
||||
EXPORT int getDBRootOfVBOID(uint32_t vbOID);
|
||||
/** @brief Returns the DBRoot of the given version buffer file.
|
||||
*
|
||||
*/
|
||||
EXPORT int getDBRootOfVBOID(uint32_t vbOID);
|
||||
|
||||
/** @brief Returns the VB OID of the given DB root.
|
||||
*
|
||||
*/
|
||||
EXPORT int getVBOIDOfDBRoot(uint32_t vbOID);
|
||||
/** @brief Returns the VB OID of the given DB root.
|
||||
*
|
||||
*/
|
||||
EXPORT int getVBOIDOfDBRoot(uint32_t vbOID);
|
||||
|
||||
/** @brief Returns the whole VB OID -> DBRoot mapping. The returned vector is indexed by VB OID.
|
||||
*
|
||||
*/
|
||||
EXPORT const std::vector<uint16_t> & getVBOIDToDBRootMap();
|
||||
/** @brief Returns the whole VB OID -> DBRoot mapping. The returned vector is indexed by VB OID.
|
||||
*
|
||||
*/
|
||||
EXPORT const std::vector<uint16_t>& getVBOIDToDBRootMap();
|
||||
|
||||
/** @brief Return a list of OIDs to the pool
|
||||
*
|
||||
* @param start The first OID to return
|
||||
* @param end The last OID to return
|
||||
*/
|
||||
EXPORT void returnOIDs(int start, int end) const;
|
||||
/** @brief Return a list of OIDs to the pool
|
||||
*
|
||||
* @param start The first OID to return
|
||||
* @param end The last OID to return
|
||||
*/
|
||||
EXPORT void returnOIDs(int start, int end) const;
|
||||
|
||||
/** @brief Counts the number of allocated OIDs
|
||||
*
|
||||
* @note This currently assumes the bitmap length is a multiple of 4096
|
||||
* @return The number of allocated OIDs
|
||||
*/
|
||||
EXPORT int size() const;
|
||||
/** @brief Counts the number of allocated OIDs
|
||||
*
|
||||
* @note This currently assumes the bitmap length is a multiple of 4096
|
||||
* @return The number of allocated OIDs
|
||||
*/
|
||||
EXPORT int size() const;
|
||||
|
||||
/** @brief Get the OID bitmap filename
|
||||
*/
|
||||
const std::string getFilename() const;
|
||||
/** @brief Get the OID bitmap filename
|
||||
*/
|
||||
const std::string getFilename() const;
|
||||
|
||||
private:
|
||||
std::string fFilename;
|
||||
static const int FreeListEntries = 256;
|
||||
static const int HeaderSize = FreeListEntries * sizeof(FEntry);
|
||||
static const int StartOfVBOidSection = HeaderSize + 2097152; // (2^24/8)
|
||||
static const int MaxRetries = 10; /// max number of retries on file operations
|
||||
static boost::mutex fMutex;
|
||||
idbdatafile::IDBDataFile* fFp;
|
||||
int fFd; /// file descriptor referencing the bitmap file
|
||||
std::vector<uint16_t> vbOidDBRootMap;
|
||||
std::string fFilename;
|
||||
static const int FreeListEntries = 256;
|
||||
static const int HeaderSize = FreeListEntries * sizeof(FEntry);
|
||||
static const int StartOfVBOidSection = HeaderSize + 2097152; // (2^24/8)
|
||||
static const int MaxRetries = 10; /// max number of retries on file operations
|
||||
static boost::mutex fMutex;
|
||||
idbdatafile::IDBDataFile* fFp;
|
||||
int fFd; /// file descriptor referencing the bitmap file
|
||||
std::vector<uint16_t> vbOidDBRootMap;
|
||||
|
||||
/** @brief Grab the file lock
|
||||
*
|
||||
* Grab the file lock.
|
||||
* @note Throws ios::failure after MaxRetries hard errors
|
||||
*/
|
||||
//void lockFile() const;
|
||||
/** @brief Grab the file lock
|
||||
*
|
||||
* Grab the file lock.
|
||||
* @note Throws ios::failure after MaxRetries hard errors
|
||||
*/
|
||||
//void lockFile() const;
|
||||
|
||||
/** @brief Reliably reads data from the bitmap file
|
||||
*
|
||||
* Reliably reads data from the bitmap file.
|
||||
* @note Throws ios::failure after MaxRetries hard errors
|
||||
* @note Caller is responsible for locking & unlocking
|
||||
* @param buf the buffer to read into
|
||||
* @param offset the offset to start reading at
|
||||
* @param size the number of bytes to read into buf
|
||||
*/
|
||||
void readData(uint8_t* buf, off_t offset, int size) const;
|
||||
/** @brief Reliably reads data from the bitmap file
|
||||
*
|
||||
* Reliably reads data from the bitmap file.
|
||||
* @note Throws ios::failure after MaxRetries hard errors
|
||||
* @note Caller is responsible for locking & unlocking
|
||||
* @param buf the buffer to read into
|
||||
* @param offset the offset to start reading at
|
||||
* @param size the number of bytes to read into buf
|
||||
*/
|
||||
void readData(uint8_t* buf, off_t offset, int size) const;
|
||||
|
||||
/** @brief Reliably writes data to the bitmap file
|
||||
*
|
||||
* Reliably write data to the bitmap file.
|
||||
* @note Throws ios::failure after MaxRetries hard errors
|
||||
* @note Caller is responsible for locking & unlocking
|
||||
* @param buf the data to write
|
||||
* @param offset the offset to start writing at
|
||||
* @param size the number of bytes to write
|
||||
*/
|
||||
void writeData(uint8_t* buf, off_t offset, int size) const;
|
||||
/** @brief Reliably writes data to the bitmap file
|
||||
*
|
||||
* Reliably write data to the bitmap file.
|
||||
* @note Throws ios::failure after MaxRetries hard errors
|
||||
* @note Caller is responsible for locking & unlocking
|
||||
* @param buf the data to write
|
||||
* @param offset the offset to start writing at
|
||||
* @param size the number of bytes to write
|
||||
*/
|
||||
void writeData(uint8_t* buf, off_t offset, int size) const;
|
||||
|
||||
/** @brief If there is no bitmap file yet, this is used to make one
|
||||
*
|
||||
* If there is no bitmap file yet, this is used to make one.
|
||||
* @note It assumes no OIDs are allocated, we may want
|
||||
* to fully rebuild it from actual DB contents instead.
|
||||
*/
|
||||
void initializeBitmap() const;
|
||||
/** @brief If there is no bitmap file yet, this is used to make one
|
||||
*
|
||||
* If there is no bitmap file yet, this is used to make one.
|
||||
* @note It assumes no OIDs are allocated, we may want
|
||||
* to fully rebuild it from actual DB contents instead.
|
||||
*/
|
||||
void initializeBitmap() const;
|
||||
|
||||
/** @brief Allocates OIDs using a designated freelist entry
|
||||
*
|
||||
* Allocates OIDs using a designated freelist entry
|
||||
* @param fe The freelist entry to use.
|
||||
* @param num The number of OIDs to allocate from that block
|
||||
*/
|
||||
void useFreeListEntry(struct FEntry& fe, int num);
|
||||
/** @brief Allocates OIDs using a designated freelist entry
|
||||
*
|
||||
* Allocates OIDs using a designated freelist entry
|
||||
* @param fe The freelist entry to use.
|
||||
* @param num The number of OIDs to allocate from that block
|
||||
*/
|
||||
void useFreeListEntry(struct FEntry& fe, int num);
|
||||
|
||||
/** @brief This allocates or deallocates a block of OIDs
|
||||
*
|
||||
* This allocates or deallocates a block of OIDs
|
||||
* @param start The first OID to alloc/dealloc
|
||||
* @param end The number of OIDs to flip
|
||||
* @param mode mode = 0 means 'allocate', mode = 1 means 'deallocate'
|
||||
*/
|
||||
void flipOIDBlock(int start, int num, int mode) const;
|
||||
/** @brief This allocates or deallocates a block of OIDs
|
||||
*
|
||||
* This allocates or deallocates a block of OIDs
|
||||
* @param start The first OID to alloc/dealloc
|
||||
* @param end The number of OIDs to flip
|
||||
* @param mode mode = 0 means 'allocate', mode = 1 means 'deallocate'
|
||||
*/
|
||||
void flipOIDBlock(int start, int num, int mode) const;
|
||||
|
||||
/** @brief This scans the whole bitmap for a block of free OIDs
|
||||
*
|
||||
* This scans the whole bitmap for a block of free OIDs
|
||||
* @param num the size of the block to locate
|
||||
* @param freelist the freelist
|
||||
* @return The first OID of the block allocated, or -1 if there is no match
|
||||
*/
|
||||
int fullScan(int num, struct FEntry* freelist) const;
|
||||
/** @brief This scans the whole bitmap for a block of free OIDs
|
||||
*
|
||||
* This scans the whole bitmap for a block of free OIDs
|
||||
* @param num the size of the block to locate
|
||||
* @param freelist the freelist
|
||||
* @return The first OID of the block allocated, or -1 if there is no match
|
||||
*/
|
||||
int fullScan(int num, struct FEntry* freelist) const;
|
||||
|
||||
/** @brief This is used by allocOIDs to fix the freelist after a full scan
|
||||
*
|
||||
* This is used by fullScan to fix the freelist before an allocation
|
||||
* @param freelist The freelist
|
||||
* @param start The first OID of the block allocated by fullScan
|
||||
* @param num The number of OIDs allocated
|
||||
* @note At the moment it throws logic_error if it detects a specific error in
|
||||
* fullscan
|
||||
*/
|
||||
void patchFreelist(struct FEntry* freelist, int start, int num) const;
|
||||
/** @brief This is used by allocOIDs to fix the freelist after a full scan
|
||||
*
|
||||
* This is used by fullScan to fix the freelist before an allocation
|
||||
* @param freelist The freelist
|
||||
* @param start The first OID of the block allocated by fullScan
|
||||
* @param num The number of OIDs allocated
|
||||
* @note At the moment it throws logic_error if it detects a specific error in
|
||||
* fullscan
|
||||
*/
|
||||
void patchFreelist(struct FEntry* freelist, int start, int num) const;
|
||||
|
||||
void loadVBOIDs();
|
||||
void loadVBOIDs();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user