Skip to content

Commit 3445d48

Browse files
committed
Improve some of the doc comments
1 parent 18f1f0e commit 3445d48

File tree

6 files changed

+93
-7
lines changed

6 files changed

+93
-7
lines changed

‎src/LightningDB/DatabaseConfiguration.cs‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
namespace LightningDB;
88

9+
/// <summary>
10+
/// Represents the configuration for a database in the LightningDB library.
11+
/// Allows setting custom flags and configuring comparer logic for database operations.
12+
/// </summary>
913
public class DatabaseConfiguration
1014
{
1115
private IComparer<MDBValue> _comparer;
@@ -16,6 +20,15 @@ public DatabaseConfiguration()
1620
Flags = DatabaseOpenFlags.None;
1721
}
1822

23+
/// <summary>
24+
/// Gets or sets the configuration flags used when opening a database.
25+
/// </summary>
26+
/// <remarks>
27+
/// The <see cref="Flags"/> property specifies the behavior of the database based on the combination of
28+
/// values from the <see cref="DatabaseOpenFlags"/> enumeration. These flags determine how the database
29+
/// should be opened and interacted with, such as creating new databases, sorting duplicates, or using
30+
/// integer keys. The default value is <see cref="DatabaseOpenFlags.None"/>.
31+
/// </remarks>
1932
public DatabaseOpenFlags Flags { get; set; }
2033

2134

@@ -46,11 +59,23 @@ private int IsDuplicate(ref MDBValue left, ref MDBValue right)
4659
return _duplicatesComparer.Compare(left, right);
4760
}
4861

62+
/// <summary>
63+
/// Sets a custom comparer for database operations using the specified comparer.
64+
/// </summary>
65+
/// <param name="comparer">
66+
/// The comparer implementation to use for comparing MDBValue objects.
67+
/// </param>
4968
public void CompareWith(IComparer<MDBValue> comparer)
5069
{
5170
_comparer = comparer;
5271
}
5372

