CSharpTest.Net
TruncateLog() Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : TruncateLog() Method

Glossary Item Box

Truncate the log and remove all existing entries

Syntax

Visual Basic (Declaration) 
Public Sub TruncateLog() 
C# 
public void TruncateLog()

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C#Copy Code
using (TempFile tmp = new TempFile())
using (var log = new TransactionLog<int, string>(Options(tmp)))
{
    var token = log.BeginTransaction();
    log.AddValue(ref token, 1, "test");
    log.CommitTransaction(ref token);

    var test = new Dictionary<int, string>();
    log.ReplayLog(test);

    Assert.AreEqual(1, test.Count);
    Assert.IsTrue(test.ContainsKey(1));
    Assert.AreEqual("test", test[1]);

    log.TruncateLog();
    test.Clear();
    log.ReplayLog(test);

    Assert.AreEqual(0, test.Count);
}
VB.NETCopy Code
Using tmp As New TempFile()
    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
        Dim token As var = log.BeginTransaction()
        log.AddValue(token, 1, "test")
        log.CommitTransaction(token)

        Dim test As var = New Dictionary(Of Integer, String)()
        log.ReplayLog(test)

        Assert.AreEqual(1, test.Count)
        Assert.IsTrue(test.ContainsKey(1))
        Assert.AreEqual("test", test(1))

        log.TruncateLog()
        test.Clear()
        log.ReplayLog(test)

        Assert.AreEqual(0, test.Count)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys