private bool SeekBlob(BlobsTable table, BlobId id, bool includeUncompleted) { if (!table.Indexes.PrimaryIndex.Find(table.Indexes.PrimaryIndex.CreateKey(id.Id))) { return(false); } if (!includeUncompleted) { return(table.Columns.IsCompleted); } return(true); }
private BlobInfo LoadBlobInfo(BlobsTable table) { var data = table.Views.FullRowUpdate.Fetch(); return(new BlobInfo() { Id = new BlobId() { Id = table.Columns.Id }, UniqueName = data.Name, Category = data.Category, CreatedTime = data.CreatedDate, Size = data.Length, ReferenceId = data.ReferenceId, IsUncompleted = !data.IsCompleted, IsFilestream = data.IsFilestream }); }
private BlobInfo?LoadBlobInfo(BlobsTable table, BlobId id) { BlobInfo?result = null; if (SeekBlob(table, id, false)) { var data = table.Views.FullRowUpdate.Fetch(); result = new BlobInfo() { Id = id, UniqueName = data.Name, Category = data.Category, CreatedTime = data.CreatedDate, Size = data.Length, ReferenceId = data.ReferenceId, IsUncompleted = !data.IsCompleted, IsFilestream = data.IsFilestream }; } return(result); }
/// <summary> /// Конструктор. Должен вызываться из потока сессии. /// </summary> /// <param name="globalErrorHandler">Обработчик глобальных ошибок.</param> /// <param name="session">Сессия.</param> /// <param name="blobId">Идентификатор блоба.</param> public BlocksBlobStream(IGlobalErrorHandler globalErrorHandler, IEsentSession session, BlobId blobId) : base(globalErrorHandler) { _session = session ?? throw new ArgumentNullException(nameof(session)); var sid = _session.Session; try { _usage = _session.UseSession(); _transaction = new Transaction(session.Session); try { var tbl = session.OpenTable(BlobTableInfo.BlobsTableName, OpenTableGrbit.ReadOnly); _table = new BlobsTable(tbl.Session, tbl); try { Api.MakeKey(sid, _table, blobId.Id, MakeKeyGrbit.NewKey); if (!Api.TrySeek(sid, _table, SeekGrbit.SeekEQ)) { throw new BlobNotFoundException(blobId); } _inlinedStream = new ColumnStream(sid, _table, _table.GetColumnid(BlobsTable.Column.Data)); Length = _inlinedStream.Length; } catch { _table.Dispose(); } } catch { _transaction.Dispose(); throw; } } catch { _usage.Dispose(); throw; } }
private void InitializeBlobsTable(IEsentSession session, JET_TABLEID tableid) { BlobsTable.CreateColumnsAndIndexes(session.Session, tableid); }