73+
/// <summary>
74+
/// Sets a custom comparer for detecting duplicate records in the database.
75+
/// </summary>
76+
/// <param name="comparer">
77+
/// The comparer implementation to use for identifying duplicates between MDBValue objects.
78+
/// </param>
5479
public void FindDuplicatesWith(IComparer<MDBValue> comparer)
5580
{
5681
_duplicatesComparer = comparer;

‎src/LightningDB/EnvironmentConfiguration.cs‎

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,87 @@
11
namespace LightningDB;
22

33
/// <summary>
4-
/// Basic environment configuration
4+
/// Represents the configuration options for a LightningEnvironment instance.
55
/// </summary>
6+
/// <remarks>
7+
/// This class enables customization of various environment parameters such as the size of the memory map,
8+
/// the maximum number of databases, and the maximum number of reader slots. These configurations are applied
9+
/// to a LightningEnvironment during its creation or initialization.
10+
/// </remarks>
611
public class EnvironmentConfiguration
712
{
813
private long? _mapSize;
914
private int? _maxReaders;
1015
private int? _maxDatabases;
11-
16+
17+
/// <summary>
18+
/// Gets or sets the size of the memory map (in bytes) for a LightningEnvironment.
19+
/// </summary>
20+
/// <remarks>
21+
/// This property specifies the maximum size of the database file that can be mapped into memory. Adjusting this value
22+
/// is critical when working with databases expected to grow over time, as it defines the capacity available for storing data.
23+
/// - Increasing the map size allows the database to accommodate more data, but it may consume more virtual memory.
24+
/// - Decreasing the map size can restrict database growth or limit memory consumption.
25+
/// Changes to the <c>MapSize</c> might require restarting the environment or re-creating it with the new configuration,
26+
/// depending on the implementation of the underlying storage environment.
27+
/// Use caution when setting this value in applications running in 32-bit processes, as the effective addressable memory
28+
/// space is limited. For such scenarios, auto-adjustments may be applied to ensure compatibility.
29+
/// </remarks>
1230
public long MapSize
1331
{
1432
get => _mapSize ?? 0;
1533
set => _mapSize = value;
1634
}
1735

36+
/// <summary>
37+
/// Gets or sets the maximum number of reader slots available for a LightningEnvironment instance.
38+
/// </summary>
39+
/// <remarks>
40+
/// This property defines the maximum number of simultaneous read transactions that can be performed on the environment.
41+
/// - Increasing the value allows for more concurrent read operations, but it may increase resource usage.
42+
/// - Decreasing the value limits the number of concurrent reads but may reduce memory consumption.
43+
/// Changes to the <c>MaxReaders</c> property must be set before the environment is opened. Attempting to modify this
44+
/// property after the environment is already initialized will result in an exception. Adjust this parameter to match
45+
/// the requirements of your application's workload and concurrency needs.
46+
/// </remarks>
1847
public int MaxReaders
1948
{
2049
get => _maxReaders ?? 0;
2150
set => _maxReaders = value;
2251
}
2352

53+
/// <summary>
54+
/// Gets or sets the maximum number of databases that can be opened within a LightningEnvironment instance.
55+
/// </summary>
56+
/// <remarks>
57+
/// This property defines the upper limit on the number of named databases that can be created or opened within the environment.
58+
/// - Increasing the maximum database count may allow complex applications to organize data across multiple logical databases.
59+
/// - Decreasing the maximum database count can help reduce overhead in environments with constrained resources or simpler use cases.
60+
/// Changes to the <c>MaxDatabases</c> property must be configured before the environment is opened. Attempting to modify this
61+
/// value after the environment has been initialized will result in an exception. This limitation ensures consistency across
62+
/// resources allocated for the environment.
63+
/// Configuring the appropriate <c>MaxDatabases</c> value is particularly relevant for applications requiring concurrency or
64+
/// multiple named databases.
65+
/// </remarks>
2466
public int MaxDatabases
2567
{
2668
get => _maxDatabases ?? 0;
2769
set => _maxDatabases = value;
2870
}
2971

72+
/// <summary>
73+
/// Gets or sets a value indicating whether the map size should be automatically reduced
74+
/// in 32-bit processes to ensure compatibility with limited addressable memory space.
75+
/// </summary>
76+
/// <remarks>
77+
/// In 32-bit processes, the addressable memory space is constrained, which may lead to issues
78+
/// when working with large map sizes. When this property is set to <c>true</c>, the environment
79+
/// will automatically adjust the map size to a suitable value (e.g., <c>int.MaxValue</c>) during
80+
/// configuration to prevent memory allocation errors or crashes. This adjustment is only applied
81+
/// on 32-bit systems and has no effect on 64-bit processes.
82+
/// This setting is critical for maintaining stability in environments with constrained memory
83+
/// while allowing applications to utilize an appropriate map size without manual intervention.
84+
/// </remarks>
3085
public bool AutoReduceMapSizeIn32BitProcess { get; set; }
3186

3287
internal void Configure(LightningEnvironment env)

‎src/LightningDB/LightningCursor.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace LightningDB;
88

99
/// <summary>
10-
/// Cursor to iterate over a database
10+
/// Represents a cursor used to navigate and manipulate records within a database in the context of a transaction.
1111
/// </summary>
1212
public class LightningCursor : IDisposable
1313
{

‎src/LightningDB/LightningDatabase.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
namespace LightningDB;
55

66
/// <summary>
7-
/// Lightning database.
7+
/// Represents a database in the Lightning environment, providing mechanisms to perform
8+
/// various operations such as opening, dropping, and accessing database statistics. Generally,
9+
/// a database can be reused and rarely needs to be disposed.
810
/// </summary>
911
public sealed class LightningDatabase : IDisposable
1012
{

‎src/LightningDB/LightningEnvironment.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
namespace LightningDB;
66

77
/// <summary>
8-
/// LMDB Environment.
8+
/// Represents a managed environment for lightning-fast database storage and retrieval. Typically, your application
9+
/// will have one instance of LightningEnvironment. Also, it is possible for separate processes to read from the
10+
/// same environment when set to read-only.
911
/// </summary>
1012
public sealed class LightningEnvironment : IDisposable
1113
{

‎src/LightningDB/LightningTransaction.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
namespace LightningDB;
66

77
/// <summary>
8-
/// Represents a transaction.
8+
/// Represents a transaction in the LightningDB environment.
9+
/// Provides methods for managing database operations within the scope of a transaction, including
10+
/// database access, key-value storage, and transaction control (commit, abort, etc.).
911
/// </summary>
1012
public sealed class LightningTransaction : IDisposable
1113
{
@@ -371,7 +373,7 @@ private void Dispose(bool disposing)
371373
}
372374

373375
/// <summary>
374-
/// Dispose this transaction and deallocate all resources associated with it (including databases).
376+
/// Dispose this transaction
375377
/// </summary>
376378
public void Dispose()
377379
{

0 commit comments

Comments
 (0)