This repository has been archived by the owner on Oct 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
TotalIndexAttribute.cs
67 lines (64 loc) · 2.76 KB
/
TotalIndexAttribute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
namespace Orleans.Indexing
{
/// <summary>
/// The attribute for declaring the property fields of an
/// indexed grain interface to have a "Total Index", which
/// is also known as "Initialized Index".
///
/// A "Total Index" indexes all the grains that have been
/// created during the lifetime of the application.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public sealed class TotalIndexAttribute : IndexAttribute
{
/// <summary>
/// The default constructor for TotalIndex.
/// </summary>
public TotalIndexAttribute() : this(false)
{
}
/// <summary>
/// The constructor for TotalIndex.
/// </summary>
/// <param name="IsEager">Determines whether the index should be
/// updated eagerly upon any change in the indexed grains. Otherwise,
/// the update propagation happens lazily after applying the update
/// to the grain itself.</param>
public TotalIndexAttribute(bool IsEager) : this(Indexing.TotalIndexType.HashIndexSingleBucket, IsEager, false)
{
}
/// <summary>
/// The full-option constructor for TotalIndex.
/// </summary>
/// <param name="type">The index type for the Total index</param>
/// <param name="IsEager">Determines whether the index should be
/// updated eagerly upon any change in the indexed grains. Otherwise,
/// the update propagation happens lazily after applying the update
/// to the grain itself.</param>
/// <param name="IsUnique">Determines whether the index should maintain
/// a uniqueness constraint.</param>
/// <param name="MaxEntriesPerBucket">The maximum number of entries
/// that should be stored in each bucket of a distributed index. This
/// option is only considered if the index is a distributed index.
/// Use -1 to declare no limit.</param>
public TotalIndexAttribute(TotalIndexType type, bool IsEager = false, bool IsUnique = false, int MaxEntriesPerBucket = -1)
{
switch (type)
{
case Indexing.TotalIndexType.HashIndexSingleBucket:
IndexType = typeof(TotalHashIndexSingleBucket<,>);
break;
case Indexing.TotalIndexType.HashIndexPartitionedByKeyHash:
IndexType = typeof(TotalHashIndexPartitionedPerKey<,>);
break;
default:
IndexType = typeof(TotalHashIndexSingleBucket<,>);
break;
}
this.IsEager = IsEager;
this.IsUnique = IsUnique;
this.MaxEntriesPerBucket = MaxEntriesPerBucket;
}
}
}