@Override public Number[][] getSparklinesXAndYNumbers(Object value) { TimestampMap timestampMap = (TimestampMap) value; Double[] timestamps = timestampMap.toKeysArray(); Number[] values = (Number[]) timestampMap.toValuesArray(); return new Number[][]{timestamps, values}; } }
@Override public String toString() { return toString(TimeFormat.DOUBLE, null); } }
@Override public Object get(Interval interval, Estimator estimator) { 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."); } }
private void serializeTimestampMap(final DataOutput out, final TimestampMap timestampMap) throws IOException { serialize(out, timestampMap.getTimestamps()); Class mapClass = timestampMap.getClass(); if (mapClass.equals(TimestampBooleanMap.class)) { serialize(out, ((TimestampBooleanMap) timestampMap).toBooleanArray()); } else if (mapClass.equals(TimestampByteMap.class)) { serialize(out, ((TimestampByteMap) timestampMap).toByteArray()); } else if (mapClass.equals(TimestampCharMap.class)) { serialize(out, ((TimestampCharMap) timestampMap).toCharacterArray()); } else if (mapClass.equals(TimestampDoubleMap.class)) { serialize(out, ((TimestampDoubleMap) timestampMap).toDoubleArray()); } else if (mapClass.equals(TimestampFloatMap.class)) { serialize(out, ((TimestampFloatMap) timestampMap).toFloatArray()); } else if (mapClass.equals(TimestampIntegerMap.class)) { serialize(out, ((TimestampIntegerMap) timestampMap).toIntegerArray()); } else if (mapClass.equals(TimestampLongMap.class)) { serialize(out, ((TimestampLongMap) timestampMap).toLongArray()); } else if (mapClass.equals(TimestampShortMap.class)) { serialize(out, ((TimestampShortMap) timestampMap).toShortArray()); } else if (mapClass.equals(TimestampStringMap.class)) { serialize(out, timestampMap.toValuesArray()); } else { throw new RuntimeException("Unrecognized timestamp map class"); } }
public String toString(TimeFormat timeFormat, DateTimeZone timeZone) { if (size == 0) { return FormattingAndParsingUtils.EMPTY_VALUE; } T[] values = toValuesArray(); StringBuilder sb = new StringBuilder(); sb.append('<'); for (int i = 0; i < size; i++) { sb.append('['); sb.append(AttributeUtils.printTimestampInFormat(array[i], timeFormat, timeZone)); sb.append(", "); String stringValue = values[i].toString(); if (FormattingAndParsingUtils.containsDynamicSpecialCharacters(stringValue) || stringValue.trim().isEmpty()) { sb.append('"'); sb.append(stringValue.replace("\\", "\\\\").replace("\"", "\\\"")); sb.append('"'); } else { sb.append(stringValue); } sb.append(']'); if (i < size - 1) { sb.append("; "); } } sb.append('>'); return sb.toString(); }
@Override public boolean contains(Double timestamp) { return getIndex(timestamp) >= 0; }
protected Object getAverage(final Interval interval) { BigDecimal average = getAverageBigDecimal(interval); return average != null ? average.doubleValue() : null; }
protected Object getMax(final Interval interval) { Double max = getMaxDouble(interval); return max != null ? max.doubleValue() : null; }
private void serializeTimestampMap(final DataOutput out, final TimestampMap timestampMap) throws IOException { serialize(out, timestampMap.getTimestamps()); Class mapClass = timestampMap.getClass(); if (mapClass.equals(TimestampBooleanMap.class)) { serialize(out, ((TimestampBooleanMap) timestampMap).toBooleanArray()); } else if (mapClass.equals(TimestampByteMap.class)) { serialize(out, ((TimestampByteMap) timestampMap).toByteArray()); } else if (mapClass.equals(TimestampCharMap.class)) { serialize(out, ((TimestampCharMap) timestampMap).toCharacterArray()); } else if (mapClass.equals(TimestampDoubleMap.class)) { serialize(out, ((TimestampDoubleMap) timestampMap).toDoubleArray()); } else if (mapClass.equals(TimestampFloatMap.class)) { serialize(out, ((TimestampFloatMap) timestampMap).toFloatArray()); } else if (mapClass.equals(TimestampIntegerMap.class)) { serialize(out, ((TimestampIntegerMap) timestampMap).toIntegerArray()); } else if (mapClass.equals(TimestampLongMap.class)) { serialize(out, ((TimestampLongMap) timestampMap).toLongArray()); } else if (mapClass.equals(TimestampShortMap.class)) { serialize(out, ((TimestampShortMap) timestampMap).toShortArray()); } else if (mapClass.equals(TimestampStringMap.class)) { serialize(out, timestampMap.toValuesArray()); } else { throw new RuntimeException("Unrecognized timestamp map class"); } }
public String toString(TimeFormat timeFormat, DateTimeZone timeZone) { if (size == 0) { return FormattingAndParsingUtils.EMPTY_VALUE; } T[] values = toValuesArray(); StringBuilder sb = new StringBuilder(); sb.append('<'); for (int i = 0; i < size; i++) { sb.append('['); sb.append(AttributeUtils.printTimestampInFormat(array[i], timeFormat, timeZone)); sb.append(", "); String stringValue = values[i].toString(); if (FormattingAndParsingUtils.containsDynamicSpecialCharacters(stringValue) || stringValue.trim().isEmpty()) { sb.append('"'); sb.append(stringValue.replace("\\", "\\\\").replace("\"", "\\\"")); sb.append('"'); } else { sb.append(stringValue); } sb.append(']'); if (i < size - 1) { sb.append("; "); } } sb.append('>'); return sb.toString(); }
@Override public boolean contains(Double timestamp) { return getIndex(timestamp) >= 0; }
protected Object getAverage(final Interval interval) { BigDecimal average = getAverageBigDecimal(interval); return average != null ? average.doubleValue() : null; }
protected Object getMax(final Interval interval) { Double max = getMaxDouble(interval); return max != null ? max.doubleValue() : null; }
@Override public Object get(Interval interval, Estimator estimator) { 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."); } }
/** * Used for obtaining a list of the numbers of row of a dynamic number column. * * @param row Row * @param column Column with dynamic type * @return list of numbers */ private List<Number> getDynamicNumberColumnNumbers(Element row, Column column) { Class type = column.getTypeClass(); if (!(AttributeUtils.isNumberType(type) && AttributeUtils.isDynamicType(type))) { throw new IllegalArgumentException("Column must be a dynamic number column"); } if (TimestampMap.class.isAssignableFrom(type)) {//Timestamp type: TimestampMap timestampMap = (TimestampMap) row.getAttribute(column); if (timestampMap == null) { return new ArrayList<>(); } Number[] dynamicNumbers = (Number[]) timestampMap.toValuesArray(); return Arrays.asList(dynamicNumbers); } else if (IntervalMap.class.isAssignableFrom(type)) {//Interval type: IntervalMap intervalMap = (IntervalMap) row.getAttribute(column); if (intervalMap == null) { return new ArrayList<>(); } Number[] dynamicNumbers = (Number[]) intervalMap.toValuesArray(); return Arrays.asList(dynamicNumbers); } else { throw new IllegalArgumentException("Unsupported dynamic type class " + type.getCanonicalName()); } }
@Override public String toString() { return toString(TimeFormat.DOUBLE, null); } }
public String toString(TimeFormat timeFormat) { return toString(timeFormat, null); }
public String toString(TimeFormat timeFormat) { return toString(timeFormat, null); }