public override void BeginInvoke(SpoolSpace Memory) { // Do the checks, need an aggregate and we must be part of a loop if (!this._Parameters.ContainsAggregate || !this._Parameters.ContainsNonAggregate) { throw new Exception("Dictionary aggregates must contain at least one aggregate and one non-aggregate"); } //if (this._Parent == null || !this._Parent.IsBreakable) // throw new Exception("Aggregates can only appear in loop statements"); // We don't need to invoke the base method // Build the keys Key k = new Key(), v = new Key(); int idx = 0; foreach (Expression x in this._Parameters) { if (x.IsAggregate) { v.Add(idx); } else { k.Add(idx); } idx++; } // Set up the staging table // this._StorageTree = new DictionaryTable(this._Host, Host.RandomPath(), this._Parameters.Columns, k, Page.DEFAULT_SIZE); }
private void buttonFormula_Click(object sender, EventArgs e) { if (transform == null) { return; } transform.AcceptFormula(userFormulaEditor.Formula); DictionaryTable <double> .Set(transform.Variables, propertyGrid); }
public void Store(DictionaryTable data) { itemHolder.Clear(); foreach (var memoryItem in data.Items) { itemHolder.Add(memoryItem.Id, memoryItem); } tableName = data.Name; empty = false; OnSotrageChanged(); }
/// <summary> /// Gets the memoized value for the given key if available, otherwise populates it /// using the specified populator function and stores it in association with its keys /// for later reuse. /// </summary> /// <param name="key">The key by which to look up a memoized result.</param> /// <param name="populator">The populator for the value associated with the key.</param> /// <returns>The value returned by the populator, possibly memoized.</returns> public TValue Memoize(TKey key, GallioFunc <TValue> populator) { TValue value; if (table != null) { if (table.Lookup(key, out value)) { #if STATISTICS OnHit(); OnReturn(); #endif return(value); } } else { table = new ArrayTable(); #if STATISTICS OnSmallCacheCreated(); #endif } #if STATISTICS OnMiss(); #endif value = populator(); if (!table.Store(key, value)) { var newTable = new DictionaryTable(); table.CopyTo(newTable); table = newTable; table.Store(key, value); #if STATISTICS OnSmallCachePromotedToLarge(); #endif } #if STATISTICS OnReturn(); #endif return(value); }
/// <summary> /// Initializes a new instance of the <see cref="DictionaryTable{TKey, TValue}"/> class. /// </summary> /// <param name="other">The table to copy from.</param> DictionaryTable(DictionaryTable <TKey, TValue> other) { _buffer = new Dictionary <int, TValue>(other._buffer); }
private void StoreInternal(DictionaryTable data) { File.WriteAllText(FilePath, GetJsonData(data), Encoding.UTF8); }
public void Store(DictionaryTable data) { StoreInternal(data); memcacheStorage.Store(data); }
public SimpleDictionarySourceSupplier(string name, IEnumerable <DictionaryItem> items, IEnumerable <string> sourceList) { this.source = new DictionaryTable(name, items.ToArray()); this.sourceList = sourceList; }
public override bool Equals(Table other) { DictionaryTable <T> rhs = other as DictionaryTable <T>; return(rhs != null && ReferenceEquals(values, rhs.values)); }