1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

View File

@ -53,132 +53,172 @@ typedef uint64_t CacheKey; /** @brief Key definition
//typedef std::map<CacheKey, BlockBuffer*, std::greater<CacheKey> > CacheMap; /** @brief Cache map */
//typedef CacheMap::iterator CacheMapIt; /** @brief CacheMap iterator */
template<class T>struct hashCacheKey{ };
template<class T>struct hashCacheKey { };
template<> struct hashCacheKey<CacheKey>
{
size_t
operator()(CacheKey __x) const
{ return __x; }
size_t
operator()(CacheKey __x) const
{
return __x;
}
};
struct eqCacheKey
{
bool operator() (const CacheKey k1, const CacheKey k2 ) const
{
return k1 == k2;
}
bool operator() (const CacheKey k1, const CacheKey k2 ) const
{
return k1 == k2;
}
};
//typedef hash_map<Signature, TokenStruc, signatureHash<Signature>, eqSig> DCTNRYHASHMAP;
#if __GNUC__ == 4 && __GNUC_MINOR__ < 2
typedef __gnu_cxx::hash_map<CacheKey, BlockBuffer*, hashCacheKey<CacheKey>, eqCacheKey> CacheMap;
typedef __gnu_cxx::hash_map<CacheKey, BlockBuffer*, hashCacheKey<CacheKey>, eqCacheKey> CacheMap;
#else
typedef std::tr1::unordered_map<CacheKey, BlockBuffer*, hashCacheKey<CacheKey>, eqCacheKey> CacheMap;
typedef std::tr1::unordered_map<CacheKey, BlockBuffer*, hashCacheKey<CacheKey>, eqCacheKey> CacheMap;
#endif
//typedef __gnu_cxx::hash_map<CacheKey, BlockBuffer*> CacheMap;
//typedef __gnu_cxx::hash_map<CacheKey, BlockBuffer*> CacheMap;
typedef CacheMap::iterator CacheMapIt;
//typedef CacheMap LRUBufList; /** @brief Least Recent Used Buffer list */
//typedef CacheMap WriteBufList; /** @brief Write buffer list */
/** Class Cache */
class Cache
class Cache
{
public:
/**
* @brief Constructor
*/
Cache() {}
/**
* @brief Constructor
*/
Cache() {}
/**
* @brief Default Destructor
*/
~Cache() {}
/**
* @brief Default Destructor
*/
~Cache() {}
/**
* @brief Check whether cache key exists
*/
static const bool cacheKeyExist( CacheMap* map, const OID oid, const uint64_t lbid ) { CacheKey key = getCacheKey( oid, lbid ); return map->find(key) == map->end() ? false: true; }
static const bool cacheKeyExist( CacheMap* map, BlockBuffer* buffer ) { return cacheKeyExist( map, (*buffer).cb.file.oid, (*buffer).block.lbid ); }
static const bool cacheKeyExist( const OID oid, const uint64_t lbid ) { return cacheKeyExist( m_lruList, oid, lbid ) || cacheKeyExist( m_writeList, oid, lbid ); }
/**
* @brief Check whether cache key exists
*/
static const bool cacheKeyExist( CacheMap* map, const OID oid, const uint64_t lbid )
{
CacheKey key = getCacheKey( oid, lbid );
return map->find(key) == map->end() ? false : true;
}
static const bool cacheKeyExist( CacheMap* map, BlockBuffer* buffer )
{
return cacheKeyExist( map, (*buffer).cb.file.oid, (*buffer).block.lbid );
}
static const bool cacheKeyExist( const OID oid, const uint64_t lbid )
{
return cacheKeyExist( m_lruList, oid, lbid ) || cacheKeyExist( m_writeList, oid, lbid );
}
/**
* @brief Clear the buffer
*/
EXPORT static void clear();
/**
* @brief Clear the buffer
*/
EXPORT static void clear();
/**
* @brief Free the buffer memory
*/
EXPORT static void freeMemory();
/**
* @brief Free the buffer memory
*/
EXPORT static void freeMemory();
/**
* @brief Flush the write cache
*/
EXPORT static const int flushCache();
/**
* @brief Flush the write cache
*/
EXPORT static const int flushCache();
/**
* @brief Get the cache key
*/
static CacheKey getCacheKey( const OID oid, const uint64_t lbid ) { CacheKey key = lbid; /*Convertor::int2Str( oid ) + "|" + Convertor::int2Str(lbid)*/; return key; }
static CacheKey getCacheKey( const BlockBuffer* buffer ) { return getCacheKey( (*buffer).cb.file.oid, (*buffer).block.lbid ); }
/**
* @brief Get the cache key
*/
static CacheKey getCacheKey( const OID oid, const uint64_t lbid )
{
CacheKey key = lbid; /*Convertor::int2Str( oid ) + "|" + Convertor::int2Str(lbid)*/;
return key;
}
static CacheKey getCacheKey( const BlockBuffer* buffer )
{
return getCacheKey( (*buffer).cb.file.oid, (*buffer).block.lbid );
}
EXPORT static const int getListSize( const CacheListType listType );
EXPORT static const int getListSize( const CacheListType listType );
/**
* @brief Init the buffers
*/
EXPORT static void init( const int totalBlock, const int chkPoint, const int pctFree );
static void init() { init( DEFAULT_CACHE_BLOCK, DEFAULT_CHK_INTERVAL, DEFAULT_CACHE_PCT_FREE ); }
/**
* @brief Init the buffers
*/
EXPORT static void init( const int totalBlock, const int chkPoint, const int pctFree );
static void init()
{
init( DEFAULT_CACHE_BLOCK, DEFAULT_CHK_INTERVAL, DEFAULT_CACHE_PCT_FREE );
}
/**
* @brief Insert into LRU list
*/
EXPORT static const int insertLRUList( CommBlock& cb, const uint64_t lbid, const uint64_t fbo, const unsigned char* buf );
static const int insertLRUList( CommBlock& cb, const uint64_t lbid, const uint64_t fbo, const DataBlock& block ) { return insertLRUList( cb, lbid, fbo, block.data ); }
/**
* @brief Insert into LRU list
*/
EXPORT static const int insertLRUList( CommBlock& cb, const uint64_t lbid, const uint64_t fbo, const unsigned char* buf );
static const int insertLRUList( CommBlock& cb, const uint64_t lbid, const uint64_t fbo, const DataBlock& block )
{
return insertLRUList( cb, lbid, fbo, block.data );
}
/**
* @brief Insert into Write list
*/
/**
* @brief Insert into Write list
*/
// static const int insertWriteList( const CacheKey& key );
/**
* @brief Load cache block to a buffer
*/
static const int loadCacheBlock( const CacheKey& key, DataBlock& block ) { return loadCacheBlock( key, block.data ); }
EXPORT static const int loadCacheBlock( const CacheKey& key, unsigned char* buf );
/**
* @brief Load cache block to a buffer
*/
static const int loadCacheBlock( const CacheKey& key, DataBlock& block )
{
return loadCacheBlock( key, block.data );
}
EXPORT static const int loadCacheBlock( const CacheKey& key, unsigned char* buf );
/**
* @brief Modify a cache block
*/
static const int modifyCacheBlock( const CacheKey& key, const DataBlock& block ) { return modifyCacheBlock( key, block.data ); }
EXPORT static const int modifyCacheBlock( const CacheKey& key, const unsigned char* buf );
/**
* @brief Modify a cache block
*/
static const int modifyCacheBlock( const CacheKey& key, const DataBlock& block )
{
return modifyCacheBlock( key, block.data );
}
EXPORT static const int modifyCacheBlock( const CacheKey& key, const unsigned char* buf );
/**
* @brief Print
*/
EXPORT static void printCacheMapList( const CacheMap* map );
EXPORT static void printCacheList();
/**
* @brief Print
*/
EXPORT static void printCacheMapList( const CacheMap* map );
EXPORT static void printCacheList();
/**
* @brief Insert/Delete an element in cache map
*/
EXPORT static const int processCacheMap( CacheMap* map, BlockBuffer* buffer, OpType opType );
/**
* @brief Insert/Delete an element in cache map
*/
EXPORT static const int processCacheMap( CacheMap* map, BlockBuffer* buffer, OpType opType );
// accessory
static const int getTotalBlock() { return m_cacheParam->totalBlock; }
static const bool getUseCache() { return m_useCache; }
static void setUseCache( const bool flag ) { m_useCache = flag; }
// accessory
static const int getTotalBlock()
{
return m_cacheParam->totalBlock;
}
static const bool getUseCache()
{
return m_useCache;
}
static void setUseCache( const bool flag )
{
m_useCache = flag;
}
static CacheControl* m_cacheParam; // Cache parameters
static FreeBufList* m_freeList; // free buffer list
static CacheMap* m_lruList; // LRU buffer list
static CacheMap* m_writeList; // Write buffer list
static CacheControl* m_cacheParam; // Cache parameters
static FreeBufList* m_freeList; // free buffer list
static CacheMap* m_lruList; // LRU buffer list
static CacheMap* m_writeList; // Write buffer list
#if defined(_MSC_VER) && !defined(WRITEENGINE_DLLEXPORT)
__declspec(dllimport)
__declspec(dllimport)
#endif
EXPORT static bool m_useCache; // Use cache flag
EXPORT static bool m_useCache; // Use cache flag
private:
};