Esempio n. 1
0
 public new static void UpdateBinaryProperty(BinaryDataValue value)
 {
     BlobStorageBase.UpdateBinaryProperty(value);
 }
Esempio n. 2
0
 public new static IBlobProvider GetProvider(long fullSize)
 {
     return(BlobStorageBase.GetProvider(fullSize));
 }
Esempio n. 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));
 }
Esempio n. 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));
 }
Esempio n. 5
0
        /*================================================================== Maintenance*/

        public new static Task CleanupFilesSetFlagAsync(CancellationToken cancellationToken)
        {
            return(BlobStorageBase.CleanupFilesSetFlagAsync(cancellationToken));
        }
Esempio n. 6
0
 public new static Task <BinaryCacheEntity> LoadBinaryCacheEntityAsync(int nodeVersionId, int propertyTypeId, SnDataContext dataContext)
 {
     return(BlobStorageBase.LoadBinaryCacheEntityAsync(nodeVersionId, propertyTypeId, dataContext));
 }
Esempio n. 7
0
 public new static Task <string> StartChunkAsync(int versionId, int propertyTypeId, long fullSize,
                                                 CancellationToken cancellationToken)
 {
     return(BlobStorageBase.StartChunkAsync(versionId, propertyTypeId, fullSize, cancellationToken));
 }
Esempio n. 8
0
 public new static void WriteChunk(int versionId, string token, byte[] buffer, long offset, long fullSize)
 {
     BlobStorageBase.WriteChunk(versionId, token, buffer, offset, fullSize);
 }
Esempio n. 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);
 }
Esempio n. 10
0
 public new static byte[] LoadBinaryFragment(int fileId, long position, int count)
 {
     return(BlobStorageBase.LoadBinaryFragment(fileId, position, count));
 }
Esempio n. 11
0
 public new static string StartChunk(int versionId, int propertyTypeId, long fullSize)
 {
     return(BlobStorageBase.StartChunk(versionId, propertyTypeId, fullSize));
 }
Esempio n. 12
0
 public new static BinaryCacheEntity LoadBinaryCacheEntity(int nodeVersionId, int propertyTypeId)
 {
     return(BlobStorageBase.LoadBinaryCacheEntity(nodeVersionId, propertyTypeId));
 }
Esempio n. 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));
 }
Esempio n. 14
0
 public new static void DeleteBinaryProperty(int versionId, int propertyTypeId)
 {
     BlobStorageBase.DeleteBinaryProperty(versionId, propertyTypeId);
 }
Esempio n. 15
0
 public new static Task <BinaryDataValue> LoadBinaryPropertyAsync(int versionId, int propertyTypeId, SnDataContext dataContext)
 {
     return(BlobStorageBase.LoadBinaryPropertyAsync(versionId, propertyTypeId, dataContext));
 }
Esempio n. 16
0
 public new static void CopyFromStream(int versionId, string token, Stream input)
 {
     BlobStorageBase.CopyFromStream(versionId, token, input);
 }
Esempio n. 17
0
 public new static Task <BinaryCacheEntity> LoadBinaryCacheEntityAsync(int nodeVersionId, int propertyTypeId, CancellationToken cancellationToken)
 {
     return(BlobStorageBase.LoadBinaryCacheEntityAsync(nodeVersionId, propertyTypeId, cancellationToken));
 }
Esempio n. 18
0
        /*================================================================== Maintenance*/

        public new static void CleanupFilesSetFlag()
        {
            BlobStorageBase.CleanupFilesSetFlag();
        }
Esempio n. 19
0
 public new static Task <byte[]> LoadBinaryFragmentAsync(int fileId, long position, int count, CancellationToken cancellationToken)
 {
     return(BlobStorageBase.LoadBinaryFragmentAsync(fileId, position, count, cancellationToken));
 }
Esempio n. 20
0
 public new static bool CleanupFiles()
 {
     return(BlobStorageBase.CleanupFiles());
 }
Esempio n. 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));
 }
Esempio n. 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);
        }
Esempio n. 23
0
 public new static Task CopyFromStreamAsync(int versionId, string token, Stream input, CancellationToken cancellationToken)
 {
     return(BlobStorageBase.CopyFromStreamAsync(versionId, token, input, cancellationToken));
 }
Esempio n. 24
0
 public new static Task DeleteBinaryPropertyAsync(int versionId, int propertyTypeId, SnDataContext dataContext)
 {
     return(BlobStorageBase.DeleteBinaryPropertyAsync(versionId, propertyTypeId, dataContext));
 }
Esempio n. 25
0
 public new static Task <bool> CleanupFilesAsync(CancellationToken cancellationToken)
 {
     return(BlobStorageBase.CleanupFilesAsync(cancellationToken));
 }
Esempio n. 26
0
 public new static Task DeleteBinaryPropertiesAsync(IEnumerable <int> versionIds, SnDataContext dataContext)
 {
     return(BlobStorageBase.DeleteBinaryPropertiesAsync(versionIds, dataContext));
 }
Esempio n. 27
0
 public new static IBlobProvider GetProvider(string providerName)
 {
     return(BlobStorageBase.GetProvider(providerName));
 }
Esempio n. 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));
 }
Esempio n. 29
0
 public new static Task UpdateBinaryPropertyAsync(BinaryDataValue value, SnDataContext dataContext)
 {
     return(BlobStorageBase.UpdateBinaryPropertyAsync(value, dataContext));
 }
Esempio n. 30
0
 public new static void InsertBinaryProperty(BinaryDataValue value, int versionId, int propertyTypeId, bool isNewNode)
 {
     BlobStorageBase.InsertBinaryProperty(value, versionId, propertyTypeId, isNewNode);
 }