コード例 #1
0
        /// <summary>
        /// Converts a sub grid directory into its immutable form, using the source object
        /// </summary>
        /// <param name="source"></param>
        /// <param name="immutableStream"></param>
        /// <returns></returns>
        private bool ConvertSubGridDirectoryToImmutable(object source, out MemoryStream immutableStream)
        {
            try
            {
                var originSource = (IServerLeafSubGrid)source;

                // create a copy and compress the latestPasses(and ensure the global latest cells is the mutable variety)
                using (var leaf = new ServerSubGridTreeLeaf(null, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Immutable)
                {
                    LeafStartTime = originSource.LeafStartTime,
                    LeafEndTime = originSource.LeafEndTime,
                    Directory =
                    {
                        SegmentDirectory  = originSource.Directory.SegmentDirectory,
                        GlobalLatestCells = ConvertLatestPassesToImmutable(originSource.Directory.GlobalLatestCells,
                                                                           SegmentLatestPassesContext.Global)
                    }
                })
                {
                    immutableStream = RecyclableMemoryStreamManagerHelper.Manager.GetStream();
                    leaf.SaveDirectoryToStream(immutableStream);
                }

                return(true);
            }
            catch (Exception e)
            {
                immutableStream = null;

                Log.LogError(e, "Exception in conversion of sub grid directory mutable data to immutable schema");
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Converts a sub grid directory into its immutable form, using a cached stream
        /// </summary>
        /// <param name="mutableStream"></param>
        /// <param name="immutableStream"></param>
        /// <returns></returns>
        private bool ConvertSubGridDirectoryToImmutable(MemoryStream mutableStream, out MemoryStream immutableStream)
        {
            try
            {
                // create a leaf to contain the mutable directory (and ensure the global latest cells is the mutable variety)
                using (var leaf = new ServerSubGridTreeLeaf(null, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Immutable)
                {
                    Directory = { GlobalLatestCells = subGridCellLatestPassesDataWrapperFactory.NewMutableWrapper_Global() }
                })
                {
                    // Load the mutable stream of information
                    mutableStream.Position = 0;
                    leaf.LoadDirectoryFromStream(mutableStream);

                    using (var directory = leaf.Directory.GlobalLatestCells)
                    {
                        leaf.Directory.GlobalLatestCells = ConvertLatestPassesToImmutable(directory, SegmentLatestPassesContext.Global);
                    }

                    immutableStream = RecyclableMemoryStreamManagerHelper.Manager.GetStream();
                    leaf.SaveDirectoryToStream(immutableStream);
                }

                return(true);
            }
            catch (Exception e)
            {
                immutableStream = null;

                Log.LogError(e, "Exception in conversion of sub grid directory mutable data to immutable schema");
                return(false);
            }
        }
コード例 #3
0
 public static string GetLeafSubGridFullFileName(SubGridCellAddress cellAddress)
 {
     // Work out the cell address of the origin cell in the appropriate leaf
     // sub grid. We use this cell position to derive the name of the file
     // containing the leaf sub grid data
     return(ServerSubGridTreeLeaf.FileNameFromOriginPosition(new SubGridCellAddress(cellAddress.X & ~SubGridTreeConsts.SubGridLocalKeyMask, cellAddress.Y & ~SubGridTreeConsts.SubGridLocalKeyMask)));
 }