Example #1
0
        public int RemoveByKeyPrefixWithoutIterate(ByteBuffer keyBytesPrefix)
        {
            if (_hasSecondaryIndexes)
            {
                //keyBytePrefix contains [Index Relation, Primary key prefix] we need
                //                       [Index Relation, Secondary Key Index, Primary key prefix]
                int idBytesLength = ObjectDB.AllRelationsPKPrefix.Length + PackUnpack.LengthVUInt(_relationInfo.Id);
                var writer        = new ByteBufferWriter();
                foreach (var secKey in _relationInfo.ClientRelationVersionInfo.SecondaryKeys)
                {
                    writer.WriteBlock(ObjectDB.AllRelationsSKPrefix);
                    writer.WriteVUInt32(_relationInfo.Id);
                    writer.WriteVUInt32(secKey.Key);
                    writer.WriteBlock(keyBytesPrefix.Buffer, idBytesLength, keyBytesPrefix.Length - idBytesLength);
                    _transaction.KeyValueDBTransaction.SetKeyPrefix(writer.Data);
                    _transaction.KeyValueDBTransaction.EraseAll();
                    writer.Reset();
                }
            }

            return(RemovePrimaryKeysByPrefix(keyBytesPrefix));
        }