Esempio n. 1
0
        public int RemoveByPrimaryKeyPrefix(ByteBuffer keyBytesPrefix)
        {
            var keysToDelete = new List <ByteBuffer>();
            var enumerator   = new RelationPrimaryKeyEnumerator <T>(_transaction, _relationInfo, keyBytesPrefix, _modificationCounter);

            while (enumerator.MoveNext())
            {
                keysToDelete.Add(enumerator.GetKeyBytes());
            }

            foreach (var key in keysToDelete)
            {
                StartWorkingWithPK();
                if (_transaction.KeyValueDBTransaction.Find(key) != FindResult.Exact)
                {
                    throw new BTDBException("Not found record to delete.");
                }

                var valueBytes = _transaction.KeyValueDBTransaction.GetValue();

                if (_hasSecondaryIndexes)
                {
                    RemoveSecondaryIndexes(key, valueBytes);
                }

                if (_relationInfo.NeedImplementFreeContent())
                {
                    _relationInfo.FreeContent(_transaction, valueBytes);
                }
            }

            return(RemovePrimaryKeysByPrefix(keyBytesPrefix));
        }
Esempio n. 2
0
        public int RemoveByPrimaryKeyPrefixPartial(ByteBuffer keyBytesPrefix, int maxCount)
        {
            var enumerator   = new RelationPrimaryKeyEnumerator <T>(_transaction, _relationInfo, keyBytesPrefix, _modificationCounter);
            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);
        }
Esempio n. 3
0
        public int RemoveByPrimaryKeyPrefix(ByteBuffer keyBytesPrefix)
        {
            var removedCount = 0;
            var keysToDelete = new List <ByteBuffer>();

            var enumerator = new RelationPrimaryKeyEnumerator <T>(_transaction, _relationInfo, keyBytesPrefix, this);

            while (enumerator.MoveNext())
            {
                keysToDelete.Add(enumerator.GetKeyBytes());
            }
            foreach (var key in keysToDelete)
            {
                RemoveById(key, true);
                removedCount++;
            }

            return(removedCount);
        }