/// <summary>
        /// Reads data from a BerkeleyDb store entry.
        /// </summary>
        /// <param name="typeId">The type of the store accessed.</param>
        /// <param name="objectId">The object id used for store access.</param>
        /// <param name="key">The key of the store entry accessed.</param>
        /// <param name="options">The options for the read.</param>
        /// <returns>A <see cref="Stream"/> that accesses
        /// the entry data via unmanaged memory allocated from BerkeleyDb.</returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="options"/> has a negative offset.</para>
        /// </exception>
        /// <remarks>
        /// <para></para>
        /// <para>Return value is null if</para>
        /// <para>Entry is not found in store.</para>
        /// <para>-or-</para>
        /// <para><paramref name="typeId"/> isn't valid.</para>
        /// <para>-or-</para>
        /// <para>A <see cref="BdbException"/> was thrown from the underlying store
        /// (Exception is logged but not rethrown).</para>
        /// </remarks>
        public Stream GetEntryStream(short typeId, int objectId,
                                     DataBuffer key, GetOptions options)
        {
            options.AssertValid("options");
            if (!CanProcessMessage(typeId))
            {
                return(null);
            }
            DebugLog("GetEntry()", typeId, objectId);
            Database db = GetDatabase(typeId, objectId);

            try
            {
                return(db.Get(key, options.Offset, options.Length, options.Flags));
            }
            catch (BdbException ex)
            {
                HandleBdbError(ex, db);
                return(null);
            }
            catch (Exception ex)
            {
                ErrorLog("GetEntry()", ex);
                throw;
            }
        }
        /// <summary>
        /// Reads data from a BerkeleyDb store entry.
        /// </summary>
        /// <param name="typeId">The type of the store accessed.</param>
        /// <param name="objectId">The object id used for store access.</param>
        /// <param name="key">The key of the store entry accessed.</param>
        /// <param name="buffer">The buffer to which the read data is written.</param>
        /// <param name="options">The options for the read.</param>
        /// <returns>The length of the entry in the store.</returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="buffer"/> has an <see cref="DataBuffer.IsWritable"/> of
        /// <see langword="false"/>.</para>
        /// <para>-or-</para>
        /// <para><paramref name="options"/> has a negative offset.</para>
        /// </exception>
        /// <remarks>
        /// <para>If the entry is longer than <paramref name="buffer"/>, then
        /// <paramref name="buffer"/> is written to its full capacity, but the
        /// entry length is still returned.
        /// </para>
        /// <para>Return value is negative if</para>
        /// <para>Entry is not found in store.</para>
        /// <para>-or-</para>
        /// <para><paramref name="typeId"/> isn't valid.</para>
        /// <para>-or-</para>
        /// <para>A <see cref="BdbException"/> was thrown from the underlying store
        /// (Exception is logged but not rethrown).</para>
        /// </remarks>
        public int GetEntry(short typeId, int objectId, DataBuffer key, DataBuffer buffer,
                            GetOptions options)
        {
            if (!buffer.IsWritable)
            {
                throw new ArgumentOutOfRangeException("buffer");
            }
            options.AssertValid("options");
            if (!CanProcessMessage(typeId))
            {
                return(-1);
            }
            DebugLog("GetEntry()", typeId, objectId);
            Database db = GetDatabase(typeId, objectId);

            try
            {
                return(db.Get(key, options.Offset, buffer, options.Flags));
            }
            catch (BdbException ex)
            {
                HandleBdbError(ex, db);
                return(-1);
            }
            catch (Exception ex)
            {
                ErrorLog("GetEntry()", ex);
                throw;
            }
        }
