Skip to content

Commit

Permalink
Remove index analyze and checkintegrety for now
Browse files Browse the repository at this point in the history
  • Loading branch information
mbdavid committed Jan 3, 2020
1 parent d070a3f commit f72f6e5
Show file tree
Hide file tree
Showing 25 changed files with 40 additions and 708 deletions.
37 changes: 23 additions & 14 deletions LiteDB.Demo/Debugger/HtmlPageDump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,13 @@ private void SpanHeaderPage()
h += this.SpanItem(h, 7, null, "CreationTime", (byte[] b, int i) => new DateTime(BitConverter.ToInt64(b, i)).ToString("o"));
h += this.SpanItem(h, 3, null, "UserVersion", BitConverter.ToInt32);

this.SpanItem(96, 3, null, "Length", BitConverter.ToInt32);
var collectionPosition = 128;

var p = 100;
this.SpanItem(collectionPosition, 3, null, "Length", BitConverter.ToInt32);

var p = collectionPosition + 4;

while (p < 100 + BitConverter.ToInt32(_buffer, 96) - 5)
while (p < collectionPosition + 4 + BitConverter.ToInt32(_buffer, collectionPosition) - 5)
{
var initial = p;

Expand All @@ -210,7 +212,6 @@ private void SpanHeaderPage()

color++;
}

}

private void SpanCollectionPage()
Expand All @@ -222,9 +223,6 @@ private void SpanCollectionPage()
this.SpanPageID(32 + (i * 4), "DataPageList #" + i, false, true);
}

this.SpanItem(32 + (5 * 4), 7, null, "CreationTime", (byte[] b, int i) => new DateTime(BitConverter.ToInt64(b, i)).ToString("o"));
this.SpanItem(32 + (5 * 4) + 8, 7, null, "LastAnalyzed", (byte[] b, int i) => new DateTime(BitConverter.ToInt64(b, i)).ToString("yyyy-MM-dd"));

var h = 96;
var indexes = _buffer[h];

Expand All @@ -242,8 +240,6 @@ private void SpanCollectionPage()
h += this.SpanPageID(h, "Head", true, false);
h += this.SpanPageID(h, "Tail", true, false);
h += this.SpanItem<byte>(h, 0, null, "MaxLevel", null);
h += this.SpanItem(h, 3, null, "KeyCount", BitConverter.ToUInt32);
h += this.SpanItem(h, 3, null, "UniqueKeyCount", BitConverter.ToUInt32);
h += this.SpanPageID(h, "IndexPageList", false, true);

for (var k = initial; k <= h; k++)
Expand Down Expand Up @@ -337,7 +333,7 @@ private void RenderHeader()
_writer.AppendLine("* { box-sizing: border-box; }");
_writer.AppendLine("body { font-family: monospace; }");
_writer.AppendLine("h1 { border-bottom: 2px solid #545454; color: #545454; margin: 0; }");
_writer.AppendLine("textarea { margin: 0px; width: 1164px; height: 61px; vertical-align: top; }");
_writer.AppendLine("textarea { margin: 0px; width: 1000px; height: 61px; vertical-align: top; }");
_writer.AppendLine(".page { display: flex; min-width: 1245px; }");
_writer.AppendLine($".rules > div {{ padding: 9px 0 0; height: 31px; width: {BLOCK_WIDTH}px; color: gray; background-color: #f1f1f1; margin: 1px; text-align: center; position: relative; }}");
_writer.AppendLine(".line { min-width: 1024px; }");
Expand Down Expand Up @@ -418,15 +414,19 @@ private void RenderBlocks()

span -= (item.Span + 1);

this.RenderItem(item, span);
var renderText = this.RenderItem(item, span);

if (span <= 0)
{
_writer.AppendLine("</div><div class='line'>");

if (span < 0)
{
this.RenderItem(new PageItem { Color = item.Color, Span = Math.Abs(span + 1), Text = "&nbsp;" }, 0);
var overflow = new PageItem { Color = item.Color, Span = Math.Abs(span + 1), Text = "&nbsp;" };

if (renderText == false) overflow.Text = item.Text;

this.RenderItem(overflow, 0);
}

span = 32 + span;
Expand All @@ -439,8 +439,10 @@ private void RenderBlocks()
_writer.AppendLine("</div>");
}

