Rdb: constness

This commit is contained in:
Ivan Skytte Jørgensen
2016-10-17 12:29:51 +02:00
parent f2b8058f8d
commit 71ac1a5fe8
4 changed files with 24 additions and 23 deletions

16
Rdb.cpp

@ -2134,7 +2134,7 @@ bool Rdb::addRecord(collnum_t collnum, char *key, char *data, int32_t dataSize)
// . use the maps and tree to estimate the size of this list w/o hitting disk
// . used by Indexdb.cpp to get the size of a list for IDF weighting purposes
int64_t Rdb::getListSize(collnum_t collnum, const char *startKey, const char *endKey, char *max, int64_t oldTruncationLimit) {
int64_t Rdb::getListSize(collnum_t collnum, const char *startKey, const char *endKey, char *max, int64_t oldTruncationLimit) const {
// pick it
if ( collnum < 0 || collnum > getNumBases() || ! getBase(collnum) ) {
log(LOG_WARN, "db: %s bad collnum of %i", m_dbname, collnum);
@ -2143,12 +2143,12 @@ int64_t Rdb::getListSize(collnum_t collnum, const char *startKey, const char *en
return getBase(collnum)->getListSize(startKey, endKey, max, oldTruncationLimit);
}
int64_t Rdb::getNumGlobalRecs() {
int64_t Rdb::getNumGlobalRecs() const {
return (getNumTotalRecs() * g_hostdb.m_numShards);
}
// . return number of positive records - negative records
int64_t Rdb::getNumTotalRecs ( bool useCache ) {
int64_t Rdb::getNumTotalRecs(bool useCache) const {
// are we statsdb? then we have no associated collections
// because we are used globally, by all collections
@ -2190,7 +2190,7 @@ int64_t Rdb::getNumTotalRecs ( bool useCache ) {
}
int64_t Rdb::getCollNumTotalRecs ( collnum_t collnum ) {
int64_t Rdb::getCollNumTotalRecs(collnum_t collnum) const {
if ( collnum < 0 ) return 0;
@ -2209,7 +2209,7 @@ int64_t Rdb::getCollNumTotalRecs ( collnum_t collnum ) {
// . how much mem is allocated for all of our maps?
// . we have one map per file
int64_t Rdb::getMapMemAllocated() {
int64_t Rdb::getMapMemAllocated() const {
int64_t total = 0;
for ( int32_t i = 0 ; i < getNumBases() ; i++ ) {
// skip null base if swapped out
@ -2223,7 +2223,7 @@ int64_t Rdb::getMapMemAllocated() {
}
// sum of all parts of all big files
int32_t Rdb::getNumSmallFiles ( ) {
int32_t Rdb::getNumSmallFiles() const {
int32_t total = 0;
for ( int32_t i = 0 ; i < getNumBases() ; i++ ) {
// skip null base if swapped out
@ -2237,7 +2237,7 @@ int32_t Rdb::getNumSmallFiles ( ) {
}
// sum of all parts of all big files
int32_t Rdb::getNumFiles ( ) {
int32_t Rdb::getNumFiles() const {
int32_t total = 0;
for ( int32_t i = 0 ; i < getNumBases() ; i++ ) {
CollectionRec *cr = g_collectiondb.getRec(i);
@ -2250,7 +2250,7 @@ int32_t Rdb::getNumFiles ( ) {
return total;
}
int64_t Rdb::getDiskSpaceUsed ( ) {
int64_t Rdb::getDiskSpaceUsed() const {
int64_t total = 0;
for ( int32_t i = 0 ; i < getNumBases() ; i++ ) {
CollectionRec *cr = g_collectiondb.getRec(i);

27
Rdb.h

@ -169,22 +169,23 @@ public:
void cleanTree();
RdbBase *getBase ( collnum_t collnum ) ;
int32_t getNumBases ( ) { return g_collectiondb.m_numRecs; }
RdbBase *getBase(collnum_t collnum );
const RdbBase *getBase(collnum_t collnum ) const { return const_cast<Rdb*>(this)->getBase(collnum); }
int32_t getNumBases() const { return g_collectiondb.m_numRecs; }
void addBase ( collnum_t collnum , class RdbBase *base ) ;
// how much mem is allocated for our maps?
int64_t getMapMemAllocated();
int64_t getMapMemAllocated() const;
int32_t getNumFiles ( ) ;
int32_t getNumFiles() const;
// sum of all parts of all big files
int32_t getNumSmallFiles ( ) ;
int64_t getDiskSpaceUsed ( );
int32_t getNumSmallFiles() const;
int64_t getDiskSpaceUsed() const;
// returns -1 if variable (variable dataSize)
int32_t getRecSize ( ) {
int32_t getRecSize() const {
if ( m_fixedDataSize == -1 ) {
return -1;
}
@ -195,14 +196,14 @@ public:
// use the maps and tree to estimate the size of this list
int64_t getListSize(collnum_t collnum,
const char *startKey, const char *endKey, char *maxKey,
int64_t oldTruncationLimit);
int64_t oldTruncationLimit) const;
// positive minus negative
int64_t getNumTotalRecs ( bool useCache = false ) ;
int64_t getNumTotalRecs(bool useCache = false) const;
int64_t getCollNumTotalRecs ( collnum_t collnum );
int64_t getCollNumTotalRecs(collnum_t collnum) const; //could technically be static
int64_t getNumGlobalRecs ( );
int64_t getNumGlobalRecs() const;
// used for keeping track of stats
void didSeek() { m_numSeeks++; }
@ -321,8 +322,8 @@ private:
// memory for us to use to avoid calling malloc()/mdup()/...
RdbMem m_mem;
int32_t m_cacheLastTime;
int64_t m_cacheLastTotal;
mutable int32_t m_cacheLastTime;
mutable int64_t m_cacheLastTotal;
bool m_inAddList;

@ -2043,7 +2043,7 @@ void RdbBase::selectFilesToMerge(int32_t mergeFileCount, int32_t numFiles, int32
// . use the maps and tree to estimate the size of this list w/o hitting disk
// . used by Indexdb.cpp to get the size of a list for IDF weighting purposes
int64_t RdbBase::getListSize(const char *startKey, const char *endKey, char *maxKey,
int64_t oldTruncationLimit) {
int64_t oldTruncationLimit) const {
// . reset this to low points
// . this is on
KEYSET(maxKey,endKey,m_ks);

@ -126,7 +126,7 @@ class RdbBase {
// use the maps and tree to estimate the size of this list
int64_t getListSize(const char *startKey, const char *endKey, char *maxKey,
int64_t oldTruncationLimit);
int64_t oldTruncationLimit) const;
// positive minus negative
int64_t getNumTotalRecs() const;