/// <summary> /// Initializes a new instance of the <see cref="AttributeTempFile"/> class. /// </summary> /// <param name="tempPath"> /// The temp path. /// </param> /// <param name="map"> /// The dimension position in the ARR map /// </param> /// <param name="level"> /// The level. /// </param> public AttributeTempFile(string tempPath, GesmesKeyMap map, RelStatus level) { string filePath = Path.Combine(tempPath, Path.GetRandomFileName()); this._fileStream = File.Create(filePath, BufferSize, FileOptions.DeleteOnClose | FileOptions.SequentialScan); this._writer = new GesmesAttributeGroupWriter(this._fileStream); this._currentGroup = new GesmesAttributeGroup(map, level); }
/// <summary> /// Initializes a new instance of the <see cref="GesmesArrayCell"/> class. /// </summary> /// <param name="map"> /// The dimension position inside the ARR segment /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="map"/> is null /// </exception> public GesmesArrayCell(GesmesKeyMap map) { if (map == null) { throw new ArgumentNullException("map"); } this._map = map; this._dimensionValues = new string[map.Count]; this.Observation = new GesmesObservation(); }
/// <summary> /// Initializes a new instance of the <see cref="GesmesAttributeGroup"/> class. /// </summary> /// <param name="map"> /// The map. /// </param> /// <param name="level"> /// The attachment level /// </param> public GesmesAttributeGroup(GesmesKeyMap map, RelStatus level) { this._map = map; switch (level) { case RelStatus.None: throw new ArgumentException(Resources.ErrorInvalidAttachmentLevel, "level"); case RelStatus.DataSet: // no dimension this._dimensionValues = new string[0]; this._level = AttachmentLevel.DataSet; break; case RelStatus.Sibling: // all dimensions. FREQ is wildcarded this._dimensionValues = new string[map.Count]; this._dimensionValues[0] = string.Empty; this._firstDimension = 1; this._level = AttachmentLevel.Group; break; case RelStatus.Series: // all dimensions this._dimensionValues = new string[map.Count]; this._level = AttachmentLevel.Series; break; case RelStatus.Observation: // all dimensions plus time period and time format this._dimensionValues = new string[map.Count + 2]; this._timePeriodPosition = map.Count; this._timeFormatPosition = this._timePeriodPosition + 1; this._level = AttachmentLevel.Observation; break; } }
/// <summary> /// Setups the key family. /// </summary> /// <param name="keyFamily">The key family.</param> private void SetupKeyFamily(IDataStructureObject keyFamily) { WriterHelper.ValidateErrors(Validator.ValidateForCompact(keyFamily)); this._map = new GesmesKeyMap(keyFamily); this._gesmesArrayCell = new GesmesArrayCell(this._map); IDimension frequencyDimension = keyFamily.FrequencyDimension; this.FindSiblingGroup(keyFamily, frequencyDimension); RelStatus levels = this.GetLevels(keyFamily); if (levels != RelStatus.None) { this._tempPath = GesmesHelper.TempPath; Directory.CreateDirectory(this._tempPath); this._seriesStream = this.CreateTempStream(levels, RelStatus.Series); this._groupStream = this.CreateTempStream(levels, RelStatus.Sibling); this._observationStream = this.CreateTempStream(levels, RelStatus.Observation); this._dataSetStream = this.CreateTempStream(levels, RelStatus.DataSet); } this._tempFiles = new[] { this._dataSetStream, this._groupStream, this._seriesStream, this._observationStream }; }