private void RenderItem(PageItem item, int span)
private bool RenderItem(PageItem item, int span)
{
var renderText = true;

_writer.Append($"<a title='{item.Index}'");

if (!string.IsNullOrEmpty(item.Href))
Expand All @@ -462,6 +464,11 @@ private void RenderItem(PageItem item, int span)
{
var s = item.Span + (span < 0 ? span : 0);

if (s < item.Span && Math.Abs(span) > s)
{
renderText = false;
}

_writer.Append($" style='min-width: {BLOCK_WIDTH * (s + 1) + (s * 2)}px'");
}

Expand All @@ -476,8 +483,10 @@ private void RenderItem(PageItem item, int span)
}

_writer.Append(">");
_writer.Append(item.Text ?? item.Value.ToString());
_writer.Append(renderText ? (item.Text ?? item.Value.ToString()) : "&#8594;");
_writer.Append("</a>");

return renderText;
}

private void RenderFooter()
Expand Down
2 changes: 0 additions & 2 deletions LiteDB.Demo/StressTools/StressTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ public virtual void Run(TimeSpan timer)

// finalize database
this.OnCleanUp(new Database("OnCleanUp", _db, _logger, watch, concurrent, 0));

this.Engine.CheckIntegrity(Console.Out);
}

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions LiteDB.Demo/Tests/BugTrackTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public override void Run(TimeSpan timer)
this.Engine.Insert("col1", this.GetDocs(400), BsonAutoId.Int32);

this.Engine.DeleteMany("col1", "1=1");

this.Engine.CheckIntegrity(Console.Out);
}

private IEnumerable<BsonDocument> GetDocs(int count)
Expand Down
2 changes: 1 addition & 1 deletion LiteDB.Demo/Tests/ExampleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override void OnInit(Database db)
["name"] = "John"
});

db.ExecuteScalar("insert into orders values {a:1}");
db.ExecuteScalar("insert into orders1 values {a:1}");
db.ExecuteScalar("insert into customers values {a:1}");

// o ERRO ocorre quando:
Expand Down
59 changes: 0 additions & 59 deletions LiteDB.Tests/Engine/Analyze_Tests.cs

This file was deleted.

8 changes: 0 additions & 8 deletions LiteDB/Client/Database/LiteDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,6 @@ public void Checkpoint()
_engine.Value.Checkpoint();
}

/// <summary>
/// Analyze indexes in collections to better index choose decision
/// </summary>
public int Analyze(params string[] collections)
{
return _engine.Value.Analyze(collections);
}

/// <summary>
/// Rebuild all database to remove unused pages - reduce data file
/// </summary>
Expand Down
14 changes: 0 additions & 14 deletions LiteDB/Client/Shared/SharedEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,6 @@ public int UserVersion

#region Write Operations

public int Analyze(string[] collections)
{
this.OpenDatabase();

try
{
return _engine.Analyze(collections);
}
finally
{
this.CloseDatabase();
}
}

public void Checkpoint()
{
this.OpenDatabase();
Expand Down
28 changes: 0 additions & 28 deletions LiteDB/Client/SqlParser/Commands/Analyze.cs

This file was deleted.

1 change: 0 additions & 1 deletion LiteDB/Client/SqlParser/SqlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public IBsonDataReader Execute()
case "RENAME": return this.ParseRename();
case "CREATE": return this.ParseCreate();

case "ANALYZE": return this.ParseAnalyze();
case "CHECKPOINT": return this.ParseCheckpoint();
case "SHRINK": return this.ParseShrink();

Expand Down
81 changes: 0 additions & 81 deletions LiteDB/Engine/Engine/Analyze.cs

This file was deleted.

Loading

0 comments on commit f72f6e5

Please sign in to comment.