Пример #1
0
        protected Index(Tangle <TValue> tangle, string name, Delegate function)
        {
            IndexFunction         = function as IndexFunc <TIndexKey, TValue>;
            IndexMultipleFunction = function as IndexMultipleFunc <TIndexKey, TValue>;

            if ((IndexFunction == null) && (IndexMultipleFunction == null))
            {
                throw new InvalidOperationException("An index must have either an IndexFunc or IndexMultipleFunc");
            }

            Tangle       = tangle;
            Name         = name;
            KeyConverter = TangleKey.GetConverter <TIndexKey>();

            IndexBase <TValue> temp;

            if (tangle.Indices.TryGetValue(name, out temp))
            {
                throw new InvalidOperationException("An index with that name already exists");
            }

            BTree = new BTree(tangle.Storage, Name + "_");

            tangle.Indices.Add(name, this);

            if (tangle.Count != BTree.MutationSentinel)
            {
                Populate();
            }
        }
Пример #2
0
 public static Future <Index <TIndexKey, TValue> > Create(Tangle <TValue> tangle, string name, IndexMultipleFunc <TIndexKey, TValue> function)
 {
     return(tangle.QueueWorkItem(new CreateThunk(name, function)));
 }
Пример #3
0
 public Future <Index <U, T> > CreateIndex <U> (string name, IndexMultipleFunc <U, T> function)
 {
     return(Index <U, T> .Create(this, name, function));
 }