Exemplo n.º 1
0
 public SurfaceElevationPatchRequestViaLocalCompute(ITRexSpatialMemoryCache cache, ITRexSpatialMemoryCacheContext context) : this()
 {
     if (cache != null && context != null)
     {
         _cache = new SurfaceElevationPatchRequestCache(cache, context, _clientLeafSubGridFactory);
     }
 }
Exemplo n.º 2
0
 public TRexSpatialMemoryCacheContextRemover(ITRexSpatialMemoryCache cache, int sleepTimeSeconds)
 {
     _cache         = cache;
     _sleepTimeMs   = sleepTimeSeconds * 1000;
     _removalThread = new Thread(PerformRemovalOperation);
     _removalThread.Start();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new ring buffer in T
        /// </summary>
        /// <param name="maxNumElements">The maximum number of elements to be stored in the ring buffer</param>
        /// <param name="fragmentationMultiplier">A multiplier factor to derive the number of slots to create in the ring buffer to take into account likely fragmentation in the buffer due to element LRU updates and eviction</param>
        /// <param name="mruDeadBandFraction">The most recently used fraction of the slot space within the ring buffer queue that is not subject to moving to the head of the ring buffer when touched. EG: A value of 0.10 means any element touched in the top 10% of the slots will not be moved to the head of the ring buffer</param>
        public MRURingBuffer(ITRexSpatialMemoryCache ownerCache, int maxNumElements, double fragmentationMultiplier, double mruDeadBandFraction)
        {
            if (maxNumElements < 1 || maxNumElements > MAX_SUPPORTED_SLOTS)
            {
                throw new ArgumentException($"maxNumElements ({maxNumElements}) not in range 1..{MAX_SUPPORTED_SLOTS}");
            }

            if (fragmentationMultiplier < 1 || fragmentationMultiplier > 10)
            {
                throw new ArgumentException($"Fragmentation factor {fragmentationMultiplier} is less than 1.0 or more than 10.0");
            }

            if (mruDeadBandFraction < 0.0 || mruDeadBandFraction > 1.0)
            {
                throw new ArgumentException($"mruDeadBandFraction ({mruDeadBandFraction}) not in range 0.0..1.0");
            }

            TotalSlots = (int)Math.Truncate(maxNumElements * fragmentationMultiplier);

            if (TotalSlots < 1 || maxNumElements > MAX_SUPPORTED_SLOTS)
            {
                throw new ArgumentException($"Total number of slots in the rung buffer ({TotalSlots}) not in range 1..{MAX_SUPPORTED_SLOTS}");
            }

            OwnerCache = ownerCache ?? throw new ArgumentException("Cannot create an MRU ring buffer without an owning memory cache");

            MaxNumElements            = maxNumElements;
            FragmentationMultiplier   = fragmentationMultiplier;
            MruNonUpdateableSlotCount = (int)Math.Truncate(TotalSlots * mruDeadBandFraction);

            // Construct the array of slots to hold the elements in the ring buffer taking into account the fragmentation multiplier
            ElementSlots = new T[TotalSlots];
        }
Exemplo n.º 4
0
 public SurfaceElevationPatchRequestCache(ITRexSpatialMemoryCache cache, ITRexSpatialMemoryCacheContext context, IClientLeafSubGridFactory clientLeafSubGridFactory)
 {
     _cache   = cache;
     _context = context;
     _clientLeafSubGridFactory = clientLeafSubGridFactory;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Constructor that accepts the common parameters around a set of sub grids the requester will be asked to process
        /// and initializes the requester state ready to start processing individual sub grid requests.
        /// </summary>
        public void Initialize(ISubGridsRequestArgument subGridsRequestArgument,
                               ISiteModel siteModel,
                               GridDataType gridDataType,
                               IStorageProxy storageProxy,
                               ICombinedFilter filter,
                               bool hasOverrideSpatialCellRestriction,
                               BoundingIntegerExtent2D overrideSpatialCellRestriction,
                               int maxNumberOfPassesToReturn,
                               AreaControlSet areaControlSet,
                               IFilteredValuePopulationControl populationControl,
                               ISubGridTreeBitMask pdExistenceMap,
                               ITRexSpatialMemoryCache subGridCache,
                               ITRexSpatialMemoryCacheContext[] subGridCacheContexts,
                               ISurveyedSurfaces filteredSurveyedSurfaces,
                               ISurfaceElevationPatchRequest surfaceElevationPatchRequest,
                               IOverrideParameters overrides,
                               ILiftParameters liftParams)
        {
            _siteModel    = siteModel;
            _gridDataType = gridDataType;
            _filter       = filter;

            _hasOverrideSpatialCellRestriction = hasOverrideSpatialCellRestriction;
            _overrideSpatialCellRestriction    = overrideSpatialCellRestriction;

            _retriever = DIContext.Obtain <ISubGridRetrieverFactory>().Instance(subGridsRequestArgument,
                                                                                siteModel,
                                                                                gridDataType,
                                                                                storageProxy,
                                                                                filter,
                                                                                _filterAnnex,
                                                                                hasOverrideSpatialCellRestriction,
                                                                                overrideSpatialCellRestriction,
                                                                                maxNumberOfPassesToReturn,
                                                                                areaControlSet,
                                                                                populationControl,
                                                                                pdExistenceMap,
                                                                                subGridCacheContexts,
                                                                                overrides,
                                                                                liftParams);

            _returnEarliestFilteredCellPass = _filter.AttributeFilter.ReturnEarliestFilteredCellPass;
            _processingMap = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled);

            _surfaceElevationPatchRequest = surfaceElevationPatchRequest;

            _subGridCache         = subGridCache;
            _subGridCacheContexts = subGridCacheContexts;

            _surveyedSurfacePatchType = _filter.AttributeFilter.ReturnEarliestFilteredCellPass ? SurveyedSurfacePatchType.EarliestSingleElevation : SurveyedSurfacePatchType.LatestSingleElevation;

            _filteredSurveyedSurfaces = filteredSurveyedSurfaces;
            _filteredSurveyedSurfaces?.SortChronologically(_surveyedSurfacePatchType == SurveyedSurfacePatchType.LatestSingleElevation);
            _filteredSurveyedSurfacesAsGuidArray = _filteredSurveyedSurfaces?.Select(x => x.ID).ToArray() ?? new Guid[0];

            var elevRangeDesignFilter = _filter.AttributeFilter.ElevationRangeDesign;

            if (elevRangeDesignFilter.DesignID != Guid.Empty)
            {
                var design = _siteModel.Designs.Locate(elevRangeDesignFilter.DesignID);
                if (design == null)
                {
                    _log.LogError($"ElevationRangeDesign {elevRangeDesignFilter.DesignID} is unknown in project {siteModel.ID}");
                }
                else
                {
                    _elevationRangeDesign = new DesignWrapper(elevRangeDesignFilter, design);
                }
            }

            if (_filter.SpatialFilter.IsDesignMask)
            {
                _surfaceDesignMaskDesign = _siteModel.Designs.Locate(_filter.SpatialFilter.SurfaceDesignMaskDesignUid);
            }

            _filter.AttributeFilter.SiteModel = _siteModel;
        }