public Record AppendRecord(byte [] data, IAllocationStrategy allocationStrategy, bool allowRecordReuse = true) { Record record = null; int maxAllocationSize = allocationStrategy.CalculateSize(data.Length); if (allowRecordReuse) { record = ReuseEmptyRecord(data.Length, maxAllocationSize); } if (record == null) { //append record = new Record(); record.Header.AllocatedDataSize = maxAllocationSize; record.Data = data; WriteRecordAtHead(record); } else //reuse { UpdateRecord(record, data, allocationStrategy); } return(record); }
public AbstractTokenizer(ITokenObserver <T> observer, IAllocationStrategy allocationStrategy, ITokenEncoding encoding) { _observer = observer; _allocationStrategy = allocationStrategy; _encoding = encoding; }
public Record UpdateRecord( Record record, byte[] data, IAllocationStrategy allocationStrategy = null) { Records[record.Header.Address].Data = data; this.UsedAllocationStrategy = allocationStrategy; return(record); }
/// <summary> /// Constructor for the resource manager. /// </summary> /// <param name="alloc">The allocation strategy to use.</param> public ResourceManager(IAllocationStrategy alloc = null) { m_ReleaseOpNonCached = OnOperationDestroyNonCached; m_ReleaseOpCached = OnOperationDestroyCached; m_ReleaseInstanceOp = OnInstanceOperationDestroy; m_allocator = alloc == null ? new LRUCacheAllocationStrategy(1000, 1000, 100, 10) : alloc; m_ResourceProviders.OnElementAdded += OnObjectAdded; m_ResourceProviders.OnElementRemoved += OnObjectRemoved; m_UpdateReceivers.OnElementAdded += x => RegisterForCallbacks(); }
public void Initialize() { _platform = new TestPlatform(); _streamProvider = (InMemoryStreamProvider)_platform.CreateStorageStreamProvider("/"); _session = new Session(_platform, "/"); _allocationStrategy = _session.AllocationStrategyResolver.StrategyFor(new object()); _recordManager = new RecordManager( _session, new StorageEngine(_session, "article")); }
public Record AppendRecord( byte[] data, IAllocationStrategy allocationStrategy) { var record = new Record(); record.Header.Address = _records.Values.Count + 1; record.Header.AllocatedDataSize = data.Length; record.Header.DataSize = data.Length; record.Data = data; _records[record.Header.Address] = record; return(record); }
public Record UpdateRecord(Record record, byte[] data, IAllocationStrategy allocationStrategy) { if (data.Length > record.Header.AllocatedDataSize) { Recycle(record.Header.Address); return(AppendRecord(data, allocationStrategy)); } else { record.Data = data; StorageEngine.Write(record.Header.Address, record.AsBytes()); return(record); } }
public Record AppendRecord( byte[] data, IAllocationStrategy allocationStrategy = null) { this.UsedAllocationStrategy = allocationStrategy; var record = new Record(); record.Header.AllocatedDataSize = data.Length * 10; //To be sure record.Data = data; record.Header.Address = Records.Count + 1; Records.Add(record.Header.Address, record); return(record); }
public Record UpdateRecord(Record record, byte[] data, IAllocationStrategy allocationStrategy, bool allowRecordReuse = true) { if (data.Length > record.Header.AllocatedDataSize) { RegisterEmpty(record.Header.Address); return(AppendRecord(data, allocationStrategy, allowRecordReuse)); } else { record.Data = data; StorageEngine.Write(record.Header.Address, record.AsBytes()); return(record); } }
public Record AppendRecord(byte[] data, IAllocationStrategy allocationStrategy) { Record record = null; record = ReuseRecycledRecord(data.Length); if (record == null) { //append record = new Record(); record.Header.AllocatedDataSize = allocationStrategy.CalculateSize(data.Length); record.Data = data; WriteRecordAtHead(record); } else //reuse { UpdateRecord(record, data, allocationStrategy); } return(record); }
public Record UpdateRecord( Record record, byte[] data, IAllocationStrategy allocationStrategy) { if (_records.ContainsKey(record.Header.Address)) { if (data.Length > record.Header.AllocatedDataSize) { return(AppendRecord(data, allocationStrategy)); } else { _records[record.Header.Address].Data = data; return(_records[record.Header.Address]); } } else { throw new ArgumentException("No record here: " + record.Header.Address.ToString()); } }
public SpanDictionary(uint size, IAllocationStrategy allocationStrategy) : this() { _valuesInfo = new Node[size]; _values = allocationStrategy.Allocate <TValue>(size); _buckets = new int[HashHelpers.GetPrime((int)size)]; }
public AddressablesImpl(IAllocationStrategy alloc) { m_ResourceManager = new ResourceManager(alloc); SceneManager.sceneUnloaded += OnSceneUnloaded; }
public SimpleTokenizer(ITokenObserver <TokenType> observer, IAllocationStrategy allocationStrategy, ITokenEncoding encoding) : base(observer, allocationStrategy, encoding) { }
public SimpleTokenizer(ITokenObserver <TokenType> observer, IAllocationStrategy allocationStrategy) : base( observer, allocationStrategy) { }
public AbstractTokenizer(ITokenObserver <T> observer, IAllocationStrategy allocationStrategy) : this(observer, allocationStrategy, DefaultEncoding) { }