Skip to content

Commit

Permalink
Fix build errors with gcc 4.6.
Browse files Browse the repository at this point in the history
With gcc 4.6 there were plenty of warnings (treated as errors) related to name
shadowing (mostly variables named 'item' shadowing memcached's type
'item'). Renamed those conflicting definitions trying to use the names
already present in the project.

Conflicts:
	ep_engine.cc
	ep_engine.h

Change-Id: Icd6fca933a6018f0b1b98e5efe6b7076b33fc48c
Reviewed-on: http://review.couchbase.org/8352
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
  • Loading branch information
aartamonau authored and chiyoung committed Jul 29, 2011
1 parent 901d1e4 commit d0ade99
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 204 deletions.
20 changes: 10 additions & 10 deletions checkpoint.cc
Expand Up @@ -23,13 +23,13 @@ uint64_t Checkpoint::getCasForKey(const std::string &key) {
return cas; return cas;
} }


queue_dirty_t Checkpoint::queueDirty(const queued_item &item, CheckpointManager *checkpointManager) { queue_dirty_t Checkpoint::queueDirty(const queued_item &qi, CheckpointManager *checkpointManager) {
assert (checkpointState == opened); assert (checkpointState == opened);


uint64_t newMutationId = checkpointManager->nextMutationId(); uint64_t newMutationId = checkpointManager->nextMutationId();
queue_dirty_t rv; queue_dirty_t rv;


checkpoint_index::iterator it = keyIndex.find(item->getKey()); checkpoint_index::iterator it = keyIndex.find(qi->getKey());
// Check if this checkpoint already had an item for the same key. // Check if this checkpoint already had an item for the same key.
if (it != keyIndex.end()) { if (it != keyIndex.end()) {
std::list<queued_item>::iterator currPos = it->second.position; std::list<queued_item>::iterator currPos = it->second.position;
Expand Down Expand Up @@ -73,27 +73,27 @@ queue_dirty_t Checkpoint::queueDirty(const queued_item &item, CheckpointManager
} }
} }
// Copy the queued time of the existing item to the new one. // Copy the queued time of the existing item to the new one.
item->setQueuedTime((*currPos)->getQueuedTime()); qi->setQueuedTime((*currPos)->getQueuedTime());
// Remove the existing item for the same key from the list. // Remove the existing item for the same key from the list.
toWrite.erase(currPos); toWrite.erase(currPos);
rv = EXISTING_ITEM; rv = EXISTING_ITEM;
} else { } else {
if (item->getKey().size() > 0) { if (qi->getKey().size() > 0) {
++numItems; ++numItems;
} }
rv = NEW_ITEM; rv = NEW_ITEM;
} }
// Push the new item into the list // Push the new item into the list
toWrite.push_back(item); toWrite.push_back(qi);


