public int RemoveByPrimaryKeyPrefix(ByteBuffer keyBytesPrefix) { var keysToDelete = new List <ByteBuffer>(); var enumerator = new RelationPrimaryKeyEnumerator <T>(_transaction, _relationInfo, keyBytesPrefix, _modificationCounter, 0); while (enumerator.MoveNext()) { keysToDelete.Add(enumerator.GetKeyBytes()); } foreach (var key in keysToDelete) { ResetKeyPrefix(); if (_kvtr.Find(key) != FindResult.Exact) { throw new BTDBException("Not found record to delete."); } var valueBytes = _kvtr.GetValue(); if (_hasSecondaryIndexes) { RemoveSecondaryIndexes(key, valueBytes); } if (_relationInfo.NeedImplementFreeContent()) { _relationInfo.FreeContent(_transaction, valueBytes); } } return(RemovePrimaryKeysByPrefix(keyBytesPrefix)); }
public int RemoveByPrimaryKeyPrefixPartial(ByteBuffer keyBytesPrefix, int maxCount) { var enumerator = new RelationPrimaryKeyEnumerator <T>(_transaction, _relationInfo, keyBytesPrefix, _modificationCounter, 0); var keysToDelete = new List <ByteBuffer>(); while (enumerator.MoveNext()) { keysToDelete.Add(enumerator.GetKeyBytes()); if (keysToDelete.Count == maxCount) { break; } } foreach (var key in keysToDelete) { RemoveById(key, true); } return(keysToDelete.Count); }