void EphemeralVBucket::dump() const {
std::cerr << "EphemeralVBucket[" << this
- << "] with state: " << toString(getState())
+ << "] with state:" << toString(getState())
<< " numItems:" << getNumItems()
<< std::endl;
seqList->dump();
+ std::cerr << ht << std::endl;
}
ENGINE_ERROR_CODE EphemeralVBucket::completeBGFetchForSingleItem(
++datatypeCounts[v.getDatatype()];
}
}
+
+std::ostream& operator<<(std::ostream& os, const HashTable& ht) {
+ os << "HashTable[" << &ht << "] with"
+ << " numInMemory:" << ht.getNumInMemoryItems()
+ << " numDeleted:" << ht.getNumDeletedItems()
+ << " values: " << std::endl;
+ for (const auto& chain : ht.values) {
+ if (chain) {
+ for (StoredValue* sv = chain.get(); sv != nullptr;
+ sv = sv->next.get()) {
+ os << " " << *sv << std::endl;
+ }
+ }
+ }
+ return os;
+}
using table_type = std::vector<StoredValue::UniquePtr>;
friend class StoredValue;
+ friend std::ostream& operator<<(std::ostream& os, const HashTable& ht);
inline bool isActive() const { return activeState; }
inline void setActiveState(bool newv) { activeState = newv; }
DISALLOW_COPY_AND_ASSIGN(HashTable);
};
+std::ostream& operator<<(std::ostream& os, const HashTable& ht);
+
/**
* Base class for visiting a hash table.
*/
for (const auto& val : ll.seqList) {
os << " " << val << std::endl;
}
- os << "]" << std::endl;
+ os << "]";
return os;
}
os << (sv.isNewCacheItem() ? 'N' : '.');
os << ' ';
- // seqno, revid
+ // Temporary states
+ os << "temp:"
+ << (sv.isTempInitialItem() ? 'I' : ' ')
+ << (sv.isTempDeletedItem() ? 'D' : ' ')
+ << (sv.isTempNonExistentItem() ? 'N' : ' ')
+ << ' ';
+
+ // seqno, revid, expiry
os << "seq:" << sv.getBySeqno() << " rev:" << sv.getRevSeqno();
- os << " key:\"" << sv.getKey();
- os << "\" val:[";
+ os << " key:\"" << sv.getKey() << "\"";
+ os << " exp:" << sv.getExptime();
+
+ os << " vallen:" << sv.valuelen();
if (sv.getValue().get()) {
+ os << " val:\"";
const char* data = sv.getValue()->getData();
// print up to first 40 bytes of value.
const size_t limit = std::min(size_t(40), sv.getValue()->vlength());
if (limit < sv.getValue()->vlength()) {
os << " <cut>";
}
- } else {
- os << "<null>";
+ os << "\"";
}
- os << "]";
return os;
}
friend class HashTable;
friend class StoredValueFactory;
+ friend std::ostream& operator<<(std::ostream& os, const HashTable& ht);
value_t value; // 8 bytes
// Used to implement HashTable chaining (for elements hashing to the same
void VBucket::dump() const {
std::cerr << "VBucket[" << this << "] with state: " << toString(getState())
<< " numItems:" << getNumItems()
- << " numNonResident:" << getNumNonResidentItems() << std::endl;
+ << " numNonResident:" << getNumNonResidentItems()
+ << " ht: " << std::endl << " " << ht << std::endl
+ << "]" << std::endl;
}
void VBucket::_addStats(bool details, ADD_STAT add_stat, const void* c) {