func (m *peerManager) peerDie(h Handle) { p := m.peers[h] if p == nil { log.Errorln("peerManager.peerDie: invalid handle", h) } delete(m.peers, h) log.Debugln("-peer.Peer count: ", len(m.peers), h) }
// Removing a record doesn't delete the value of the record in the data section // For non-internal-key-collision cases,it only modifies the slot section in two possible ways // - If we know the next slot is empty, we can safely mark the deleted as empty // - If we don't know the next slot is empty or not, we can only mark the deleted as deleted // For internal-key-collision cases, we in-place change the slotData func (db *KDB) Remove(key []byte) (bool, error) { kdata := toInternal(key) db.mutex.Lock() defer db.mutex.Unlock() db.smutex.RLock() defer db.smutex.RUnlock() found := false _, err := db.slotScan(kdata, func(slotData keyData, slotNum int64, emptyFollow bool, val []byte, mv bool) error { found = true if mv { var cd collisionData cd.fromBytes(val) cd.remove(key) if cd.len() == 1 { val = cd.firstVal if len(val) == ValLenUnit { } mv = false log.Debugln("KDB Remove keyCollision: From multi-val to val") } else { val = cd.toBytes() log.Debugln("KDB Remove keyCollision: From multi-val to multi-val") } ul := (len(val) == ValLenUnit) slotData.setFlags(ul) binary.LittleEndian.PutUint32(slotData[InternalKeySize:], db.dataLoc()) db.writeKey(slotData, slotNum) db.writeValue(val, ul, mv) } else { if emptyFollow { slotData.setEmpty() } else { slotData.setDeleted() } db.writeKey(slotData, slotNum) } return nil }, nil) if err != nil { return false, err } return found, nil }