if (item->getKey().size() > 0) { if (qi->getKey().size() > 0) {
std::list<queued_item>::iterator last = toWrite.end(); std::list<queued_item>::iterator last = toWrite.end();
// --last is okay as the list is not empty now. // --last is okay as the list is not empty now.
index_entry entry = {--last, newMutationId}; index_entry entry = {--last, newMutationId};
// Set the index of the key to the new item that is pushed back into the list. // Set the index of the key to the new item that is pushed back into the list.
keyIndex[item->getKey()] = entry; keyIndex[qi->getKey()] = entry;
if (rv == NEW_ITEM) { if (rv == NEW_ITEM) {
size_t newEntrySize = item->getKey().size() + sizeof(index_entry); size_t newEntrySize = qi->getKey().size() + sizeof(index_entry);
indexMemOverhead += newEntrySize; indexMemOverhead += newEntrySize;
stats.memOverhead.incr(newEntrySize); stats.memOverhead.incr(newEntrySize);
assert(stats.memOverhead.get() < GIGANTOR); assert(stats.memOverhead.get() < GIGANTOR);
Expand Down Expand Up @@ -481,7 +481,7 @@ size_t CheckpointManager::removeClosedUnrefCheckpoints(const RCPtr<VBucket> &vbu
return numUnrefItems; return numUnrefItems;
} }


bool CheckpointManager::queueDirty(const queued_item &item, const RCPtr<VBucket> &vbucket) { bool CheckpointManager::queueDirty(const queued_item &qi, const RCPtr<VBucket> &vbucket) {
LockHolder lh(queueLock); LockHolder lh(queueLock);
if (vbucket->getState() != vbucket_state_active && if (vbucket->getState() != vbucket_state_active &&
checkpointList.back()->getState() == closed) { checkpointList.back()->getState() == closed) {
Expand All @@ -494,7 +494,7 @@ bool CheckpointManager::queueDirty(const queued_item &item, const RCPtr<VBucket>
// The current open checkpoint should be always the last one in the checkpoint list. // The current open checkpoint should be always the last one in the checkpoint list.
assert(checkpointList.back()->getState() == opened); assert(checkpointList.back()->getState() == opened);
size_t numItemsBefore = getNumItemsForPersistence_UNLOCKED(); size_t numItemsBefore = getNumItemsForPersistence_UNLOCKED();
if (checkpointList.back()->queueDirty(item, this) == NEW_ITEM) { if (checkpointList.back()->queueDirty(qi, this) == NEW_ITEM) {
++numItems; ++numItems;
} }
size_t numItemsAfter = getNumItemsForPersistence_UNLOCKED(); size_t numItemsAfter = getNumItemsForPersistence_UNLOCKED();
Expand Down
56 changes: 28 additions & 28 deletions ep.cc
Expand Up @@ -296,7 +296,7 @@ class VBucketDeletionCallback : public DispatcherCallback {
bool callback(Dispatcher &d, TaskId t) { bool callback(Dispatcher &d, TaskId t) {
bool rv = false, isLastChunk = false; bool rv = false, isLastChunk = false;


chunk_range range; chunk_range_t range;
if (current_range == range_list.end()) { if (current_range == range_list.end()) {
range.first = -1; range.first = -1;
range.second = -1; range.second = -1;
Expand Down Expand Up @@ -386,7 +386,7 @@ class VBucketDeletionCallback : public DispatcherCallback {
hrtime_t execution_time; hrtime_t execution_time;
hrtime_t start_wall_time; hrtime_t start_wall_time;
VBDeletionChunkRangeList range_list; VBDeletionChunkRangeList range_list;
chunk_range_iterator current_range; chunk_range_iterator_t current_range;
}; };


EventuallyPersistentStore::EventuallyPersistentStore(EventuallyPersistentEngine &theEngine, EventuallyPersistentStore::EventuallyPersistentStore(EventuallyPersistentEngine &theEngine,
Expand Down Expand Up @@ -764,11 +764,11 @@ protocol_binary_response_status EventuallyPersistentStore::evictKey(const std::s
return rv; return rv;
} }


ENGINE_ERROR_CODE EventuallyPersistentStore::set(const Item &item, ENGINE_ERROR_CODE EventuallyPersistentStore::set(const Item &itm,
const void *cookie, const void *cookie,
bool force) { bool force) {


RCPtr<VBucket> vb = getVBucket(item.getVBucketId()); RCPtr<VBucket> vb = getVBucket(itm.getVBucketId());
if (!vb || vb->getState() == vbucket_state_dead) { if (!vb || vb->getState() == vbucket_state_dead) {
++stats.numNotMyVBuckets; ++stats.numNotMyVBuckets;
return ENGINE_NOT_MY_VBUCKET; return ENGINE_NOT_MY_VBUCKET;
Expand All @@ -787,10 +787,10 @@ ENGINE_ERROR_CODE EventuallyPersistentStore::set(const Item &item,
} }
} }


bool cas_op = (item.getCas() != 0); bool cas_op = (itm.getCas() != 0);


int64_t row_id = -1; int64_t row_id = -1;
mutation_type_t mtype = vb->ht.set(item, row_id); mutation_type_t mtype = vb->ht.set(itm, row_id);
ENGINE_ERROR_CODE ret = ENGINE_SUCCESS; ENGINE_ERROR_CODE ret = ENGINE_SUCCESS;


switch (mtype) { switch (mtype) {
Expand All @@ -810,8 +810,8 @@ ENGINE_ERROR_CODE EventuallyPersistentStore::set(const Item &item,
case WAS_DIRTY: case WAS_DIRTY:
// Even if the item was dirty, push it into the vbucket's open checkpoint. // Even if the item was dirty, push it into the vbucket's open checkpoint.
case WAS_CLEAN: case WAS_CLEAN:
queueDirty(item.getKey(), item.getVBucketId(), queue_op_set, item.getValue(), queueDirty(itm.getKey(), itm.getVBucketId(), queue_op_set, itm.getValue(),
item.getFlags(), item.getExptime(), item.getCas(), row_id); itm.getFlags(), itm.getExptime(), itm.getCas(), row_id);
break; break;
case INVALID_VBUCKET: case INVALID_VBUCKET:
ret = ENGINE_NOT_MY_VBUCKET; ret = ENGINE_NOT_MY_VBUCKET;
Expand All @@ -821,10 +821,10 @@ ENGINE_ERROR_CODE EventuallyPersistentStore::set(const Item &item,
return ret; return ret;
} }


ENGINE_ERROR_CODE EventuallyPersistentStore::add(const Item &item, ENGINE_ERROR_CODE EventuallyPersistentStore::add(const Item &itm,
const void *cookie) const void *cookie)
{ {
RCPtr<VBucket> vb = getVBucket(item.getVBucketId()); RCPtr<VBucket> vb = getVBucket(itm.getVBucketId());
if (!vb || vb->getState() == vbucket_state_dead || vb->getState() == vbucket_state_replica) { if (!vb || vb->getState() == vbucket_state_dead || vb->getState() == vbucket_state_replica) {
++stats.numNotMyVBuckets; ++stats.numNotMyVBuckets;
return ENGINE_NOT_MY_VBUCKET; return ENGINE_NOT_MY_VBUCKET;
Expand All @@ -840,36 +840,36 @@ ENGINE_ERROR_CODE EventuallyPersistentStore::add(const Item &item,
} }
} }


if (item.getCas() != 0) { if (itm.getCas() != 0) {
// Adding with a cas value doesn't make sense.. // Adding with a cas value doesn't make sense..
return ENGINE_NOT_STORED; return ENGINE_NOT_STORED;
} }


switch (vb->ht.add(item)) { switch (vb->ht.add(itm)) {
case ADD_NOMEM: case ADD_NOMEM:
return ENGINE_ENOMEM; return ENGINE_ENOMEM;
case ADD_EXISTS: case ADD_EXISTS:
return ENGINE_NOT_STORED; return ENGINE_NOT_STORED;
case ADD_SUCCESS: case ADD_SUCCESS:
case ADD_UNDEL: case ADD_UNDEL:
queueDirty(item.getKey(), item.getVBucketId(), queue_op_set, item.getValue(), queueDirty(itm.getKey(), itm.getVBucketId(), queue_op_set, itm.getValue(),
item.getFlags(), item.getExptime(), item.getCas(), -1); itm.getFlags(), itm.getExptime(), itm.getCas(), -1);
} }
return ENGINE_SUCCESS; return ENGINE_SUCCESS;
} }


ENGINE_ERROR_CODE EventuallyPersistentStore::addTAPBackfillItem(const Item &item) { ENGINE_ERROR_CODE EventuallyPersistentStore::addTAPBackfillItem(const Item &itm) {


RCPtr<VBucket> vb = getVBucket(item.getVBucketId()); RCPtr<VBucket> vb = getVBucket(itm.getVBucketId());
if (!vb || vb->getState() == vbucket_state_dead || vb->getState() == vbucket_state_active) { if (!vb || vb->getState() == vbucket_state_dead || vb->getState() == vbucket_state_active) {
++stats.numNotMyVBuckets; ++stats.numNotMyVBuckets;
return ENGINE_NOT_MY_VBUCKET; return ENGINE_NOT_MY_VBUCKET;
} }


bool cas_op = (item.getCas() != 0); bool cas_op = (itm.getCas() != 0);


int64_t row_id = -1; int64_t row_id = -1;
mutation_type_t mtype = vb->ht.set(item, row_id); mutation_type_t mtype = vb->ht.set(itm, row_id);
ENGINE_ERROR_CODE ret = ENGINE_SUCCESS; ENGINE_ERROR_CODE ret = ENGINE_SUCCESS;


switch (mtype) { switch (mtype) {
Expand All @@ -890,8 +890,8 @@ ENGINE_ERROR_CODE EventuallyPersistentStore::addTAPBackfillItem(const Item &item
} }
// FALLTHROUGH // FALLTHROUGH
case WAS_CLEAN: case WAS_CLEAN:
queueDirty(item.getKey(), item.getVBucketId(), queue_op_set, item.getValue(), queueDirty(itm.getKey(), itm.getVBucketId(), queue_op_set, itm.getValue(),
item.getFlags(), item.getExptime(), item.getCas(), row_id, true); itm.getFlags(), itm.getExptime(), itm.getCas(), row_id, true);
break; break;
case INVALID_VBUCKET: case INVALID_VBUCKET:
ret = ENGINE_NOT_MY_VBUCKET; ret = ENGINE_NOT_MY_VBUCKET;
Expand Down Expand Up @@ -1834,11 +1834,11 @@ protocol_binary_response_status EventuallyPersistentStore::revertOnlineUpdate(RC
// For this, traverse the array from the last element. // For this, traverse the array from the last element.
uint64_t total = 0; uint64_t total = 0;
for(; reverse_it != item_list.rend(); ++reverse_it, ++total) { for(; reverse_it != item_list.rend(); ++reverse_it, ++total) {
queued_item item = *reverse_it; queued_item qi = *reverse_it;


ret = item_set.insert(item); ret = item_set.insert(qi);


vb->doStatsForFlushing(*item, item->size()); vb->doStatsForFlushing(*qi, qi->size());
} }
item_list.assign(item_set.begin(), item_set.end()); item_list.assign(item_set.begin(), item_set.end());


Expand Down Expand Up @@ -2212,13 +2212,13 @@ void EventuallyPersistentStore::queueDirty(const std::string &key,
exptime, cas); exptime, cas);
} }


queued_item item(qi); queued_item itm(qi);
bool rv = tapBackfill ? bool rv = tapBackfill ?
vb->queueBackfillItem(item) : vb->checkpointManager.queueDirty(item, vb); vb->queueBackfillItem(itm) : vb->checkpointManager.queueDirty(itm, vb);
if (rv) { if (rv) {
++stats.queue_size; ++stats.queue_size;
++stats.totalEnqueued; ++stats.totalEnqueued;
vb->doStatsForQueueing(*item, item->size()); vb->doStatsForQueueing(*itm, itm->size());
} }
} }
} }
Expand Down Expand Up @@ -2438,8 +2438,8 @@ void TransactionContext::commit() {
numUncommittedItems = 0; numUncommittedItems = 0;
} }


void TransactionContext::addUncommittedItem(const queued_item &item) { void TransactionContext::addUncommittedItem(const queued_item &qi) {
uncommittedItems.push_back(item); uncommittedItems.push_back(qi);
++numUncommittedItems; ++numUncommittedItems;
} }


Expand Down
38 changes: 19 additions & 19 deletions ep.hh
Expand Up @@ -93,8 +93,8 @@ protected:
RCPtr<VBucket> currentBucket; RCPtr<VBucket> currentBucket;
}; };


typedef std::pair<int64_t, int64_t> chunk_range; typedef std::pair<int64_t, int64_t> chunk_range_t;
typedef std::list<chunk_range>::iterator chunk_range_iterator; typedef std::list<chunk_range_t>::iterator chunk_range_iterator_t;


/** /**
* Collection class that maintains the sorted list of row ID chunk ranges * Collection class that maintains the sorted list of row ID chunk ranges
Expand All @@ -105,31 +105,31 @@ public:


VBDeletionChunkRangeList() { } VBDeletionChunkRangeList() { }


chunk_range_iterator begin() { chunk_range_iterator_t begin() {
return range_list.begin(); return range_list.begin();
} }


chunk_range_iterator end() { chunk_range_iterator_t end() {
return range_list.end(); return range_list.end();
} }


void add(int64_t start_id, int64_t end_id) { void add(int64_t start_id, int64_t end_id) {
chunk_range r(start_id, end_id); chunk_range_t r(start_id, end_id);
add(r); add(r);
} }


void add(chunk_range range) { void add(chunk_range_t range) {
if (range.first > range.second || (size() > 0 && back().second > range.first)) { if (range.first > range.second || (size() > 0 && back().second > range.first)) {
return; return;
} }
range_list.push_back(range); range_list.push_back(range);
} }


const chunk_range& front() { const chunk_range_t& front() {
return range_list.front(); return range_list.front();
} }


const chunk_range& back() { const chunk_range_t& back() {
return range_list.back(); return range_list.back();
} }


Expand All @@ -142,14 +142,14 @@ public:
* @param it pointer to a chunk range to be split * @param it pointer to a chunk range to be split
* @param range_size range size used for chunk split * @param range_size range size used for chunk split
*/ */
void splitChunkRange(chunk_range_iterator it, int64_t range_size) { void splitChunkRange(chunk_range_iterator_t it, int64_t range_size) {
if (it == end() || (it->second - it->first) <= range_size) { if (it == end() || (it->second - it->first) <= range_size) {
return; return;
} }


int64_t range_end = it->second; int64_t range_end = it->second;
it->second = it->first + range_size; it->second = it->first + range_size;
chunk_range r(it->second + 1, range_end); chunk_range_t r(it->second + 1, range_end);
range_list.insert(++it, r); range_list.insert(++it, r);
} }


Expand All @@ -158,21 +158,21 @@ public:
* @param start the pointer to the start chunk range for the merge operation * @param start the pointer to the start chunk range for the merge operation
* @param range_size the new range size used for merging chunk ranges * @param range_size the new range size used for merging chunk ranges
*/ */
void mergeChunkRanges(chunk_range_iterator start, int64_t range_size) { void mergeChunkRanges(chunk_range_iterator_t start, int64_t range_size) {
if (start == end() || (start->second - start->first) >= range_size) { if (start == end() || (start->second - start->first) >= range_size) {
return; return;
} }
// Find the closest chunk C1 whose end point is greater than the point advanced by // Find the closest chunk C1 whose end point is greater than the point advanced by
// the new range size from the start chunk range's start point. // the new range size from the start chunk range's start point.
chunk_range_iterator p = findClosestChunkByRangeSize(start, range_size); chunk_range_iterator_t p = findClosestChunkByRangeSize(start, range_size);
if (p != end()) { if (p != end()) {
int64_t endpoint = start->first + range_size; int64_t endpoint = start->first + range_size;
if (p->first <= endpoint && endpoint <= p->second) { if (p->first <= endpoint && endpoint <= p->second) {
// Set the start chunk range's end point by using the new range size // Set the start chunk range's end point by using the new range size
start->second = endpoint; start->second = endpoint;
p->first = endpoint + 1; p->first = endpoint + 1;
} else { } else {
chunk_range_iterator iter = p; chunk_range_iterator_t iter = p;
start->second = (--iter)->second; start->second = (--iter)->second;
} }
} else { // Reached to the end of the range list } else { // Reached to the end of the range list
Expand All @@ -191,7 +191,7 @@ private:
* @param first iterator that points to the first chunk range in the sub list * @param first iterator that points to the first chunk range in the sub list
* @param last iterator that points to the last chunk range in the sub list * @param last iterator that points to the last chunk range in the sub list
*/ */
void removeChunkRanges(chunk_range_iterator first, chunk_range_iterator last) { void removeChunkRanges(chunk_range_iterator_t first, chunk_range_iterator_t last) {
if (first == last || first == end() || if (first == last || first == end() ||
(first != end() && last != end() && first->second > last->first)) { (first != end() && last != end() && first->second > last->first)) {
return; return;
Expand All @@ -206,16 +206,16 @@ private:
* @param range_size range size to be advanced * @param range_size range size to be advanced
* @return the iterator that points to the chunk range found * @return the iterator that points to the chunk range found
*/ */
chunk_range_iterator findClosestChunkByRangeSize(chunk_range_iterator it, chunk_range_iterator_t findClosestChunkByRangeSize(chunk_range_iterator_t it,
int64_t range_size) { int64_t range_size) {
chunk_range_iterator p = it; chunk_range_iterator_t p = it;
while (p != end() && p->second <= (it->first + range_size)) { while (p != end() && p->second <= (it->first + range_size)) {
++p; ++p;
} }
return p; return p;
} }


std::list<chunk_range> range_list; std::list<chunk_range_t> range_list;
}; };


/** /**
Expand Down Expand Up @@ -260,7 +260,7 @@ public:
} }
if (counter == chunk_size || iter == --(row_ids->end())) { if (counter == chunk_size || iter == --(row_ids->end())) {
end_row_id = *iter; end_row_id = *iter;
chunk_range r(start_row_id, end_row_id); chunk_range_t r(start_row_id, end_row_id);
range_list.add(r); range_list.add(r);
counter = 0; counter = 0;
} }
Expand Down

0 comments on commit d0ade99

Please sign in to comment.