internal float GetStatistic(int indexId, IndexCostSource src, IndexCostType type, IndexCostInformation info, int?theoreticalIndexSize) { IndexInfo <T> index; var i = _indexes.Where(p => p.IndexID == indexId); if (i.Count() != 1) { throw new WronxIndexIdException(indexId); } else { index = i.Single(); } switch (src) { case IndexCostSource.Statistic: return(getStatistics(index, type, info)); case IndexCostSource.Theoretic: return(getTheoretical(GetIndex(indexId), type, info, theoreticalIndexSize)); default: throw new UnexpectedStatisticSourceException(src); } }
public UnexpectedStatisticTypeException(IndexCostType type) : base(String.Format("Unexpected index statistic type requested: {0}", type.ToString())) { }
private float getTheoretical(IIndex <T> index, IndexCostType type, IndexCostInformation info, int?theoreticalIndexSize) { IndexOperationCost statisticInfo; switch (info) { case IndexCostInformation.OneObjectSearch: statisticInfo = index.ObjectFindCost(theoreticalIndexSize == null ? 0 : (int)theoreticalIndexSize); break; case IndexCostInformation.OneObjectIndexAdd: statisticInfo = index.ObjectIndexingCost(theoreticalIndexSize == null ? 0 : (int)theoreticalIndexSize); break; case IndexCostInformation.OneObjectIndexRemove: statisticInfo = index.ObjectIndexRemoveCost(theoreticalIndexSize == null ? 0 : (int)theoreticalIndexSize); break; case IndexCostInformation.OneObjectIndexRefresh: statisticInfo = index.ObjectIndexRefreshCost(theoreticalIndexSize == null ? 0 : (int)theoreticalIndexSize); break; case IndexCostInformation.OneRoleIndexRefresh: statisticInfo = index.RoleIndexRefreshCost(theoreticalIndexSize == null ? 0 : (int)theoreticalIndexSize); break; case IndexCostInformation.OneRoleIndexRemove: statisticInfo = index.RoleIndexRemoveCost(theoreticalIndexSize == null ? 0 : (int)theoreticalIndexSize); break; case IndexCostInformation.OneRoleIndexing: statisticInfo = index.RoleIndexingCost(theoreticalIndexSize == null ? 0 : (int)theoreticalIndexSize); break; case IndexCostInformation.OneRoleSearch: statisticInfo = index.RoleFindCost(theoreticalIndexSize == null ? 0 : (int)theoreticalIndexSize); break; default: throw new UnexpectedStatisticRequestException(info); } int ret; switch (type) { case IndexCostType.Optimistic: ret = statisticInfo.OptimisticCost; break; case IndexCostType.Pessimistic: ret = statisticInfo.PessimisticCost; break; case IndexCostType.Average: ret = statisticInfo.AverageCost; break; default: throw new UnexpectedStatisticTypeException(type); } return(ret); }
private float getStatistics(IndexInfo <T> index, IndexCostType type, IndexCostInformation info) { StatisticInfo statisticInfo; switch (info) { case IndexCostInformation.OneObjectSearch: statisticInfo = index.IndexStatistic.ObjectSearch; break; case IndexCostInformation.OneObjectIndexAdd: statisticInfo = index.IndexStatistic.ObjectIndexing; break; case IndexCostInformation.OneObjectIndexRemove: statisticInfo = index.IndexStatistic.ObjectIndexRemove; break; case IndexCostInformation.OneObjectIndexRefresh: statisticInfo = index.IndexStatistic.ObjectIndexRefresh; break; case IndexCostInformation.HitRatio: statisticInfo = index.IndexStatistic.HitRatio; break; case IndexCostInformation.OneRoleIndexRefresh: statisticInfo = index.IndexStatistic.RoleIndexRefresh; break; case IndexCostInformation.OneRoleIndexRemove: statisticInfo = index.IndexStatistic.RoleIndexRemove; break; case IndexCostInformation.OneRoleIndexing: statisticInfo = index.IndexStatistic.RoleIndexing; break; case IndexCostInformation.OneRoleSearch: statisticInfo = index.IndexStatistic.RoleSearch; break; default: throw new UnexpectedStatisticRequestException(info); } float ret; switch (type) { case IndexCostType.Optimistic: ret = statisticInfo.Optimistic; break; case IndexCostType.Pessimistic: ret = statisticInfo.Pessimistic; break; case IndexCostType.Average: ret = statisticInfo.Average; break; default: throw new UnexpectedStatisticTypeException(type); } return(ret); }
public float GetStatistic(int indexID, IndexCostSource src, IndexCostType type, IndexCostInformation info, int?theoreticalIndexSize) { return(global::IndexMechanism.IndexManager.IndexManager <T> .GetInstance().GetStatistic(indexID, src, type, info, theoreticalIndexSize)); }