diff --git a/LiteDB/Client/SqlParser/Commands/Create.cs b/LiteDB/Client/SqlParser/Commands/Create.cs index d5bd543cc..f71564222 100644 --- a/LiteDB/Client/SqlParser/Commands/Create.cs +++ b/LiteDB/Client/SqlParser/Commands/Create.cs @@ -9,7 +9,7 @@ namespace LiteDB internal partial class SqlParser { /// - /// CREATE [ UNQIUE ] INDEX {indexName} ON {collection} ({indexExpr}) + /// CREATE [ UNIQUE ] INDEX {indexName} ON {collection} ({indexExpr}) /// private BsonDataReader ParseCreate() { diff --git a/LiteDB/Engine/Engine/Index.cs b/LiteDB/Engine/Engine/Index.cs index 9f56e27c0..edf5e65ea 100644 --- a/LiteDB/Engine/Engine/Index.cs +++ b/LiteDB/Engine/Engine/Index.cs @@ -20,7 +20,7 @@ public bool EnsureIndex(string collection, string name, BsonExpression expressio if (name.Length > INDEX_NAME_MAX_LENGTH) throw LiteException.InvalidIndexName(name, collection, "MaxLength = " + INDEX_NAME_MAX_LENGTH); if (!name.IsWord()) throw LiteException.InvalidIndexName(name, collection, "Use only [a-Z$_]"); - if (name.StartsWith("$")) throw LiteException.InvalidIndexName(name, collection, "Index name can't starts with `$`"); + if (name.StartsWith("$")) throw LiteException.InvalidIndexName(name, collection, "Index name can't start with `$`"); if (expression.IsScalar == false && unique) throw new LiteException(0, "Multikey index expression do not support unique option"); if (expression.Source == "$._id") return false; // always exists diff --git a/LiteDB/Engine/Pages/DataPage.cs b/LiteDB/Engine/Pages/DataPage.cs index ef1d74a72..46033664c 100644 --- a/LiteDB/Engine/Pages/DataPage.cs +++ b/LiteDB/Engine/Pages/DataPage.cs @@ -103,8 +103,9 @@ public IEnumerable GetBlocks() }; /// - /// Get page index slot on FreeDataPageID + /// Returns the slot the page should be in, given the it has /// + /// A slot number between 0 and 4 public static byte FreeIndexSlot(int freeBytes) { ENSURE(freeBytes >= 0, "freeBytes must be positive"); @@ -118,9 +119,10 @@ public static byte FreeIndexSlot(int freeBytes) } /// - /// Get minimum slot with space enough for your data content - /// Returns -1 if no space guaranteed (more than 90%) + /// Returns the slot where there is a page with enough space for bytes of data. + /// Returns -1 if no space guaranteed (more than 90% of a DataPage net size) /// + /// A slot number between -1 and 3 public static int GetMinimumIndexSlot(int length) { return FreeIndexSlot(length) - 1; diff --git a/LiteDB/Engine/Services/IndexService.cs b/LiteDB/Engine/Services/IndexService.cs index 46fc800e9..89001d709 100644 --- a/LiteDB/Engine/Services/IndexService.cs +++ b/LiteDB/Engine/Services/IndexService.cs @@ -30,10 +30,10 @@ public IndexService(Snapshot snapshot, Collation collation) /// public CollectionIndex CreateIndex(string name, string expr, bool unique) { - // get how many butes needed fore each head/tail (both has same size) + // get how many bytes needed for each head/tail (both has same size) var bytesLength = IndexNode.GetNodeLength(MAX_LEVEL_LENGTH, BsonValue.MinValue, out var keyLength); - // get a new empty page (each index contains your own linked nodes) + // get a new empty page (each index contains its own linked nodes) var indexPage = _snapshot.NewPage(); // create index ref diff --git a/LiteDB/Engine/Services/SnapShot.cs b/LiteDB/Engine/Services/SnapShot.cs index 045ce927c..a0c3e65c4 100644 --- a/LiteDB/Engine/Services/SnapShot.cs +++ b/LiteDB/Engine/Services/SnapShot.cs @@ -252,7 +252,7 @@ public DataPage GetFreeDataPage(int bytesLength) // get minimum slot to check for free page. Returns -1 if need NewPage var startSlot = DataPage.GetMinimumIndexSlot(length); - // check for avaiable re-usable page + // check for available re-usable page for (int currentSlot = startSlot; currentSlot >= 0; currentSlot--) { var freePageID = _collectionPage.FreeDataPageList[currentSlot]; @@ -263,7 +263,7 @@ public DataPage GetFreeDataPage(int bytesLength) var page = this.GetPage(freePageID); ENSURE(page.PageListSlot == currentSlot, "stored slot must be same as called"); - ENSURE(page.FreeBytes >= length, "ensure selected page has space enougth for this content"); + ENSURE(page.FreeBytes >= length, "ensure selected page has space enough for this content"); // mark page page as dirty page.IsDirty = true; @@ -271,7 +271,7 @@ public DataPage GetFreeDataPage(int bytesLength) return page; } - // if not page free list page avaiable, create new page + // if there is no re-usable page, create a new one return this.NewPage(); } diff --git a/LiteDB/Engine/Structures/CollectionIndex.cs b/LiteDB/Engine/Structures/CollectionIndex.cs index a112ab831..fce53b032 100644 --- a/LiteDB/Engine/Structures/CollectionIndex.cs +++ b/LiteDB/Engine/Structures/CollectionIndex.cs @@ -127,7 +127,7 @@ public static int GetLength(string name, string expr) PageAddress.SIZE + // Head PageAddress.SIZE + // Tail 1 + // MaxLevel - (PAGE_FREE_LIST_SLOTS * PageAddress.SIZE); // FreeListPage + 4; // FreeListPage } } } \ No newline at end of file