예제 #1
0
        internal static async ValueTask DeleteModelCodeAsync(ulong modelId, Transaction txn)
        {
            IntPtr keyPtr;
            int    keySize = 9;

            unsafe
            {
                byte *pk = stackalloc byte[keySize];
                KeyUtil.WriteModelCodeKey(pk, modelId);
                keyPtr = new IntPtr(pk);
            }
            var req = new ClrDeleteRequire
            {
                RaftGroupId   = KeyUtil.META_RAFTGROUP_ID,
                KeyPtr        = keyPtr,
                KeySize       = new IntPtr(keySize),
                SchemaVersion = 0,
                ReturnExists  = false,
                DataCF        = -1
            };
            IntPtr reqPtr;

            unsafe { reqPtr = new IntPtr(&req); }
            await HostApi.ExecKVDeleteAsync(txn.Handle, reqPtr);
        }
예제 #2
0
        internal static async ValueTask DeleteViewRoute(string viewName, Transaction txn)
        {
            IntPtr keyPtr;
            int    keySize = EntityStoreWriter.CalcStringUtf8Size(viewName) + 1;

            unsafe
            {
                byte *pk = stackalloc byte[keySize];
                KeyUtil.WriteViewRouteKey(pk, viewName);
                keyPtr = new IntPtr(pk);
            }

            var req = new ClrDeleteRequire
            {
                RaftGroupId   = KeyUtil.META_RAFTGROUP_ID,
                KeyPtr        = keyPtr,
                KeySize       = new IntPtr(keySize),
                SchemaVersion = 0,
                ReturnExists  = false,
                DataCF        = -1
            };
            IntPtr reqPtr;

            unsafe { reqPtr = new IntPtr(&req); }
            await HostApi.ExecKVDeleteAsync(txn.Handle, reqPtr);
        }
예제 #3
0
 internal static async ValueTask DeleteModelAsync(ModelBase model, Transaction txn, Func <uint, ApplicationModel> getApp)
 {
     if (model.ModelType == ModelType.Entity && ((EntityModel)model).SysStoreOptions != null)
     {
         //TODO:考虑先保存删除状态的实体模型,存储层异步任务完成后会删除相应的实体模型
         var         app     = getApp(model.AppId);
         EntityModel em      = (EntityModel)model;
         var         tableId = em.TableId | ((uint)app.StoreId << 24);
         //TODO:全局索引入参处理
         await HostApi.ExecMetaDropTableAsync(txn.Handle, tableId, model.Id, IntPtr.Zero, IntPtr.Zero, false);
     }
     else //----以下非系统存储的实体模型直接删除原数据----
     {
         IntPtr keyPtr;
         unsafe
         {
             byte *pk = stackalloc byte[KeyUtil.MODEL_KEY_SIZE];
             KeyUtil.WriteModelKey(pk, model.Id);
             keyPtr = new IntPtr(pk);
         }
         var req = new ClrDeleteRequire
         {
             RaftGroupId   = KeyUtil.META_RAFTGROUP_ID,
             KeyPtr        = keyPtr,
             KeySize       = new IntPtr(KeyUtil.MODEL_KEY_SIZE),
             SchemaVersion = 0,
             ReturnExists  = false,
             DataCF        = -1
         };
         IntPtr reqPtr;
         unsafe { reqPtr = new IntPtr(&req); }
         await HostApi.ExecKVDeleteAsync(txn.Handle, reqPtr);
     }
 }