public void Update(DocumentId documentId, byte[] blob)
        {
            Document document;
            try
            {
                document = m_documentStore.GetDocumentForUpdate(documentId, -1);
            }
            catch (DocumentLockedException)
            {
                m_log.InfoFormat("Update failed because document is locked by another transaction, documentId(bytes):{0}",
                    documentId.GetBytesReprestnation());

                throw;
            }

            DBTimeStamp++;

            m_databaseFileWriter.BeginTimestamp(DBTimeStamp, 1);

            long documentLocation = m_databaseFileWriter.WriteDocument(documentId, blob);

            if (blob.Length > 0)
            {
                m_cacheProvider.Set(documentLocation, blob);
            }

            m_databaseFileWriter.Flush();

            if (document != null)
            {
                document.Update(DBTimeStamp, documentLocation, blob.Length, true);
            }
            else
            {
                m_documentStore.AddNewDocument(documentId, DBTimeStamp, documentLocation, blob.Length);
            }
        }
        public void TransactionUpdate(int transactionId, DocumentId documentId, byte[] blob)
        {
            Transaction transaction;

            if (!m_pendingTransaction.TryGetValue(transactionId, out transaction))
            {
                throw new TransactionNotExistException();
            }

            try
            {
                // mark the document is updated by transaction
                m_documentStore.GetDocumentForUpdate(documentId, transactionId);
            }
            catch (DocumentLockedException)
            {
                m_log.InfoFormat("Tranasction {1} update failed because document is locked by another transaction, documentId(bytes):{0}",
                    documentId.GetBytesReprestnation(), transactionId);

                throw;
            }

            transaction.AddUpdate(documentId, blob);
        }