Exemple #1
0
 public int Write(Record record)
 {
     _recordsPositions.Add(_fileContent.Position);
     var recordAsByteArr = record.ToByteArray();
     _fileContent.Write(recordAsByteArr, 0, recordAsByteArr.Length);
     return _recordsPositions.Count - 1;
 }
        public void AddRecord(int sourceId, int sourceType, byte[] data)
        {
            var record = new Record(sourceId, sourceType, data);

            if (_currentFile.Length + record.ToByteArray().Length > AppSettings.Default.DataTableSize)
            {
                SaveData();
                AddNewDataFile();
            }

            var id = _currentFile.StartOffset + _currentFile.Write(record);
            ++_recordsCount;

            _sourceIds.InsertOrUpdate(record.SourceId, id);
            _sourceTypes.InsertOrUpdate(record.SourceType, id);
            _datetimeIndexer.AddRecord(record.creationDate, new[] { id });
        }