Skip to content

Commit

Permalink
v3-beta2 nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
mbdavid committed Nov 27, 2016
1 parent f0f60d5 commit e6b51a6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion LiteDB.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata>
<id>LiteDB</id>
<version>3.0.0-beta</version>
<version>3.0.0-beta2</version>
<title>LiteDB</title>
<authors>Mauricio David</authors>
<projectUrl>http://www.litedb.org</projectUrl>
Expand Down
52 changes: 48 additions & 4 deletions LiteDB/Engine/Update/V6/DbReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private HeaderPage_v6 ReadHeaderPage(ByteReader reader)
{
var page = new HeaderPage_v6();

reader.Skip(100);
reader.Skip(60); // HEADER_INFO + FILE_VERSION + ChangeID + FreeEmptyPageID + LastPageID + DbVersion + Password

var cols = reader.ReadByte();
for (var i = 0; i < cols; i++)
Expand All @@ -84,14 +84,58 @@ private HeaderPage_v6 ReadHeaderPage(ByteReader reader)
/// </summary>
private CollectionPage_v6 ReadCollectionPage(ByteReader reader)
{
var page = new CollectionPage_v6();
var page = new CollectionPage_v6 { Indexes = new Dictionary<string, bool>() };

page.CollectionName = reader.ReadString();
page.DocumentCount = reader.ReadInt64();
reader.ReadUInt32(); // FreeDataPageID
page.DocumentCount = reader.ReadUInt32();
reader.ReadString(); // _id
page.HeadNode = reader.ReadPageAddress(); // _id headnode
reader.Skip(15); // all index info from _id headnode

page.Indexes = new Dictionary<string, bool>();
for (var i = 1; i < 15; i++)
{
var field = reader.ReadString();
reader.Skip(16); // HeadNode + TailNode + FreeIndexPageID
var unique = reader.ReadBoolean();
reader.Skip(4); // IgnoreCase + TrimWhitespace + EmptyStringToNull + RemoveAccents

if (!string.IsNullOrEmpty(field))
{
page.Indexes.Add(field, unique);
}
}

return page;
}
/// <summary>
/// Read Index page from ByteReader
/// </summary>
private IndexPage_v6 ReadIndexPage(ByteReader reader, int itemCount)
{
var page = new IndexPage_v6 { Nodes = new Dictionary<ushort, IndexNode_v6>(itemCount) };

for (var i = 0; i < itemCount; i++)
{
var index = reader.ReadUInt16();
var levels = reader.ReadByte();

var node = new IndexNode_v6(levels);

node.Page = this;
node.Position = new PageAddress(this.PageID, index);
node.KeyLength = reader.ReadUInt16();
node.Key = reader.ReadBsonValue(node.KeyLength);
node.DataBlock = reader.ReadPageAddress();

for (var j = 0; j < node.Prev.Length; j++)
{
node.Prev[j] = reader.ReadPageAddress();
node.Next[j] = reader.ReadPageAddress();
}

this.Nodes.Add(node.Position.Index, node);
}

return page;
}
Expand Down
2 changes: 1 addition & 1 deletion LiteDB/Engine/Update/V6/Pages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class CollectionPage_v6 : BasePage_v6
{
public string CollectionName { get; set; }
public long DocumentCount { get; set; }
public PageAddress HeaderNode { get; set; }
public PageAddress HeadNode { get; set; }
public Dictionary<string, bool> Indexes { get; set; }
}

Expand Down

0 comments on commit e6b51a6

Please sign in to comment.