Ejemplo n.º 1
0
        /// <summary>
        /// Supports reading a named stream from the persistent store via the grid cache
        /// </summary>
        public FileSystemErrorStatus ReadStreamFromPersistentStore(Guid dataModelId, string streamName, FileSystemStreamType streamType, out MemoryStream stream)
        {
            stream = null;

            try
            {
                var cacheKey = ComputeNamedStreamCacheKey(dataModelId, streamName);

                //Log.LogInformation($"Getting key:{cacheKey}");

                try
                {
                    using var ms    = new MemoryStream(NonSpatialCache(streamType).Get(cacheKey).Bytes);
                    stream          = MemoryStreamCompression.Decompress(ms);
                    stream.Position = 0;
                }
                catch (KeyNotFoundException)
                {
                    return(FileSystemErrorStatus.GranuleDoesNotExist);
                }

                return(FileSystemErrorStatus.OK);
            }
            catch (Exception e)
            {
                _log.LogError(e, "Exception occurred:");

                stream = null;
                return(FileSystemErrorStatus.UnknownErrorReadingFromFS);
            }
        }
Ejemplo n.º 2
0
        public void CompressTest()
        {
            byte[] someBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };

            MemoryStream ms     = new MemoryStream(someBytes);
            MemoryStream result = MemoryStreamCompression.Decompress(MemoryStreamCompression.Compress(ms));

            Assert.True(result.ToArray().SequenceEqual(someBytes), "Bytes are not the same after compression/decompression cycle");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Supports reading a stream of spatial data from the persistent store via the grid cache
        /// </summary>
        public FileSystemErrorStatus ReadSpatialStreamFromPersistentStore(Guid dataModelId,
                                                                          string streamName,
                                                                          int subGridX, int subGridY,
                                                                          long segmentStartDateTicks,
                                                                          long segmentEndDateTicks,
                                                                          long version,
                                                                          FileSystemStreamType streamType,
                                                                          out MemoryStream stream)
        {
            stream = null;

            try
            {
                var cacheKey = new SubGridSpatialAffinityKey(version, dataModelId, subGridX, subGridY, segmentStartDateTicks, segmentEndDateTicks);

                //Log.LogInformation($"Getting key:{streamName}");

                try
                {
                    using var ms    = new MemoryStream(SpatialCache(streamType).Get(cacheKey).Bytes);
                    stream          = MemoryStreamCompression.Decompress(ms);
                    stream.Position = 0;
                }
                catch (KeyNotFoundException)
                {
                    return(FileSystemErrorStatus.GranuleDoesNotExist);
                }

                return(FileSystemErrorStatus.OK);
            }
            catch (Exception e)
            {
                _log.LogError(e, "Exception occurred:");

                stream = null;
                return(FileSystemErrorStatus.UnknownErrorReadingFromFS);
            }
        }
Ejemplo n.º 4
0
 public void DeCompressTest()
 {
     Assert.Null(MemoryStreamCompression.Decompress(null));
 }