当前位置: 首页>>代码示例>>C#>>正文


C# ITransaction.GetFile方法代码示例

本文整理汇总了C#中ITransaction.GetFile方法的典型用法代码示例。如果您正苦于以下问题:C# ITransaction.GetFile方法的具体用法?C# ITransaction.GetFile怎么用?C# ITransaction.GetFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITransaction的用法示例。


在下文中一共展示了ITransaction.GetFile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyData

 public static void CopyData(ITransaction source, ITransaction destination)
 {
     // The transaction in this object,
     TreeSystemTransaction sourcet = (TreeSystemTransaction)source;
     foreach(Key key in sourcet.Keys) {
         // Get the source and destination files
         DataFile sourceFile = sourcet.GetFile(key, FileAccess.ReadWrite);
         DataFile destFile = destination.GetFile(key, FileAccess.Write);
         // Copy the data
         sourceFile.CopyTo(destFile, sourceFile.Length);
     }
 }
开发者ID:ikvm,项目名称:cloudb,代码行数:12,代码来源:FileSystemDatabase.cs

示例2: CheckPathValid

        private void CheckPathValid(ITransaction transaction)
        {
            if (!checkPerformed) {
                lock (this) {
                    if (!checkPerformed) {
                        IDataFile df = transaction.GetFile(DbTransaction.MagicKey, FileAccess.Read);
                        StringDictionary magicSet = new StringDictionary(df);
                        string obType = magicSet["ob_type"];
                        string version = magicSet["version"];

                        // Error if the data is incorrect,
                        if (obType == null || !obType.Equals("Deveel.Data.CloudBase"))
                            throw new ApplicationException("Path '" + PathName + "' is not a CloudBase");

                        checkPerformed = true;
                    }
                }
            }
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:19,代码来源:DbSession.cs

示例3: InsertKeyRef

        private void InsertKeyRef(ITransaction t, string key, string value, long[] uid)
        {
            IDataFile keyListDf = t.GetFile(KeyUidMapKey, FileAccess.ReadWrite);
            StringDictionary keyList = new StringDictionary(keyListDf);

            // Put it in the property set,
            if (value == null) {
                keyList.SetValue(key, null);
            } else {
                keyList.SetValue(key, ToUidString(uid[0], uid[1]));
            }
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:12,代码来源:ReplicatedValueStore.cs

示例4: InsertValue

        private void InsertValue(ITransaction t, long[] uid, byte[] value)
        {
            // Make a hash value,
            long hashCode = uid[0]/16;

            // Insert the uid into a list,
            InsertToUidList(t, uid);

            // Turn it into a key object,
            Key hashKey = new Key(13, 0, hashCode);

            // The DataFile
            IDataFile dfile = t.GetFile(hashKey, FileAccess.ReadWrite);
            BinaryWriter writer = new BinaryWriter(new DataFileStream(dfile));
            // The size of the entry being added,
            int sz = 20 + value.Length;

            // Position at the end of the file,
            dfile.Position = dfile.Length;
            // Insert the entry,
            // Put the size of the value entry,
            writer.Write(sz);
            // The 128-bit uid,
            writer.Write(uid[0]);
            writer.Write(uid[1]);
            // The value content,
            writer.Write(value, 0, value.Length);
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:28,代码来源:ReplicatedValueStore.cs

示例5: GetValueFromUid

        private byte[] GetValueFromUid(ITransaction t, long[] uid)
        {
            // Make a hash value,
            long hashCode = uid[0]/16;

            // Turn it into a key object,
            Key hashKey = new Key(13, 0, hashCode);

            // The DataFile
            IDataFile dfile = t.GetFile(hashKey, FileAccess.ReadWrite);
            BinaryReader reader = new BinaryReader(new DataFileStream(dfile));

            long pos = 0;
            long size = dfile.Length;
            while (pos < size) {
                dfile.Position = pos;
                int sz = reader.ReadInt32();

                // Get the stored uid,
                long inuidH = reader.ReadInt64();
                long inuidL = reader.ReadInt64();

                // If the uid matches,
                if (inuidH == uid[0] && inuidL == uid[1]) {
                    // Match, so put the serialization of the record in the file,
                    int bufSz = sz - 20;
                    byte[] buf = new byte[bufSz];
                    reader.Read(buf, 0, bufSz);
                    // If buf is empty return null,
                    if (buf.Length == 0)
                        return null;

                    return buf;
                }

                pos = pos + sz;
            }

            // Not found, return null
            return null;
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:41,代码来源:ReplicatedValueStore.cs

示例6: HasAppliedUid

        private bool HasAppliedUid(ITransaction t, long[] uid)
        {
            // Make a hash value,
            long hashCode = uid[0]/16;

            // Turn it into a key object,
            Key hashKey = new Key(13, 0, hashCode);

            // The DataFile
            IDataFile dfile = t.GetFile(hashKey, FileAccess.ReadWrite);

            long pos = 0;
            long size = dfile.Length;
            BinaryReader reader = new BinaryReader(new DataFileStream(dfile));
            while (pos < size) {
                dfile.Position = pos;
                int sz = reader.ReadInt32();

                // Get the stored uid,
                long inuidH = reader.ReadInt64();
                long inuidL = reader.ReadInt64();

                // If the uid matches,
                if (inuidH == uid[0] && inuidL == uid[1]) {
                    // Match, so return true
                    return true;
                }

                pos = pos + sz;
            }

            // Not found, return false
            return false;
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:34,代码来源:ReplicatedValueStore.cs

示例7: GetLastBlockId

        private BlockId GetLastBlockId(ITransaction t)
        {
            IDataFile bidUidListDf = t.GetFile(BlockidUidMapKey, FileAccess.Read);
            BlockIdUidList blockidUidList = new BlockIdUidList(bidUidListDf);

            long pos = blockidUidList.Count - 1;
            if (pos < 0) {
                return null;
            }

            return blockidUidList.GetBlockIdAt(pos);
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:12,代码来源:ReplicatedValueStore.cs

示例8: InsertToUidList

        private static void InsertToUidList(ITransaction t, long[] uid)
        {
            // Create the UIDList object,
            IDataFile uidListDf = t.GetFile(UidListKey, FileAccess.ReadWrite);
            UidList uidList = new UidList(uidListDf);

            // Inserts the uid in the list
            uidList.AddUid(uid);
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:9,代码来源:ReplicatedValueStore.cs

示例9: InsertBlockIdRef

        private static void InsertBlockIdRef(ITransaction t, BlockId blockId, long[] uid)
        {
            IDataFile bidUidListDf = t.GetFile(BlockidUidMapKey, FileAccess.ReadWrite);
            BlockIdUidList blockidUidList = new BlockIdUidList(bidUidListDf);

            blockidUidList.AddBlockIdRef(blockId, uid);
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:7,代码来源:ReplicatedValueStore.cs

示例10: GetUidForKey

        private static long[] GetUidForKey(ITransaction t, string key)
        {
            IDataFile keyListDf = t.GetFile(KeyUidMapKey, FileAccess.ReadWrite);
            StringDictionary keyList = new StringDictionary(keyListDf);

            string val = keyList.GetValue(key);
            if (val == null) {
                return null;
            }
            return ParseUidString(val);
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:11,代码来源:ReplicatedValueStore.cs

示例11: GetUidForBlock

        // ------ Storage ------
        private static long[] GetUidForBlock(ITransaction t, BlockId blockId)
        {
            IDataFile bidUidListDf = t.GetFile(BlockidUidMapKey, FileAccess.ReadWrite);
            BlockIdUidList blockidUidList = new BlockIdUidList(bidUidListDf);

            long pos = blockidUidList.PositionOfBlockId(blockId);
            if (pos < 0)
                return null;

            return blockidUidList.GetUidAt(pos);
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:12,代码来源:ReplicatedValueStore.cs


注:本文中的ITransaction.GetFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。