예제 #1
0
파일: FetchData.cs 프로젝트: mujing/rrd4net
 public FetchData(long steps, long endTime, FetchRequest request)
 {
    this.arcStep = matchingArchive.getArcStep();
    this.arcEndTime = matchingArchive.getEndTime();
    this.dsNames = request.getFilter();
    this.request = request;
 }
예제 #2
0
파일: FetchData.cs 프로젝트: mujing/rrd4net
	public FetchData(Archive matchingArchive, FetchRequest request) {
		this.matchingArchive = matchingArchive;
		this.arcStep = matchingArchive.getArcStep();
		this.arcEndTime = matchingArchive.getEndTime();
		this.dsNames = request.getFilter();
		if (this.dsNames == null) {
			this.dsNames = matchingArchive.getParentDb().getDsNames();
		}
		this.request = request;
	}
예제 #3
0
        public FetchData fetchData(FetchRequest request)
        {
            long arcStep    = getArcStep();
            long fetchStart = Util.normalize(request.FetchStart, arcStep);
            long fetchEnd   = Util.normalize(request.FetchEnd, arcStep);

            if (fetchEnd < request.FetchEnd)
            {
                fetchEnd += arcStep;
            }
            long startTime = getStartTime();
            long endTime   = getEndTime();

            String[] dsToFetch = request.getFilter();
            if (dsToFetch == null)
            {
                dsToFetch = parentDb.getDsNames();
            }
            int dsCount  = dsToFetch.Length;
            int ptsCount = (int)((fetchEnd - fetchStart) / arcStep + 1);

            long[]     timestamps = new long[ptsCount];
            double[][] values     = new double[dsCount][];
            for (int i = 0; i < dsCount; i++)
            {
                values[i] = new double[ptsCount];
            }


            long matchStartTime = Math.Max(fetchStart, startTime);
            long matchEndTime   = Math.Min(fetchEnd, endTime);

            double[][] robinValues = null;
            if (matchStartTime <= matchEndTime)
            {
                // preload robin values
                int matchCount      = (int)((matchEndTime - matchStartTime) / arcStep + 1);
                int matchStartIndex = (int)((matchStartTime - startTime) / arcStep);
                robinValues = new double[dsCount][];
                for (int i = 0; i < dsCount; i++)
                {
                    int dsIndex = parentDb.getDsIndex(dsToFetch[i]);
                    robinValues[i] = robins[dsIndex].getValues(matchStartIndex, matchCount);
                }
            }
            for (int ptIndex = 0; ptIndex < ptsCount; ptIndex++)
            {
                long time = fetchStart + ptIndex * arcStep;
                timestamps[ptIndex] = time;
                for (int i = 0; i < dsCount; i++)
                {
                    double value = Double.NaN;
                    if (time >= matchStartTime && time <= matchEndTime)
                    {
                        // inbound time
                        int robinValueIndex = (int)((time - matchStartTime) / arcStep);
                        Debug.Assert(robinValues != null);
                        value = robinValues[i][robinValueIndex];
                    }
                    values[i][ptIndex] = value;
                }
            }
            FetchData fetchData = new FetchData(steps.get(), endTime, parentDb.getDsNames());

            fetchData.setTimestamps(timestamps);
            fetchData.setValues(values);
            return(fetchData);
        }