/// <summary> /// Computes a unique file name for a segment within a particular sub grid /// </summary> public static string GetLeafSubGridSegmentFullFileName(SubGridCellAddress cellAddress, ISubGridCellPassesDataSegmentInfo segmentInfo) { // Work out the cell address of the origin cell in the appropriate leaf // sub grid. We use this cell position to derive the name of the file // containing the leaf sub grid data return(segmentInfo.FileName(cellAddress.X & ~SubGridTreeConsts.SubGridLocalKeyMask, cellAddress.Y & ~SubGridTreeConsts.SubGridLocalKeyMask)); }
public ISubGridCellPassesDataSegment AddNewSegment(IServerLeafSubGrid subGrid, ISubGridCellPassesDataSegmentInfo segmentInfo) { if (segmentInfo == null) { throw new TRexSubGridProcessingException($"Null segment info passed to AddNewSegment for sub grid {subGrid.Moniker()}"); } if (segmentInfo.Segment != null) { throw new TRexSubGridProcessingException($"Segment info passed to AddNewSegment for sub grid {subGrid.Moniker()} already contains an allocated segment"); } var Result = new SubGridCellPassesDataSegment { Owner = subGrid, SegmentInfo = segmentInfo }; segmentInfo.Segment = Result; for (int I = 0; I < Count; I++) { if (segmentInfo.EndTime <= Items[I].SegmentInfo.StartTime) { Items.Insert(I, Result); if (_performSegmentAdditionIntegrityChecks) { for (int J = 0; J < Count - 1; J++) { if (Items[J].SegmentInfo.StartTime >= Items[J + 1].SegmentInfo.StartTime) { _log.LogError($"Segment passes list out of order {Items[J].SegmentInfo.StartTime} versus {Items[J + 1].SegmentInfo.StartTime}. Segment count = {Count}"); DumpSegmentsToLog(); throw new TRexSubGridProcessingException($"Segment passes list out of order {Items[J].SegmentInfo.StartTime} versus {Items[J + 1].SegmentInfo.StartTime}. Segment count = {Count}"); } } } return(Result); } } // if we get to here, then the new segment is at the end of the list, so just add it to the end Add(Result); return(Result); }