private LocalTable <T> GetCurrentTransactionTable <T>(TupleType type) { if (_transactionCount == 0) { return(_space.GetRootTable <T>(type)); } // transactions have their own tables for (var i = 0; i < _transactionTablesCount; i++) { if (_transactionTables[i].TupleTypeId != type.Id) { continue; } var table = (LocalTable <T>)_transactionTables[i].Table; if (table.HierarchyLevel == _transactionCount) { return(table); } // create nested table var nestedTable = LocalTable <T> .GetTransactional(_transactionCount, table); _transactionTables[i].Table = nestedTable; return(nestedTable); } // nothing found var newNestedTable = LocalTable <T> .GetTransactional(_transactionCount, _space.GetRootTable <T>(type)); if (_transactionTablesCount == _transactionTables.Length) { // resize _transactionTables Array.Resize(ref _transactionTables, _transactionTablesCount * 2); } _transactionTables[_transactionTablesCount++] = new TransactionTableHolder(type.Id, newNestedTable); return(newNestedTable); }
public static LocalTable <T> GetTransactional(int hierarchyLevel, LocalTable <T> parent) { var trans = _cache.Count != 0 ? _cache.Pop() : new LocalTable <T>(new ArrayTupleStorage <T>(LocalSpaceConsts.TransactionWrittenCapacity)); trans.HierarchyLevel = hierarchyLevel; trans._parent = parent; trans.Root = parent.Root ?? parent; return(trans); }
public void AddTaken(LocalTable <T> borrower, T tuple) { /*if (_takenCount == _taken.Length) * { * Array.Resize(ref _taken, _takenCount * 2); * } * _taken[_takenCount++] = new TakenTuple<T>(borrower, tuple);*/ _taken.Add(new TakenTuple <T>(borrower, tuple)); }
internal LocalTable <T> GetRootTable <T>(TupleType type) { if (type.Id >= _tables.Length) { Array.Resize(ref _tables, type.Id + 1); } var result = _tables[type.Id]; if (result != null) { return((LocalTable <T>)result); } var table = LocalTable <T> .GetRoot(); _tables[type.Id] = table; return(table); }
public TakenTuple(LocalTable <T> table, T tuple) { Table = table; Tuple = tuple; }