Пример #1
0
 public new static void UpdateBinaryProperty(BinaryDataValue value)
 {
     BlobStorageBase.UpdateBinaryProperty(value);
 }
Пример #2
0
 public new static IBlobProvider GetProvider(long fullSize)
 {
     return(BlobStorageBase.GetProvider(fullSize));
 }
Пример #3
0
 public new static Task InsertBinaryPropertyAsync(BinaryDataValue value, int versionId, int propertyTypeId, bool isNewNode, SnDataContext dataContext)
 {
     return(BlobStorageBase.InsertBinaryPropertyAsync(value, versionId, propertyTypeId, isNewNode, dataContext));
 }
Пример #4
0
 public new static Task CommitChunkAsync(int versionId, int propertyTypeId, string token, long fullSize,
                                         BinaryDataValue source, CancellationToken cancellationToken)
 {
     return(BlobStorageBase.CommitChunkAsync(versionId, propertyTypeId, token, fullSize, source, cancellationToken));
 }
Пример #5
0
        /*================================================================== Maintenance*/

        public new static Task CleanupFilesSetFlagAsync(CancellationToken cancellationToken)
        {
            return(BlobStorageBase.CleanupFilesSetFlagAsync(cancellationToken));
        }
Пример #6
0
 public new static Task <BinaryCacheEntity> LoadBinaryCacheEntityAsync(int nodeVersionId, int propertyTypeId, SnDataContext dataContext)
 {
     return(BlobStorageBase.LoadBinaryCacheEntityAsync(nodeVersionId, propertyTypeId, dataContext));
 }
Пример #7
0
 public new static Task <string> StartChunkAsync(int versionId, int propertyTypeId, long fullSize,
                                                 CancellationToken cancellationToken)
 {
     return(BlobStorageBase.StartChunkAsync(versionId, propertyTypeId, fullSize, cancellationToken));
 }
Пример #8
0
 public new static void WriteChunk(int versionId, string token, byte[] buffer, long offset, long fullSize)
 {
     BlobStorageBase.WriteChunk(versionId, token, buffer, offset, fullSize);
 }
Пример #9
0
 public new static void CommitChunk(int versionId, int propertyTypeId, string token, long fullSize, BinaryDataValue source = null)
 {
     BlobStorageBase.CommitChunk(versionId, propertyTypeId, token, fullSize, source);
 }
Пример #10
0
 public new static byte[] LoadBinaryFragment(int fileId, long position, int count)
 {
     return(BlobStorageBase.LoadBinaryFragment(fileId, position, count));
 }
Пример #11
0
 public new static string StartChunk(int versionId, int propertyTypeId, long fullSize)
 {
     return(BlobStorageBase.StartChunk(versionId, propertyTypeId, fullSize));
 }
Пример #12
0
 public new static BinaryCacheEntity LoadBinaryCacheEntity(int nodeVersionId, int propertyTypeId)
 {
     return(BlobStorageBase.LoadBinaryCacheEntity(nodeVersionId, propertyTypeId));
 }
Пример #13
0
 public new static BlobStorageContext GetBlobStorageContext(int fileId, bool clearStream = false, int versionId = 0, int propertyTypeId = 0)
 {
     return(BlobStorageBase.GetBlobStorageContext(fileId, clearStream, versionId, propertyTypeId));
 }
Пример #14
0
 public new static void DeleteBinaryProperty(int versionId, int propertyTypeId)
 {
     BlobStorageBase.DeleteBinaryProperty(versionId, propertyTypeId);
 }
Пример #15
0
 public new static Task <BinaryDataValue> LoadBinaryPropertyAsync(int versionId, int propertyTypeId, SnDataContext dataContext)
 {
     return(BlobStorageBase.LoadBinaryPropertyAsync(versionId, propertyTypeId, dataContext));
 }
Пример #16
0
 public new static void CopyFromStream(int versionId, string token, Stream input)
 {
     BlobStorageBase.CopyFromStream(versionId, token, input);
 }
Пример #17
0
 public new static Task <BinaryCacheEntity> LoadBinaryCacheEntityAsync(int nodeVersionId, int propertyTypeId, CancellationToken cancellationToken)
 {
     return(BlobStorageBase.LoadBinaryCacheEntityAsync(nodeVersionId, propertyTypeId, cancellationToken));
 }
Пример #18
0
        /*================================================================== Maintenance*/

        public new static void CleanupFilesSetFlag()
        {
            BlobStorageBase.CleanupFilesSetFlag();
        }
Пример #19
0
 public new static Task <byte[]> LoadBinaryFragmentAsync(int fileId, long position, int count, CancellationToken cancellationToken)
 {
     return(BlobStorageBase.LoadBinaryFragmentAsync(fileId, position, count, cancellationToken));
 }
Пример #20
0
 public new static bool CleanupFiles()
 {
     return(BlobStorageBase.CleanupFiles());
 }