示例#3
0
        /// <summary>
        /// Reads data from a BerkeleyDb store entry.
        /// </summary>
        /// <param name="typeId">The type of the store accessed.</param>
        /// <param name="objectId">The object id used for store access.</param>
        /// <param name="key">The key of the store entry accessed.</param>
        /// <param name="options">The options for the read.</param>
        /// <returns>A <see cref="Byte"/> array that contains the entry data.</returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="options"/> has a negative offset.</para>
        /// </exception>
        /// <remarks>
        /// <para></para>
        /// <para>Return value is null if</para>
        /// <para>Entry is not found in store.</para>
        /// <para>-or-</para>
        /// <para><paramref name="typeId"/> isn't valid.</para>
        /// <para>-or-</para>
        /// <para>A <see cref="BdbException"/> was thrown from the underlying store
        /// (Exception is logged but not rethrown).</para>
        /// </remarks>
        public byte[] GetEntryBuffer(short typeId, int objectId,
                                     DataBuffer key, GetOptions options)
        {
            options.AssertValid("options");
            DebugLog("GetEntryBuffer()", typeId, objectId);
            Database db = GetDatabase(typeId, objectId);

            try
            {
                return(db.GetBuffer(key, options.Offset, options.Length, options.Flags));
            }
            catch (BdbException ex)
            {
                HandleBdbError(ex, db);
                return(null);
            }
            catch (Exception ex)
            {
                ErrorLog("GetEntryBuffer()", ex);
                throw;
            }
        }
		/// <summary>
		/// Reads data from a BerkeleyDb store entry.
		/// </summary>
		/// <param name="typeId">The type of the store accessed.</param>
		/// <param name="key">The key of the store entry accessed.</param>
		/// <param name="options">The options for the read.</param>
		/// <returns>A <see cref="Stream"/> that accesses
		/// the entry data via unmanaged memory allocated from BerkeleyDb.</returns>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="options"/> has a negative offset.</para>
		/// </exception>
		/// <remarks>
		/// <para>Return value is null if</para>
		/// <para>Entry is not found in store.</para>
		/// <para>-or-</para>
		/// <para><paramref name="typeId"/> isn't valid.</para>
		/// <para>-or-</para>
		/// <para>A <see cref="BdbException"/> was thrown from the underlying store
		/// (Exception is logged but not rethrown).</para>
		/// </remarks>
		public Stream GetEntryStream(short typeId, DataBuffer key,
			GetOptions options)
		{
			return GetEntryStream(typeId, key.GetObjectId(), key, options);
		}
		/// <summary>
		/// Reads data from a BerkeleyDb store entry.
		/// </summary>
		/// <param name="typeId">The type of the store accessed.</param>
		/// <param name="key">The key of the store entry accessed.</param>
		/// <param name="buffer">The buffer to which the read data is written.</param>
		/// <param name="options">The options for the read.</param>
		/// <returns>The length of the entry in the store.</returns>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="buffer"/> has an <see cref="DataBuffer.IsWritable"/> of
		/// <see langword="false"/>.</para>
		/// <para>-or-</para>
		/// <para><paramref name="options"/> has a negative offset.</para>
		/// </exception>
		/// <remarks>
		/// <para><see cref="DataBuffer.GetHashCode"/> of <paramref name="key"/> is used
		/// as the object id.</para>
		/// <para>If the entry is longer than <paramref name="buffer"/>, then
		/// <paramref name="buffer"/> is written to its full capacity, but the
		/// entry length is still returned.
		/// </para>
		/// <para>Return value is negative if</para>
		/// <para>Entry is not found in store.</para>
		/// <para>-or-</para>
		/// <para><paramref name="typeId"/> isn't valid.</para>
		/// <para>-or-</para>
		/// <para>A <see cref="BdbException"/> was thrown from the underlying store
		/// (Exception is logged but not rethrown).</para>
		/// </remarks>
		public int GetEntry(short typeId, DataBuffer key, DataBuffer buffer,
			GetOptions options)
		{
			return GetEntry(typeId, key.GetObjectId(), key, buffer, options);
		}
		/// <summary>
		/// Reads data from a BerkeleyDb store entry.
		/// </summary>
		/// <param name="typeId">The type of the store accessed.</param>
		/// <param name="objectId">The object id used for store access.</param>
		/// <param name="key">The key of the store entry accessed.</param>
		/// <param name="options">The options for the read.</param>
		/// <returns>A <see cref="Stream"/> that accesses
		/// the entry data via unmanaged memory allocated from BerkeleyDb.</returns>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="options"/> has a negative offset.</para>
		/// </exception>
		/// <remarks>
		/// <para></para>
		/// <para>Return value is null if</para>
		/// <para>Entry is not found in store.</para>
		/// <para>-or-</para>
		/// <para><paramref name="typeId"/> isn't valid.</para>
		/// <para>-or-</para>
		/// <para>A <see cref="BdbException"/> was thrown from the underlying store
		/// (Exception is logged but not rethrown).</para>
		/// </remarks>
		public Stream GetEntryStream(short typeId, int objectId,
			DataBuffer key, GetOptions options)
		{
			options.AssertValid("options");
			if (!CanProcessMessage(typeId)) return null;
			DebugLog("GetEntry()", typeId, objectId);
			Database db = GetDatabase(typeId, objectId);
			try
			{
				return db.Get(key, options.Offset, options.Length, options.Flags);
			}
			catch (BdbException ex)
			{
				HandleBdbError(ex, db);
				return null;
			}
			catch (Exception ex)
			{
				ErrorLog("GetEntry()", ex);
				throw;
			}
		}
		/// <summary>
		/// Reads data from a BerkeleyDb store entry.
		/// </summary>
		/// <param name="typeId">The type of the store accessed.</param>
		/// <param name="objectId">The object id used for store access.</param>
		/// <param name="key">The key of the store entry accessed.</param>
		/// <param name="buffer">The buffer to which the read data is written.</param>
		/// <param name="options">The options for the read.</param>
		/// <returns>The length of the entry in the store.</returns>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="buffer"/> has an <see cref="DataBuffer.IsWritable"/> of
		/// <see langword="false"/>.</para>
		/// <para>-or-</para>
		/// <para><paramref name="options"/> has a negative offset.</para>
		/// </exception>
		/// <remarks>
		/// <para>If the entry is longer than <paramref name="buffer"/>, then
		/// <paramref name="buffer"/> is written to its full capacity, but the
		/// entry length is still returned.
		/// </para>
		/// <para>Return value is negative if</para>
		/// <para>Entry is not found in store.</para>
		/// <para>-or-</para>
		/// <para><paramref name="typeId"/> isn't valid.</para>
		/// <para>-or-</para>
		/// <para>A <see cref="BdbException"/> was thrown from the underlying store
		/// (Exception is logged but not rethrown).</para>
		/// </remarks>
		public int GetEntry(short typeId, int objectId, DataBuffer key, DataBuffer buffer,
			GetOptions options)
		{
			if (!buffer.IsWritable) throw new ArgumentOutOfRangeException("buffer");
			options.AssertValid("options");
			if (!CanProcessMessage(typeId)) return -1;
			DebugLog("GetEntry()", typeId, objectId);
			Database db = GetDatabase(typeId, objectId);
			try
			{
				return db.Get(key, options.Offset, buffer, options.Flags);
			}
			catch (BdbException ex)
			{
				HandleBdbError(ex, db);
				return -1;
			}
			catch (Exception ex)
			{
				ErrorLog("GetEntry()", ex);
				throw;
			}
		}
 /// <summary>
 /// Reads data from a BerkeleyDb store entry.
 /// </summary>
 /// <param name="typeId">The type of the store accessed.</param>
 /// <param name="key">The key of the store entry accessed.</param>
 /// <param name="options">The options for the read.</param>
 /// <returns>A <see cref="Stream"/> that accesses
 /// the entry data via unmanaged memory allocated from BerkeleyDb.</returns>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <para><paramref name="options"/> has a negative offset.</para>
 /// </exception>
 /// <remarks>
 /// <para>Return value is null if</para>
 /// <para>Entry is not found in store.</para>
 /// <para>-or-</para>
 /// <para><paramref name="typeId"/> isn't valid.</para>
 /// <para>-or-</para>
 /// <para>A <see cref="BdbException"/> was thrown from the underlying store
 /// (Exception is logged but not rethrown).</para>
 /// </remarks>
 public Stream GetEntryStream(short typeId, DataBuffer key,
                              GetOptions options)
 {
     return(GetEntryStream(typeId, key.GetObjectId(), key, options));
 }
 /// <summary>
 /// Reads data from a BerkeleyDb store entry.
 /// </summary>
 /// <param name="typeId">The type of the store accessed.</param>
 /// <param name="key">The key of the store entry accessed.</param>
 /// <param name="buffer">The buffer to which the read data is written.</param>
 /// <param name="options">The options for the read.</param>
 /// <returns>The length of the entry in the store.</returns>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <para><paramref name="buffer"/> has an <see cref="DataBuffer.IsWritable"/> of
 /// <see langword="false"/>.</para>
 /// <para>-or-</para>
 /// <para><paramref name="options"/> has a negative offset.</para>
 /// </exception>
 /// <remarks>
 /// <para><see cref="DataBuffer.GetHashCode"/> of <paramref name="key"/> is used
 /// as the object id.</para>
 /// <para>If the entry is longer than <paramref name="buffer"/>, then
 /// <paramref name="buffer"/> is written to its full capacity, but the
 /// entry length is still returned.
 /// </para>
 /// <para>Return value is negative if</para>
 /// <para>Entry is not found in store.</para>
 /// <para>-or-</para>
 /// <para><paramref name="typeId"/> isn't valid.</para>
 /// <para>-or-</para>
 /// <para>A <see cref="BdbException"/> was thrown from the underlying store
 /// (Exception is logged but not rethrown).</para>
 /// </remarks>
 public int GetEntry(short typeId, DataBuffer key, DataBuffer buffer,
                     GetOptions options)
 {
     return(GetEntry(typeId, key.GetObjectId(), key, buffer, options));
 }
示例#10
0
 /// <summary>
 /// Reads data from a BerkeleyDb store entry.
 /// </summary>
 /// <param name="typeId">The type of the store accessed.</param>
 /// <param name="key">The key of the store entry accessed.</param>
 /// <param name="options">The options for the read.</param>
 /// <returns>A <see cref="Byte"/> array that contains the entry data.</returns>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <para><paramref name="options"/> has a negative offset.</para>
 /// </exception>
 /// <remarks>
 /// <para></para>
 /// <para>Return value is null if</para>
 /// <para>Entry is not found in store.</para>
 /// <para>-or-</para>
 /// <para><paramref name="typeId"/> isn't valid.</para>
 /// <para>-or-</para>
 /// <para>A <see cref="BdbException"/> was thrown from the underlying store
 /// (Exception is logged but not rethrown).</para>
 /// </remarks>
 public byte[] GetEntryBuffer(short typeId, DataBuffer key,
                              GetOptions options)
 {
     return(GetEntryBuffer(typeId, key.GetObjectId(), key, options));
 }