Ejemplo n.º 1
0
 void PersistTableInfo(TableInfo tableInfo)
 {
     _keyValueTrProtector.Start();
     if (tableInfo.LastPersistedVersion != tableInfo.ClientTypeVersion)
     {
         if (tableInfo.LastPersistedVersion <= 0)
         {
             _keyValueTr.SetKeyPrefix(ObjectDB.TableNamesPrefix);
             if (_keyValueTr.CreateKey(BuildKeyFromOid(tableInfo.Id)))
             {
                 using (var writer = new KeyValueDBValueWriter(_keyValueTr))
                 {
                     writer.WriteString(tableInfo.Name);
                 }
             }
         }
         _keyValueTr.SetKeyPrefix(ObjectDB.TableVersionsPrefix);
         if (_keyValueTr.CreateKey(TableInfo.BuildKeyForTableVersions(tableInfo.Id, tableInfo.ClientTypeVersion)))
         {
             var tableVersionInfo = tableInfo.ClientTableVersionInfo;
             using (var writer = new KeyValueDBValueWriter(_keyValueTr))
             {
                 tableVersionInfo.Save(writer);
             }
         }
     }
     if (tableInfo.NeedStoreSingletonOid)
     {
         _keyValueTr.SetKeyPrefix(ObjectDB.TableSingletonsPrefix);
         _keyValueTr.CreateOrUpdateKeyValue(BuildKeyFromOid(tableInfo.Id), BuildKeyFromOid((ulong)tableInfo.SingletonOid));
     }
 }
Ejemplo n.º 2
0
        bool PersistTableInfo(TableInfo tableInfo)
        {
            var taken = false;

            try
            {
                _keyValueTrProtector.Start(ref taken);
                byte[] key;
                int    ofs;
                if (tableInfo.LastPersistedVersion <= 0)
                {
                    _keyValueTr.SetKeyPrefix(ObjectDB.TableNamesPrefix);
                    key = new byte[PackUnpack.LengthVUInt(tableInfo.Id)];
                    ofs = 0;
                    PackUnpack.PackVUInt(key, ref ofs, tableInfo.Id);
                    if (_keyValueTr.CreateKey(key))
                    {
                        using (var writer = new KeyValueDBValueWriter(_keyValueTr))
                        {
                            writer.WriteString(tableInfo.Name);
                        }
                    }
                }
                _keyValueTr.SetKeyPrefix(ObjectDB.TableVersionsPrefix);
                key = new byte[PackUnpack.LengthVUInt(tableInfo.Id) + PackUnpack.LengthVUInt(tableInfo.ClientTypeVersion)];
                ofs = 0;
                PackUnpack.PackVUInt(key, ref ofs, tableInfo.Id);
                PackUnpack.PackVUInt(key, ref ofs, tableInfo.ClientTypeVersion);
                if (_keyValueTr.CreateKey(key))
                {
                    var tableVersionInfo = tableInfo.ClientTableVersionInfo;
                    using (var writer = new KeyValueDBValueWriter(_keyValueTr))
                    {
                        tableVersionInfo.Save(writer);
                    }
                }
                return(true);
            }
            finally
            {
                if (taken)
                {
                    _keyValueTrProtector.Stop();
                }
            }
        }