@Override public Object get(Interval interval, Estimator estimator) { if (estimator == null) { return get(interval, (T) null); } if (!isSupported(estimator)) { throw new UnsupportedOperationException("Not supported estimator."); } switch (estimator) { case AVERAGE: return getAverage(interval); case MIN: return getMin(interval); case MAX: return getMax(interval); case FIRST: return getFirst(interval); case LAST: return getLast(interval); default: throw new UnsupportedOperationException("Not supported estimator."); } }
/** * For getting x and y values from a dynamic number Use the intervals start * time as X values */ private Number[][] getDynamicNumberNumbers(IntervalMap dynamicNumber) { ArrayList<Number> xValuesList = new ArrayList<Number>(); ArrayList<Number> yValuesList = new ArrayList<Number>(); if (dynamicNumber == null) { return new Number[2][0]; } Number n; for (Interval interval : dynamicNumber.toKeysArray()) { n = (Number) dynamicNumber.get(interval, null); if (n != null) { xValuesList.add(interval.getLow()); yValuesList.add(n); } } return new Number[][]{xValuesList.toArray(new Number[0]), yValuesList.toArray(new Number[0])}; } }
@Override public Object get(Interval interval, Estimator estimator) { if (estimator == null) { return get(interval, (T) null); } if (!isSupported(estimator)) { throw new UnsupportedOperationException("Not supported estimator."); } switch (estimator) { case AVERAGE: return getAverage(interval); case MIN: return getMin(interval); case MAX: return getMax(interval); case FIRST: return getFirst(interval); case LAST: return getLast(interval); default: throw new UnsupportedOperationException("Not supported estimator."); } }
@Override public double getWeight(double timestamp) { synchronized (this) { Object weightValue = attributes[GraphStoreConfiguration.EDGE_WEIGHT_INDEX]; if (weightValue instanceof Double) { throw new IllegalStateException("The weight is static, call getWeight() instead"); } TimeMap dynamicValue = (TimeMap) weightValue; if (dynamicValue == null) { return DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING; } if (dynamicValue instanceof IntervalMap) { return (Double) ((IntervalMap) dynamicValue) .get(new Interval(timestamp, timestamp), DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING); } else { return (Double) dynamicValue.get(timestamp, DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING); } } }
@Override public double getWeight(double timestamp) { synchronized (this) { Object weightValue = attributes[GraphStoreConfiguration.EDGE_WEIGHT_INDEX]; if (weightValue instanceof Double) { throw new IllegalStateException("The weight is static, call getWeight() instead"); } TimeMap dynamicValue = (TimeMap) weightValue; if (dynamicValue == null) { return DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING; } if (dynamicValue instanceof IntervalMap) { return (Double) ((IntervalMap) dynamicValue) .get(new Interval(timestamp, timestamp), DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING); } else { return (Double) dynamicValue.get(timestamp, DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING); } } }