CSharpTest.Net
DuplicateHandling Property
See Also  Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BulkInsertOptions Class : DuplicateHandling Property

Glossary Item Box

Gets or sets the handling for duplicate key collisions

Syntax

Visual Basic (Declaration) 
Public Property DuplicateHandling As DuplicateHandling
C# 
public DuplicateHandling DuplicateHandling {get; set;}

Example

BPlusTree/BPlusTree.Test/TestBulkInsert.cs

C#Copy Code
Dictionary<int, string> test = new Dictionary<int, string>();
IEnumerable<KeyValuePair<int, string>>[] sets =
    new List<IEnumerable<KeyValuePair<int, string>>>(CreateSets(1, 1000, test)).ToArray();

using (BPlusTree<int, string> tree = new BPlusTree<int, string>(Options))
{
    tree.BulkInsert(
        new OrderedKeyValuePairs<int, string>(sets[0]),
        new BulkInsertOptions { DuplicateHandling = DuplicateHandling.LastValueWins, InputIsSorted = true }
        );

    VerifyDictionary(test, tree);

    // Use bulk insert to overwrite the contents of tree
    test = new Dictionary<int, string>();
    sets = new List<IEnumerable<KeyValuePair<int, string>>>(CreateSets(1, 100, test)).ToArray();

    tree.BulkInsert(
        new OrderedKeyValuePairs<int, string>(sets[0]),
        new BulkInsertOptions 
        {
            CommitOnCompletion = false,
            InputIsSorted = true,
            ReplaceContents = true,
            DuplicateHandling = DuplicateHandling.RaisesException, 
        }
    );

    VerifyDictionary(test, tree);
}
VB.NETCopy Code
Dim test As New Dictionary(Of Integer, String)()
Dim sets As IEnumerable(Of KeyValuePair(Of Integer, String))() = New List(Of IEnumerable(Of KeyValuePair(Of Integer, String)))(CreateSets(1, 1000, test)).ToArray()

Using tree As New BPlusTree(Of Integer, String)(Options)
    tree.BulkInsert(New OrderedKeyValuePairs(Of Integer, String)(sets(0)), New BulkInsertOptions() With { _
        Key .DuplicateHandling = DuplicateHandling.LastValueWins, _
        Key .InputIsSorted = True _
    })

    VerifyDictionary(test, tree)

    ' Use bulk insert to overwrite the contents of tree
    test = New Dictionary(Of Integer, String)()
    sets = New List(Of IEnumerable(Of KeyValuePair(Of Integer, String)))(CreateSets(1, 100, test)).ToArray()

    tree.BulkInsert(New OrderedKeyValuePairs(Of Integer, String)(sets(0)), New BulkInsertOptions() With { _
        Key .CommitOnCompletion = False, _
        Key .InputIsSorted = True, _
        Key .ReplaceContents = True, _
        Key .DuplicateHandling = DuplicateHandling.RaisesException _
    })

    VerifyDictionary(test, tree)
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