Пример #21
0
 public new static Task WriteChunkAsync(int versionId, string token, byte[] buffer, long offset, long fullSize,
                                        CancellationToken cancellationToken)
 {
     return(BlobStorageBase.WriteChunkAsync(versionId, token, buffer, offset, fullSize, cancellationToken));
 }
Пример #22
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (offset + count > buffer.Length)
            {
                throw new ArgumentException("Offset + count must not be greater than the buffer length.");
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(offset), "The offset must be greater than zero.");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count), "The count must be greater than zero.");
            }

            // Calculate the maximum count of the bytes that can be read.
            // Return immediately if nothing to read.
            var maximumReadableByteCount = Length - Position;

            if (maximumReadableByteCount < 1)
            {
                return(0);
            }

            var realCount = (int)Math.Min(count, maximumReadableByteCount);

            if (CanInnerBufferHandleReadRequest(realCount))
            {
                Array.Copy(_innerBuffer, (int)Position - _innerBufferFirstPostion, buffer, offset, realCount);
            }
            else
            {
                _innerBuffer = null;

                var bytesRead = 0;
                var bytesStoredInInnerBuffer = 0;

                while (bytesRead < realCount)
                {
                    // bytes to load from the db
                    var bytesToReadInThisIteration = (int)Math.Min(this.Length - Position - bytesRead, BlobStorage.BinaryChunkSize);

                    // bytes that we will copy to the buffer of the caller
                    var bytesToStoreInThisIteration = Math.Min(bytesToReadInThisIteration, realCount - bytesRead);

                    // stores the current chunk
                    var tempBuffer = BlobStorageBase.LoadBinaryFragmentAsync(this.FileId, Position + bytesRead,
                                                                             bytesToReadInThisIteration, CancellationToken.None).GetAwaiter().GetResult();

                    // first iteration: create inner buffer for caching a part of the stream in memory
                    if (_innerBuffer == null)
                    {
                        _innerBuffer             = new byte[GetInnerBufferSize(realCount)];
                        _innerBufferFirstPostion = Position;
                    }

                    // store a fragment of the data in the inner buffer if possible
                    if (bytesStoredInInnerBuffer < _innerBuffer.Length)
                    {
                        var bytesToStoreInInnerBuffer = Math.Min(bytesToReadInThisIteration, _innerBuffer.Length - bytesStoredInInnerBuffer);

                        Array.Copy(tempBuffer, 0, _innerBuffer, bytesStoredInInnerBuffer, bytesToStoreInInnerBuffer);
                        bytesStoredInInnerBuffer += bytesToStoreInInnerBuffer;
                    }

                    // copy the chunk from the temp buffer to the buffer of the caller
                    Array.Copy(tempBuffer, 0, buffer, bytesRead, bytesToStoreInThisIteration);
                    bytesRead += bytesToReadInThisIteration;
                }
            }

            Position += realCount;

            return(realCount);
        }
Пример #23
0
 public new static Task CopyFromStreamAsync(int versionId, string token, Stream input, CancellationToken cancellationToken)
 {
     return(BlobStorageBase.CopyFromStreamAsync(versionId, token, input, cancellationToken));
 }
Пример #24
0
 public new static Task DeleteBinaryPropertyAsync(int versionId, int propertyTypeId, SnDataContext dataContext)
 {
     return(BlobStorageBase.DeleteBinaryPropertyAsync(versionId, propertyTypeId, dataContext));
 }
Пример #25
0
 public new static Task <bool> CleanupFilesAsync(CancellationToken cancellationToken)
 {
     return(BlobStorageBase.CleanupFilesAsync(cancellationToken));
 }
Пример #26
0
 public new static Task DeleteBinaryPropertiesAsync(IEnumerable <int> versionIds, SnDataContext dataContext)
 {
     return(BlobStorageBase.DeleteBinaryPropertiesAsync(versionIds, dataContext));
 }
Пример #27
0
 public new static IBlobProvider GetProvider(string providerName)
 {
     return(BlobStorageBase.GetProvider(providerName));
 }
Пример #28
0
 public static Task <BlobStorageContext> GetBlobStorageContextAsync(int fileId, CancellationToken cancellationToken, bool clearStream = false, int versionId = 0, int propertyTypeId = 0)
 {
     return(BlobStorageBase.GetBlobStorageContextAsync(fileId, clearStream, versionId, propertyTypeId, cancellationToken));
 }
Пример #29
0
 public new static Task UpdateBinaryPropertyAsync(BinaryDataValue value, SnDataContext dataContext)
 {
     return(BlobStorageBase.UpdateBinaryPropertyAsync(value, dataContext));
 }
Пример #30
0
 public new static void InsertBinaryProperty(BinaryDataValue value, int versionId, int propertyTypeId, bool isNewNode)
 {
     BlobStorageBase.InsertBinaryProperty(value, versionId, propertyTypeId, isNewNode);
 }